Do thread testing from configure in a much cleaner fashion.

This commit is contained in:
Bruce Momjian 2004-04-27 19:51:12 +00:00
parent ca8a8baa76
commit e27338f26c
3 changed files with 108 additions and 156 deletions

161
configure vendored
View file

@ -17876,6 +17876,65 @@ fi
done
# Thread testing
# We have to run the thread test near the end so we have all our symbols
# defined. Cross compiling throws a warning.
#
if test "$enable_thread_safety" = yes; then
echo "$as_me:$LINENO: checking thread safety of required library functions" >&5
echo $ECHO_N "checking thread safety of required library functions... $ECHO_C" >&6
_CFLAGS="$CFLAGS"
_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
LIBS="$LIBS $PTHREAD_LIBS"
if test "$cross_compiling" = yes; then
echo "$as_me:$LINENO: result: maybe" >&5
echo "${ECHO_T}maybe" >&6
{ echo "$as_me:$LINENO: WARNING:
*** Skipping thread test program because of cross-compile build.
*** Run the program in src/tools/thread on the target matchine.
" >&5
echo "$as_me: WARNING:
*** Skipping thread test program because of cross-compile build.
*** Run the program in src/tools/thread on the target matchine.
" >&2;}
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include "src/tools/thread/thread_test.c"
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
( exit $ac_status )
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
{ { echo "$as_me:$LINENO: error: Thread test program failed. Your platform is not thread-safe. See 'config.log" >&5
echo "$as_me: error: Thread test program failed. Your platform is not thread-safe. See 'config.log" >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
CFLAGS="$_CFLAGS"
LIBS="$_LIBS"
fi
# prepare build tree if outside source tree
# Note 1: test -ef might not exist, but it's more reliable than `pwd`.
@ -19112,105 +19171,3 @@ if test "$no_create" != yes; then
$ac_cs_success || { (exit 1); exit 1; }
fi
# Check for gmake.
for ac_prog in gmake make
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_MAKE+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$MAKE"; then
ac_cv_prog_MAKE="$MAKE" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_MAKE="$ac_prog"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
MAKE=$ac_cv_prog_MAKE
if test -n "$MAKE"; then
echo "$as_me:$LINENO: result: $MAKE" >&5
echo "${ECHO_T}$MAKE" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
test -n "$MAKE" && break
done
if ! $MAKE -v | grep 'GNU Make' >/dev/null
then rm -f $srcdir/src/Makefile.global
echo "$as_me:$LINENO: checking Can not find GNU Make. It is required." >&5
echo $ECHO_N "checking Can not find GNU Make. It is required.... $ECHO_C" >&6
fi
# Thread testing
# We have to run the thread test here because it is an external program
# that has to be runable separately for cross-compiling.
#
if test "$enable_thread_safety" = yes; then
if test cross_compiling != yes; then
#
# Clean, compile, run, and clean thread test directory.
# If test fails for any reason, remove Makefile.global so the user can't
# compile (to simulate a configure failure).
#
echo "$as_me:$LINENO: checking thread safety of required library functions" >&5
echo $ECHO_N "checking thread safety of required library functions... $ECHO_C" >&6
if ! $MAKE -C src/tools/thread clean >&5
then rm -f src/Makefile.global
{ { echo "$as_me:$LINENO: error: Can not clean thread test directory." >&5
echo "$as_me: error: Can not clean thread test directory." >&2;}
{ (exit 1); exit 1; }; }
fi
if ! $MAKE -C src/tools/thread >&5
then rm -f src/Makefile.global
{ { echo "$as_me:$LINENO: error: Can not build thread test proram." >&5
echo "$as_me: error: Can not build thread test proram." >&2;}
{ (exit 1); exit 1; }; }
fi
if ! src/tools/thread/thread_test >&5
then rm -f src/Makefile.global
echo "no"
echo
src/tools/thread/thread_test
echo
{ { echo "$as_me:$LINENO: error: Thread test program failed. Your platform is not thread-safe." >&5
echo "$as_me: error: Thread test program failed. Your platform is not thread-safe." >&2;}
{ (exit 1); exit 1; }; }
fi
if ! $MAKE -C src/tools/thread clean >&5
then rm -f src/Makefile.global
{ { echo "$as_me:$LINENO: error: Can not clean thread test directory." >&5
echo "$as_me: error: Can not clean thread test directory." >&2;}
{ (exit 1); exit 1; }; }
fi
echo "yes"
else
{ echo "$as_me:$LINENO: WARNING:
*** Skipping thread test program because of cross-compile build.
*** Run the program in src/tools/thread on the target matchine.
" >&5
echo "$as_me: WARNING:
*** Skipping thread test program because of cross-compile build.
*** Run the program in src/tools/thread on the target matchine.
" >&2;}
fi
fi

View file

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.336 2004/04/26 19:08:57 momjian Exp $
dnl $PostgreSQL: pgsql/configure.in,v 1.337 2004/04/27 19:51:12 momjian Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@ -1176,6 +1176,30 @@ PGAC_PATH_DOCBOOK_STYLESHEETS
PGAC_PATH_COLLATEINDEX
AC_CHECK_PROGS(SGMLSPL, sgmlspl)
# Thread testing
# We have to run the thread test near the end so we have all our symbols
# defined. Cross compiling throws a warning.
#
if test "$enable_thread_safety" = yes; then
AC_MSG_CHECKING([thread safety of required library functions])
_CFLAGS="$CFLAGS"
_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
LIBS="$LIBS $PTHREAD_LIBS"
AC_TRY_RUN([#include "src/tools/thread/thread_test.c"],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([Thread test program failed. Your platform is not thread-safe. See 'config.log])],
[AC_MSG_RESULT(maybe)
AC_MSG_WARN([
*** Skipping thread test program because of cross-compile build.
*** Run the program in src/tools/thread on the target matchine.
])])
CFLAGS="$_CFLAGS"
LIBS="$_LIBS"
fi
# prepare build tree if outside source tree
# Note 1: test -ef might not exist, but it's more reliable than `pwd`.
@ -1214,52 +1238,3 @@ echo >src/include/stamp-h
])
AC_OUTPUT
# Check for gmake.
AC_CHECK_PROGS(MAKE, gmake make)
if ! $MAKE -v | grep 'GNU Make' >/dev/null
then rm -f $srcdir/src/Makefile.global
AC_MSG_CHECKING([Can not find GNU Make. It is required.])
fi
# Thread testing
# We have to run the thread test here because it is an external program
# that has to be runable separately for cross-compiling.
#
if test "$enable_thread_safety" = yes; then
if test cross_compiling != yes; then
#
# Clean, compile, run, and clean thread test directory.
# If test fails for any reason, remove Makefile.global so the user can't
# compile (to simulate a configure failure).
#
AC_MSG_CHECKING([thread safety of required library functions])
if ! $MAKE -C src/tools/thread clean >&5
then rm -f src/Makefile.global
AC_MSG_ERROR([Can not clean thread test directory.])
fi
if ! $MAKE -C src/tools/thread >&5
then rm -f src/Makefile.global
AC_MSG_ERROR([Can not build thread test proram.])
fi
if ! src/tools/thread/thread_test >&5
then rm -f src/Makefile.global
echo "no"
echo
src/tools/thread/thread_test
echo
AC_MSG_ERROR([Thread test program failed. Your platform is not thread-safe.])
fi
if ! $MAKE -C src/tools/thread clean >&5
then rm -f src/Makefile.global
AC_MSG_ERROR([Can not clean thread test directory.])
fi
echo "yes"
else
AC_MSG_WARN([
*** Skipping thread test program because of cross-compile build.
*** Run the program in src/tools/thread on the target matchine.
])
fi
fi

View file

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.28 2004/04/27 18:40:50 momjian Exp $
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.29 2004/04/27 19:51:12 momjian Exp $
*
* This program tests to see if your standard libc functions use
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
@ -20,7 +20,22 @@
*-------------------------------------------------------------------------
*/
#ifndef IN_CONFIGURE
#include "postgres.h"
#else
/* From src/include/c.h" */
#ifndef bool
typedef char bool;
#endif
#ifndef true
#define true ((bool) 1)
#endif
#ifndef false
#define false ((bool) 0)
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
@ -32,7 +47,7 @@
#include <fcntl.h>
#include <errno.h>
#ifndef ENABLE_THREAD_SAFETY
#if !defined(ENABLE_THREAD_SAFETY) && !defined(IN_CONFIGURE)
int
main(int argc, char *argv[])
{
@ -96,6 +111,12 @@ main(int argc, char *argv[])
return 1;
}
#ifdef IN_CONFIGURE
/* Send stdout to 'config.log' */
close(1);
dup(5);
#endif
/* Make temp filenames, might not have strdup() */
temp_filename_1 = malloc(strlen(TEMP_FILENAME_1) + 1);
strcpy(temp_filename_1, TEMP_FILENAME_1);
@ -339,5 +360,4 @@ func_call_2(void)
pthread_mutex_lock(&init_mutex); /* wait for parent to test */
pthread_mutex_unlock(&init_mutex);
}
#endif /* !ENABLE_THREAD_SAFETY */
#endif /* !ENABLE_THREAD_SAFETY && !IN_CONFIGURE */