bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warn-on-use preview, v2


From: Eric Blake
Subject: Re: warn-on-use preview, v2
Date: Mon, 04 Jan 2010 06:51:36 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

According to Eric Blake on 1/1/2010 7:24 AM:
>> I would prefer an implementation where the expansion of
>>   gl_WARN_ON_USE_PREPARE([locale.h], [setlocale])
>> does not depend on other invocations of gl_WARN_ON_USE_PREPARE, even if it
>> leads to a larger 'configure' file.
> 
> OK, I'll work on refactoring that to emit one AC_COMPILE_IFELSE loop per
> header.  By the way, that will fail to poison identifiers that are
> declared in the wrong header, but hopefully there aren't too many of those
> (especially now that our unit tests can detect that, and we are pushing
> fixes into platforms like cygwin as fast as we find those bugs).

Here's spin two of the patch.  It turns out that doing one shell loop per
header also allows us to fold in platform-specific inclusion requirements.

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
From e0351740e1fc1e3fd12c0e3b42ed6c34c8e71b95 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 16 Dec 2009 14:53:06 -0700
Subject: [PATCH 1/4] warn-on-use: new module

The goal of GNULIB_POSIXCHECK is to allow a developer on a reasonably
portable system to detect instances where they may have succeeded
because their system is up-to-date, but where compilation would fail
or create a misbehaving application on some other system due to some
portability problem, all without requiring that the developer have
access to other machines.  In other words, we want to poison all
interfaces that have a gnulib replacement if the corresponding gnulib
module is not in use.  For macros, the solution is undefining the
macro; unfortunately this causes compilation error without many
details as to why, but it is better than nothing.  For functions, the
solution is to cause a warning if the function is used.

Previously, the link-warning could poison functions, but only on glibc
systems and with gcc.  This module introduces _GL_WARN_ON_USE as a way
of poisoning functions for a few more systems.

Using the gcc __warning__ attribute (added in 4.3.0, early 2008)
rather than using link-warning.h is favorable because:
1) Provides a warning immediately at compile-time. The user does not
   have to wait until he links a program.
2) Less use of C macros. Less risk of collision.
3) It's available on more platforms. Depends only on GCC.
4) The formatting of the message is nicer.

There is a minor regression: the gcc attribute is currently not as
powerful as a link warning at detecting uses via function pointers:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42384
However, that style of coding is less frequent.

* modules/warn-on-use: New file.
* build-aux/warn-on-use.h: Likewise.
* m4/warn-on-use.m4: Likewise.
* MODULES.html.sh (Support for building): Mention it.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |    6 ++++
 MODULES.html.sh         |    4 ++-
 build-aux/warn-on-use.h |   75 +++++++++++++++++++++++++++++++++++++++++++++++
 m4/warn-on-use.m4       |   45 ++++++++++++++++++++++++++++
 modules/warn-on-use     |   35 ++++++++++++++++++++++
 5 files changed, 164 insertions(+), 1 deletions(-)
 create mode 100644 build-aux/warn-on-use.h
 create mode 100644 m4/warn-on-use.m4
 create mode 100644 modules/warn-on-use

diff --git a/ChangeLog b/ChangeLog
index 272c77f..a437f9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-01-04  Eric Blake  <address@hidden>

+       warn-on-use: new module
+       * modules/warn-on-use: New file.
+       * build-aux/warn-on-use.h: Likewise.
+       * m4/warn-on-use.m4: Likewise.
+       * MODULES.html.sh (Support for building): Mention it.
+
        fdopendir: fix configure test
        * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Check for existing file.

diff --git a/MODULES.html.sh b/MODULES.html.sh
index 5bbb18c..e3602ef 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -3172,6 +3172,7 @@ func_all_modules ()

   func_begin_table
   func_module absolute-header
+  func_module arg-nonnull
   func_module config-h
   func_module configmake
   func_module dummy
@@ -3184,14 +3185,15 @@ func_all_modules ()
   func_module lib-msvc-compat
   func_module lib-symbol-versions
   func_module link-warning
+  func_module manywarnings
   func_module no-c++
   func_module relocatable-lib
   func_module relocatable-lib-lgpl
   func_module relocatable-prog
   func_module relocatable-prog-wrapper
   func_module relocatable-script
+  func_module warn-on-use
   func_module warnings
-  func_module manywarnings
   func_end_table

   element="Support for building documentation"
