about summary refs log tree commit diff stats
path: root/aclocal.m4
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2001-02-13 01:44:28 -0500
committerThomas E. Dickey <dickey@invisible-island.net>2001-02-13 01:44:28 -0500
commitaffaa4f761ddf2c0edce3e00f3a989a0ef8a44d8 (patch)
tree3da4fcaa7cba63a893e69b0e6737b6eb4cea4079 /aclocal.m4
parent2a786b2632ff4fe945cb5826f7a378778caf72eb (diff)
downloadlynx-snapshots-affaa4f761ddf2c0edce3e00f3a989a0ef8a44d8.tar.gz
snapshot of project "lynx", label v2-8-4dev_18
Diffstat (limited to 'aclocal.m4')
-rw-r--r--aclocal.m438
1 files changed, 32 insertions, 6 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index b2fede78..b7b32f39 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2567,9 +2567,9 @@ AC_MSG_RESULT($cf_use_socks5p_h)
 test "$cf_use_socks5p_h" = yes && AC_DEFINE(INCLUDE_PROTOTYPES)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl srand() and rand() are more standard, but we'll accept other variations
-dnl if they are available.  All return an integer between 0 and RAND_MAX,
-dnl which must be defined for use in scaling.
+dnl Check for functions similar to srand() and rand().  lrand48() and random()
+dnl return a 31-bit value, while rand() returns a value less than RAND_MAX
+dnl which usually is only 16-bits.
 AC_DEFUN([CF_SRAND],[
 AC_CACHE_CHECK(for random-integer functions, cf_cv_srand_func,[
 cf_cv_srand_func=unknown
@@ -2581,16 +2581,42 @@ AC_TRY_LINK([
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
 ],[long seed = 1; $cf_srand_func(seed); seed = $cf_rand_func()],
 [cf_cv_srand_func=$cf_func
  break])
 done
 ])
 if test "$cf_cv_srand_func" != unknown ; then
+	AC_CACHE_CHECK(for range of random-integers, cf_cv_rand_max,[
+		case $cf_cv_srand_func in
+		srand/rand)
+			cf_cv_rand_max=RAND_MAX
+			cf_rand_max=16
+			;;
+		*)
+			cf_cv_rand_max=INT_MAX
+			cf_rand_max=31
+			;;
+		esac
+		AC_TRY_COMPILE([
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+		],[long x = $cf_cv_rand_max],,
+		[cf_cv_rand_max="(1L<<$cf_rand_max)-1"])
+	])
 	cf_srand_func=`echo $cf_func | sed -e 's@/.*@@'`
-	cf_rand_func=`echo $cf_func | sed -e 's@.*/@@'`
-	AC_DEFINE_UNQUOTED(my_srand,$cf_srand_func)
-	AC_DEFINE_UNQUOTED(my_rand, $cf_rand_func)
+	cf_rand_func=`echo  $cf_func | sed -e 's@.*/@@'`
+	CF_UPPER(cf_rand_max,ifelse($1,,my_,$1)rand_max)
+	AC_DEFINE_UNQUOTED(ifelse($1,,my_,$1)srand,$cf_srand_func)
+	AC_DEFINE_UNQUOTED(ifelse($1,,my_,$1)rand, $cf_rand_func)
+	AC_DEFINE_UNQUOTED([$]cf_rand_max, $cf_cv_rand_max)
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------