bug-gnulib
[Top][All Lists]
Advanced

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

warn-on-use preview


From: Eric Blake
Subject: warn-on-use preview
Date: Thu, 31 Dec 2009 23:03:09 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

I've learned my lesson from this morning - I won't push this until it's had a 
bit longer for reviews.  At any rate, this introduces warn-on-use, then 
demonstrates three distinct ways to use it.  I am still working on the global 
change of all remaining uses of GL_LINK_WARNING over to _GL_WARN_ON_USE, but 
getting these out of the way makes that patch more mechanical.

Eric Blake (4):
      [1/4] warn-on-use: new module
Introduce the new module.  Hopefully the comments in the commit log and in warn-
on-use.h give a good overview.  I also put quite a bit of m4 magic into 
gl_WARN_ON_USE_PREPARE to make it result in the minimal increase to configure 
size (for declaration warnings to work, we have to know whether a declaration 
exists).  I ended up inventing something better than AC_CHECK_DECLS_ONCE, since 
that macro accepts a macro as a declaration (which breaks things if the macro 
is not hiding an actual declaration by the same name), only operates on the 
standard headers (AC_INCLUDES_DEFAULT - but we want to check for declarations 
in all headers that we are replacing), and it expands to a lot of bulky shell 
code (we can do better with a single shell loop).

      [2/4] stdio: warn on suspicious uses
An obvious one - unconditionally poison gets (not even hiding it behind -
DGNULIB_POSIXCHECK).  Also, rewrite the ftell/ftello warnings.  I almost feel 
bad that the commit log is about as long as the patch.

      [3/4] unistd: warn on use of environ without module
