From: Bruno Haible Date: Thu, 17 Aug 2017 12:17:58 +0000 (+0200) Subject: random: Fix test compilation failure on Cygwin 1.5.25. X-Git-Tag: v1.0~5991 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=299d6d5f9ae9ea6ece5da41ae16a53331ff55a02;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index d073889887..5d618bca86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2017-08-17 Bruno Haible + + 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 stdnoreturn: Fix test compilation failure on Cygwin. diff --git a/doc/posix-functions/initstate.texi b/doc/posix-functions/initstate.texi index aca7e7bbc3..0ddfebf56a 100644 --- a/doc/posix-functions/initstate.texi +++ b/doc/posix-functions/initstate.texi @@ -11,6 +11,9 @@ Portability problems fixed by Gnulib: @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: diff --git a/doc/posix-functions/random.texi b/doc/posix-functions/random.texi index 93093df3ee..88d36f92b6 100644 --- a/doc/posix-functions/random.texi +++ b/doc/posix-functions/random.texi @@ -15,4 +15,8 @@ Solaris 2.4, mingw, MSVC 14. 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 diff --git a/doc/posix-functions/setstate.texi b/doc/posix-functions/setstate.texi index bc4a01e752..23935745e9 100644 --- a/doc/posix-functions/setstate.texi +++ b/doc/posix-functions/setstate.texi @@ -11,6 +11,9 @@ Portability problems fixed by Gnulib: @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: diff --git a/doc/posix-functions/srandom.texi b/doc/posix-functions/srandom.texi index db0eaefc0a..74770f78ca 100644 --- a/doc/posix-functions/srandom.texi +++ b/doc/posix-functions/srandom.texi @@ -15,4 +15,8 @@ Solaris 2.4, mingw, MSVC 14. 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 diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index c6e68fddc4..ef41c992df 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -597,7 +597,7 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - " #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 @@ _GL_WARN_ON_USE (initstate, "initstate is unportable - " #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)); diff --git a/m4/random.m4 b/m4/random.m4 index acd093ddab..f5cf0b54b0 100644 --- a/m4/random.m4 +++ b/m4/random.m4 @@ -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 @@ AC_DEFUN([gl_FUNC_RANDOM], 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. diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index ec4a058154..3537346368 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -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 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], 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 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], 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]) diff --git a/modules/stdlib b/modules/stdlib index 257b5dbd69..62224e89f3 100644 --- a/modules/stdlib +++ b/modules/stdlib @@ -72,6 +72,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -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 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -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' \