diff --git a/build-aux/warn-on-use.h b/build-aux/warn-on-use.h
new file mode 100644
index 0000000..6c6ddf9
--- /dev/null
+++ b/build-aux/warn-on-use.h
@@ -0,0 +1,75 @@
+/* A C macro for emitting warnings if a function is used.
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* _GL_WARN_ON_USE(function, "literal string") issues a declaration
+   for FUNCTION which will then trigger a compiler warning containing
+   the text of "literal string" anywhere that function is called, if
+   supported by the compiler.  If the compiler does not support this
+   feature, the macro expands to an unused typedef declaration.
+
+   This macro is useful for marking a function as a potential
+   portability trap, with the intent that "literal string" include
+   instructions on the replacement function that should be used
+   instead.  However, one of the reasons that a function is a
+   portability trap is if it has the wrong signature.  Declaring
+   FUNCTION with a different signature in C is a compilation error, so
+   this macro must use the same type as any existing declaration so
+   that programs that avoid the problematic FUNCTION do not fail to
+   compile merely because they included a header that poisoned the
+   function.  But this implies that _GL_WARN_ON_USE is only safe to
+   use if FUNCTION is known to already have a declaration.  Use of
+   this macro implies that there must not be any other macro hiding
+   the declaration of FUNCTION; but undefining FUNCTION first is part
+   of the poisoning process anyway (although for symbols that are
+   provided only via a macro, the result is a compilation error rather
+   than a warning containing "literal string").  Also note that in
+   C++, it is only safe to use if FUNCTION has no overloads.
+
+   For an example, it is possible to poison 'getline' by:
+   - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
+     [getline]) in configure.ac, which potentially defines
+     HAVE_RAW_DECL_GETLINE
+   - adding this code to a header that wraps the system <stdio.h>:
+     #undef getline
+     #if HAVE_RAW_DECL_GETLINE
+     _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
+       "not universally present; use the gnulib module getline");
+     #endif
+
+   It is not possible to directly poison global variables.  But it is
+   possible to write a wrapper accessor function, and poison that
+   (less common usage, like &environ, will cause a compilation error
+   rather than issue the nice warning, but the end result of informing
+   the developer about their portability problem is still achieved):
+   #if HAVE_RAW_DECL_ENVIRON
+   static inline char ***rpl_environ (void) { return &environ; }
+   _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
+   # undef environ
+   # define environ (*rpl_environ ())
+   #endif
+   */
+#ifndef _GL_WARN_ON_USE
+
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
+#  define _GL_WARN_ON_USE(function, message) \
+extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
+
+# else /* Unsupported.  */
+#  define _GL_WARN_ON_USE(function, message) \
+extern int _gl_warn_on_use
+# endif
+#endif
diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4
new file mode 100644
index 0000000..dc9089c
--- /dev/null
+++ b/m4/warn-on-use.m4
@@ -0,0 +1,45 @@
+# warn-on-use.m4 serial 1
+dnl Copyright (C) 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
+# ---------------------------------------
+# For each whitespace-separated element in the list of NAMES, define
+# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
+# even after being undefined as a macro.
+#
+# See warn-on-use.h for some hints on how to poison function names, as
+# well as ideas on poisoning global variables and macros.  NAMES may
+# include global variables, but remember that only functions work with
+# _GL_WARN_ON_USE.  Typically, INCLUDES only needs to list a single
+# header, but if the replacement header pulls in other headers because
+# some systems declare functions in the wrong header, then INCLUDES
+# should do likewise.
+#
+# If you assume C89, then it is generally safe to assume declarations
+# for functions declared in that standard (such as gets) without
+# needing gl_WARN_ON_USE_PREPARE.
+AC_DEFUN([gl_WARN_ON_USE_PREPARE],
+[
+  m4_foreach_w([gl_decl], [$2],
+    [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
+      [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
+       undefining macros.])])dnl
+  for gl_func in $2; do
+    AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
+    AC_CACHE_CHECK([whether $gl_func is declared without a macro],
+      [gl_Symbol],
+      [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
address@hidden:@undef $gl_func
+  (void) $gl_func;])],
+        [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
+     AS_VAR_IF([gl_Symbol], [yes],
+       [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
+       dnl shortcut - if the raw declaration exists, then set a cache
+       dnl variable to allow skipping any later AC_CHECK_DECL efforts
+       eval ac_cv_have_decl_$gl_func=yes])
+    AS_VAR_POPDEF([gl_Symbol])dnl
+  done
+])
diff --git a/modules/warn-on-use b/modules/warn-on-use
new file mode 100644
index 0000000..f0ee83b
--- /dev/null
+++ b/modules/warn-on-use
@@ -0,0 +1,35 @@
+Description:
+A C macro for emitting a warning if a function is used.
+
+Applicability:
+all
+
+Files:
+build-aux/warn-on-use.h
+m4/warn-on-use.m4
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+BUILT_SOURCES += warn-on-use.h
+# The warn-on-use.h that gets inserted into generated .h files is the same as
+# build-aux/warn-on-use.h, except that it has the copyright header cut off.
+warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       sed -n -e '/^.ifndef/,$$p' \
+         < $(top_srcdir)/build-aux/warn-on-use.h \
+         > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
+
+WARN_ON_USE_H=warn-on-use.h
+
+Include:
+
+License:
+LGPLv2+
+
+Maintainer:
+Eric Blake
-- 
1.6.4.2


From f43754ff3d5a855e5bb86cf560f8123bdc108cd1 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 31 Dec 2009 11:53:33 -0700
Subject: [PATCH 2/4] stdio: warn on suspicious uses

