[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
random_r on AIX, OSF/1
From: |
Bruno Haible |
Subject: |
random_r on AIX, OSF/1 |
Date: |
Thu, 12 Jan 2012 22:54:32 +0100 |
User-agent: |
KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; ) |
The 'random_r' module is supposed to implement the glibc API. But
it fails to override the native API on AIX and OSF/1. Comparison:
glibc API:
int random_r (struct random_data *buf, int32_t *result);
int srandom_r (unsigned int seed, struct random_data *buf);
int initstate_r (unsigned int seed, char *statebuf,
size_t statelen, struct random_data *buf);
int setstate_r (char *statebuf, struct random_data *buf);
AIX, OSF/1 API:
int random_r ({int,long} *result, struct random_data *buf);
int srandom_r (unsigned int seed, struct random_data *buf);
int initstate_r (unsigned int seed, char *statebuf,
{int|size_t} size, char **retval, struct random_data *buf);
int setstate_r (char *state, char **retval, struct random_data *buf);
On AIX, the declarations are not present if -D_ALL_SOURCE -D_THREAD_SAFE
are not defined. And on OSF/1 the declarations occur in <random.h>, not
in <stdlib.h>. So, rather than testing whether the declarations are
present or not, simply test whether the host OS is AIX or OSF/1.
I'm committing this, so that recutils (which uses the 'random_r' module)
can make a release tomorrow.
2012-01-12 Bruno Haible <address@hidden>
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.
--- doc/glibc-functions/initstate_r.texi.orig Thu Jan 12 22:51:25 2012
+++ doc/glibc-functions/initstate_r.texi Thu Jan 12 22:17:46 2012
@@ -9,6 +9,9 @@
@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.
address@hidden
+This function has an incompatible declaration on some platforms:
+AIX 7.1, OSF/1 5.1.
@end itemize
Portability problems not fixed by Gnulib:
--- doc/glibc-functions/random_r.texi.orig Thu Jan 12 22:51:25 2012
+++ doc/glibc-functions/random_r.texi Thu Jan 12 22:17:46 2012
@@ -9,6 +9,9 @@
@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.
address@hidden
+This function has an incompatible declaration on some platforms:
+AIX 7.1, OSF/1 5.1.
@end itemize
Portability problems not fixed by Gnulib:
--- doc/glibc-functions/setstate_r.texi.orig Thu Jan 12 22:51:25 2012
+++ doc/glibc-functions/setstate_r.texi Thu Jan 12 22:17:46 2012
@@ -9,6 +9,9 @@
@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.
address@hidden
+This function has an incompatible declaration on some platforms:
+AIX 7.1, OSF/1 5.1.
@end itemize
Portability problems not fixed by Gnulib:
--- lib/stdlib.in.h.orig Thu Jan 12 22:51:25 2012
+++ lib/stdlib.in.h Thu Jan 12 22:45:54 2012
@@ -58,7 +58,7 @@
# include <random.h>
# endif
-# if address@hidden@ || address@hidden@
+# if address@hidden@ || @REPLACE_RANDOM_R@ || address@hidden@
# include <stdint.h>
# endif
@@ -505,11 +505,21 @@
#endif
#if @GNULIB_RANDOM_R@
-# if address@hidden@
+# 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 address@hidden@
_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 @@
#endif
#if @GNULIB_RANDOM_R@
-# if address@hidden@
+# 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 address@hidden@
_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 @@
#endif
#if @GNULIB_RANDOM_R@
-# if address@hidden@
+# 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 address@hidden@
_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 @@
#endif
#if @GNULIB_RANDOM_R@
-# if address@hidden@
+# 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 address@hidden@
_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
--- m4/random_r.m4.orig Thu Jan 12 22:51:25 2012
+++ m4/random_r.m4 Thu Jan 12 22:25:25 2012
@@ -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 @@
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 @@
#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.
--- m4/stdlib_h.m4.orig Thu Jan 12 22:51:25 2012
+++ m4/stdlib_h.m4 Thu Jan 12 22:26:04 2012
@@ -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 @@
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])
--- modules/random_r.orig Thu Jan 12 22:51:25 2012
+++ modules/random_r Thu Jan 12 22:26:30 2012
@@ -11,7 +11,7 @@
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
--- modules/stdlib.orig Thu Jan 12 22:51:25 2012
+++ modules/stdlib Thu Jan 12 22:27:08 2012
@@ -95,6 +95,7 @@
-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' \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- random_r on AIX, OSF/1,
Bruno Haible <=