Unfortunately, gcc 4.3.4 silently ignores __attribute__((warning(""))) on 
variables, even though it honors __attribute__((deprecated)):
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42562.  Fortunately, I can work 
around that shortcoming, to poison anyone who happens to use environ in their 
code (which is properly declared in glibc's unistd.h) but didn't use the 
environ module (since many other platforms lack the declaration).

      [4/4] math: add portability warnings for classification macros
Fix a todo in the file.  Since _GL_WARN_ON_USE and GNULIB_POSIXCHECK only work 
on gcc, I don't feel bad using a gcc-specific hack to issue warnings for 
developers that use isfinite without the right module.


>From 7330bd61d5de6b10b69e28fd2f12de132b06b4e4 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               |    8 +++++
 MODULES.html.sh         |    4 ++-
 build-aux/warn-on-use.h |   70 +++++++++++++++++++++++++++++++++++++++++
 m4/warn-on-use.m4       |   80 +++++++++++++++++++++++++++++++++++++++++++++++
 modules/warn-on-use     |   35 ++++++++++++++++++++
 5 files changed, 196 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 8b420c4..c52b3e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-12-31  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.
+
+2009-12-31  Eric Blake  <address@hidden>
+
        doc: correct availability of cygwin 1.5.x getopt
        * doc/posix-functions/optarg.texi (optarg): Cygwin supplies getopt
        variables.
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 7f079d3..2ebef88 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..b4c2b7b
--- /dev/null
+++ b/build-aux/warn-on-use.h
@@ -0,0 +1,70 @@
+/* A C macro for emitting warnings if a function is used.
+   Copyright (C) 2009 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 'gets' by:
+   - adding a call to gl_WARN_ON_USE_PREPARE([stdio.h], [gets]) in
+     configure.ac, which potentially defines HAVE_RAW_DECL_GETS
+   - adding this code to a header that wraps the system <stdio.h>:
+     #undef gets
+     #if HAVE_RAW_DECL_GETS
+     _GL_WARN_ON_USE (gets, "gets is a security hole, use fgets instead");
+     #endif
+
+   It is not possible to directly poison global variables.  But it is
+   possible to write a wrapper accessor function, and poison that:
+   #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..bf5f2d1
--- /dev/null
+++ b/m4/warn-on-use.m4
@@ -0,0 +1,80 @@
+# warn-on-use.m4 serial 1
+dnl Copyright (C) 2009 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(HEADER, NAMES)
+# -------------------------------------
+# If HEADER can be compiled, then define HAVE_RAW_DECL_name for each
+# element of the whitespace-separated NAMES where the function has a
+# declaration even after being undefined as a macro.
+#
+# For an example, it is possible to poison 'gets' by:
+# - adding a call to gl_WARN_ON_USE_PREPARE([stdio.h], [gets]) in
+#   configure.ac, which potentially defines HAVE_RAW_DECL_GETS
+# - adding this code to a header that wraps the system <stdio.h>:
+#   #undef gets
+#   #if HAVE_RAW_DECL_GETS
+#   _GL_WARN_ON_USE (gets, "gets is a security hole, use fgets instead");
+#   #endif
+#
+# NAMES may include global variables, but remember that only functions
+# work with _GL_WARN_ON_USE.  For example, poison environ by:
+# - adding a call to gl_WARN_ON_USE_PREPARE([unistd.h], [environ]) in
+#   configure.ac, which potentially defines HAVE_RAW_DECL_ENVIRON,
+#   and also a call to AC_REQUIRE([AC_C_INLINE])
+# - adding this code to a header that wraps the system <unistd.h>:
+#   #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
+#
+# If you assume C89, then it is generally safe to assume declarations
+# for functions declared in that standard without needing
+# gl_WARN_ON_USE_PREPARE.
+AC_DEFUN([gl_WARN_ON_USE_PREPARE],
+[
+  AC_CHECK_HEADERS_ONCE([$1])
+  m4_divert_text([INIT_PREPARE],
+    [AS_VAR_APPEND([gl_include_headers_list], ["
address@hidden:@if HAVE_[]AS_TR_CPP([$1])
address@hidden:@ include <$1>
address@hidden:@endif"])])
+  m4_divert_text([INIT_PREPARE],
+    [AS_VAR_APPEND([gl_raw_decl_list], [" $2"])])
+  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.])])
+  _gl_WARN_ON_USE_PREPARE
+])
+
+# One-shot helper macro, expanded on the first instance where
+# gl_WARN_ON_USE_PREPARE is used.  This works because our lists
+# are built up in earlier diversions.
+m4_define([_gl_WARN_ON_USE_PREPARE],
+[
+  m4_divert_text([DEFAULTS], [gl_raw_decl_list= gl_include_headers_list=])
+  for gl_func in $gl_raw_decl_list; do
+    AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])
+    AC_CACHE_CHECK([whether $gl_func is declared without a macro],
+      [gl_Symbol],
+      [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$gl_include_headers_list],
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])])
+    AS_VAR_POPDEF([gl_Symbol])
+  done
+  m4_define([_gl_WARN_ON_USE_PREPARE])
+])
+
+dnl Simpler than the real AS_VAR_APPEND introduced in autoconf 2.63b,
+dnl but achieves the same end.
+m4_ifndef([AS_VAR_APPEND],
+[m4_define([AS_VAR_APPEND],
+  [AS_LITERAL_IF([$1], [$1=$$1$2], [as_val=$2; eval $1=\$$1\$as_val])])])
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 49ef8711cb9a59ffe6335ea04e76ec440a7849e8 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.

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 patch intentionally avoids adding
more warnings to sprintf.

The use of ftell runs up against an arbitrary limitation on 32-bit
hosts (in addition to having portability bugs on some platforms).
This is not a security hole, but it does violate GNU coding standards,
so it would be nice to warn.  Remember that fseek depends on fseeko,
so we only have three cases to consider:

1. The developer forget to use either module.  Issue a warning under
GNULIB_POSIXCHECK for both functions, to remind them to add
appropriate modules.  There is no need to silence the warning, since
only developers will use GNULIB_POSIXCHECK.

2. The developer included both fseek and fseeko modules.  They might
not be aware of the arbitrary limitation on 32-bit hosts, so issue a
warning on fseek under GNULIB_POSIXCHECK.  On the other hand, since
they explicitly requested fseek, they may have a reason for using it,
so allow the definition of _GL_NO_LARGE_FILES to silence the warning.

3. The developer included only the fseeko module.  Gnulib guarantees
that fseek bugs will be avoided in that case, but we can presume that
the developer is aware of the 32-bit limitation, so issue a warning
for fseek even if GNULIB_POSIXCHECK is undefined.  But still allow
_GL_NO_LARGE_FILES to silence the warning.

The above applies equally to ftell/ftello.

Our unit tests never fall into category 1 (as the tests are only built
if the module is requested), but we have unit tests that intentionally
use fseek in order to avoid dragging in extra dependencies.  So our
tests are the first client of _GL_NO_LARGE_FILES, whether the package
they are used in falls under category 2 or 3.

* 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              |   21 +++++++
 lib/stdio.in.h         |  150 ++++++++++++++++++++++++++++++-----------------
 m4/stdio_h.m4          |    7 ++-
 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    |   10 +--
 13 files changed, 151 insertions(+), 110 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c52b3e7..a5f9328 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2009-12-31  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.
+
+2009-12-31  Eric Blake  <address@hidden>
+
        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 55c36dd..0f32e6c 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,10 @@ extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
     fflush (f))
 #endif

+/* gets is flat out unsafe.  Assume it is always declared.  */
+#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 +212,128 @@ 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
-#  define fseek rpl_fseek
+/* Set up the following warnings, based on which modules are in use.
+   - neither fseek nor fseeko: warn for fseek and fseeko, but only if
+     GNULIB_POSIXCHECK is defined.
+   - fseeko but not fseek: warn for fseek, unless _GL_NO_LARGE_FILES
+     is defined, but regardless of GNULIB_POSIXCHECK.
+   - fseek and fseeko: warn for fseek, but only if GNULIB_POSIXCHECK
+     and not _GL_NO_LARGE_FILES.
+
+   In other words, _GL_NO_LARGE_FILES is a witness macro that states
+   that arbitrarily limiting to 32-bit offsets is safe for a given
+   program, while GNULIB_POSIXCHECK is a witness macro for spotting
+   instances where the function may misbehave when ported to another
+   platform.  */
+
+#if @GNULIB_FSEEK@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+#  define _GL_FSEEK_WARN
+#  undef 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))
+# if @REPLACE_FSEEK@
+#  undef fseek
+#  define fseek rpl_fseek
+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
+#  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
+# 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
+
+/* Set up the following warnings, based on which modules are in use.
+   - neither ftell nor ftello: warn for ftell and ftello, but only if
+     GNULIB_POSIXCHECK is defined.
+   - ftello but not ftell: warn for ftell, unless _GL_NO_LARGE_FILES
+     is defined, but regardless of GNULIB_POSIXCHECK
+   - ftell and ftello: warn for ftell, but only if GNULIB_POSIXCHECK
+     and not _GL_NO_LARGE_FILES.  */
+
+#if @GNULIB_FTELL@
+# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
+#  define _GL_FTELL_WARN
+#  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
+#  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
+# 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@
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index c690565..d53aab8 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-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,7 @@ dnl with or without modifications, as long as this notice is 
preserved.

 AC_DEFUN([gl_STDIO_H],
 [
+  AC_REQUIRE([AC_C_INLINE])
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   gl_CHECK_NEXT_HEADERS([stdio.h])
   dnl No need to create extra modules for these functions. Everyone who uses
@@ -30,6 +31,10 @@ 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.
+  gl_WARN_ON_USE_PREPARE([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 ad77fa9..8a58041 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 0582ffd..368bf34 100644
--- a/tests/test-freadable.c
+++ b/tests/test-freadable.c
@@ -20,16 +20,13 @@

 #include "freadable.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 "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 1f9af7f..d9b1fa8 100644
--- a/tests/test-freading.c
+++ b/tests/test-freading.c
@@ -20,16 +20,13 @@

 #include "freading.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 "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 6a8a1c0..bef5770 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 0f35da4..30cd08b 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 bde4e06..c3be7ee 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 f4c4082..b5287f7 100644
--- a/tests/test-fwritable.c
+++ b/tests/test-fwritable.c
@@ -20,16 +20,13 @@

 #include "fwritable.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 "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 61c4f80..2477bda 100644
--- a/tests/test-fwriting.c
+++ b/tests/test-fwriting.c
@@ -20,16 +20,13 @@

 #include "fwriting.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 "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 8896590..295c072 100644
--- a/tests/test-getopt.c
+++ b/tests/test-getopt.c
@@ -18,13 +18,6 @@

 #include <config.h>

-/* 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
-
 #if GNULIB_GETOPT_GNU
 # include <getopt.h>

@@ -46,6 +39,9 @@ SIGNATURE_CHECK (getopt_long_only, int, (int, char 
*__getopt_argv_const *,
 #include "signature.h"
 SIGNATURE_CHECK (getopt, int, (int, char * const[], char const *));

+/* 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.  */
+#define _GL_NO_LARGE_FILES
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-- 
1.6.4.2


>From 0c38f9cd7ee08bad2127ce73f621a8642df9d333 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       |    8 ++++++++
 lib/unistd.in.h |   18 +++++++++++++-----
 m4/unistd_h.m4  |    5 +++++
 modules/unistd  |    6 ++++--
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a5f9328..d88431a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-12-31  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.
+
+2009-12-31  Eric Blake  <address@hidden>
+
        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 1e4060c..518bb66 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 fdf6455..e8a1aa0 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -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])

@@ -20,6 +21,10 @@ 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([unistd.h], [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_A
ND_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 12a9b6164ef6cd65b1832a3a4ecf16ff3b7264bb 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 gcc 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     |   11 +++++++++++
 lib/math.in.h |   47 +++++++++++++++++++++++++++++++++++++++++++----
 m4/math_h.m4  |    4 +++-
 modules/math  |    6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d88431a..d70f754 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2009-12-31  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.
+
+2009-12-31  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.
diff --git a/lib/math.in.h b/lib/math.in.h
index 803fd2d..0783934 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -32,6 +32,29 @@

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

+/* Helper macros to define a portability warning for the
+   classification macro FUNC called with VALUE.  */
+#define _GL_WARN_REAL_FLOATING_DECL(func) \
+static inline int                                                   \
+rpl_ ## func (float f, double d, long double l, int which)          \
+{                                                                   \
+  switch (which)                                                    \
+    {                                                               \
+    case 1: return func (f);                                        \
+    case 2: return func (d);                                        \
+    default: return func (l);                                       \
+    }                                                               \
+}                                                                   \
+_GL_WARN_ON_USE (rpl_ ## func, #func " is unportable - "            \
+                 "use gnulib module " #func " for portability")
+#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \
+  ({                                                                \
+    __typeof__ (value) __x = (value);                               \
+    rpl_ ## func (__x, __x, __x,                                    \
+                  (sizeof __x == sizeof (float) ? 1                 \
+                   : sizeof __x == sizeof (double) ? 2 : 3));       \
+  })
+

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


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


@@ -501,7 +532,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 && defined __GNUC__
+_GL_WARN_REAL_FLOATING_DECL (isnan);
+#  undef isnan
+#  define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x)
+# endif
 #endif


@@ -557,7 +592,11 @@ extern int gl_signbitl (long double arg);
     gl_signbitf (x))
 # endif
 #elif defined GNULIB_POSIXCHECK
-  /* How to override a macro?  */
+# if defined signbit && defined __GNUC__
+_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 b7a2d9c..07ce0e1 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-2009 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







reply via email to

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