Using gets is almost ALWAYS wrong (it is extremely rare that you have
full control over stdin).  POSIX 2008 marked it as obsolete, even
though C89 requires it.  Attach a warning to remind developers.  Add
a comment to sprint explaining why it does not get this treatment.

Improve the warnings for fseek/fseeko (and ftell/ftello), with
comments justifying our position.

Some of our unit tests never use large files, so rather than drag
in a dependency on fseeko, they should be the first compilation
units to use _GL_NO_LARGE_FILES.

* modules/stdio (Depends-on): Add warn-on-use.
(Makefile.am): Provide new substitutions.
* m4/stdio_h.m4 (gl_STDIO_H): Check for inline, ftello, and
fseeko.
* lib/stdio.in.h (gets): Always warn on use.
(fseek, ftell): Adjust when warnings are issued, and honor
_GL_NO_LARGE_FILES as a way to silence the warning.
* tests/test-fpurge.c [!GNULIB_FSEEK]: Use new means to squelch
any warning about large file offsets.
* tests/test-freadable.c [!GNULIB_FSEEK]: Likewise.
* tests/test-freading.c [!GNULIB_FSEEK]: Likewise.
* tests/test-fseeko.c [!GNULIB_FSEEK]: Likewise.
* tests/test-ftell.c [!GNULIB_FSEEK]: Likewise.
* tests/test-ftello.c [!GNULIB_FSEEK]: Likewise.
* tests/test-fwritable.c [!GNULIB_FSEEK]: Likewise.
* tests/test-fwriting.c [!GNULIB_FSEEK]: Likewise.
* tests/test-getopt.c [!GNULIB_FTELL]: Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |   19 ++++++
 lib/stdio.in.h         |  169 ++++++++++++++++++++++++++++++++---------------
 m4/stdio_h.m4          |    9 ++-
 modules/stdio          |    4 +-
 tests/test-fpurge.c    |    9 +--
 tests/test-freadable.c |    9 +--
 tests/test-freading.c  |    9 +--
 tests/test-fseeko.c    |    6 +--
 tests/test-ftell.c     |    9 +--
 tests/test-ftello.c    |    9 +--
 tests/test-fwritable.c |    9 +--
 tests/test-fwriting.c  |    9 +--
 tests/test-getopt.c    |    5 +-
 13 files changed, 168 insertions(+), 107 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a437f9b..11ab307 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2010-01-04  Eric Blake  <address@hidden>

+       stdio: warn on suspicious uses
+       * modules/stdio (Depends-on): Add warn-on-use.
+       (Makefile.am): Provide new substitutions.
+       * m4/stdio_h.m4 (gl_STDIO_H): Check for inline, ftello, and
+       fseeko.
+       * lib/stdio.in.h (gets): Always warn on use.
+       (fseek, ftell): Adjust when warnings are issued, and honor
+       _GL_NO_LARGE_FILES as a way to silence the warning.
+       * tests/test-fpurge.c [!GNULIB_FSEEK]: Use new means to squelch
+       any warning about large file offsets.
+       * tests/test-freadable.c [!GNULIB_FSEEK]: Likewise.
+       * tests/test-freading.c [!GNULIB_FSEEK]: Likewise.
+       * tests/test-fseeko.c [!GNULIB_FSEEK]: Likewise.
+       * tests/test-ftell.c [!GNULIB_FSEEK]: Likewise.
+       * tests/test-ftello.c [!GNULIB_FSEEK]: Likewise.
+       * tests/test-fwritable.c [!GNULIB_FSEEK]: Likewise.
+       * tests/test-fwriting.c [!GNULIB_FSEEK]: Likewise.
+       * tests/test-getopt.c [!GNULIB_FTELL]: Likewise.
+
        warn-on-use: new module
        * modules/warn-on-use: New file.
        * build-aux/warn-on-use.h: Likewise.
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 1c73db6..94b2522 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -66,6 +66,8 @@

 /* The definition of _GL_ARG_NONNULL is copied here.  */

+/* The definition of _GL_WARN_ON_USE is copied here.  */
+

 #ifdef __cplusplus
 extern "C" {
@@ -122,6 +124,12 @@ extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
     fflush (f))
 #endif

+/* It is very rare that the developer ever has full control of stdin,
+   so any use of gets warrants an unconditional warning.  Assume it is
+   always declared, since it is required by C89.  */
+#undef gets
+_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+
 #if @GNULIB_FOPEN@
 # if @REPLACE_FOPEN@
 #  undef fopen
@@ -206,92 +214,136 @@ extern FILE * freopen (const char *filename, const char 
*mode, FILE *stream)
     freopen (f, m, s))
 #endif

