From 222a5b1d6701dd5de06526b4bc4523a807b160c7 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Wed, 1 Oct 2003 20:45:59 +0000 Subject: [PATCH] linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0): Define. * linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0): Define. (GLIBCXX_CHECK_STDLIB_SUPPORT): Use it to test for lrand48 instead of drand48. * acconfig.h (HAVE_DRAND48): Renamed to HAVE_LRAND48. * crossconfig.m4 (*-freebsd*): Define HAVE_LRAND48 instead of HAVE_DRAND48. * config.h.in, configure: Regenerate. * include/bits/stl_algo.h: Use _GLIBCXX_HAVE_LRAND48 to guard lrand48 use. From-SVN: r71990 --- libstdc++-v3/ChangeLog | 12 +++ libstdc++-v3/acconfig.h | 4 +- libstdc++-v3/config.h.in | 8 +- libstdc++-v3/configure | 140 ++++++++++++++++++++++++++- libstdc++-v3/crossconfig.m4 | 2 +- libstdc++-v3/include/bits/stl_algo.h | 2 +- libstdc++-v3/linkage.m4 | 33 ++++++- 7 files changed, 188 insertions(+), 13 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4d0f71b420c..4bf9102d8bb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2003-10-01 Rainer Orth + + * linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0): Define. + (GLIBCXX_CHECK_STDLIB_SUPPORT): Use it to test for lrand48 + instead of drand48. + * acconfig.h (HAVE_DRAND48): Renamed to HAVE_LRAND48. + * crossconfig.m4 (*-freebsd*): Define HAVE_LRAND48 instead of + HAVE_DRAND48. + * config.h.in, configure: Regenerate. + * include/bits/stl_algo.h: Use _GLIBCXX_HAVE_LRAND48 to guard + lrand48 use. + 2003-10-01 Nathan Myers * include/bits/locale_facets.tcc (time_put::put): Avoid diff --git a/libstdc++-v3/acconfig.h b/libstdc++-v3/acconfig.h index 783f6d6db5e..1532bb2d1dc 100644 --- a/libstdc++-v3/acconfig.h +++ b/libstdc++-v3/acconfig.h @@ -63,8 +63,8 @@ // Define if gthr-default.h exists (meaning that threading support is enabled). #undef HAVE_GTHR_DEFAULT -// Define if drand48 exists. -#undef HAVE_DRAND48 +// Define if lrand48 exists. +#undef HAVE_LRAND48 // Define if getpagesize exists. #undef HAVE_GETPAGESIZE diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 2233e82a8a6..b9a9d146354 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -64,8 +64,8 @@ // Define if gthr-default.h exists (meaning that threading support is enabled). #undef HAVE_GTHR_DEFAULT -// Define if drand48 exists. -#undef HAVE_DRAND48 +// Define if lrand48 exists. +#undef HAVE_LRAND48 // Define if getpagesize exists. #undef HAVE_GETPAGESIZE @@ -221,8 +221,8 @@ /* Define to 1 if you have the `cosl' function. */ #undef HAVE_COSL -/* Define to 1 if you have the `drand48' function. */ -#undef HAVE_DRAND48 +/* Define to 1 if you have the `lrand48' function. */ +#undef HAVE_LRAND48 /* Define to 1 if you have the header file. */ #undef HAVE_ENDIAN_H diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 4c8a71b6195..4bf083265e9 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -26140,7 +26140,72 @@ done fi -for ac_func in drand48 + echo "$as_me:$LINENO: checking for lrand48 declaration" >&5 +echo $ECHO_N "checking for lrand48 declaration... $ECHO_C" >&6 + if test x${glibcxx_cv_func_lrand48_use+set} != xset; then + if test "${glibcxx_cv_func_lrand48_use+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + + + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + lrand48(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (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 + glibcxx_cv_func_lrand48_use=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +glibcxx_cv_func_lrand48_use=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi + + fi + echo "$as_me:$LINENO: result: $glibcxx_cv_func_lrand48_use" >&5 +echo "${ECHO_T}$glibcxx_cv_func_lrand48_use" >&6 + if test x$glibcxx_cv_func_lrand48_use = x"yes"; then + +for ac_func in lrand48 do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -26228,6 +26293,8 @@ _ACEOF fi done + fi + CXXFLAGS="$ac_save_CXXFLAGS" @@ -46100,7 +46167,72 @@ done fi -for ac_func in drand48 + echo "$as_me:$LINENO: checking for lrand48 declaration" >&5 +echo $ECHO_N "checking for lrand48 declaration... $ECHO_C" >&6 + if test x${glibcxx_cv_func_lrand48_use+set} != xset; then + if test "${glibcxx_cv_func_lrand48_use+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + + + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + lrand48(); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (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 + glibcxx_cv_func_lrand48_use=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +glibcxx_cv_func_lrand48_use=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi + + fi + echo "$as_me:$LINENO: result: $glibcxx_cv_func_lrand48_use" >&5 +echo "${ECHO_T}$glibcxx_cv_func_lrand48_use" >&6 + if test x$glibcxx_cv_func_lrand48_use = x"yes"; then + +for ac_func in lrand48 do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -46188,6 +46320,8 @@ _ACEOF fi done + fi + CXXFLAGS="$ac_save_CXXFLAGS" @@ -48730,7 +48864,7 @@ echo "${ECHO_T}$enable_wchar_t" >&6 _ACEOF cat >>confdefs.h <<\_ACEOF -#define HAVE_DRAND48 1 +#define HAVE_LRAND48 1 _ACEOF cat >>confdefs.h <<\_ACEOF diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 index db31b7eca74..2da80389263 100644 --- a/libstdc++-v3/crossconfig.m4 +++ b/libstdc++-v3/crossconfig.m4 @@ -54,7 +54,7 @@ case "${host}" in GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT GLIBCXX_CHECK_WCHAR_T_SUPPORT AC_DEFINE(HAVE_LC_MESSAGES) - AC_DEFINE(HAVE_DRAND48) + AC_DEFINE(HAVE_LRAND48) AC_DEFINE(HAVE_GETPAGESIZE) AC_DEFINE(HAVE_SETENV) AC_DEFINE(HAVE_SIGSETJMP) diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 83e56469cc6..062550cc98b 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -1612,7 +1612,7 @@ namespace std inline _Distance __random_number(_Distance __n) { - #ifdef _GLIBCXX_HAVE_DRAND48 + #ifdef _GLIBCXX_HAVE_LRAND48 return lrand48() % __n; #else return rand() % __n; diff --git a/libstdc++-v3/linkage.m4 b/libstdc++-v3/linkage.m4 index fc4e22924b9..9597635359c 100644 --- a/libstdc++-v3/linkage.m4 +++ b/libstdc++-v3/linkage.m4 @@ -166,6 +166,35 @@ AC_DEFUN(GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3, [ ]) +dnl +dnl Check to see if the (stdlib function) argument passed is +dnl 1) declared when using the c++ compiler +dnl 2) has "C" linkage +dnl +dnl argument 1 is name of function to check +dnl +dnl ASSUMES argument is a stdlib function without parameters +dnl +dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0 +AC_DEFUN(GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0, [ + AC_MSG_CHECKING([for $1 declaration]) + if test x${glibcxx_cv_func_$1_use+set} != xset; then + AC_CACHE_VAL(glibcxx_cv_func_$1_use, [ + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include ], + [ $1();], + [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no]) + AC_LANG_RESTORE + ]) + fi + AC_MSG_RESULT($glibcxx_cv_func_$1_use) + if test x$glibcxx_cv_func_$1_use = x"yes"; then + AC_CHECK_FUNCS($1) + fi +]) + + dnl dnl Check to see if the (stdlib function) argument passed is dnl 1) declared when using the c++ compiler @@ -342,7 +371,7 @@ dnl This might seem like overkill but experience has shown that it's not... dnl dnl Define HAVE_STRTOLD if "strtold" is declared and links dnl Define HAVE_STRTOF if "strtof" is declared and links -dnl Define HAVE_DRAND48 if "drand48" is declared and links +dnl Define HAVE_LRAND48 if "lrand48" is declared and links dnl dnl GLIBCXX_CHECK_STDLIB_SUPPORT AC_DEFUN(GLIBCXX_CHECK_STDLIB_SUPPORT, [ @@ -352,7 +381,7 @@ AC_DEFUN(GLIBCXX_CHECK_STDLIB_SUPPORT, [ GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold) GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof) - AC_CHECK_FUNCS(drand48) + GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0(lrand48) CXXFLAGS="$ac_save_CXXFLAGS" ])