changeset 19068:fc627b1b3ccd

random: Fix test compilation failure on Cygwin 1.5.25. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize HAVE_DECL_INITSTATE, HAVE_DECL_SETSTATE. * m4/random.m4 (gl_FUNC_RANDOM): Test whether initstate and setstate are declared. * modules/stdlib (Makefile.am): Substitute HAVE_DECL_INITSTATE, HAVE_DECL_SETSTATE. * lib/stdlib.in.h (initstate): Declare also if HAVE_DECL_INITSTATE is 0. (setstate): Declare also if HAVE_DECL_SETSTATE is 0. * doc/posix-functions/initstate.texi: Mention the Cygwin 1.5.x problem. * doc/posix-functions/random.texi: Likewise. * doc/posix-functions/setstate.texi: Likewise. * doc/posix-functions/srandom.texi: Likewise.
author Bruno Haible <bruno@clisp.org>
date Thu, 17 Aug 2017 14:17:58 +0200
parents c6565d813330
children 00b9ec96a125
files ChangeLog doc/posix-functions/initstate.texi doc/posix-functions/random.texi doc/posix-functions/setstate.texi doc/posix-functions/srandom.texi lib/stdlib.in.h m4/random.m4 m4/stdlib_h.m4 modules/stdlib
diffstat 9 files changed, 48 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Aug 17 01:59:11 2017 +0200
+++ b/ChangeLog	Thu Aug 17 14:17:58 2017 +0200
@@ -1,3 +1,19 @@
+2017-08-17  Bruno Haible  <bruno@clisp.org>
+
+	random: Fix test compilation failure on Cygwin 1.5.25.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize HAVE_DECL_INITSTATE,
+	HAVE_DECL_SETSTATE.
+	* m4/random.m4 (gl_FUNC_RANDOM): Test whether initstate and setstate are
+	declared.
+	* modules/stdlib (Makefile.am): Substitute HAVE_DECL_INITSTATE,
+	HAVE_DECL_SETSTATE.
+	* lib/stdlib.in.h (initstate): Declare also if HAVE_DECL_INITSTATE is 0.
+	(setstate): Declare also if HAVE_DECL_SETSTATE is 0.
+	* doc/posix-functions/initstate.texi: Mention the Cygwin 1.5.x problem.
+	* doc/posix-functions/random.texi: Likewise.
+	* doc/posix-functions/setstate.texi: Likewise.
+	* doc/posix-functions/srandom.texi: Likewise.
+
 2017-08-16  Bruno Haible  <bruno@clisp.org>
 
 	stdnoreturn: Fix test compilation failure on Cygwin.
--- a/doc/posix-functions/initstate.texi	Thu Aug 17 01:59:11 2017 +0200
+++ b/doc/posix-functions/initstate.texi	Thu Aug 17 14:17:58 2017 +0200
@@ -11,6 +11,9 @@
 @item
 This function is missing on some platforms:
 Solaris 2.4, mingw, MSVC 14.
+@item
+This function is not declared on some platforms:
+Cygwin 1.5.25.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/doc/posix-functions/random.texi	Thu Aug 17 01:59:11 2017 +0200
+++ b/doc/posix-functions/random.texi	Thu Aug 17 14:17:58 2017 +0200
@@ -15,4 +15,8 @@
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+This function has a slightly incompatible declaration (the return type being
+@samp{int} instead of @samp{long}) on some platforms:
+Cygwin 1.5.25.
 @end itemize
--- a/doc/posix-functions/setstate.texi	Thu Aug 17 01:59:11 2017 +0200
+++ b/doc/posix-functions/setstate.texi	Thu Aug 17 14:17:58 2017 +0200
@@ -11,6 +11,9 @@
 @item
 This function is missing on some platforms:
 Solaris 2.4, mingw, MSVC 14.