-#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
-extern int rpl_fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
-# undef fseek
-# if defined GNULIB_POSIXCHECK
-#  define fseek(f,o,w) \
-     (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
-                       "on 32-bit platforms - " \
-                       "use fseeko function for handling of large files"), \
-      rpl_fseek (f, o, w))
-# else
+/* Set up the following warnings, based on which modules are in use.
+   GNU Coding Standards discourage the use of fseek, since it imposes
+   an arbitrary limitation on some 32-bit hosts.  Remember that the
+   fseek module depends on the fseeko module, so we only have three
+   cases to consider:
+
+   1. The developer is not using either module.  Issue a warning under
+   GNULIB_POSIXCHECK for both functions, to remind them that both
+   functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
+   impact on this warning.
+
+   2. The developer is using both modules.  They may be unaware of the
+   arbitrary limitations of fseek, so issue a warning under
+   GNULIB_POSIXCHECK.  On the other hand, they may be using both
+   modules intentionally, so the developer can define
+   _GL_NO_LARGE_FILES in the compilation units where the use of fseek
+   is safe, to silence the warning.
+
+   3. The developer is using the fseeko module, but not fseek.  Gnulib
+   guarantees that fseek will still work around platform bugs in that
+   case, but we presume that the developer is aware of the pitfalls of
+   fseek, so issue a warning even when GNULIB_POSIXCHECK is undefined.
+   Again, _GL_NO_LARGE_FILES can be defined to silence the warning in
+   particular compilation units.
+
+   Most gnulib clients that perform stream operations should fall into
+   category three.  */
+
+#if @GNULIB_FSEEK@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+#  define _GL_FSEEK_WARN /* Category 3, above.  */
+#  undef fseek
+# endif
+# if @REPLACE_FSEEK@
+#  undef fseek
 #  define fseek rpl_fseek
-# endif
-#elif defined GNULIB_POSIXCHECK
-# ifndef fseek
-#  define fseek(f,o,w) \
-     (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
-                       "on 32-bit platforms - " \
-                       "use fseeko function for handling of large files"), \
-      fseek (f, o, w))
+extern int fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
 # endif
 #endif

 #if @GNULIB_FSEEKO@
+# if address@hidden@ && !defined _GL_NO_LARGE_FILES
+#  define _GL_FSEEK_WARN /* Category 2, above.  */
+#  undef fseek
+# endif
 # if @REPLACE_FSEEKO@
 /* Provide fseek, fseeko functions that are aware of a preceding
    fflush(), and which detect pipes.  */
+#  undef fseeko
 #  define fseeko rpl_fseeko
 extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1));
 #  if address@hidden@
 #   undef fseek
-#   define fseek(f,o,w) \
-     (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
-                       "on 32-bit platforms - " \
-                       "use fseeko function for handling of large files"), \
-      fseeko (f, o, w))
+#   define fseek rpl_fseek
+static inline int _GL_ARG_NONNULL ((1))
+rpl_fseek (FILE *fp, long offset, int whence)
+{
+  return fseeko (fp, offset, whence);
+}
 #  endif
 # endif
 #elif defined GNULIB_POSIXCHECK
+# define _GL_FSEEK_WARN /* Category 1, above.  */
+# undef fseek
 # undef fseeko
-# define fseeko(f,o,w) \
-   (GL_LINK_WARNING ("fseeko is unportable - " \
-                     "use gnulib module fseeko for portability"), \
-    fseeko (f, o, w))
+# if HAVE_RAW_DECL_FSEEKO
+_GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
+                 "use gnulib module fseeko for portability");
+# endif
 #endif

-#if @GNULIB_FTELL@ && @REPLACE_FTELL@
-extern long rpl_ftell (FILE *fp) _GL_ARG_NONNULL ((1));
-# undef ftell
-# if GNULIB_POSIXCHECK
-#  define ftell(f) \
-     (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
-                       "on 32-bit platforms - " \
-                       "use ftello function for handling of large files"), \
-      rpl_ftell (f))
-# else
-#  define ftell rpl_ftell
+#ifdef _GL_FSEEK_WARN
+# undef _GL_FSEEK_WARN
+/* Here, either fseek is undefined (but C89 guarantees that it is
+   declared), or it is defined as rpl_fseek (declared above).  */
+_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
+                 "on 32-bit platforms - "
+                 "use fseeko function for handling of large files");
+#endif
+
+/* See the comments on fseek/fseeko.  */
+
+#if @GNULIB_FTELL@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+#  define _GL_FTELL_WARN /* Category 3, above.  */
+#  undef ftell
 # endif
-#elif defined GNULIB_POSIXCHECK
-# ifndef ftell
-#  define ftell(f) \
-     (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
-                       "on 32-bit platforms - " \
-                       "use ftello function for handling of large files"), \
-      ftell (f))
+# if && @REPLACE_FTELL@
+#  undef ftell
+#  define ftell rpl_ftell
+extern long ftell (FILE *fp) _GL_ARG_NONNULL ((1));
 # endif
 #endif

 #if @GNULIB_FTELLO@
+# if address@hidden@ && !defined _GL_NO_LARGE_FILES
+#  define _GL_FTELL_WARN /* Category 2, above.  */
+#  undef ftell
+# endif
 # if @REPLACE_FTELLO@
