Mercurial > hg > octave-lyh > gnulib-hg
changeset 16277:58a55a7ffba8
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 12 Jan 2012 22:54:15 +0100 |
parents | d43b527a2e6c |
children | 0872da28238e |
files | ChangeLog doc/glibc-functions/initstate_r.texi doc/glibc-functions/random_r.texi doc/glibc-functions/setstate_r.texi lib/stdlib.in.h m4/random_r.m4 m4/stdlib_h.m4 modules/random_r modules/stdlib |
diffstat | 9 files changed, 97 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- a/doc/glibc-functions/initstate_r.texi +++ b/doc/glibc-functions/initstate_r.texi @@ -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. +@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:
--- a/doc/glibc-functions/random_r.texi +++ b/doc/glibc-functions/random_r.texi @@ -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. +@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:
--- a/doc/glibc-functions/setstate_r.texi +++ b/doc/glibc-functions/setstate_r.texi @@ -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. +@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:
--- 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 @@ #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 +_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); # endif -_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); _GL_CXXALIASWARN (random_r); #elif defined GNULIB_POSIXCHECK # undef random_r @@ -520,13 +530,25 @@ #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 @@ #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 @@ #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
--- 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 @@ 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.
--- 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 @@ 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])
--- a/modules/random_r +++ b/modules/random_r @@ -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
--- a/modules/stdlib +++ b/modules/stdlib @@ -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' \