+@item
+This function is not declared on some platforms:
+Cygwin 1.5.25.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/doc/posix-functions/srandom.texi	Thu Aug 17 01:59:11 2017 +0200
+++ b/doc/posix-functions/srandom.texi	Thu Aug 17 14:17:58 2017 +0200
@@ -15,4 +15,8 @@
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+This function has a slightly incompatible declaration (the return type being
+@samp{long} instead of @samp{void) on some platforms:
+Cygwin 1.5.25.
 @end itemize
--- a/lib/stdlib.in.h	Thu Aug 17 01:59:11 2017 +0200
+++ b/lib/stdlib.in.h	Thu Aug 17 14:17:58 2017 +0200
@@ -597,7 +597,7 @@
 #endif
 
 #if @GNULIB_RANDOM@
-# if !@HAVE_RANDOM@
+# if !@HAVE_RANDOM@ || !@HAVE_DECL_INITSTATE@
 _GL_FUNCDECL_SYS (initstate, char *,
                   (unsigned int seed, char *buf, size_t buf_size)
                   _GL_ARG_NONNULL ((2)));
@@ -614,7 +614,7 @@
 #endif
 
 #if @GNULIB_RANDOM@
-# if !@HAVE_RANDOM@
+# if !@HAVE_RANDOM@ || !@HAVE_DECL_SETSTATE@
 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
 # endif
 _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
--- a/m4/random.m4	Thu Aug 17 01:59:11 2017 +0200
+++ b/m4/random.m4	Thu Aug 17 14:17:58 2017 +0200
@@ -1,4 +1,4 @@
-# random.m4 serial 1
+# random.m4 serial 2
 dnl Copyright (C) 2012-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,16 @@
   if test $ac_cv_func_random = no; then
     HAVE_RANDOM=0
   fi
+
+  AC_CHECK_DECLS_ONCE([initstate])
+  if test $ac_cv_have_decl_initstate = no; then
+    HAVE_DECL_INITSTATE=0
+  fi
+
+  AC_CHECK_DECLS_ONCE([setstate])
+  if test $ac_cv_have_decl_setstate = no; then
+    HAVE_DECL_SETSTATE=0
+  fi
 ])
 
 # Prerequisites of lib/random.c.
--- a/m4/stdlib_h.m4	Thu Aug 17 01:59:11 2017 +0200
+++ b/m4/stdlib_h.m4	Thu Aug 17 14:17:58 2017 +0200
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 43
+# stdlib_h.m4 serial 44
 dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -78,6 +78,7 @@
   HAVE_DECL_GETLOADAVG=1;    AC_SUBST([HAVE_DECL_GETLOADAVG])
   HAVE_GETSUBOPT=1;          AC_SUBST([HAVE_GETSUBOPT])
   HAVE_GRANTPT=1;            AC_SUBST([HAVE_GRANTPT])
+  HAVE_DECL_INITSTATE=1;     AC_SUBST([HAVE_DECL_INITSTATE])
   HAVE_MKDTEMP=1;            AC_SUBST([HAVE_MKDTEMP])
   HAVE_MKOSTEMP=1;           AC_SUBST([HAVE_MKOSTEMP])
   HAVE_MKOSTEMPS=1;          AC_SUBST([HAVE_MKOSTEMPS])
@@ -96,6 +97,7 @@
   HAVE_SECURE_GETENV=1;      AC_SUBST([HAVE_SECURE_GETENV])
   HAVE_SETENV=1;             AC_SUBST([HAVE_SETENV])
   HAVE_DECL_SETENV=1;        AC_SUBST([HAVE_DECL_SETENV])
+  HAVE_DECL_SETSTATE=1;      AC_SUBST([HAVE_DECL_SETSTATE])
   HAVE_STRTOD=1;             AC_SUBST([HAVE_STRTOD])
   HAVE_STRTOLL=1;            AC_SUBST([HAVE_STRTOLL])
   HAVE_STRTOULL=1;           AC_SUBST([HAVE_STRTOULL])
--- a/modules/stdlib	Thu Aug 17 01:59:11 2017 +0200
+++ b/modules/stdlib	Thu Aug 17 14:17:58 2017 +0200
@@ -72,6 +72,7 @@
 	      -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
 	      -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
 	      -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
+	      -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \
 	      -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
 	      -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
 	      -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
@@ -89,6 +90,7 @@
 	      -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
 	      -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
 	      -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
+	      -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \
 	      -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
 	      -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
 	      -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \