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

Commit edc999b

Browse files
committed
Make NEED_REENTRANT_FUNC_NAMES _require_ *_r functions, and add tests to
configure to report if they are not found.
1 parent dcfa895 commit edc999b

File tree

10 files changed

+182
-45
lines changed

10 files changed

+182
-45
lines changed

configure

+162-21
Original file line numberDiff line numberDiff line change
@@ -13102,6 +13102,7 @@ fi
1310213102
#
1310313103
# For each platform, we need to know about any special compile and link
1310413104
# libraries, and whether the normal C function names are thread-safe.
13105+
# See the comment at the top of src/port/thread.c for more information.
1310513106
#
1310613107
if test "$enable_thread_safety" = yes; then
1310713108
if test "${ac_cv_header_pthread_h+set}" = set; then
@@ -13208,8 +13209,8 @@ fi
1320813209
if test $ac_cv_header_pthread_h = yes; then
1320913210
:
1321013211
else
13211-
{ { echo "$as_me:$LINENO: error: pthread.h not found, required for --with-threads" >&5
13212-
echo "$as_me: error: pthread.h not found, required for --with-threads" >&2;}
13212+
{ { echo "$as_me:$LINENO: error: pthread.h not found, required for --enable-thread-safetys" >&5
13213+
echo "$as_me: error: pthread.h not found, required for --enable-thread-safetys" >&2;}
1321313214
{ (exit 1); exit 1; }; }
1321413215
fi
1321513216

@@ -13221,12 +13222,14 @@ Cannot enable threads on your platform.
1322113222
Please report your platform threading info to the PostgreSQL mailing lists
1322213223
so it can be added to the next release. Report all compile flags, link flags,
1322313224
functions, or libraries required for threading support.
13225+
See the comment at the top of src/port/thread.c for more information.
1322413226
" >&5
1322513227
echo "$as_me: error:
1322613228
Cannot enable threads on your platform.
1322713229
Please report your platform threading info to the PostgreSQL mailing lists
1322813230
so it can be added to the next release. Report all compile flags, link flags,
1322913231
functions, or libraries required for threading support.
13232+
See the comment at the top of src/port/thread.c for more information.
1323013233
" >&2;}
1323113234
{ (exit 1); exit 1; }; }
1323213235
fi
@@ -13254,30 +13257,96 @@ _CFLAGS="$CFLAGS"
1325413257
_LIBS="$LIBS"
1325513258
CFLAGS="$CFLAGS $THREAD_CFLAGS"
1325613259
LIBS="$LIBS $THREAD_LIBS"
13260+
echo "$as_me:$LINENO: checking for strerror_r" >&5
13261+
echo $ECHO_N "checking for strerror_r... $ECHO_C" >&6
13262+
if test "${ac_cv_func_strerror_r+set}" = set; then
13263+
echo $ECHO_N "(cached) $ECHO_C" >&6
13264+
else
13265+
cat >conftest.$ac_ext <<_ACEOF
13266+
#line $LINENO "configure"
13267+
#include "confdefs.h"
13268+
/* System header to define __stub macros and hopefully few prototypes,
13269+
which can conflict with char strerror_r (); below. */
13270+
#include <assert.h>
13271+
/* Override any gcc2 internal prototype to avoid an error. */
13272+
#ifdef __cplusplus
13273+
extern "C"
13274+
#endif
13275+
/* We use char because int might match the return type of a gcc2
13276+
builtin and then its argument prototype would still apply. */
13277+
char strerror_r ();
13278+
char (*f) ();
1325713279

