threading NEED_REENTRANT_FUNC_NAMES patch - Mailing list pgsql-patches
From | Bruce Momjian |
---|---|
Subject | threading NEED_REENTRANT_FUNC_NAMES patch |
Date | |
Msg-id | 200308161535.h7GFZ2w02337@candle.pha.pa.us Whole thread Raw |
List | pgsql-patches |
Here is the threading patch I mentioned on hackers. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 Index: configure =================================================================== RCS file: /cvsroot/pgsql-server/configure,v retrieving revision 1.289 diff -c -c -r1.289 configure *** configure 11 Aug 2003 18:07:38 -0000 1.289 --- configure 16 Aug 2003 15:14:21 -0000 *************** *** 13102,13107 **** --- 13102,13108 ---- # # For each platform, we need to know about any special compile and link # libraries, and whether the normal C function names are thread-safe. + # See the comment at the top of src/port/thread.c for more information. # if test "$enable_thread_safety" = yes; then if test "${ac_cv_header_pthread_h+set}" = set; then *************** *** 13208,13215 **** if test $ac_cv_header_pthread_h = yes; then : else ! { { echo "$as_me:$LINENO: error: pthread.h not found, required for --with-threads" >&5 ! echo "$as_me: error: pthread.h not found, required for --with-threads" >&2;} { (exit 1); exit 1; }; } fi --- 13209,13216 ---- if test $ac_cv_header_pthread_h = yes; then : else ! { { echo "$as_me:$LINENO: error: pthread.h not found, required for --enable-thread-safetys" >&5 ! echo "$as_me: error: pthread.h not found, required for --enable-thread-safetys" >&2;} { (exit 1); exit 1; }; } fi *************** *** 13221,13232 **** --- 13222,13235 ---- Please report your platform threading info to the PostgreSQL mailing lists so it can be added to the next release. Report all compile flags, link flags, functions, or libraries required for threading support. + See the comment at the top of src/port/thread.c for more information. " >&5 echo "$as_me: error: Cannot enable threads on your platform. Please report your platform threading info to the PostgreSQL mailing lists so it can be added to the next release. Report all compile flags, link flags, functions, or libraries required for threading support. + See the comment at the top of src/port/thread.c for more information. " >&2;} { (exit 1); exit 1; }; } fi *************** *** 13254,13275 **** _LIBS="$LIBS" CFLAGS="$CFLAGS $THREAD_CFLAGS" LIBS="$LIBS $THREAD_LIBS" ! for ac_func in strerror_r getpwuid_r gethostbyname_r ! do ! as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` ! echo "$as_me:$LINENO: checking for $ac_func" >&5 ! echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 ! if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, ! which can conflict with char $ac_func (); below. */ #include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus --- 13257,13344 ---- _LIBS="$LIBS" CFLAGS="$CFLAGS $THREAD_CFLAGS" LIBS="$LIBS $THREAD_LIBS" + echo "$as_me:$LINENO: checking for strerror_r" >&5 + echo $ECHO_N "checking for strerror_r... $ECHO_C" >&6 + if test "${ac_cv_func_strerror_r+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 + else + cat >conftest.$ac_ext <<_ACEOF + #line $LINENO "configure" + #include "confdefs.h" + /* System header to define __stub macros and hopefully few prototypes, + which can conflict with char strerror_r (); below. */ + #include <assert.h> + /* Override any gcc2 internal prototype to avoid an error. */ + #ifdef __cplusplus + extern "C" + #endif + /* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ + char strerror_r (); + char (*f) (); + #ifdef F77_DUMMY_MAIN + # ifdef __cplusplus + extern "C" + # endif + int F77_DUMMY_MAIN() { return 1; } + #endif + int + main () + { + /* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ + #if defined (__stub_strerror_r) || defined (__stub___strerror_r) + choke me + #else + f = strerror_r; + #endif + ; + return 0; + } + _ACEOF + rm -f conftest.$ac_objext 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='test -s 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 + ac_cv_func_strerror_r=yes + else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_func_strerror_r=no + fi + rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + fi + echo "$as_me:$LINENO: result: $ac_cv_func_strerror_r" >&5 + echo "${ECHO_T}$ac_cv_func_strerror_r" >&6 + if test $ac_cv_func_strerror_r = yes; then + : + else + { { echo "$as_me:$LINENO: error: strerror_r not found, required on this platform for --enable-thread-safety" >&5 + echo "$as_me: error: strerror_r not found, required on this platform for --enable-thread-safety" >&2;} + { (exit 1); exit 1; }; } + fi ! echo "$as_me:$LINENO: checking for getpwuid_r" >&5 ! echo $ECHO_N "checking for getpwuid_r... $ECHO_C" >&6 ! if test "${ac_cv_func_getpwuid_r+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, ! which can conflict with char getpwuid_r (); below. */ #include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus *************** *** 13277,13283 **** #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ ! char $ac_func (); char (*f) (); #ifdef F77_DUMMY_MAIN --- 13346,13352 ---- #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ ! char getpwuid_r (); char (*f) (); #ifdef F77_DUMMY_MAIN *************** *** 13292,13301 **** /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ ! #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else ! f = $ac_func; #endif ; --- 13361,13370 ---- /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ ! #if defined (__stub_getpwuid_r) || defined (__stub___getpwuid_r) choke me #else ! f = getpwuid_r; #endif ; *************** *** 13314,13336 **** ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ! eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ! eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi ! echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 ! echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 ! if test `eval echo '${'$as_ac_var'}'` = yes; then ! cat >>confdefs.h <<_ACEOF ! #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 ! _ACEOF fi - done CFLAGS="$_CFLAGS" LIBS="$_LIBS" --- 13383,13477 ---- ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ! ac_cv_func_getpwuid_r=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ! ac_cv_func_getpwuid_r=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi ! echo "$as_me:$LINENO: result: $ac_cv_func_getpwuid_r" >&5 ! echo "${ECHO_T}$ac_cv_func_getpwuid_r" >&6 ! if test $ac_cv_func_getpwuid_r = yes; then ! : ! else ! { { echo "$as_me:$LINENO: error: getpwuid_r not found, required on this platform for --enable-thread-safety" >&5 ! echo "$as_me: error: getpwuid_r not found, required on this platform for --enable-thread-safety" >&2;} ! { (exit 1); exit 1; }; } ! fi ! ! echo "$as_me:$LINENO: checking for gethostbyname_r" >&5 ! echo $ECHO_N "checking for gethostbyname_r... $ECHO_C" >&6 ! if test "${ac_cv_func_gethostbyname_r+set}" = set; then ! echo $ECHO_N "(cached) $ECHO_C" >&6 ! else ! cat >conftest.$ac_ext <<_ACEOF ! #line $LINENO "configure" ! #include "confdefs.h" ! /* System header to define __stub macros and hopefully few prototypes, ! which can conflict with char gethostbyname_r (); below. */ ! #include <assert.h> ! /* Override any gcc2 internal prototype to avoid an error. */ ! #ifdef __cplusplus ! extern "C" ! #endif ! /* We use char because int might match the return type of a gcc2 ! builtin and then its argument prototype would still apply. */ ! char gethostbyname_r (); ! char (*f) (); ! ! #ifdef F77_DUMMY_MAIN ! # ifdef __cplusplus ! extern "C" ! # endif ! int F77_DUMMY_MAIN() { return 1; } ! #endif ! int ! main () ! { ! /* The GNU C library defines this for functions which it implements ! to always fail with ENOSYS. Some functions are actually named ! something starting with __ and the normal name is an alias. */ ! #if defined (__stub_gethostbyname_r) || defined (__stub___gethostbyname_r) ! choke me ! #else ! f = gethostbyname_r; ! #endif + ; + return 0; + } + _ACEOF + rm -f conftest.$ac_objext 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='test -s 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 + ac_cv_func_gethostbyname_r=yes + else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_func_gethostbyname_r=no + fi + rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + fi + echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname_r" >&5 + echo "${ECHO_T}$ac_cv_func_gethostbyname_r" >&6 + if test $ac_cv_func_gethostbyname_r = yes; then + : + else + { { echo "$as_me:$LINENO: error: gethostbyname_r not found, required on this platform for --enable-thread-safety" >&5 + echo "$as_me: error: gethostbyname_r not found, required on this platform for --enable-thread-safety" >&2;} + { (exit 1); exit 1; }; } fi CFLAGS="$_CFLAGS" LIBS="$_LIBS" Index: configure.in =================================================================== RCS file: /cvsroot/pgsql-server/configure.in,v retrieving revision 1.280 diff -c -c -r1.280 configure.in *** configure.in 11 Aug 2003 18:07:38 -0000 1.280 --- configure.in 16 Aug 2003 15:14:23 -0000 *************** *** 978,986 **** # # For each platform, we need to know about any special compile and link # libraries, and whether the normal C function names are thread-safe. # if test "$enable_thread_safety" = yes; then ! AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --with-threads])]) if test "$SUPPORTS_THREADS" != yes; then AC_MSG_ERROR([ --- 978,987 ---- # # For each platform, we need to know about any special compile and link # libraries, and whether the normal C function names are thread-safe. + # See the comment at the top of src/port/thread.c for more information. # if test "$enable_thread_safety" = yes; then ! AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --enable-thread-safetys])]) if test "$SUPPORTS_THREADS" != yes; then AC_MSG_ERROR([ *************** *** 988,993 **** --- 989,995 ---- Please report your platform threading info to the PostgreSQL mailing lists so it can be added to the next release. Report all compile flags, link flags, functions, or libraries required for threading support. + See the comment at the top of src/port/thread.c for more information. ]) fi else *************** *** 1014,1020 **** _LIBS="$LIBS" CFLAGS="$CFLAGS $THREAD_CFLAGS" LIBS="$LIBS $THREAD_LIBS" ! AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r]) CFLAGS="$_CFLAGS" LIBS="$_LIBS" fi --- 1016,1027 ---- _LIBS="$LIBS" CFLAGS="$CFLAGS $THREAD_CFLAGS" LIBS="$LIBS $THREAD_LIBS" ! AC_CHECK_FUNC(strerror_r, ! [], [AC_MSG_ERROR([strerror_r not found, required on this platform for --enable-thread-safety])]) ! AC_CHECK_FUNC(getpwuid_r, ! [], [AC_MSG_ERROR([getpwuid_r not found, required on this platform for --enable-thread-safety])]) ! AC_CHECK_FUNC(gethostbyname_r, ! [], [AC_MSG_ERROR([gethostbyname_r not found, required on this platform for --enable-thread-safety])]) CFLAGS="$_CFLAGS" LIBS="$_LIBS" fi Index: src/include/pg_config.h.in =================================================================== RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v retrieving revision 1.60 diff -c -c -r1.60 pg_config.h.in *** src/include/pg_config.h.in 11 Aug 2003 18:07:38 -0000 1.60 --- src/include/pg_config.h.in 16 Aug 2003 15:14:31 -0000 *************** *** 118,126 **** /* Define to 1 if you have the `getaddrinfo' function. */ #undef HAVE_GETADDRINFO - /* Define to 1 if you have the `gethostbyname_r' function. */ - #undef HAVE_GETHOSTBYNAME_R - /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME --- 118,123 ---- *************** *** 136,144 **** /* Define to 1 if you have the `getpeereid' function. */ #undef HAVE_GETPEEREID - /* Define to 1 if you have the `getpwuid_r' function. */ - #undef HAVE_GETPWUID_R - /* Define to 1 if you have the `getrusage' function. */ #undef HAVE_GETRUSAGE --- 133,138 ---- *************** *** 377,385 **** /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR - - /* Define to 1 if you have the `strerror_r' function. */ - #undef HAVE_STRERROR_R /* Define to 1 if cpp supports the ANSI # stringizing operator. */ #undef HAVE_STRINGIZE --- 371,376 ---- Index: src/port/thread.c =================================================================== RCS file: /cvsroot/pgsql-server/src/port/thread.c,v retrieving revision 1.3 diff -c -c -r1.3 thread.c *** src/port/thread.c 14 Aug 2003 05:27:18 -0000 1.3 --- src/port/thread.c 16 Aug 2003 15:14:32 -0000 *************** *** 49,55 **** char * pqStrerror(int errnum, char *strerrbuf, size_t buflen) { ! #if defined(USE_THREADS) && defined(HAVE_STRERROR_R) /* reentrant strerror_r is available */ /* some early standards had strerror_r returning char * */ strerror_r(errnum, strerrbuf, buflen); --- 49,55 ---- char * pqStrerror(int errnum, char *strerrbuf, size_t buflen) { ! #if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES) /* reentrant strerror_r is available */ /* some early standards had strerror_r returning char * */ strerror_r(errnum, strerrbuf, buflen); *************** *** 68,74 **** pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer, size_t buflen, struct passwd **result) { ! #if defined(USE_THREADS) && defined(HAVE_GETPWUID_R) /* * Early POSIX draft of getpwuid_r() returns 'struct passwd *'. * getpwuid_r(uid, resultbuf, buffer, buflen) --- 68,74 ---- pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer, size_t buflen, struct passwd **result) { ! #if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES) /* * Early POSIX draft of getpwuid_r() returns 'struct passwd *'. * getpwuid_r(uid, resultbuf, buffer, buflen) *************** *** 94,101 **** struct hostent **result, int *herrno) { ! #if defined(USE_THREADS) && defined(HAVE_GETHOSTBYNAME_R) ! /* * broken (well early POSIX draft) gethostbyname_r() which returns * 'struct hostent *' --- 94,100 ---- struct hostent **result, int *herrno) { ! #if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES) /* * broken (well early POSIX draft) gethostbyname_r() which returns * 'struct hostent *' Index: src/template/bsdi =================================================================== RCS file: /cvsroot/pgsql-server/src/template/bsdi,v retrieving revision 1.10 diff -c -c -r1.10 bsdi *** src/template/bsdi 14 Jun 2003 19:21:42 -0000 1.10 --- src/template/bsdi 16 Aug 2003 15:14:32 -0000 *************** *** 12,15 **** SUPPORTS_THREADS=yes NEED_REENTRANT_FUNC_NAMES=no - --- 12,14 ---- Index: src/template/freebsd =================================================================== RCS file: /cvsroot/pgsql-server/src/template/freebsd,v retrieving revision 1.18 diff -c -c -r1.18 freebsd *** src/template/freebsd 14 Jun 2003 19:21:42 -0000 1.18 --- src/template/freebsd 16 Aug 2003 15:14:32 -0000 *************** *** 5,17 **** esac SUPPORTS_THREADS=yes case $host_os in freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" - NEED_REENTRANT_FUNC_NAMES=yes ;; *) THREAD_LIBS="-lc_r" - NEED_REENTRANT_FUNC_NAMES=yes ;; esac --- 5,17 ---- esac SUPPORTS_THREADS=yes + NEED_REENTRANT_FUNC_NAMES=no + case $host_os in freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" ;; *) THREAD_LIBS="-lc_r" ;; esac Index: src/template/linux =================================================================== RCS file: /cvsroot/pgsql-server/src/template/linux,v retrieving revision 1.11 diff -c -c -r1.11 linux *** src/template/linux 14 Jun 2003 19:21:42 -0000 1.11 --- src/template/linux 16 Aug 2003 15:14:32 -0000 *************** *** 1,7 **** CFLAGS=-O2 SUPPORTS_THREADS=yes THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS" THREAD_LIBS="-lpthread" - NEED_REENTRANT_FUNC_NAMES=yes --- 1,7 ---- CFLAGS=-O2 SUPPORTS_THREADS=yes + NEED_REENTRANT_FUNC_NAMES=yes THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS" THREAD_LIBS="-lpthread" Index: src/template/netbsd =================================================================== RCS file: /cvsroot/pgsql-server/src/template/netbsd,v retrieving revision 1.9 diff -c -c -r1.9 netbsd *** src/template/netbsd 14 Jun 2003 19:21:42 -0000 1.9 --- src/template/netbsd 16 Aug 2003 15:14:32 -0000 *************** *** 2,5 **** SUPPORTS_THREADS=yes NEED_REENTRANT_FUNC_NAMES=no - --- 2,4 ---- Index: src/template/osf =================================================================== RCS file: /cvsroot/pgsql-server/src/template/osf,v retrieving revision 1.6 diff -c -c -r1.6 osf *** src/template/osf 15 Jul 2003 17:28:36 -0000 1.6 --- src/template/osf 16 Aug 2003 15:14:32 -0000 *************** *** 4,9 **** CC="$CC -std" CFLAGS='-O4 -Olimit 2000' fi SUPPORTS_THREADS=yes THREAD_CFLAGS="-pthread" - --- 4,10 ---- CC="$CC -std" CFLAGS='-O4 -Olimit 2000' fi + SUPPORTS_THREADS=yes + NEED_REENTRANT_FUNC_NAMES=no THREAD_CFLAGS="-pthread" Index: src/template/unixware =================================================================== RCS file: /cvsroot/pgsql-server/src/template/unixware,v retrieving revision 1.14 diff -c -c -r1.14 unixware *** src/template/unixware 14 Aug 2003 21:24:38 -0000 1.14 --- src/template/unixware 16 Aug 2003 15:14:32 -0000 *************** *** 10,14 **** fi SUPPORTS_THREADS=yes - THREAD_CFLAGS += -D_REENTRANT NEED_REENTRANT_FUNC_NAMES=yes --- 10,14 ---- fi SUPPORTS_THREADS=yes NEED_REENTRANT_FUNC_NAMES=yes + THREAD_CFLAGS += -D_REENTRANT
pgsql-patches by date: