summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-02-08 12:27:12 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2011-02-08 12:28:28 -0800
commit7e50c8f03e02002e7cf66f05844501be136fedd0 (patch)
treefc97569a34f39283fac5857cad15311378e091c1
parent4f8c7a6e29f65cb71eca3092f712c71d580ba936 (diff)
downloadgnulib-7e50c8f03e02002e7cf66f05844501be136fedd0.tar.gz
stdlib: improve random_r modularization
-rw-r--r--ChangeLog11
-rw-r--r--lib/stdlib.in.h24
-rw-r--r--m4/random_r.m47
-rw-r--r--m4/stdlib_h.m410
4 files changed, 33 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index e29abe8ad9..6c79e2c85d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,15 @@
2011-02-08 Paul Eggert <eggert@cs.ucla.edu>
+ Bruno Haible <bruno@clisp.org>
+
+ stdlib: improve random_r modularization
+ * lib/stdlib.in.h: Encapsulate all the stuff having to do with
+ random_r inside "#if @GNULIB_RANDOM_R@", so that it's clearer that
+ you also need the random_r module to get this material right.
+ * m4/random_r.m4 (gl_FUNC_RANDOM_R): Move check for random.h here ...
+ * m4/stdlib_h.m4 (gl_STDLIB_H): ... from here.
+ (gl_STDLIB_H_DEFAULTS): Default HAVE_RANDOM_H to 1, and AC_SUBST it.
+
+2011-02-08 Paul Eggert <eggert@cs.ucla.edu>
stdlib: don't depend on stdint
* lib/stdlib.in.h: Don't include <stdint.h> merely because
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index b3bb9d4e5d..6e69a277af 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -49,20 +49,23 @@
# include <sys/loadavg.h>
#endif
+#if @GNULIB_RANDOM_R@
+
/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
- from <stdlib.h> if _REENTRANT is defined. Include it always. */
-#if @HAVE_RANDOM_H@
-# include <random.h>
-#endif
+ from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
+ 'struct random_data'. */
+# if @HAVE_RANDOM_H@
+# include <random.h>
+# endif
-#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@)
-# include <stdint.h>
-#endif
+# if !@HAVE_STRUCT_RANDOM_DATA@ || !@HAVE_RANDOM_R@
+# include <stdint.h>
+# endif
-#if !@HAVE_STRUCT_RANDOM_DATA@
+# if !@HAVE_STRUCT_RANDOM_DATA@
/* Define 'struct random_data'.
But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
-# if !GNULIB_defined_struct_random_data
+# if !GNULIB_defined_struct_random_data
struct random_data
{
int32_t *fptr; /* Front pointer. */
@@ -73,7 +76,8 @@ struct random_data
int rand_sep; /* Distance between front and rear. */
int32_t *end_ptr; /* Pointer behind state table. */
};
-# define GNULIB_defined_struct_random_data 1
+# define GNULIB_defined_struct_random_data 1
+# endif
# endif
#endif
diff --git a/m4/random_r.m4 b/m4/random_r.m4
index 81ede1fa09..cbe445d801 100644
--- a/m4/random_r.m4
+++ b/m4/random_r.m4
@@ -1,4 +1,4 @@
-# serial 2
+# serial 3
dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,11 @@ AC_DEFUN([gl_FUNC_RANDOM_R],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+ AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
+ if test $ac_cv_header_random_h = no; then
+ HAVE_RANDOM_H=0
+ fi
+
AC_CHECK_TYPES([struct random_data],
[], [HAVE_STRUCT_RANDOM_DATA=0],
[[#include <stdlib.h>
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 28eb1a0e53..d28b552e90 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 35
+# stdlib_h.m4 serial 36
dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -8,13 +8,6 @@ AC_DEFUN([gl_STDLIB_H],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
gl_NEXT_HEADERS([stdlib.h])
- AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
- if test $ac_cv_header_random_h = yes; then
- HAVE_RANDOM_H=1
- else
- HAVE_RANDOM_H=0
- fi
- AC_SUBST([HAVE_RANDOM_H])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use, and which is not
@@ -82,6 +75,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
+ HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H])
HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])