+#  undef ftello
 #  define ftello rpl_ftello
 extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
 #  if address@hidden@
 #   undef ftell
-#   define ftell(f) \
-     (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
-                       "on 32-bit platforms - " \
-                       "use ftello function for handling of large files"), \
-      ftello (f))
+#   define ftell rpl_ftell
+static inline long _GL_ARG_NONNULL ((1))
+rpl_ftell (FILE *f)
+{
+  return ftello (f);
+}
 #  endif
 # endif
 #elif defined GNULIB_POSIXCHECK
+# define _GL_FTELL_WARN /* Category 1, above.  */
+# undef ftell
 # undef ftello
-# define ftello(f) \
-   (GL_LINK_WARNING ("ftello is unportable - " \
-                     "use gnulib module ftello for portability"), \
-    ftello (f))
+# if HAVE_RAW_DECL_FTELLO
+_GL_WARN_ON_USE (ftello, "ftello is unportable - "
+                 "use gnulib module ftello for portability");
+# endif
+#endif
+
+#ifdef _GL_FTELL_WARN
+# undef _GL_FTELL_WARN
+/* Here, either ftell is undefined (but C89 guarantees that it is
+   declared), or it is defined as rpl_ftell (declared above).  */
+_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
+                 "on 32-bit platforms - "
+                 "use ftello function for handling of large files");
 #endif

 #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
@@ -504,6 +556,15 @@ extern int snprintf (char *str, size_t size, const char 
*format, ...)
      snprintf)
 #endif

+/* Some people would argue that sprintf should be handled like gets
+   (for example, OpenBSD issues a link warning for both functions),
+   since both can cause security holes due to buffer overruns.
+   However, we believe that sprintf can be used safely, and is more
+   efficient than snprintf in those safe cases; and as proof of our
+   belief, we use sprintf in several gnulib modules.  So this header
+   intentionally avoids adding a warning to sprintf except when
+   GNULIB_POSIXCHECK is defined.  */
+
 #if @GNULIB_SPRINTF_POSIX@
 # if @REPLACE_SPRINTF@
 #  define sprintf rpl_sprintf
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index 7e59692..be79896 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 22
+# stdio_h.m4 serial 23
 dnl Copyright (C) 2007-2010 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 @@ dnl with or without modifications, as long as this notice is 
preserved.
 AC_DEFUN([gl_STDIO_H],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  AC_REQUIRE([AC_C_INLINE])
   gl_CHECK_NEXT_HEADERS([stdio.h])
   dnl No need to create extra modules for these functions. Everyone who uses
   dnl <stdio.h> likely needs them.
@@ -30,6 +31,12 @@ AC_DEFUN([gl_STDIO_H],
       AC_LIBOBJ([stdio-write])
     fi
   ])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use, and which is not
+  dnl guaranteed by C89.
+  gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
+    ]], [fseeko ftello])
 ])

 AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
diff --git a/modules/stdio b/modules/stdio
index eca3581..6da339b 100644
--- a/modules/stdio
+++ b/modules/stdio
@@ -12,6 +12,7 @@ link-warning
 arg-nonnull
 raise
 stddef
+warn-on-use

 configure.ac:
 gl_STDIO_H
@@ -21,7 +22,7 @@ BUILT_SOURCES += stdio.h

 # We need the following in order to create <stdio.h> when the system
 # doesn't have one that works with the given compiler.
-stdio.h: stdio.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+stdio.h: stdio.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -107,6 +108,7 @@ stdio.h: stdio.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
              -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/stdio.in.h; \
        } > address@hidden && \
        mv address@hidden $@
diff --git a/tests/test-fpurge.c b/tests/test-fpurge.c
index 15eff65..89fe8c0 100644
--- a/tests/test-fpurge.c
+++ b/tests/test-fpurge.c
@@ -18,18 +18,15 @@

 #include <config.h>

+/* None of the files accessed by this test are large, so disable the
+   fseek link warning if we are not using the gnulib fseek module.  */
+#define _GL_NO_LARGE_FILES
 #include <stdio.h>

 #include <string.h>

 #include "macros.h"

-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#if !GNULIB_FSEEK
-# undef fseek
-#endif
-
 #define TESTFILE "t-fpurge.tmp"

 int
diff --git a/tests/test-freadable.c b/tests/test-freadable.c
index 8f337d8..2aa6743 100644
--- a/tests/test-freadable.c
+++ b/tests/test-freadable.c
@@ -18,18 +18,15 @@

 #include <config.h>

+/* None of the files accessed by this test are large, so disable the
+   fseek link warning if we are not using the gnulib fseek module.  */
+#define _GL_NO_LARGE_FILES
 #include "freadable.h"

 #include <stdio.h>

 #include "macros.h"

-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#if !GNULIB_FSEEK
-# undef fseek
-#endif
-
 #define TESTFILE "t-freadable.tmp"

 int
diff --git a/tests/test-freading.c b/tests/test-freading.c
index c4c00f4..fee8228 100644
--- a/tests/test-freading.c
+++ b/tests/test-freading.c
@@ -18,18 +18,15 @@

 #include <config.h>

+/* None of the files accessed by this test are large, so disable the
+   fseek link warning if we are not using the gnulib fseek module.  */
+#define _GL_NO_LARGE_FILES
 #include "freading.h"

 #include <stdio.h>

 #include "macros.h"

-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#if !GNULIB_FSEEK
-# undef fseek
-#endif
-
 #define TESTFILE "t-freading.tmp"

 int
diff --git a/tests/test-fseeko.c b/tests/test-fseeko.c
index e8c66df..be2a78d 100644
--- a/tests/test-fseeko.c
+++ b/tests/test-fseeko.c
@@ -20,11 +20,7 @@

 /* None of the files accessed by this test are large, so disable the
    fseek link warning if we are not using the gnulib fseek module.  */
-#if !GNULIB_FSEEK
-# undef GL_LINK_WARNING
-# define GL_LINK_WARNING(ignored) ((void) 0)
-#endif
-
+#define _GL_NO_LARGE_FILES
 #include <stdio.h>

 #include "signature.h"
diff --git a/tests/test-ftell.c b/tests/test-ftell.c
index 42eff9c..6ad8e0a 100644
--- a/tests/test-ftell.c
+++ b/tests/test-ftell.c
@@ -18,6 +18,9 @@

 #include <config.h>

+/* None of the files accessed by this test are large, so disable the
+   fseek link warning if we are not using the gnulib fseek module.  */
+#define _GL_NO_LARGE_FILES
 #include <stdio.h>

 #include "signature.h"
@@ -26,12 +29,6 @@ SIGNATURE_CHECK (ftell, long, (FILE *));
 #include "binary-io.h"
 #include "macros.h"

-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#if !GNULIB_FSEEK
-# undef fseek
-#endif
-
 #ifndef FUNC_UNGETC_BROKEN
 # define FUNC_UNGETC_BROKEN 0
 #endif
diff --git a/tests/test-ftello.c b/tests/test-ftello.c
index 826df10..5fae570 100644
--- a/tests/test-ftello.c
+++ b/tests/test-ftello.c
@@ -18,6 +18,9 @@

 #include <config.h>

+/* None of the files accessed by this test are large, so disable the
+   fseek link warning if we are not using the gnulib fseek module.  */
+#define _GL_NO_LARGE_FILES
 #include <stdio.h>

 #include "signature.h"
@@ -26,12 +29,6 @@ SIGNATURE_CHECK (ftello, off_t, (FILE *));
 #include "binary-io.h"
 #include "macros.h"

-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#if !GNULIB_FSEEK
-# undef fseek
-#endif
-
 #ifndef FUNC_UNGETC_BROKEN
 # define FUNC_UNGETC_BROKEN 0
 #endif
diff --git a/tests/test-fwritable.c b/tests/test-fwritable.c
index 2d696e9..ab6ca95 100644
--- a/tests/test-fwritable.c
+++ b/tests/test-fwritable.c
@@ -18,18 +18,15 @@

 #include <config.h>

+/* None of the files accessed by this test are large, so disable the
+   fseek link warning if we are not using the gnulib fseek module.  */
+#define _GL_NO_LARGE_FILES
 #include "fwritable.h"

 #include <stdio.h>

 #include "macros.h"

-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#if !GNULIB_FSEEK
-# undef fseek
-#endif
-
 #define TESTFILE "t-fwritable.tmp"

 int
diff --git a/tests/test-fwriting.c b/tests/test-fwriting.c
index ccc302e..d44d003 100644
--- a/tests/test-fwriting.c
+++ b/tests/test-fwriting.c
@@ -18,18 +18,15 @@

 #include <config.h>

+/* None of the files accessed by this test are large, so disable the
+   fseek link warning if we are not using the gnulib fseek module.  */
+#define _GL_NO_LARGE_FILES
 #include "fwriting.h"

 #include <stdio.h>

 #include "macros.h"

-/* None of the files accessed by this test are large, so disable the
-   fseek link warning if we are not using the gnulib fseek module.  */
-#if !GNULIB_FSEEK
-# undef fseek
-#endif
-
 #define TESTFILE "t-fwriting.tmp"

 int
diff --git a/tests/test-getopt.c b/tests/test-getopt.c
index fe822ed..6bcb8e6 100644
--- a/tests/test-getopt.c
+++ b/tests/test-getopt.c
@@ -20,10 +20,7 @@

 /* None of the files accessed by this test are large, so disable the
    ftell link warning if we are not using the gnulib ftell module.  */
-#if !GNULIB_FTELL
-# undef GL_LINK_WARNING
-# define GL_LINK_WARNING(ignored) ((void) 0)
-#endif
+#define _GL_NO_LARGE_FILES

 #if GNULIB_GETOPT_GNU
 # include <getopt.h>
-- 
1.6.4.2


From 62953834901a9548602c89b3abd1d1eec82bf33d Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 31 Dec 2009 13:28:59 -0700
Subject: [PATCH 3/4] unistd: warn on use of environ without module

_GL_WARN_ON_USE only works for functions; so we wrap access to
environ through a function when CFLAGS has -DGNULIB_POSIXCHECK=1.

* modules/unistd (Depends-on): Add warn-on-use.
(Makefile.am): Provide new substitutions.
* m4/unistd_h.m4 (gl_UNISTD_H): Check for inline and environ.
* lib/unistd.in.h (environ): Wrap with a warning helper function.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog       |    6 ++++++
 lib/unistd.in.h |   18 +++++++++++++-----
 m4/unistd_h.m4  |   12 +++++++++++-
 modules/unistd  |    6 ++++--
 4 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 11ab307..d94756d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-01-04  Eric Blake  <address@hidden>

+       unistd: warn on use of environ without module
+       * modules/unistd (Depends-on): Add warn-on-use.
+       (Makefile.am): Provide new substitutions.
+       * m4/unistd_h.m4 (gl_UNISTD_H): Check for inline and environ.
+       * lib/unistd.in.h (environ): Wrap with a warning helper function.
+
        stdio: warn on suspicious uses
        * modules/stdio (Depends-on): Add warn-on-use.
        (Makefile.am): Provide new substitutions.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index f5f97f0..1eb29a3 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -120,6 +120,8 @@

 /* The definition of _GL_ARG_NONNULL is copied here.  */

+/* The definition of _GL_WARN_ON_USE is copied here.  */
+

 /* OS/2 EMX lacks these macros.  */
 #ifndef STDIN_FILENO
@@ -252,11 +254,17 @@ extern char **environ;
 #  endif
 # endif
 #elif defined GNULIB_POSIXCHECK
-# undef environ
-# define environ \
-    (GL_LINK_WARNING ("environ is unportable - " \
-                      "use gnulib module environ for portability"), \
-     environ)
+# if HAVE_RAW_DECL_ENVIRON
+static inline char ***
+rpl_environ (void)
+{
+  return &environ;
+}
+_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
+                 "use gnulib module environ for portability");
+#  undef environ
+#  define environ (*rpl_environ ())
+# endif
 #endif


diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index ff522b0..f503e41 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 36
+# unistd_h.m4 serial 37
 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,6 +11,7 @@ AC_DEFUN([gl_UNISTD_H],
   dnl Use AC_REQUIRE here, so that the default behavior below is expanded
   dnl once only, before all statements that occur in other macros.
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_REQUIRE([AC_C_INLINE])

   gl_CHECK_NEXT_HEADERS([unistd.h])

@@ -21,6 +22,15 @@ AC_DEFUN([gl_UNISTD_H],
     HAVE_UNISTD_H=0
   fi
   AC_SUBST([HAVE_UNISTD_H])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use.
+  gl_WARN_ON_USE_PREPARE([[#include <unistd.h>
+/* Some systems declare environ in the wrong header.  */
+#ifndef __GLIBC__
+# include <stdlib.h>
+#endif
+    ]], [environ])
 ])

 AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
diff --git a/modules/unistd b/modules/unistd
index 3ee8f31..137ee84 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -6,10 +6,11 @@ m4/unistd_h.m4
 lib/unistd.in.h

 Depends-on:
+arg-nonnull
 include_next
 link-warning
-arg-nonnull
 stddef
+warn-on-use

 configure.ac:
 gl_UNISTD_H
@@ -19,7 +20,7 @@ BUILT_SOURCES += unistd.h

 # We need the following in order to create an empty placeholder for
 # <unistd.h> when the system doesn't have one.
-unistd.h: unistd.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+unistd.h: unistd.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
@@ -119,6 +120,7 @@ unistd.h: unistd.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
              -e 
's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g'
 \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/unistd.in.h; \
        } > address@hidden && \
        mv address@hidden $@
-- 
1.6.4.2


From 9d2be01383f220772c262286f7b9be4e06db7b7e Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 31 Dec 2009 13:48:15 -0700
Subject: [PATCH 4/4] math: add portability warnings for classification macros

For interfaces which are defined to exist only as macros, implement
the proper magic needed to warn if the corresponding gnulib module was
not in use.  This solution avoids promoting arguments unnecessarily,
to allow reuse in case gnulib ever implements fpclassify, since
fpclassify(1e-40f) is different than fpclassify(1e-40).

* modules/math (Depends-on): Add warn-on-use.
(Makefile.am): Provide new substitutions.
* m4/math_h.m4 (gl_MATH_H): Require inline.
* lib/math.in.h (_GL_WARN_REAL_FLOATING_DECL)
(_GL_WARN_REAL_FLOATING_IMPL): New helper macros.
(isfinite, isinf, isnan, signbit) [GNULIB_POSIXCHECK]: Use them to
implement warnings.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog     |    9 +++++++++
 lib/math.in.h |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 m4/math_h.m4  |    4 +++-
 modules/math  |    6 ++++--
 4 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d94756d..ad8294b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2010-01-04  Eric Blake  <address@hidden>

