Commit edc999b0 authored by Bruce Momjian's avatar Bruce Momjian

Make NEED_REENTRANT_FUNC_NAMES _require_ *_r functions, and add tests to

configure to report if they are not found.
parent dcfa8953
...@@ -13102,6 +13102,7 @@ fi ...@@ -13102,6 +13102,7 @@ fi
# #
# For each platform, we need to know about any special compile and link # For each platform, we need to know about any special compile and link
# libraries, and whether the normal C function names are thread-safe. # 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 "$enable_thread_safety" = yes; then
if test "${ac_cv_header_pthread_h+set}" = set; then if test "${ac_cv_header_pthread_h+set}" = set; then
...@@ -13208,8 +13209,8 @@ fi ...@@ -13208,8 +13209,8 @@ fi
if test $ac_cv_header_pthread_h = yes; then if test $ac_cv_header_pthread_h = yes; then
: :
else else
{ { echo "$as_me:$LINENO: error: pthread.h not found, required for --with-threads" >&5 { { 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 --with-threads" >&2;} echo "$as_me: error: pthread.h not found, required for --enable-thread-safetys" >&2;}
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi fi
...@@ -13221,12 +13222,14 @@ Cannot enable threads on your platform. ...@@ -13221,12 +13222,14 @@ Cannot enable threads on your platform.
Please report your platform threading info to the PostgreSQL mailing lists 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, so it can be added to the next release. Report all compile flags, link flags,
functions, or libraries required for threading support. functions, or libraries required for threading support.
See the comment at the top of src/port/thread.c for more information.
" >&5 " >&5
echo "$as_me: error: echo "$as_me: error:
Cannot enable threads on your platform. Cannot enable threads on your platform.
Please report your platform threading info to the PostgreSQL mailing lists 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, so it can be added to the next release. Report all compile flags, link flags,
functions, or libraries required for threading support. functions, or libraries required for threading support.
See the comment at the top of src/port/thread.c for more information.
" >&2;} " >&2;}
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi fi
...@@ -13254,22 +13257,88 @@ _CFLAGS="$CFLAGS" ...@@ -13254,22 +13257,88 @@ _CFLAGS="$CFLAGS"
_LIBS="$LIBS" _LIBS="$LIBS"
CFLAGS="$CFLAGS $THREAD_CFLAGS" CFLAGS="$CFLAGS $THREAD_CFLAGS"
LIBS="$LIBS $THREAD_LIBS" 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
for ac_func in strerror_r getpwuid_r gethostbyname_r echo "$as_me:$LINENO: checking for getpwuid_r" >&5
do echo $ECHO_N "checking for getpwuid_r... $ECHO_C" >&6
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` if test "${ac_cv_func_getpwuid_r+set}" = set; then
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 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure" #line $LINENO "configure"
#include "confdefs.h" #include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes, /* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below. */ which can conflict with char getpwuid_r (); below. */
#include <assert.h> #include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus #ifdef __cplusplus
...@@ -13277,7 +13346,7 @@ extern "C" ...@@ -13277,7 +13346,7 @@ extern "C"
#endif #endif
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */ builtin and then its argument prototype would still apply. */
char $ac_func (); char getpwuid_r ();
char (*f) (); char (*f) ();
#ifdef F77_DUMMY_MAIN #ifdef F77_DUMMY_MAIN
...@@ -13292,10 +13361,10 @@ main () ...@@ -13292,10 +13361,10 @@ main ()
/* The GNU C library defines this for functions which it implements /* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */ something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func) #if defined (__stub_getpwuid_r) || defined (__stub___getpwuid_r)
choke me choke me
#else #else
f = $ac_func; f = getpwuid_r;
#endif #endif
; ;
...@@ -13314,23 +13383,95 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ...@@ -13314,23 +13383,95 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
eval "$as_ac_var=yes" ac_cv_func_getpwuid_r=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5 cat conftest.$ac_ext >&5
eval "$as_ac_var=no" ac_cv_func_getpwuid_r=no
fi fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "$as_me:$LINENO: result: $ac_cv_func_getpwuid_r" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 echo "${ECHO_T}$ac_cv_func_getpwuid_r" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then if test $ac_cv_func_getpwuid_r = yes; then
cat >>confdefs.h <<_ACEOF :
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 else
_ACEOF { { 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 fi
done
CFLAGS="$_CFLAGS" CFLAGS="$_CFLAGS"
LIBS="$_LIBS" LIBS="$_LIBS"
......
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $Header: /cvsroot/pgsql/configure.in,v 1.280 2003/08/11 18:07:38 tgl Exp $ dnl $Header: /cvsroot/pgsql/configure.in,v 1.281 2003/08/16 15:35:51 momjian Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
...@@ -978,9 +978,10 @@ AC_FUNC_FSEEKO ...@@ -978,9 +978,10 @@ AC_FUNC_FSEEKO
# #
# For each platform, we need to know about any special compile and link # For each platform, we need to know about any special compile and link
# libraries, and whether the normal C function names are thread-safe. # 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 "$enable_thread_safety" = yes; then
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --with-threads])]) AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --enable-thread-safetys])])
if test "$SUPPORTS_THREADS" != yes; then if test "$SUPPORTS_THREADS" != yes; then
AC_MSG_ERROR([ AC_MSG_ERROR([
...@@ -988,6 +989,7 @@ Cannot enable threads on your platform. ...@@ -988,6 +989,7 @@ Cannot enable threads on your platform.
Please report your platform threading info to the PostgreSQL mailing lists 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, so it can be added to the next release. Report all compile flags, link flags,
functions, or libraries required for threading support. functions, or libraries required for threading support.
See the comment at the top of src/port/thread.c for more information.
]) ])
fi fi
else else
...@@ -1014,7 +1016,12 @@ _CFLAGS="$CFLAGS" ...@@ -1014,7 +1016,12 @@ _CFLAGS="$CFLAGS"
_LIBS="$LIBS" _LIBS="$LIBS"
CFLAGS="$CFLAGS $THREAD_CFLAGS" CFLAGS="$CFLAGS $THREAD_CFLAGS"
LIBS="$LIBS $THREAD_LIBS" LIBS="$LIBS $THREAD_LIBS"
AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r]) 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" CFLAGS="$_CFLAGS"
LIBS="$_LIBS" LIBS="$_LIBS"
fi fi
......
...@@ -118,9 +118,6 @@ ...@@ -118,9 +118,6 @@
/* Define to 1 if you have the `getaddrinfo' function. */ /* Define to 1 if you have the `getaddrinfo' function. */
#undef HAVE_GETADDRINFO #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. */ /* Define to 1 if you have the `gethostname' function. */
#undef HAVE_GETHOSTNAME #undef HAVE_GETHOSTNAME
...@@ -136,9 +133,6 @@ ...@@ -136,9 +133,6 @@
/* Define to 1 if you have the `getpeereid' function. */ /* Define to 1 if you have the `getpeereid' function. */
#undef HAVE_GETPEEREID #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. */ /* Define to 1 if you have the `getrusage' function. */
#undef HAVE_GETRUSAGE #undef HAVE_GETRUSAGE
...@@ -378,9 +372,6 @@ ...@@ -378,9 +372,6 @@
/* Define to 1 if you have the `strerror' function. */ /* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR #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. */ /* Define to 1 if cpp supports the ANSI # stringizing operator. */
#undef HAVE_STRINGIZE #undef HAVE_STRINGIZE
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* *
* $Id: thread.c,v 1.3 2003/08/14 05:27:18 momjian Exp $ * $Id: thread.c,v 1.4 2003/08/16 15:35:51 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
char * char *
pqStrerror(int errnum, char *strerrbuf, size_t buflen) pqStrerror(int errnum, char *strerrbuf, size_t buflen)
{ {
#if defined(USE_THREADS) && defined(HAVE_STRERROR_R) #if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES)
/* reentrant strerror_r is available */ /* reentrant strerror_r is available */
/* some early standards had strerror_r returning char * */ /* some early standards had strerror_r returning char * */
strerror_r(errnum, strerrbuf, buflen); strerror_r(errnum, strerrbuf, buflen);
...@@ -68,7 +68,7 @@ int ...@@ -68,7 +68,7 @@ int
pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer, pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
size_t buflen, struct passwd **result) size_t buflen, struct passwd **result)
{ {
#if defined(USE_THREADS) && defined(HAVE_GETPWUID_R) #if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES)
/* /*
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'. * Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
* getpwuid_r(uid, resultbuf, buffer, buflen) * getpwuid_r(uid, resultbuf, buffer, buflen)
...@@ -94,8 +94,7 @@ pqGethostbyname(const char *name, ...@@ -94,8 +94,7 @@ pqGethostbyname(const char *name,
struct hostent **result, struct hostent **result,
int *herrno) int *herrno)
{ {
#if defined(USE_THREADS) && defined(HAVE_GETHOSTBYNAME_R) #if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES)
/* /*
* broken (well early POSIX draft) gethostbyname_r() which returns * broken (well early POSIX draft) gethostbyname_r() which returns
* 'struct hostent *' * 'struct hostent *'
......
...@@ -12,4 +12,3 @@ esac ...@@ -12,4 +12,3 @@ esac
SUPPORTS_THREADS=yes SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNC_NAMES=no NEED_REENTRANT_FUNC_NAMES=no
...@@ -5,13 +5,13 @@ case $host_cpu in ...@@ -5,13 +5,13 @@ case $host_cpu in
esac esac
SUPPORTS_THREADS=yes SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNC_NAMES=no
case $host_os in case $host_os in
freebsd2*|freebsd3*|freebsd4*) freebsd2*|freebsd3*|freebsd4*)
THREAD_CFLAGS="-pthread" THREAD_CFLAGS="-pthread"
NEED_REENTRANT_FUNC_NAMES=yes
;; ;;
*) *)
THREAD_LIBS="-lc_r" THREAD_LIBS="-lc_r"
NEED_REENTRANT_FUNC_NAMES=yes
;; ;;
esac esac
CFLAGS=-O2 CFLAGS=-O2
SUPPORTS_THREADS=yes SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNC_NAMES=yes
THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS" THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread" THREAD_LIBS="-lpthread"
NEED_REENTRANT_FUNC_NAMES=yes
...@@ -2,4 +2,3 @@ CFLAGS='-O2 -pipe' ...@@ -2,4 +2,3 @@ CFLAGS='-O2 -pipe'
SUPPORTS_THREADS=yes SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNC_NAMES=no NEED_REENTRANT_FUNC_NAMES=no
...@@ -4,6 +4,7 @@ else ...@@ -4,6 +4,7 @@ else
CC="$CC -std" CC="$CC -std"
CFLAGS='-O4 -Olimit 2000' CFLAGS='-O4 -Olimit 2000'
fi fi
SUPPORTS_THREADS=yes SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNC_NAMES=no
THREAD_CFLAGS="-pthread" THREAD_CFLAGS="-pthread"
...@@ -10,5 +10,5 @@ else ...@@ -10,5 +10,5 @@ else
fi fi
SUPPORTS_THREADS=yes SUPPORTS_THREADS=yes
THREAD_CFLAGS += -D_REENTRANT
NEED_REENTRANT_FUNC_NAMES=yes NEED_REENTRANT_FUNC_NAMES=yes
THREAD_CFLAGS += -D_REENTRANT
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment