diff options
author | Alexandre Oliva <oliva@dcc.unicamp.br> | 1999-08-01 00:14:32 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 1999-08-01 00:14:32 +0000 |
commit | 34c5c0e18c861856bef4bb8c4204d5dcf4a9dd4f (patch) | |
tree | 83d44668e24d60cd0ba72a110c5c6db1266ca3cc /libjava | |
parent | 5f67f48f90c767a2a8371bc4ddb5034a202e7488 (diff) | |
download | gcc-34c5c0e18c861856bef4bb8c4204d5dcf4a9dd4f.zip gcc-34c5c0e18c861856bef4bb8c4204d5dcf4a9dd4f.tar.gz gcc-34c5c0e18c861856bef4bb8c4204d5dcf4a9dd4f.tar.bz2 |
configure.in: Check for struct hostent_data and need for -D_REENTRANT for gethostbyname_r...
1999-07-31 Alexandre Oliva <oliva@dcc.unicamp.br>
* 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: r28369
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 8 | ||||
-rwxr-xr-x | libjava/configure | 275 | ||||
-rw-r--r-- | libjava/configure.in | 43 | ||||
-rw-r--r-- | libjava/include/config.h.in | 6 | ||||
-rw-r--r-- | libjava/java/net/natInetAddress.cc | 20 |
5 files changed, 268 insertions, 84 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index c6e8f03..351fa4e 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,13 @@ 1999-07-31 Alexandre Oliva <oliva@dcc.unicamp.br> + * 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 <oliva@dcc.unicamp.br> + * java/lang/natSystem.cc (arraycopy): Use bcopy if memmove is not available. Don't cast memmove args to (void*). * configure.in: Do not abort if memmove is not available. diff --git a/libjava/configure b/libjava/configure index 93e7266..e0af1c8 100755 --- a/libjava/configure +++ b/libjava/configure @@ -3477,6 +3477,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:3486: 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 <<EOF +#line 3499 "configure" +#include "confdefs.h" +#include <netdb.h> +int main() { +gethostbyname_r("", 0, 0); +; return 0; } +EOF +if { (eval echo configure:3506: \"$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 <<EOF +#line 3516 "configure" +#include "confdefs.h" +#include <netdb.h> +int main() { +gethostbyname_r("", 0, 0); +; return 0; } +EOF +if { (eval echo configure:3523: \"$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:3558: 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 <<EOF +#line 3563 "configure" +#include "confdefs.h" + +#if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT) +# define _REENTRANT 1 +#endif +#include <netdb.h> +int main() { +struct hostent_data data; +; return 0; } +EOF +if { (eval echo configure:3574: \"$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 @@ -3486,12 +3599,12 @@ done for ac_func in gethostbyaddr_r do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3490: checking for $ac_func" >&5 +echo "configure:3603: 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 <<EOF -#line 3495 "configure" +#line 3608 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3514,7 +3627,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3631: \"$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 @@ -3541,7 +3654,7 @@ EOF # We look for the one that returns `int'. # Hopefully this check is robust enough. cat > conftest.$ac_ext <<EOF -#line 3545 "configure" +#line 3658 "configure" #include "confdefs.h" #include <netdb.h> EOF @@ -3565,12 +3678,12 @@ done for ac_func in gethostname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3569: checking for $ac_func" >&5 +echo "configure:3682: 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 <<EOF -#line 3574 "configure" +#line 3687 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3593,7 +3706,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3710: \"$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 @@ -3617,7 +3730,7 @@ EOF EOF cat > conftest.$ac_ext <<EOF -#line 3621 "configure" +#line 3734 "configure" #include "confdefs.h" #include <unistd.h> EOF @@ -3644,12 +3757,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:3648: checking for $ac_func" >&5 +echo "configure:3761: 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 <<EOF -#line 3653 "configure" +#line 3766 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3672,7 +3785,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3789: \"$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 @@ -3700,12 +3813,12 @@ done for ac_func in sched_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3704: checking for $ac_func" >&5 +echo "configure:3817: 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 <<EOF -#line 3709 "configure" +#line 3822 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3728,7 +3841,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3732: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3845: \"$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 @@ -3750,7 +3863,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for sched_yield in -lposix4""... $ac_c" 1>&6 -echo "configure:3754: checking for sched_yield in -lposix4" >&5 +echo "configure:3867: 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 @@ -3758,7 +3871,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix4 $LIBS" cat > conftest.$ac_ext <<EOF -#line 3762 "configure" +#line 3875 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3769,7 +3882,7 @@ int main() { sched_yield() ; return 0; } EOF -if { (eval echo configure:3773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3886: \"$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 @@ -3804,12 +3917,12 @@ done for ac_func in gettimeofday time ftime do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3808: checking for $ac_func" >&5 +echo "configure:3921: 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 <<EOF -#line 3813 "configure" +#line 3926 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3832,7 +3945,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3949: \"$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 @@ -3863,12 +3976,12 @@ done for ac_func in memmove do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3867: checking for $ac_func" >&5 +echo "configure:3980: 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 <<EOF -#line 3872 "configure" +#line 3985 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3891,7 +4004,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4008: \"$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 @@ -3921,12 +4034,12 @@ done for ac_func in memcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3925: checking for $ac_func" >&5 +echo "configure:4038: 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 <<EOF -#line 3930 "configure" +#line 4043 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -3949,7 +4062,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:3953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4066: \"$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 @@ -3997,7 +4110,7 @@ done #-------------------------------------------------------------------- echo $ac_n "checking for socket libraries""... $ac_c" 1>&6 -echo "configure:4001: checking for socket libraries" >&5 +echo "configure:4114: 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 @@ -4005,12 +4118,12 @@ else gcj_checkBoth=0 unset ac_cv_func_connect echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:4009: checking for connect" >&5 +echo "configure:4122: 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 <<EOF -#line 4014 "configure" +#line 4127 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char connect(); below. */ @@ -4033,7 +4146,7 @@ connect(); ; return 0; } EOF -if { (eval echo configure:4037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4150: \"$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 @@ -4056,7 +4169,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:4060: checking for main in -lsocket" >&5 +echo "configure:4173: 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 @@ -4064,14 +4177,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <<EOF -#line 4068 "configure" +#line 4181 "configure" #include "confdefs.h" int main() { main() ; return 0; } EOF -if { (eval echo configure:4075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4188: \"$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 @@ -4098,12 +4211,12 @@ fi LIBS="$LIBS -lsocket -lnsl" unset ac_cv_func_accept echo $ac_n "checking for accept""... $ac_c" 1>&6 -echo "configure:4102: checking for accept" >&5 +echo "configure:4215: 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 <<EOF -#line 4107 "configure" +#line 4220 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char accept(); below. */ @@ -4126,7 +4239,7 @@ accept(); ; return 0; } EOF -if { (eval echo configure:4130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4243: \"$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 @@ -4153,12 +4266,12 @@ fi gcj_oldLibs=$LIBS LIBS="$LIBS $gcj_cv_lib_sockets" echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:4157: checking for gethostbyname" >&5 +echo "configure:4270: 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 <<EOF -#line 4162 "configure" +#line 4275 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char gethostbyname(); below. */ @@ -4181,7 +4294,7 @@ gethostbyname(); ; return 0; } EOF -if { (eval echo configure:4185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4298: \"$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 @@ -4199,7 +4312,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:4203: checking for main in -lnsl" >&5 +echo "configure:4316: 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 @@ -4207,14 +4320,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <<EOF -#line 4211 "configure" +#line 4324 "configure" #include "confdefs.h" int main() { main() ; return 0; } EOF -if { (eval echo configure:4218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4331: \"$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 @@ -4246,7 +4359,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:4250: checking for deflate in -lz" >&5 +echo "configure:4363: 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 @@ -4254,7 +4367,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat > conftest.$ac_ext <<EOF -#line 4258 "configure" +#line 4371 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4265,7 +4378,7 @@ int main() { deflate() ; return 0; } EOF -if { (eval echo configure:4269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4382: \"$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 @@ -4294,7 +4407,7 @@ fi # requires -ldl. if test "$GC" = boehm; then echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6 -echo "configure:4298: checking for main in -ldl" >&5 +echo "configure:4411: 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 @@ -4302,14 +4415,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <<EOF -#line 4306 "configure" +#line 4419 "configure" #include "confdefs.h" int main() { main() ; return 0; } EOF -if { (eval echo configure:4313: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4426: \"$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 @@ -4418,17 +4531,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:4422: checking for $ac_hdr" >&5 +echo "configure:4535: 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 -#line 4427 "configure" +#line 4540 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4432: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4545: \"$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* @@ -4458,17 +4571,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:4462: checking for $ac_hdr" >&5 +echo "configure:4575: 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 -#line 4467 "configure" +#line 4580 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4472: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4585: \"$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* @@ -4496,16 +4609,16 @@ done echo $ac_n "checking whether struct sockaddr_in6 is in netinet/in.h""... $ac_c" 1>&6 -echo "configure:4500: checking whether struct sockaddr_in6 is in netinet/in.h" >&5 +echo "configure:4613: checking whether struct sockaddr_in6 is in netinet/in.h" >&5 cat > conftest.$ac_ext <<EOF -#line 4502 "configure" +#line 4615 "configure" #include "confdefs.h" #include <netinet/in.h> int main() { struct sockaddr_in6 addr6; ; return 0; } EOF -if { (eval echo configure:4509: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4622: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_INET6 1 @@ -4521,16 +4634,16 @@ fi rm -f conftest* echo $ac_n "checking for socklen_t in sys/socket.h""... $ac_c" 1>&6 -echo "configure:4525: checking for socklen_t in sys/socket.h" >&5 +echo "configure:4638: checking for socklen_t in sys/socket.h" >&5 cat > conftest.$ac_ext <<EOF -#line 4527 "configure" +#line 4640 "configure" #include "confdefs.h" #include <sys/socket.h> int main() { socklen_t x = 5; ; return 0; } EOF -if { (eval echo configure:4534: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4647: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_SOCKLEN_T 1 @@ -4546,16 +4659,16 @@ fi rm -f conftest* echo $ac_n "checking for tm_gmtoff in struct tm""... $ac_c" 1>&6 -echo "configure:4550: checking for tm_gmtoff in struct tm" >&5 +echo "configure:4663: checking for tm_gmtoff in struct tm" >&5 cat > conftest.$ac_ext <<EOF -#line 4552 "configure" +#line 4665 "configure" #include "confdefs.h" #include <time.h> int main() { struct tm tim; tim.tm_gmtoff = 0; ; return 0; } EOF -if { (eval echo configure:4559: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4672: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define STRUCT_TM_HAS_GMTOFF 1 @@ -4568,16 +4681,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:4572: checking for global timezone variable" >&5 +echo "configure:4685: checking for global timezone variable" >&5 cat > conftest.$ac_ext <<EOF -#line 4574 "configure" +#line 4687 "configure" #include "confdefs.h" #include <time.h> int main() { long z2 = timezone; ; return 0; } EOF -if { (eval echo configure:4581: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4694: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_TIMEZONE 1 @@ -4597,19 +4710,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:4601: checking for working alloca.h" >&5 +echo "configure:4714: 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 <<EOF -#line 4606 "configure" +#line 4719 "configure" #include "confdefs.h" #include <alloca.h> int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:4613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4726: \"$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 @@ -4630,12 +4743,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:4634: checking for alloca" >&5 +echo "configure:4747: 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 <<EOF -#line 4639 "configure" +#line 4752 "configure" #include "confdefs.h" #ifdef __GNUC__ @@ -4663,7 +4776,7 @@ int main() { char *p = (char *) alloca(1); ; return 0; } EOF -if { (eval echo configure:4667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4780: \"$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 @@ -4695,12 +4808,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:4699: checking whether alloca needs Cray hooks" >&5 +echo "configure:4812: 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 <<EOF -#line 4704 "configure" +#line 4817 "configure" #include "confdefs.h" #if defined(CRAY) && ! defined(CRAY2) webecray @@ -4725,12 +4838,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&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:4729: checking for $ac_func" >&5 +echo "configure:4842: 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 <<EOF -#line 4734 "configure" +#line 4847 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4753,7 +4866,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4870: \"$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 @@ -4780,7 +4893,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:4784: checking stack direction for C alloca" >&5 +echo "configure:4897: 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 @@ -4788,7 +4901,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <<EOF -#line 4792 "configure" +#line 4905 "configure" #include "confdefs.h" find_stack_direction () { @@ -4807,7 +4920,7 @@ main () exit (find_stack_direction() < 0); } EOF -if { (eval echo configure:4811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4924: \"$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 @@ -4834,7 +4947,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:4838: checking for $ac_word" >&5 +echo "configure:4951: 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 46cfa21..0d62de6 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 <netdb.h>], + [gethostbyname_r("", 0, 0);], + [libjava_cv_gethostbyname_r_needs_reentrant=no], [dnl + CPPFLAGS_SAVE="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + AC_TRY_COMPILE([#include <netdb.h>], [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 <netdb.h>], [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 e6fbe5d..bd43c75 100644 --- a/libjava/include/config.h.in +++ b/libjava/include/config.h.in @@ -268,3 +268,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 feac469..b15590a 100644 --- a/libjava/java/net/natInetAddress.cc +++ b/libjava/java/net/natInetAddress.cc @@ -10,6 +10,10 @@ details. */ #include <config.h> +#if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT) +# define _REENTRANT 1 +#endif + #ifdef HAVE_UNISTD_H #include <unistd.h> #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 @@ -109,6 +116,7 @@ java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr, 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 */ |