summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-01-25 01:36:26 +0100
committerBruno Haible <bruno@clisp.org>2019-01-25 02:14:28 +0100
commit26653040b88fde1a98e6a7bbefc8f0bb0ff797fc (patch)
tree7a32ee7c3baabc3d065a105a8373111856636d5c /lib
parent3215a9f5672562b3698ad231f57857ab11b355ec (diff)
downloadgnulib-26653040b88fde1a98e6a7bbefc8f0bb0ff797fc.tar.gz
random: Fix compilation error on Android 4.3.
* lib/stdlib.in.h (random, srandom): Test also REPLACE_RANDOM. (initstate): Test REPLACE_INITSTATE and HAVE_INITSTATE, not HAVE_RANDOM. (setstate): Test REPLACE_SETSTATE and HAVE_SETSTATE, not HAVE_RANDOM. * m4/random.m4 (gl_FUNC_RANDOM): Set HAVE_INITSTATE, HAVE_SETSTATE, REPLACE_RANDOM, REPLACE_INITSTATE, REPLACE_SETSTATE. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize HAVE_INITSTATE, HAVE_SETSTATE, REPLACE_RANDOM, REPLACE_INITSTATE, REPLACE_SETSTATE. * modules/stdlib (Makefile.am): Substitute HAVE_INITSTATE, HAVE_SETSTATE, REPLACE_RANDOM, REPLACE_INITSTATE, REPLACE_SETSTATE. * modules/random (Depends-on, configure.ac): Test also REPLACE_RANDOM, REPLACE_INITSTATE, REPLACE_SETSTATE. * doc/posix-functions/random.texi: Correct the description of the situation on Android. * doc/posix-functions/srandom.texi: Likewise. * doc/posix-functions/rand.texi: Likewise. * doc/posix-functions/srand.texi: Likewise.
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib.in.h59
1 files changed, 49 insertions, 10 deletions
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 0f581d9fc5..be8ab3b86c 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -582,10 +582,19 @@ _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
#if @GNULIB_RANDOM@
-# if !@HAVE_RANDOM@
+# if @REPLACE_RANDOM@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef random
+# define random rpl_random
+# endif
+_GL_FUNCDECL_RPL (random, long, (void));
+_GL_CXXALIAS_RPL (random, long, (void));
+# else
+# if !@HAVE_RANDOM@
_GL_FUNCDECL_SYS (random, long, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (random, long, (void));
+# endif
_GL_CXXALIASWARN (random);
#elif defined GNULIB_POSIXCHECK
# undef random
@@ -596,10 +605,19 @@ _GL_WARN_ON_USE (random, "random is unportable - "
#endif
#if @GNULIB_RANDOM@
-# if !@HAVE_RANDOM@
+# if @REPLACE_RANDOM@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef srandom
+# define srandom rpl_srandom
+# endif
+_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed));
+_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
+# else
+# if !@HAVE_RANDOM@
_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
-# endif
+# endif
_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
+# endif
_GL_CXXALIASWARN (srandom);
#elif defined GNULIB_POSIXCHECK
# undef srandom
@@ -610,31 +628,52 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - "
#endif
#if @GNULIB_RANDOM@
-# if !@HAVE_RANDOM@ || !@HAVE_DECL_INITSTATE@
+# if @REPLACE_INITSTATE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef initstate
+# define initstate rpl_initstate
+# endif
+_GL_FUNCDECL_RPL (initstate, char *,
+ (unsigned int seed, char *buf, size_t buf_size)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (initstate, char *,
+ (unsigned int seed, char *buf, size_t buf_size));
+# else
+# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
_GL_FUNCDECL_SYS (initstate, char *,
(unsigned int seed, char *buf, size_t buf_size)
_GL_ARG_NONNULL ((2)));
-# endif
+# endif
_GL_CXXALIAS_SYS (initstate, char *,
(unsigned int seed, char *buf, size_t buf_size));
+# endif
_GL_CXXALIASWARN (initstate);
#elif defined GNULIB_POSIXCHECK
# undef initstate
-# if HAVE_RAW_DECL_INITSTATE_R
+# if HAVE_RAW_DECL_INITSTATE
_GL_WARN_ON_USE (initstate, "initstate is unportable - "
"use gnulib module random for portability");
# endif
#endif
#if @GNULIB_RANDOM@
-# if !@HAVE_RANDOM@ || !@HAVE_DECL_SETSTATE@
+# if @REPLACE_SETSTATE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef setstate
+# define setstate rpl_setstate
+# endif
+_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
+# else
+# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
-# endif
+# endif
_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
+# endif
_GL_CXXALIASWARN (setstate);
#elif defined GNULIB_POSIXCHECK
# undef setstate
-# if HAVE_RAW_DECL_SETSTATE_R
+# if HAVE_RAW_DECL_SETSTATE
_GL_WARN_ON_USE (setstate, "setstate is unportable - "
"use gnulib module random for portability");
# endif