summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-01-12 22:54:15 +0100
committerBruno Haible <bruno@clisp.org>2012-01-12 22:54:15 +0100
commit2c0e4c5dc88b2161bd53617a02c36e87954c7b5e (patch)
treeb473f7f34903fdd23fa440ac123e48c5a44b6b2a
parentb2e2341dc7a666aa9ec733d6259d4fbab80c5e9b (diff)
downloadgnulib-2c0e4c5dc88b2161bd53617a02c36e87954c7b5e.tar.gz
random_r: Override incompatible API on AIX, OSF/1.
* lib/stdlib.in.h (random_r, srandom_r, initstate_r, setstate_r): Override the system function if REPLACE_RANDOM_R is 1. * m4/random_r.m4 (gl_FUNC_RANDOM_R): Require AC_CANONICAL_HOST. On AIX and OSF/1, set REPLACE_RANDOM_R. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_RANDOM_R. * modules/stdlib (Makefile.am): Substitute REPLACE_RANDOM_R. * modules/random_r (configure.ac): Test REPLACE_RANDOM_R. * doc/glibc-functions/initstate_r.texi: Mention the AIX, OSF/1 problem. * doc/glibc-functions/random_r.texi: Likewise. * doc/glibc-functions/setstate_r.texi: Likewise.
-rw-r--r--ChangeLog12
-rw-r--r--doc/glibc-functions/initstate_r.texi3
-rw-r--r--doc/glibc-functions/random_r.texi3
-rw-r--r--doc/glibc-functions/setstate_r.texi3
-rw-r--r--lib/stdlib.in.h66
-rw-r--r--m4/random_r.m420
-rw-r--r--m4/stdlib_h.m43
-rw-r--r--modules/random_r2
-rw-r--r--modules/stdlib1
9 files changed, 97 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 9a0a69a760..d85e99aac7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2012-01-12 Bruno Haible <bruno@clisp.org>
+ random_r: Override incompatible API on AIX, OSF/1.
+ * lib/stdlib.in.h (random_r, srandom_r, initstate_r, setstate_r):
+ Override the system function if REPLACE_RANDOM_R is 1.
+ * m4/random_r.m4 (gl_FUNC_RANDOM_R): Require AC_CANONICAL_HOST. On AIX
+ and OSF/1, set REPLACE_RANDOM_R.
+ * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_RANDOM_R.
+ * modules/stdlib (Makefile.am): Substitute REPLACE_RANDOM_R.
+ * modules/random_r (configure.ac): Test REPLACE_RANDOM_R.
+ * doc/glibc-functions/initstate_r.texi: Mention the AIX, OSF/1 problem.
+ * doc/glibc-functions/random_r.texi: Likewise.
+ * doc/glibc-functions/setstate_r.texi: Likewise.
+
random_r: Support for MSVC 9.
* lib/random_r.c: Include stdint.h, not inttypes.h.
diff --git a/doc/glibc-functions/initstate_r.texi b/doc/glibc-functions/initstate_r.texi
index 03a90a2b7d..2ad27b5a38 100644
--- a/doc/glibc-functions/initstate_r.texi
+++ b/doc/glibc-functions/initstate_r.texi
@@ -9,6 +9,9 @@ Portability problems fixed by Gnulib:
@item
This function is missing on some platforms:
MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 11 2011-11, Cygwin, mingw, MSVC 9, Interix 3.5.
+@item
+This function has an incompatible declaration on some platforms:
+AIX 7.1, OSF/1 5.1.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/doc/glibc-functions/random_r.texi b/doc/glibc-functions/random_r.texi
index ee1e692986..cdd0b5934c 100644
--- a/doc/glibc-functions/random_r.texi
+++ b/doc/glibc-functions/random_r.texi
@@ -9,6 +9,9 @@ Portability problems fixed by Gnulib:
@item
This function is missing on some platforms:
MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 11 2011-11, Cygwin, mingw, MSVC 9, Interix 3.5.
+@item
+This function has an incompatible declaration on some platforms:
+AIX 7.1, OSF/1 5.1.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/doc/glibc-functions/setstate_r.texi b/doc/glibc-functions/setstate_r.texi
index c1a3a5a566..a906724723 100644
--- a/doc/glibc-functions/setstate_r.texi
+++ b/doc/glibc-functions/setstate_r.texi
@@ -9,6 +9,9 @@ Portability problems fixed by Gnulib:
@item
This function is missing on some platforms:
MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 11 2011-11, Cygwin, mingw, MSVC 9, Interix 3.5.
+@item
+This function has an incompatible declaration on some platforms:
+AIX 7.1, OSF/1 5.1.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index ea1c1c3be3..0a439e1b0b 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -58,7 +58,7 @@
# include <random.h>
# endif
-# if !@HAVE_STRUCT_RANDOM_DATA@ || !@HAVE_RANDOM_R@
+# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
# include <stdint.h>
# endif
@@ -505,11 +505,21 @@ _GL_CXXALIASWARN (putenv);
#endif
#if @GNULIB_RANDOM_R@
-# if !@HAVE_RANDOM_R@
+# if @REPLACE_RANDOM_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef random_r
+# define random_r rpl_random_r
+# endif
+_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
+# else
+# if !@HAVE_RANDOM_R@
_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
_GL_ARG_NONNULL ((1, 2)));
-# endif
+# endif
_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
+# endif
_GL_CXXALIASWARN (random_r);
#elif defined GNULIB_POSIXCHECK
# undef random_r
@@ -520,13 +530,25 @@ _GL_WARN_ON_USE (random_r, "random_r is unportable - "
#endif
#if @GNULIB_RANDOM_R@
-# if !@HAVE_RANDOM_R@
+# if @REPLACE_RANDOM_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef srandom_r
+# define srandom_r rpl_srandom_r
+# endif
+_GL_FUNCDECL_RPL (srandom_r, int,
+ (unsigned int seed, struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (srandom_r, int,
+ (unsigned int seed, struct random_data *rand_state));
+# else
+# if !@HAVE_RANDOM_R@
_GL_FUNCDECL_SYS (srandom_r, int,
(unsigned int seed, struct random_data *rand_state)
_GL_ARG_NONNULL ((2)));
-# endif
+# endif
_GL_CXXALIAS_SYS (srandom_r, int,
(unsigned int seed, struct random_data *rand_state));
+# endif
_GL_CXXALIASWARN (srandom_r);
#elif defined GNULIB_POSIXCHECK
# undef srandom_r
@@ -537,15 +559,29 @@ _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
#endif
#if @GNULIB_RANDOM_R@
-# if !@HAVE_RANDOM_R@
+# if @REPLACE_RANDOM_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef initstate_r
+# define initstate_r rpl_initstate_r
+# endif
+_GL_FUNCDECL_RPL (initstate_r, int,
+ (unsigned int seed, char *buf, size_t buf_size,
+ struct random_data *rand_state)
+ _GL_ARG_NONNULL ((2, 4)));
+_GL_CXXALIAS_RPL (initstate_r, int,
+ (unsigned int seed, char *buf, size_t buf_size,
+ struct random_data *rand_state));
+# else
+# if !@HAVE_RANDOM_R@
_GL_FUNCDECL_SYS (initstate_r, int,
(unsigned int seed, char *buf, size_t buf_size,
struct random_data *rand_state)
_GL_ARG_NONNULL ((2, 4)));
-# endif
+# endif
_GL_CXXALIAS_SYS (initstate_r, int,
(unsigned int seed, char *buf, size_t buf_size,
struct random_data *rand_state));
+# endif
_GL_CXXALIASWARN (initstate_r);
#elif defined GNULIB_POSIXCHECK
# undef initstate_r
@@ -556,13 +592,25 @@ _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
#endif
#if @GNULIB_RANDOM_R@
-# if !@HAVE_RANDOM_R@
+# if @REPLACE_RANDOM_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef setstate_r
+# define setstate_r rpl_setstate_r
+# endif
+_GL_FUNCDECL_RPL (setstate_r, int,
+ (char *arg_state, struct random_data *rand_state)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (setstate_r, int,
+ (char *arg_state, struct random_data *rand_state));
+# else
+# if !@HAVE_RANDOM_R@
_GL_FUNCDECL_SYS (setstate_r, int,
(char *arg_state, struct random_data *rand_state)
_GL_ARG_NONNULL ((1, 2)));
-# endif
+# endif
_GL_CXXALIAS_SYS (setstate_r, int,
(char *arg_state, struct random_data *rand_state));
+# endif
_GL_CXXALIASWARN (setstate_r);
#elif defined GNULIB_POSIXCHECK
# undef setstate_r
diff --git a/m4/random_r.m4 b/m4/random_r.m4
index 7dddada1a3..f8f863d302 100644
--- a/m4/random_r.m4
+++ b/m4/random_r.m4
@@ -1,4 +1,4 @@
-# serial 4
+# serial 5
dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_RANDOM_R],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
if test $ac_cv_header_random_h = no; then
@@ -21,10 +22,19 @@ AC_DEFUN([gl_FUNC_RANDOM_R],
#endif
]])
- AC_CHECK_FUNCS([random_r])
- if test $ac_cv_func_random_r = no; then
- HAVE_RANDOM_R=0
- fi
+ dnl On AIX and OSF/1, these functions exist, but with different declarations.
+ dnl Override them all.
+ case "$host_os" in
+ aix* | osf*)
+ REPLACE_RANDOM_R=1
+ ;;
+ *)
+ AC_CHECK_FUNCS([random_r])
+ if test $ac_cv_func_random_r = no; then
+ HAVE_RANDOM_R=0
+ fi
+ ;;
+ esac
])
# Prerequisites of lib/random_r.c.
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index bcb4cb854c..85f7126d30 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 39
+# stdlib_h.m4 serial 40
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -101,6 +101,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R])
REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
+ REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC])
REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
diff --git a/modules/random_r b/modules/random_r
index 41b9b8d4ec..52a8842795 100644
--- a/modules/random_r
+++ b/modules/random_r
@@ -11,7 +11,7 @@ stdint
configure.ac:
gl_FUNC_RANDOM_R
-if test $HAVE_RANDOM_R = 0; then
+if test $HAVE_RANDOM_R = 0 || test $REPLACE_RANDOM_R = 1; then
AC_LIBOBJ([random_r])
gl_PREREQ_RANDOM_R
fi
diff --git a/modules/stdlib b/modules/stdlib
index 2beee3d2e5..4633841ad2 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -95,6 +95,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
-e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
-e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
-e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \