Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e27338f

Browse files
committed
Do thread testing from configure in a much cleaner fashion.
1 parent ca8a8ba commit e27338f

File tree

3 files changed

+108
-156
lines changed

3 files changed

+108
-156
lines changed

configure

Lines changed: 59 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -17876,6 +17876,65 @@ fi
1787617876
done
1787717877

1787817878

17879+
# Thread testing
17880+
17881+
# We have to run the thread test near the end so we have all our symbols
17882+
# defined. Cross compiling throws a warning.
17883+
#
17884+
if test "$enable_thread_safety" = yes; then
17885+
echo "$as_me:$LINENO: checking thread safety of required library functions" >&5
17886+
echo $ECHO_N "checking thread safety of required library functions... $ECHO_C" >&6
17887+
17888+
_CFLAGS="$CFLAGS"
17889+
_LIBS="$LIBS"
17890+
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
17891+
LIBS="$LIBS $PTHREAD_LIBS"
17892+
if test "$cross_compiling" = yes; then
17893+
echo "$as_me:$LINENO: result: maybe" >&5
17894+
echo "${ECHO_T}maybe" >&6
17895+
{ echo "$as_me:$LINENO: WARNING:
17896+
*** Skipping thread test program because of cross-compile build.
17897+
*** Run the program in src/tools/thread on the target matchine.
17898+
" >&5
17899+
echo "$as_me: WARNING:
17900+
*** Skipping thread test program because of cross-compile build.
17901+
*** Run the program in src/tools/thread on the target matchine.
17902+
" >&2;}
17903+
else
17904+
cat >conftest.$ac_ext <<_ACEOF
17905+
#line $LINENO "configure"
17906+
#include "confdefs.h"
17907+
#include "src/tools/thread/thread_test.c"
17908+
_ACEOF
17909+
rm -f conftest$ac_exeext
17910+
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
17911+
(eval $ac_link) 2>&5
17912+
ac_status=$?
17913+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
17914+
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
17915+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
17916+
(eval $ac_try) 2>&5
17917+
ac_status=$?
17918+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
17919+
(exit $ac_status); }; }; then
17920+
echo "$as_me:$LINENO: result: yes" >&5
17921+
echo "${ECHO_T}yes" >&6
17922+
else
17923+
echo "$as_me: program exited with status $ac_status" >&5
17924+
echo "$as_me: failed program was:" >&5
17925+
cat conftest.$ac_ext >&5
17926+
( exit $ac_status )
17927+
echo "$as_me:$LINENO: result: no" >&5
17928+
echo "${ECHO_T}no" >&6
17929+
{ { echo "$as_me:$LINENO: error: Thread test program failed. Your platform is not thread-safe. See 'config.log" >&5
17930+
echo "$as_me: error: Thread test program failed. Your platform is not thread-safe. See 'config.log" >&2;}
17931+
{ (exit 1); exit 1; }; }
17932+
fi
17933+
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
17934+
fi
17935+
CFLAGS="$_CFLAGS"
17936+
LIBS="$_LIBS"
17937+
fi
1787917938

1788017939
# prepare build tree if outside source tree
1788117940
# Note 1: test -ef might not exist, but it's more reliable than `pwd`.
@@ -19112,105 +19171,3 @@ if test "$no_create" != yes; then
1911219171
$ac_cs_success || { (exit 1); exit 1; }
1911319172
fi
1911419173