+       math: add portability warnings for classification macros
+       * modules/math (Depends-on): Add warn-on-use.
+       (Makefile.am): Provide new substitutions.
+       * m4/math_h.m4 (gl_MATH_H): Require inline.
+       * lib/math.in.h (_GL_WARN_REAL_FLOATING_DECL)
+       (_GL_WARN_REAL_FLOATING_IMPL): New helper macros.
+       (isfinite, isinf, isnan, signbit) [GNULIB_POSIXCHECK]: Use them to
+       implement warnings.
+
        unistd: warn on use of environ without module
        * modules/unistd (Depends-on): Add warn-on-use.
        (Makefile.am): Provide new substitutions.
diff --git a/lib/math.in.h b/lib/math.in.h
index 5cefd4d..7f09424 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -32,6 +32,37 @@

 /* The definition of _GL_ARG_NONNULL is copied here.  */

+/* Helper macros to define a portability warning for the
+   classification macro FUNC called with VALUE.  POSIX declares the
+   classification macros with an argument of real-floating (that is,
+   one of float, double, or long double).  */
+#define _GL_WARN_REAL_FLOATING_DECL(func) \
+static inline int                                                   \
+rpl_ ## func ## f (float f)                                         \
+{                                                                   \
+  return func (f);                                                  \
+}                                                                   \
+static inline int                                                   \
+rpl_ ## func ## d (double d)                                        \
+{                                                                   \
+  return func (d);                                                  \
+}                                                                   \
+static inline int                                                   \
+rpl_ ## func ## l (long double l)                                   \
+{                                                                   \
+  return func (l);                                                  \
+}                                                                   \
+_GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - "       \
+                 "use gnulib module " #func " for portability");    \
+_GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - "       \
+                 "use gnulib module " #func " for portability");    \
+_GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - "       \
+                 "use gnulib module " #func " for portability")
+#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \
+  (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value)     \
+   : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value)  \
+   : rpl_ ## func ## l (value))
+

 #ifdef __cplusplus
 extern "C" {
@@ -386,7 +417,11 @@ extern int gl_isfinitel (long double x);
     gl_isfinitef (x))
 # endif
 #elif defined GNULIB_POSIXCHECK
-  /* How to override a macro?  */
+# if defined isfinite
+_GL_WARN_REAL_FLOATING_DECL (isfinite);
+#  undef isfinite
+#  define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x)
+# endif
 #endif


@@ -402,7 +437,11 @@ extern int gl_isinfl (long double x);
     gl_isinff (x))
 # endif
 #elif defined GNULIB_POSIXCHECK
-  /* How to override a macro?  */
+# if defined isinf
+_GL_WARN_REAL_FLOATING_DECL (isinf);
+#  undef isinf
+#  define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x)
+# endif
 #endif


@@ -501,7 +540,11 @@ extern int rpl_isnanl (long double x);
     gl_isnan_f (x))
 # endif
 #elif defined GNULIB_POSIXCHECK
-  /* How to override a macro?  */
+# if defined isnan
+_GL_WARN_REAL_FLOATING_DECL (isnan);
+#  undef isnan
+#  define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x)
+# endif
 #endif


@@ -557,7 +600,11 @@ extern int gl_signbitl (long double arg);
     gl_signbitf (x))
 # endif
 #elif defined GNULIB_POSIXCHECK
-  /* How to override a macro?  */
+# if defined signbit
+_GL_WARN_REAL_FLOATING_DECL (signbit);
+#  undef signbit
+#  define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x)
+# endif
 #endif


diff --git a/m4/math_h.m4 b/m4/math_h.m4
index 00cbeb7..bd8128b 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 14
+# math_h.m4 serial 15
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,8 @@ AC_DEFUN([gl_MATH_H],
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
   gl_CHECK_NEXT_HEADERS([math.h])
+  AC_REQUIRE([AC_C_INLINE])
+
   AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(address@hidden:@include <math.h>]],
       [[/* Solaris 10 has a broken definition of NAN.  Other platforms
diff --git a/modules/math b/modules/math
index 0e2bc0b..dda67df 100644
--- a/modules/math
+++ b/modules/math
@@ -6,9 +6,10 @@ lib/math.in.h
 m4/math_h.m4

 Depends-on:
+arg-nonnull
 include_next
 link-warning
-arg-nonnull
+warn-on-use

 configure.ac:
 gl_MATH_H
@@ -18,7 +19,7 @@ BUILT_SOURCES += math.h

 # We need the following in order to create <math.h> when the system
 # doesn't have one that works with the given compiler.
-math.h: math.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+math.h: math.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          sed -e 
's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
@@ -81,6 +82,7 @@ math.h: math.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
              -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/math.in.h; \
        } > address@hidden && \
        mv address@hidden $@
-- 
1.6.4.2

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]