13280+
#ifdef F77_DUMMY_MAIN
13281+
# ifdef __cplusplus
13282+
extern "C"
13283+
# endif
13284+
int F77_DUMMY_MAIN() { return 1; }
13285+
#endif
13286+
int
13287+
main ()
13288+
{
13289+
/* The GNU C library defines this for functions which it implements
13290+
to always fail with ENOSYS. Some functions are actually named
13291+
something starting with __ and the normal name is an alias. */
13292+
#if defined (__stub_strerror_r) || defined (__stub___strerror_r)
13293+
choke me
13294+
#else
13295+
f = strerror_r;
13296+
#endif
1325813297

13298+
;
13299+
return 0;
13300+
}
13301+
_ACEOF
13302+
rm -f conftest.$ac_objext conftest$ac_exeext
13303+
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
13304+
(eval $ac_link) 2>&5
13305+
ac_status=$?
13306+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
13307+
(exit $ac_status); } &&
13308+
{ ac_try='test -s conftest$ac_exeext'
13309+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
13310+
(eval $ac_try) 2>&5
13311+
ac_status=$?
13312+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
13313+
(exit $ac_status); }; }; then
13314+
ac_cv_func_strerror_r=yes
13315+
else
13316+
echo "$as_me: failed program was:" >&5
13317+
cat conftest.$ac_ext >&5
13318+
ac_cv_func_strerror_r=no
13319+
fi
13320+
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
13321+
fi
13322+
echo "$as_me:$LINENO: result: $ac_cv_func_strerror_r" >&5
13323+
echo "${ECHO_T}$ac_cv_func_strerror_r" >&6
13324+
if test $ac_cv_func_strerror_r = yes; then
13325+
:
13326+
else
13327+
{ { echo "$as_me:$LINENO: error: strerror_r not found, required on this platform for --enable-thread-safety" >&5
13328+
echo "$as_me: error: strerror_r not found, required on this platform for --enable-thread-safety" >&2;}
13329+
{ (exit 1); exit 1; }; }
13330+
fi
1325913331

13260-
for ac_func in strerror_r getpwuid_r gethostbyname_r
13261-
do
13262-
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
13263-
echo "$as_me:$LINENO: checking for $ac_func" >&5
13264-
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
13265-
if eval "test \"\${$as_ac_var+set}\" = set"; then
13332+
echo "$as_me:$LINENO: checking for getpwuid_r" >&5
13333+
echo $ECHO_N "checking for getpwuid_r... $ECHO_C" >&6
13334+
if test "${ac_cv_func_getpwuid_r+set}" = set; then
1326613335
echo $ECHO_N "(cached) $ECHO_C" >&6
1326713336
else
1326813337
cat >conftest.$ac_ext <<_ACEOF
1326913338
#line $LINENO "configure"
1327013339
#include "confdefs.h"
1327113340
/* System header to define __stub macros and hopefully few prototypes,
13272-
which can conflict with char $ac_func (); below. */
13341+
which can conflict with char getpwuid_r (); below. */
1327313342
#include <assert.h>
1327413343
/* Override any gcc2 internal prototype to avoid an error. */
1327513344
#ifdef __cplusplus
1327613345
extern "C"
1327713346
#endif
1327813347
/* We use char because int might match the return type of a gcc2
1327913348
builtin and then its argument prototype would still apply. */
13280-
char $ac_func ();
13349+
char getpwuid_r ();
1328113350
char (*f) ();
1328213351

1328313352
#ifdef F77_DUMMY_MAIN
@@ -13292,10 +13361,10 @@ main ()
1329213361
/* The GNU C library defines this for functions which it implements
1329313362
to always fail with ENOSYS. Some functions are actually named
1329413363
something starting with __ and the normal name is an alias. */
13295-
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
13364+
#if defined (__stub_getpwuid_r) || defined (__stub___getpwuid_r)
1329613365
choke me
1329713366
#else
13298-
f = $ac_func;
13367+
f = getpwuid_r;
1329913368
#endif
1330013369