19115-
19116-
# Check for gmake.
19117-
for ac_prog in gmake make
19118-
do
19119-
# Extract the first word of "$ac_prog", so it can be a program name with args.
19120-
set dummy $ac_prog; ac_word=$2
19121-
echo "$as_me:$LINENO: checking for $ac_word" >&5
19122-
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
19123-
if test "${ac_cv_prog_MAKE+set}" = set; then
19124-
echo $ECHO_N "(cached) $ECHO_C" >&6
19125-
else
19126-
if test -n "$MAKE"; then
19127-
ac_cv_prog_MAKE="$MAKE" # Let the user override the test.
19128-
else
19129-
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
19130-
for as_dir in $PATH
19131-
do
19132-
IFS=$as_save_IFS
19133-
test -z "$as_dir" && as_dir=.
19134-
for ac_exec_ext in '' $ac_executable_extensions; do
19135-
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
19136-
ac_cv_prog_MAKE="$ac_prog"
19137-
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
19138-
break 2
19139-
fi
19140-
done
19141-
done
19142-
19143-
fi
19144-
fi
19145-
MAKE=$ac_cv_prog_MAKE
19146-
if test -n "$MAKE"; then
19147-
echo "$as_me:$LINENO: result: $MAKE" >&5
19148-
echo "${ECHO_T}$MAKE" >&6
19149-
else
19150-
echo "$as_me:$LINENO: result: no" >&5
19151-
echo "${ECHO_T}no" >&6
19152-
fi
19153-
19154-
test -n "$MAKE" && break
19155-
done
19156-
19157-
if ! $MAKE -v | grep 'GNU Make' >/dev/null
19158-
then rm -f $srcdir/src/Makefile.global
19159-
echo "$as_me:$LINENO: checking Can not find GNU Make. It is required." >&5
19160-
echo $ECHO_N "checking Can not find GNU Make. It is required.... $ECHO_C" >&6
19161-
fi
19162-
19163-
# Thread testing
19164-
19165-
# We have to run the thread test here because it is an external program
19166-
# that has to be runable separately for cross-compiling.
19167-
#
19168-
if test "$enable_thread_safety" = yes; then
19169-
if test cross_compiling != yes; then
19170-
#
19171-
# Clean, compile, run, and clean thread test directory.
19172-
# If test fails for any reason, remove Makefile.global so the user can't
19173-
# compile (to simulate a configure failure).
19174-
#
19175-
echo "$as_me:$LINENO: checking thread safety of required library functions" >&5
19176-
echo $ECHO_N "checking thread safety of required library functions... $ECHO_C" >&6
19177-
if ! $MAKE -C src/tools/thread clean >&5
19178-
then rm -f src/Makefile.global
19179-
{ { echo "$as_me:$LINENO: error: Can not clean thread test directory." >&5
19180-
echo "$as_me: error: Can not clean thread test directory." >&2;}
19181-
{ (exit 1); exit 1; }; }
19182-
fi
19183-
if ! $MAKE -C src/tools/thread >&5
19184-
then rm -f src/Makefile.global
19185-
{ { echo "$as_me:$LINENO: error: Can not build thread test proram." >&5
19186-
echo "$as_me: error: Can not build thread test proram." >&2;}
19187-
{ (exit 1); exit 1; }; }
19188-
fi
19189-
if ! src/tools/thread/thread_test >&5
19190-
then rm -f src/Makefile.global
19191-
echo "no"
19192-
echo
19193-
src/tools/thread/thread_test
19194-
echo
19195-
{ { echo "$as_me:$LINENO: error: Thread test program failed. Your platform is not thread-safe." >&5
19196-
echo "$as_me: error: Thread test program failed. Your platform is not thread-safe." >&2;}
19197-
{ (exit 1); exit 1; }; }
19198-
fi
19199-
if ! $MAKE -C src/tools/thread clean >&5
19200-
then rm -f src/Makefile.global
19201-
{ { echo "$as_me:$LINENO: error: Can not clean thread test directory." >&5
19202-
echo "$as_me: error: Can not clean thread test directory." >&2;}
19203-
{ (exit 1); exit 1; }; }
19204-
fi
19205-
echo "yes"
19206-
else
19207-
{ echo "$as_me:$LINENO: WARNING:
19208-
*** Skipping thread test program because of cross-compile build.
19209-
*** Run the program in src/tools/thread on the target matchine.
19210-
" >&5
19211-
echo "$as_me: WARNING:
19212-
*** Skipping thread test program because of cross-compile build.
19213-
*** Run the program in src/tools/thread on the target matchine.
19214-
" >&2;}
19215-
fi
19216-
fi

configure.in

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.336 2004/04/26 19:08:57 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.337 2004/04/27 19:51:12 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1176,6 +1176,30 @@ PGAC_PATH_DOCBOOK_STYLESHEETS
11761176
PGAC_PATH_COLLATEINDEX
11771177
AC_CHECK_PROGS(SGMLSPL, sgmlspl)
11781178

1179+
# Thread testing
1180+
1181+
# We have to run the thread test near the end so we have all our symbols
1182+
# defined. Cross compiling throws a warning.
1183+
#
1184+
if test "$enable_thread_safety" = yes; then
1185+
AC_MSG_CHECKING([thread safety of required library functions])
1186+
1187+
_CFLAGS="$CFLAGS"
1188+
_LIBS="$LIBS"
1189+
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
1190+
LIBS="$LIBS $PTHREAD_LIBS"
1191+
AC_TRY_RUN([#include "src/tools/thread/thread_test.c"],
1192+
[AC_MSG_RESULT(yes)],
1193+
[AC_MSG_RESULT(no)
1194+
AC_MSG_ERROR([Thread test program failed. Your platform is not thread-safe. See 'config.log])],
1195+
[AC_MSG_RESULT(maybe)
1196+
AC_MSG_WARN([
1197+
*** Skipping thread test program because of cross-compile build.
1198+
*** Run the program in src/tools/thread on the target matchine.
1199+
])])
1200+
CFLAGS="$_CFLAGS"
1201+
LIBS="$_LIBS"
1202+
fi
11791203

11801204
# prepare build tree if outside source tree
11811205
# Note 1: test -ef might not exist, but it's more reliable than `pwd`.
@@ -1214,52 +1238,3 @@ echo >src/include/stamp-h
12141238
])
12151239

12161240
AC_OUTPUT
1217-
1218-
# Check for gmake.
1219-
AC_CHECK_PROGS(MAKE, gmake make)
1220-
if ! $MAKE -v | grep 'GNU Make' >/dev/null
1221-
then rm -f $srcdir/src/Makefile.global
1222-
AC_MSG_CHECKING([Can not find GNU Make. It is required.])
1223-
fi
1224-
1225-
# Thread testing
1226-
1227-
# We have to run the thread test here because it is an external program
1228-
# that has to be runable separately for cross-compiling.
1229-
#
1230-
if test "$enable_thread_safety" = yes; then
1231-
if test cross_compiling != yes; then
1232-
#
1233-
# Clean, compile, run, and clean thread test directory.
1234-
# If test fails for any reason, remove Makefile.global so the user can't
1235-
# compile (to simulate a configure failure).
1236-
#
1237-
AC_MSG_CHECKING([thread safety of required library functions])
1238-
if ! $MAKE -C src/tools/thread clean >&5
1239-
then rm -f src/Makefile.global
1240-
AC_MSG_ERROR([Can not clean thread test directory.])
1241-
fi
1242-
if ! $MAKE -C src/tools/thread >&5
1243-
then rm -f src/Makefile.global
1244-
AC_MSG_ERROR([Can not build thread test proram.])
1245-
fi
1246-
if ! src/tools/thread/thread_test >&5
1247-
then rm -f src/Makefile.global
1248-
echo "no"
1249-
echo
1250-
src/tools/thread/thread_test
1251-
echo
1252-
AC_MSG_ERROR([Thread test program failed. Your platform is not thread-safe.])
1253-
fi
1254-
if ! $MAKE -C src/tools/thread clean >&5
1255-
then rm -f src/Makefile.global
1256-
AC_MSG_ERROR([Can not clean thread test directory.])
1257-
fi
1258-
echo "yes"
1259-
else
1260-
AC_MSG_WARN([
1261-
*** Skipping thread test program because of cross-compile build.
1262-
*** Run the program in src/tools/thread on the target matchine.
1263-
])
1264-
fi
1265-
fi

src/tools/thread/thread_test.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.28 2004/04/27 18:40:50 momjian Exp $
9+
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.29 2004/04/27 19:51:12 momjian Exp $
1010
*
1111
* This program tests to see if your standard libc functions use
1212
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
@@ -20,7 +20,22 @@
2020
*-------------------------------------------------------------------------
2121
*/
2222

23+
#ifndef IN_CONFIGURE
2324
#include "postgres.h"
25+
#else
26+
/* From src/include/c.h" */
27+
#ifndef bool
28+
typedef char bool;
29+
#endif
30+
31+
#ifndef true
32+
#define true ((bool) 1)
33+
#endif
34+
35+
#ifndef false
36+
#define false ((bool) 0)
37+
#endif
38+
#endif
2439

2540
#include <stdio.h>
2641
#include <stdlib.h>
@@ -32,7 +47,7 @@
3247
#include <fcntl.h>
3348
#include <errno.h>
3449

35-
#ifndef ENABLE_THREAD_SAFETY
50+
#if !defined(ENABLE_THREAD_SAFETY) && !defined(IN_CONFIGURE)
3651
int
3752
main(int argc, char *argv[])
3853
{
@@ -96,6 +111,12 @@ main(int argc, char *argv[])
96111
return 1;
97112
}
98113

114+
#ifdef IN_CONFIGURE
115+
/* Send stdout to 'config.log' */
116+
close(1);
117+
dup(5);
118+
#endif
119+
99120
/* Make temp filenames, might not have strdup() */
100121
temp_filename_1 = malloc(strlen(TEMP_FILENAME_1) + 1);
101122
strcpy(temp_filename_1, TEMP_FILENAME_1);
@@ -339,5 +360,4 @@ func_call_2(void)
339360
pthread_mutex_lock(&init_mutex); /* wait for parent to test */
340361
pthread_mutex_unlock(&init_mutex);
341362
}
342-
#endif /* !ENABLE_THREAD_SAFETY */
343-
363+
#endif /* !ENABLE_THREAD_SAFETY && !IN_CONFIGURE */

0 commit comments

Comments
 (0)