From: Alexandre Oliva Date: Sun, 1 Aug 1999 00:14:00 +0000 (+0000) Subject: configure.in: Check for struct hostent_data and need for -D_REENTRANT for gethostbyna... X-Git-Tag: releases/libgcj-2.95.0~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37c8132a28658e51750ae26d6d2d1473c9e1b80e;p=thirdparty%2Fgcc.git configure.in: Check for struct hostent_data and need for -D_REENTRANT for gethostbyname_r... 1999-07-31 Alexandre Oliva * configure.in: Check for struct hostent_data and need for -D_REENTRANT for gethostbyname_r declaration. * java/net/natInetAddress.cc: Define _REENTRANT if needed. (lookup): Use hostent_data for fixed_buffer. * configure, include/config.h.in: Rebuilt. From-SVN: r28368 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index cf051217c93f..4e15f7c18037 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,11 @@ +1999-07-31 Alexandre Oliva + + * configure.in: Check for struct hostent_data and need for + -D_REENTRANT for gethostbyname_r declaration. + * java/net/natInetAddress.cc: Define _REENTRANT if needed. + (lookup): Use hostent_data for fixed_buffer. + * configure, include/config.h.in: Rebuilt. + 1999-07-31 Alexandre Oliva * include/javaprims.h (TRUE, FALSE): Redefine as themselves. diff --git a/libjava/configure b/libjava/configure index fc95e227f4cf..5ac3fcc5cd05 100755 --- a/libjava/configure +++ b/libjava/configure @@ -3474,6 +3474,119 @@ EOF fi rm -f conftest* + + case " $GCINCS " in + *" -D_REENTRANT "*) ;; + *) + echo $ac_n "checking whether gethostbyname_r declaration requires -D_REENTRANT""... $ac_c" 1>&6 +echo "configure:3483: checking whether gethostbyname_r declaration requires -D_REENTRANT" >&5 +if eval "test \"`echo '$''{'libjava_cv_gethostbyname_r_needs_reentrant'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + ac_ext=C +# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cxx_cross + + cat > conftest.$ac_ext < +int main() { +gethostbyname_r("", 0, 0); +; return 0; } +EOF +if { (eval echo configure:3503: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + libjava_cv_gethostbyname_r_needs_reentrant=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPPFLAGS_SAVE="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + cat > conftest.$ac_ext < +int main() { +gethostbyname_r("", 0, 0); +; return 0; } +EOF +if { (eval echo configure:3520: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + libjava_cv_gethostbyname_r_needs_reentrant=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + libjava_cv_gethostbyname_r_needs_reentrant=fail +fi +rm -f conftest* + CPPFLAGS="$CPPFLAGS_SAVE" + +fi +rm -f conftest* + ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + + +fi + +echo "$ac_t""$libjava_cv_gethostbyname_r_needs_reentrant" 1>&6 + if test "x$libjava_cv_gethostbyname_r_needs_reentrant" = xyes; then + cat >> confdefs.h <<\EOF +#define GETHOSTBYNAME_R_NEEDS_REENTRANT 1 +EOF + + fi + ;; + esac + + echo $ac_n "checking for struct hostent_data""... $ac_c" 1>&6 +echo "configure:3555: checking for struct hostent_data" >&5 +if eval "test \"`echo '$''{'libjava_cv_struct_hostent_data'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int main() { +struct hostent_data data; +; return 0; } +EOF +if { (eval echo configure:3571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + libjava_cv_struct_hostent_data=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + libjava_cv_struct_hostent_data=no +fi +rm -f conftest* +fi + +echo "$ac_t""$libjava_cv_struct_hostent_data" 1>&6 + if test "x$libjava_cv_struct_hostent_data" = xyes; then + cat >> confdefs.h <<\EOF +#define HAVE_STRUCT_HOSTENT_DATA 1 +EOF + + fi + else echo "$ac_t""no" 1>&6 fi @@ -3483,12 +3596,12 @@ done for ac_func in gethostbyaddr_r do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3487: checking for $ac_func" >&5 +echo "configure:3600: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3538,7 +3651,7 @@ EOF # We look for the one that returns `int'. # Hopefully this check is robust enough. cat > conftest.$ac_ext < EOF @@ -3562,12 +3675,12 @@ done for ac_func in gethostname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3566: checking for $ac_func" >&5 +echo "configure:3679: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3614,7 +3727,7 @@ EOF EOF cat > conftest.$ac_ext < EOF @@ -3641,12 +3754,12 @@ done for ac_func in pthread_mutexattr_settype pthread_mutexattr_setkind_np sched_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3645: checking for $ac_func" >&5 +echo "configure:3758: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3697,12 +3810,12 @@ done for ac_func in sched_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3701: checking for $ac_func" >&5 +echo "configure:3814: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3842: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3747,7 +3860,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for sched_yield in -lposix4""... $ac_c" 1>&6 -echo "configure:3751: checking for sched_yield in -lposix4" >&5 +echo "configure:3864: checking for sched_yield in -lposix4" >&5 ac_lib_var=`echo posix4'_'sched_yield | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3755,7 +3868,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix4 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3801,12 +3914,12 @@ done for ac_func in gettimeofday time ftime do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3805: checking for $ac_func" >&5 +echo "configure:3918: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3860,12 +3973,12 @@ done for ac_func in memmove do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3864: checking for $ac_func" >&5 +echo "configure:3977: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3918,12 +4031,12 @@ done for ac_func in memcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3922: checking for $ac_func" >&5 +echo "configure:4035: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4063: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3994,7 +4107,7 @@ done #-------------------------------------------------------------------- echo $ac_n "checking for socket libraries""... $ac_c" 1>&6 -echo "configure:3998: checking for socket libraries" >&5 +echo "configure:4111: checking for socket libraries" >&5 if eval "test \"`echo '$''{'gcj_cv_lib_sockets'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4002,12 +4115,12 @@ else gcj_checkBoth=0 unset ac_cv_func_connect echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:4006: checking for connect" >&5 +echo "configure:4119: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -4053,7 +4166,7 @@ fi if test "$gcj_checkSocket" = 1; then unset ac_cv_func_connect echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:4057: checking for main in -lsocket" >&5 +echo "configure:4170: checking for main in -lsocket" >&5 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4061,14 +4174,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4095,12 +4208,12 @@ fi LIBS="$LIBS -lsocket -lnsl" unset ac_cv_func_accept echo $ac_n "checking for accept""... $ac_c" 1>&6 -echo "configure:4099: checking for accept" >&5 +echo "configure:4212: checking for accept" >&5 if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_accept=yes" else @@ -4150,12 +4263,12 @@ fi gcj_oldLibs=$LIBS LIBS="$LIBS $gcj_cv_lib_sockets" echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:4154: checking for gethostbyname" >&5 +echo "configure:4267: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -4196,7 +4309,7 @@ if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:4200: checking for main in -lnsl" >&5 +echo "configure:4313: checking for main in -lnsl" >&5 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4204,14 +4317,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4243,7 +4356,7 @@ echo "$ac_t""$gcj_cv_lib_sockets" 1>&6 if test "$with_system_zlib" = yes; then echo $ac_n "checking for deflate in -lz""... $ac_c" 1>&6 -echo "configure:4247: checking for deflate in -lz" >&5 +echo "configure:4360: checking for deflate in -lz" >&5 ac_lib_var=`echo z'_'deflate | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4251,7 +4364,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4291,7 +4404,7 @@ fi # requires -ldl. if test "$GC" = boehm; then echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6 -echo "configure:4295: checking for main in -ldl" >&5 +echo "configure:4408: checking for main in -ldl" >&5 ac_lib_var=`echo dl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4299,14 +4412,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4423: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4415,17 +4528,17 @@ for ac_hdr in unistd.h sys/time.h sys/types.h fcntl.h sys/ioctl.h sys/filio.h sy do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4419: checking for $ac_hdr" >&5 +echo "configure:4532: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4429: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4542: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4455,17 +4568,17 @@ for ac_hdr in dirent.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4459: checking for $ac_hdr" >&5 +echo "configure:4572: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4469: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4582: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4493,16 +4606,16 @@ done echo $ac_n "checking whether struct sockaddr_in6 is in netinet/in.h""... $ac_c" 1>&6 -echo "configure:4497: checking whether struct sockaddr_in6 is in netinet/in.h" >&5 +echo "configure:4610: checking whether struct sockaddr_in6 is in netinet/in.h" >&5 cat > conftest.$ac_ext < int main() { struct sockaddr_in6 addr6; ; return 0; } EOF -if { (eval echo configure:4506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4619: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_INET6 1 @@ -4518,16 +4631,16 @@ fi rm -f conftest* echo $ac_n "checking for socklen_t in sys/socket.h""... $ac_c" 1>&6 -echo "configure:4522: checking for socklen_t in sys/socket.h" >&5 +echo "configure:4635: checking for socklen_t in sys/socket.h" >&5 cat > conftest.$ac_ext < int main() { socklen_t x = 5; ; return 0; } EOF -if { (eval echo configure:4531: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4644: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_SOCKLEN_T 1 @@ -4543,16 +4656,16 @@ fi rm -f conftest* echo $ac_n "checking for tm_gmtoff in struct tm""... $ac_c" 1>&6 -echo "configure:4547: checking for tm_gmtoff in struct tm" >&5 +echo "configure:4660: checking for tm_gmtoff in struct tm" >&5 cat > conftest.$ac_ext < int main() { struct tm tim; tim.tm_gmtoff = 0; ; return 0; } EOF -if { (eval echo configure:4556: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4669: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define STRUCT_TM_HAS_GMTOFF 1 @@ -4565,16 +4678,16 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6 echo $ac_n "checking for global timezone variable""... $ac_c" 1>&6 -echo "configure:4569: checking for global timezone variable" >&5 +echo "configure:4682: checking for global timezone variable" >&5 cat > conftest.$ac_ext < int main() { long z2 = timezone; ; return 0; } EOF -if { (eval echo configure:4578: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4691: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_TIMEZONE 1 @@ -4594,19 +4707,19 @@ rm -f conftest* # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:4598: checking for working alloca.h" >&5 +echo "configure:4711: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:4610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -4627,12 +4740,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:4631: checking for alloca" >&5 +echo "configure:4744: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -4692,12 +4805,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:4696: checking whether alloca needs Cray hooks" >&5 +echo "configure:4809: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4726: checking for $ac_func" >&5 +echo "configure:4839: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4777,7 +4890,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:4781: checking stack direction for C alloca" >&5 +echo "configure:4894: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4785,7 +4898,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4921: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -4827,7 +4940,7 @@ fi echo $ac_n "checking for g++ -g jboolean bug""... $ac_c" 1>&6 -echo "configure:4831: checking for g++ -g jboolean bug" >&5 +echo "configure:4944: checking for g++ -g jboolean bug" >&5 if eval "test \"`echo '$''{'libjava_cv_gxx_debug_jboolean_bug'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4840,14 +4953,14 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4964: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libjava_cv_gxx_debug_jboolean_bug=no else @@ -4881,7 +4994,7 @@ 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 $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4885: checking for $ac_word" >&5 +echo "configure:4998: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else diff --git a/libjava/configure.in b/libjava/configure.in index 9f926a072cc5..611f16b434f2 100644 --- a/libjava/configure.in +++ b/libjava/configure.in @@ -309,7 +309,48 @@ else # We look for the one that returns `int'. # Hopefully this check is robust enough. AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [ - AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT)])]) + AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT)]) + + case " $GCINCS " in + *" -D_REENTRANT "*) ;; + *) + dnl On DU4.0, gethostbyname_r is only declared with -D_REENTRANT + AC_CACHE_CHECK([whether gethostbyname_r declaration requires -D_REENTRANT], + [libjava_cv_gethostbyname_r_needs_reentrant], + [ AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include ], + [gethostbyname_r("", 0, 0);], + [libjava_cv_gethostbyname_r_needs_reentrant=no], [dnl + CPPFLAGS_SAVE="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + AC_TRY_COMPILE([#include ], [gethostbyname_r("", 0, 0);], + [libjava_cv_gethostbyname_r_needs_reentrant=yes], + [libjava_cv_gethostbyname_r_needs_reentrant=fail]) + CPPFLAGS="$CPPFLAGS_SAVE" + ]) + AC_LANG_RESTORE + ]) + if test "x$libjava_cv_gethostbyname_r_needs_reentrant" = xyes; then + AC_DEFINE(GETHOSTBYNAME_R_NEEDS_REENTRANT, 1, [Define if gethostbyname_r is only declared if _REENTRANT is defined]) + fi + ;; + esac + + AC_CACHE_CHECK([for struct hostent_data], + [libjava_cv_struct_hostent_data], [dnl + AC_TRY_COMPILE([ +#if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT) +# define _REENTRANT 1 +#endif +#include ], [struct hostent_data data;], + [libjava_cv_struct_hostent_data=yes], + [libjava_cv_struct_hostent_data=no])]) + if test "x$libjava_cv_struct_hostent_data" = xyes; then + AC_DEFINE(HAVE_STRUCT_HOSTENT_DATA, 1, + [Define if struct hostent_data is defined in netdb.h]) + fi + ]) AC_CHECK_FUNCS(gethostbyaddr_r, [ AC_DEFINE(HAVE_GETHOSTBYADDR_R) diff --git a/libjava/include/config.h.in b/libjava/include/config.h.in index be94a759c0db..b87f54e8edec 100644 --- a/libjava/include/config.h.in +++ b/libjava/include/config.h.in @@ -265,3 +265,9 @@ /* Version number of package */ #undef VERSION +/* Define if gethostbyname_r is only declared if _REENTRANT is defined */ +#undef GETHOSTBYNAME_R_NEEDS_REENTRANT + +/* Define if struct hostent_data is defined in netdb.h */ +#undef HAVE_STRUCT_HOSTENT_DATA + diff --git a/libjava/java/net/natInetAddress.cc b/libjava/java/net/natInetAddress.cc index feac469f3796..b15590a0ebc7 100644 --- a/libjava/java/net/natInetAddress.cc +++ b/libjava/java/net/natInetAddress.cc @@ -10,6 +10,10 @@ details. */ #include +#if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT) +# define _REENTRANT 1 +#endif + #ifdef HAVE_UNISTD_H #include #endif @@ -97,6 +101,9 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, struct hostent *hptr = NULL; #if defined (HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYADDR_R) struct hostent hent_r; +#if HAVE_STRUCT_HOSTENT_DATA + struct hostent_data fixed_buffer, *buffer_r = &fixed_buffer; +#else #if defined (__GLIBC__) // FIXME: in glibc, gethostbyname_r returns NETDB_INTERNAL to herr and // ERANGE to errno if the buffer size is too small, rather than what is @@ -108,6 +115,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, #endif char *buffer_r = fixed_buffer; int size_r = sizeof (fixed_buffer); +#endif #endif if (host != NULL) @@ -122,10 +130,13 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, JvGetStringUTFRegion (host, 0, host->length(), hostname); buf[len] = '\0'; #ifdef HAVE_GETHOSTBYNAME_R - int herr = 0; while (true) { int ok; +#if HAVE_STRUCT_HOSTENT_DATA + ok = ! gethostbyname_r (hostname, &hent_r, buffer_r); +#else + int herr = 0; #ifdef GETHOSTBYNAME_R_RETURNS_INT ok = ! gethostbyname_r (hostname, &hent_r, buffer_r, size_r, &hptr, &herr); @@ -139,6 +150,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, buffer_r = (char *) _Jv_AllocBytesChecked (size_r); } else +#endif /* HAVE_STRUCT_HOSTENT_DATA */ break; } #else @@ -171,10 +183,13 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, JvFail ("unrecognized size"); #ifdef HAVE_GETHOSTBYADDR_R - int herr = 0; while (true) { int ok; +#if HAVE_STRUCT_HOSTENT_DATA + ok = ! gethostbyaddr_r (val, len, type, &hent_r, buffer_r); +#else + int herr = 0; #ifdef GETHOSTBYADDR_R_RETURNS_INT ok = ! gethostbyaddr_r (val, len, type, &hent_r, buffer_r, size_r, &hptr, &herr); @@ -189,6 +204,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, buffer_r = (char *) _Jv_AllocBytesChecked (size_r); } else +#endif /* HAVE_STRUCT_HOSTENT_DATA */ break; } #else /* HAVE_GETHOSTBYADDR_R */