1330113370
;
@@ -13314,23 +13383,95 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
1331413383
ac_status=$?
1331513384
echo "$as_me:$LINENO: \$? = $ac_status" >&5
1331613385
(exit $ac_status); }; }; then
13317-
eval "$as_ac_var=yes"
13386+
ac_cv_func_getpwuid_r=yes
1331813387
else
1331913388
echo "$as_me: failed program was:" >&5
1332013389
cat conftest.$ac_ext >&5
13321-
eval "$as_ac_var=no"
13390+
ac_cv_func_getpwuid_r=no
1332213391
fi
1332313392
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
1332413393
fi
13325-
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
13326-
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
13327-
if test `eval echo '${'$as_ac_var'}'` = yes; then
13328-
cat >>confdefs.h <<_ACEOF
13329-
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
13330-
_ACEOF
13394+
echo "$as_me:$LINENO: result: $ac_cv_func_getpwuid_r" >&5
13395+
echo "${ECHO_T}$ac_cv_func_getpwuid_r" >&6
13396+
if test $ac_cv_func_getpwuid_r = yes; then
13397+
:
13398+
else
13399+
{ { echo "$as_me:$LINENO: error: getpwuid_r not found, required on this platform for --enable-thread-safety" >&5
13400+
echo "$as_me: error: getpwuid_r not found, required on this platform for --enable-thread-safety" >&2;}
13401+
{ (exit 1); exit 1; }; }
13402+
fi
13403+
13404+
echo "$as_me:$LINENO: checking for gethostbyname_r" >&5
13405+
echo $ECHO_N "checking for gethostbyname_r... $ECHO_C" >&6
13406+
if test "${ac_cv_func_gethostbyname_r+set}" = set; then
13407+
echo $ECHO_N "(cached) $ECHO_C" >&6
13408+
else
13409+
cat >conftest.$ac_ext <<_ACEOF
13410+
#line $LINENO "configure"
13411+
#include "confdefs.h"
13412+
/* System header to define __stub macros and hopefully few prototypes,
13413+
which can conflict with char gethostbyname_r (); below. */
13414+
#include <assert.h>
13415+
/* Override any gcc2 internal prototype to avoid an error. */
13416+
#ifdef __cplusplus
13417+
extern "C"
13418+
#endif
13419+
/* We use char because int might match the return type of a gcc2
13420+
builtin and then its argument prototype would still apply. */
13421+
char gethostbyname_r ();
13422+
char (*f) ();
13423+
13424+
#ifdef F77_DUMMY_MAIN
13425+
# ifdef __cplusplus
13426+
extern "C"
13427+
# endif
13428+
int F77_DUMMY_MAIN() { return 1; }
13429+
#endif
13430+
int
13431+
main ()
13432+
{
13433+
/* The GNU C library defines this for functions which it implements
13434+
to always fail with ENOSYS. Some functions are actually named
13435+
something starting with __ and the normal name is an alias. */
13436+
#if defined (__stub_gethostbyname_r) || defined (__stub___gethostbyname_r)
13437+
choke me
13438+
#else
13439+
f = gethostbyname_r;
13440+
#endif
1333113441

13442+
;
13443+
return 0;
13444+
}
13445+
_ACEOF
13446+
rm -f conftest.$ac_objext conftest$ac_exeext
13447+
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
13448+
(eval $ac_link) 2>&5
13449+
ac_status=$?
13450+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
13451+
(exit $ac_status); } &&
13452+
{ ac_try='test -s conftest$ac_exeext'
13453+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
13454+
(eval $ac_try) 2>&5
13455+
ac_status=$?
13456+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
13457+
(exit $ac_status); }; }; then
13458+
ac_cv_func_gethostbyname_r=yes
13459+
else
13460+
echo "$as_me: failed program was:" >&5
13461+
cat conftest.$ac_ext >&5
13462+
ac_cv_func_gethostbyname_r=no
13463+
fi
13464+
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
13465+
fi
13466+
echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname_r" >&5
13467+
echo "${ECHO_T}$ac_cv_func_gethostbyname_r" >&6
13468+
if test $ac_cv_func_gethostbyname_r = yes; then
13469+
:
13470+
else
13471+
{ { echo "$as_me:$LINENO: error: gethostbyname_r not found, required on this platform for --enable-thread-safety" >&5
13472+
echo "$as_me: error: gethostbyname_r not found, required on this platform for --enable-thread-safety" >&2;}
13473+
{ (exit 1); exit 1; }; }
1333213474
fi
13333-
done
1333413475

1333513476
CFLAGS="$_CFLAGS"
1333613477
LIBS="$_LIBS"

configure.in

+10-3
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 $Header: /cvsroot/pgsql/configure.in,v 1.280 2003/08/11 18:07:38 tgl Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.281 2003/08/16 15:35:51 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -978,16 +978,18 @@ AC_FUNC_FSEEKO
978978
#
979979
# For each platform, we need to know about any special compile and link
980980
# libraries, and whether the normal C function names are thread-safe.
981+
# See the comment at the top of src/port/thread.c for more information.
981982
#
982983
if test "$enable_thread_safety" = yes; then
983-
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --with-threads])])
984+
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --enable-thread-safetys])])
984985

985986
if test "$SUPPORTS_THREADS" != yes; then
986987
AC_MSG_ERROR([
987988
Cannot enable threads on your platform.
988989
Please report your platform threading info to the PostgreSQL mailing lists
989990
so it can be added to the next release. Report all compile flags, link flags,
990991
functions, or libraries required for threading support.
992+
See the comment at the top of src/port/thread.c for more information.
991993
])
992994
fi
993995
else
@@ -1014,7 +1016,12 @@ _CFLAGS="$CFLAGS"
10141016
_LIBS="$LIBS"
10151017
CFLAGS="$CFLAGS $THREAD_CFLAGS"
10161018
LIBS="$LIBS $THREAD_LIBS"
1017-
AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
1019+
AC_CHECK_FUNC(strerror_r,
1020+
[], [AC_MSG_ERROR([strerror_r not found, required on this platform for --enable-thread-safety])])
1021+
AC_CHECK_FUNC(getpwuid_r,
1022+
[], [AC_MSG_ERROR([getpwuid_r not found, required on this platform for --enable-thread-safety])])
1023+
AC_CHECK_FUNC(gethostbyname_r,
1024+
[], [AC_MSG_ERROR([gethostbyname_r not found, required on this platform for --enable-thread-safety])])
10181025
CFLAGS="$_CFLAGS"
10191026
LIBS="$_LIBS"
10201027
fi

src/include/pg_config.h.in

-9
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@
118118
/* Define to 1 if you have the `getaddrinfo' function. */
119119
#undef HAVE_GETADDRINFO
120120

121-
/* Define to 1 if you have the `gethostbyname_r' function. */
122-
#undef HAVE_GETHOSTBYNAME_R
123-
124121
/* Define to 1 if you have the `gethostname' function. */
125122
#undef HAVE_GETHOSTNAME
126123

@@ -136,9 +133,6 @@
136133
/* Define to 1 if you have the `getpeereid' function. */
137134
#undef HAVE_GETPEEREID
138135

139-
/* Define to 1 if you have the `getpwuid_r' function. */
140-
#undef HAVE_GETPWUID_R
141-
142136
/* Define to 1 if you have the `getrusage' function. */
143137
#undef HAVE_GETRUSAGE
144138

@@ -378,9 +372,6 @@
378372
/* Define to 1 if you have the `strerror' function. */
379373
#undef HAVE_STRERROR
380374

381-
/* Define to 1 if you have the `strerror_r' function. */
382-
#undef HAVE_STRERROR_R
383-
384375
/* Define to 1 if cpp supports the ANSI # stringizing operator. */
385376
#undef HAVE_STRINGIZE
386377

src/port/thread.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
99
*
10-
* $Id: thread.c,v 1.3 2003/08/14 05:27:18 momjian Exp $
10+
* $Id: thread.c,v 1.4 2003/08/16 15:35:51 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -49,7 +49,7 @@
4949
char *
5050
pqStrerror(int errnum, char *strerrbuf, size_t buflen)
5151
{
52-
#if defined(USE_THREADS) && defined(HAVE_STRERROR_R)
52+
#if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES)
5353
/* reentrant strerror_r is available */
5454
/* some early standards had strerror_r returning char * */
5555
strerror_r(errnum, strerrbuf, buflen);
@@ -68,7 +68,7 @@ int
6868
pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
6969
size_t buflen, struct passwd **result)
7070
{
71-
#if defined(USE_THREADS) && defined(HAVE_GETPWUID_R)
71+
#if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES)
7272
/*
7373
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
7474
* getpwuid_r(uid, resultbuf, buffer, buflen)
@@ -94,8 +94,7 @@ pqGethostbyname(const char *name,
9494
struct hostent **result,
9595
int *herrno)
9696
{
97-
#if defined(USE_THREADS) && defined(HAVE_GETHOSTBYNAME_R)
98-
97+
#if defined(USE_THREADS) && defined(NEED_REENTRANT_FUNC_NAMES)
9998
/*
10099
* broken (well early POSIX draft) gethostbyname_r() which returns
101100
* 'struct hostent *'

src/template/bsdi

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ esac
1212

1313
SUPPORTS_THREADS=yes
1414
NEED_REENTRANT_FUNC_NAMES=no
15-

src/template/freebsd

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ case $host_cpu in
55
esac
66

77
SUPPORTS_THREADS=yes
8+
NEED_REENTRANT_FUNC_NAMES=no
9+
810
case $host_os in
911
freebsd2*|freebsd3*|freebsd4*)
1012
THREAD_CFLAGS="-pthread"
11-
NEED_REENTRANT_FUNC_NAMES=yes
1213
;;
1314
*)
1415
THREAD_LIBS="-lc_r"
15-
NEED_REENTRANT_FUNC_NAMES=yes
1616
;;
1717
esac

src/template/linux

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CFLAGS=-O2
22

33
SUPPORTS_THREADS=yes
4+
NEED_REENTRANT_FUNC_NAMES=yes
45
THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
56
THREAD_LIBS="-lpthread"
6-
NEED_REENTRANT_FUNC_NAMES=yes
77

src/template/netbsd

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ CFLAGS='-O2 -pipe'
22

33
SUPPORTS_THREADS=yes
44
NEED_REENTRANT_FUNC_NAMES=no
5-

0 commit comments

Comments
 (0)