bug-gnulib
[Top][All Lists]
Advanced

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

Re: GL_LINK_WARNING


From: Eric Blake
Subject: Re: GL_LINK_WARNING
Date: Thu, 17 Dec 2009 00:16:02 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> But that appears to only work for C, since I cannot know in advance whether a 
> macro name will have overloads in C++.  A real case of this is for functions 
> like strchr, which are reasonably typed one way in C:
> 
> char *strchr (const char *, int);
> 
> and two different ways in C++:
> 
> const char *strchr (const char *, int);
> char *strchr (char *, int);
> 
> Any suggestions on a way to manage this?  Maybe some sort of way to use 
> template SFINAE to silently suppress the attempt if the declaration is 
> overloaded?  Or am I stuck using:
> 
> #if <new enough gcc...> && !defined __cplusplus
> # define _GL_WARN_ON_USE...
> #endif

On the other hand, most gnulib functions assume extern "C" linkage, even when 
compiled by C++, so there shouldn't be many overloads.  I guess we can deal 
with that on a case-by-case basis (in other words, do the filtering in *.in.h 
at the declaration in question, rather than globally excluding __cplusplus from 
warn-on-use.h).  At any rate, here's a sampling of what I'm doing; does this 
approach look decent before I continue on to the rest of the headers?  And note 
that the ctype module was missing a dependency on link-warning.



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

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.
* MODULES.html.sh (Support for building): Mention it.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |    7 +++++++
 MODULES.html.sh         |    4 +++-
 build-aux/warn-on-use.h |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 modules/warn-on-use     |   31 +++++++++++++++++++++++++++++++
 4 files changed, 88 insertions(+), 1 deletions(-)
 create mode 100644 build-aux/warn-on-use.h
 create mode 100644 modules/warn-on-use

diff --git a/ChangeLog b/ChangeLog
index 8a03a4a..c92844e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-12-16  Eric Blake  <address@hidden>

+       warn-on-use: new module
+       * modules/warn-on-use: New file.
+       * build-aux/warn-on-use.h: Likewise.
+       * MODULES.html.sh (Support for building): Mention it.
+
+2009-12-16  Eric Blake  <address@hidden>
+
        getopt: synchronize from glibc
        * lib/getopt.c (_getopt_initialize, _getopt_internal_r): Swap
        parameter order.  Adjust all callers.
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 9d5664a..9975462 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -3171,6 +3171,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
@@ -3183,14 +3184,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..a5b8ee1
--- /dev/null
+++ b/build-aux/warn-on-use.h
@@ -0,0 +1,47 @@
+/* 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.
+   Furthermore, in C++, it is only safe to use if FUNCTION has no
+   overloads.  */
+#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) \
+typedef int _gl_warn_on_use
+# endif
+#endif
diff --git a/modules/warn-on-use b/modules/warn-on-use
new file mode 100644
index 0000000..2172cdb
--- /dev/null
+++ b/modules/warn-on-use
@@ -0,0 +1,31 @@
+Description:
+A C macro for emitting a warning if a function is used.
+
+Files:
+build-aux/warn-on-use.h
+
+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 '/_GL_WARN_ON_USE/,$$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 5cfd62afda1ba2528831aa8f43ec057626f0fc72 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 16 Dec 2009 16:20:28 -0700
Subject: [PATCH 2/2] warn-on-use: use instead of link-warning

Each *.in.h file serves two purposes - provide enough self-contained
content to serve as a replacement for the system header regardless of
the user's compiler, and offer the developer the ability to detect any
gnulib modules that might have been inadvertantly excluded.  The
former requires independence from config.h, and routes everything
through a Makefile.am snippet that uses @@ substitution specific to
the modules that were in use and the details learned at configure
time.

The latter works by poisoning anything that gnulib did not replace,
but which the developer had natively available so that their tests
passed.  Poisining relies on gcc features, and requires manual
triggering by adding -DGNULIB_POSIXCHECK to CFLAGS; it assumes that
<config.h> is properly included.  In fact, we do not want to use @@
substitution for HAVE_DECL_* during poisoning, because the warning is
only relevant for the gnulib modules which were not included, and thus
where the m4 macros to set proper @@ values have not been run.
Furthermore, we only need to poison interfaces that already have a
declaration; if something is not declared, then the developer wouldn't
have been able to link, so their code won't be using the problematic
interface in the first place.

* modules/ctype (Depends-on): Add warn-on-use.
(Makefile.am): Update rules accordingly.
* modules/arpa_inet (Depends-on): Replace link-warning with
warn-on-use.
(Makefile.am): Update rules accordingly.
* modules/dirent (Depends-on, Makefile.am): Likewise.
* modules/fcntl-h (Depends-on, Makefile.am): Likewise.
* m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Check which functions
should be poisoned.
* m4/ctype.m4 (gl_CTYPE_H): Likewise.
* m4/dirent_h.m4 (gl_DIRENT_H): Likewise.
* m4/fcntl_h.m4 (gl_FCNTL_H): Likewise.
* lib/arpa_inet.in.h: Use _GL_WARN_ON_USE instead of
GL_LINK_WARNING.
* lib/ctype.in.h: Likewise.
* lib/dirent.in.h: Likewise.
* lib/fcntl.in.h: Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog          |   21 +++++++++++++++++++++
 lib/arpa_inet.in.h |   20 ++++++++++----------
 lib/ctype.in.h     |   10 ++++++----
 lib/dirent.in.h    |   35 +++++++++++++++++------------------
 lib/fcntl.in.h     |   27 +++++++++++++--------------
 m4/arpa_inet_h.m4  |    9 +++++++--
 m4/ctype.m4        |    6 +++++-
 m4/dirent_h.m4     |    9 ++++++++-
 m4/fcntl_h.m4      |    7 ++++++-
 modules/arpa_inet  |    8 ++++----
 modules/ctype      |    4 +++-
 modules/dirent     |    8 ++++----
 modules/fcntl-h    |   10 +++++-----
 13 files changed, 109 insertions(+), 65 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c92844e..d53fb2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2009-12-16  Eric Blake  <address@hidden>

+       warn-on-use: use instead of link-warning
+       * modules/ctype (Depends-on): Add warn-on-use.
+       (Makefile.am): Update rules accordingly.
+       * modules/arpa_inet (Depends-on): Replace link-warning with
+       warn-on-use.
+       (Makefile.am): Update rules accordingly.
+       * modules/dirent (Depends-on, Makefile.am): Likewise.
+       * modules/fcntl-h (Depends-on, Makefile.am): Likewise.
+       * m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Check which functions
+       should be poisoned.
+       * m4/ctype.m4 (gl_CTYPE_H): Likewise.
+       * m4/dirent_h.m4 (gl_DIRENT_H): Likewise.
+       * m4/fcntl_h.m4 (gl_FCNTL_H): Likewise.
+       * lib/arpa_inet.in.h: Use _GL_WARN_ON_USE instead of
+       GL_LINK_WARNING.
+       * lib/ctype.in.h: Likewise.
+       * lib/dirent.in.h: Likewise.
+       * lib/fcntl.in.h: Likewise.
+
+2009-12-16  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/arpa_inet.in.h b/lib/arpa_inet.in.h
index 2965629..32429ee 100644
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -36,10 +36,10 @@
 #ifndef _GL_ARPA_INET_H
 #define _GL_ARPA_INET_H

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

+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -67,10 +67,10 @@ extern const char *inet_ntop (int af, const void *restrict 
src,
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef inet_ntop
-# define inet_ntop(af,src,dst,cnt) \
-    (GL_LINK_WARNING ("inet_ntop is unportable - " \
-                      "use gnulib module inet_ntop for portability"), \
-     inet_ntop (af, src, dst, cnt))
+# if HAVE_DECL_INET_NTOP
+_GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
+                 "use gnulib module inet_ntop for portability");
+# endif
 #endif

 #if @GNULIB_INET_PTON@
@@ -80,10 +80,10 @@ extern int inet_pton (int af, const char *restrict src, 
void *restrict dst)
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef inet_pton
-# define inet_pton(af,src,dst) \
-  (GL_LINK_WARNING ("inet_pton is unportable - " \
-                    "use gnulib module inet_pton for portability"), \
-   inet_pton (af, src, dst))
+# if HAVE_DECL_INET_PTON
+_GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
+                 "use gnulib module inet_pton for portability");
+# endif
 #endif

 #ifdef __cplusplus
diff --git a/lib/ctype.in.h b/lib/ctype.in.h
index d1a3c5b..202235f 100644
--- a/lib/ctype.in.h
+++ b/lib/ctype.in.h
@@ -36,6 +36,8 @@
 #ifndef _GL_CTYPE_H
 #define _GL_CTYPE_H

+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
 /* Return non-zero if c is a blank, i.e. a space or tab character.  */
 #if @GNULIB_ISBLANK@
 # if address@hidden@
@@ -43,10 +45,10 @@ extern int isblank (int c);
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef isblank
-# define isblank(c) \
-    (GL_LINK_WARNING ("isblank is unportable - " \
-                      "use gnulib module isblank for portability"), \
-     isblank (c))
+# if HAVE_DECL_ISBLANK
+_GL_WARN_ON_USE (isblank, "isblank is unportable - "
+                 "use gnulib module isblank for portability");
+# endif
 #endif

 #endif /* _GL_CTYPE_H */
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 8694b85..ef11c47 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -26,10 +26,9 @@
 #ifndef _GL_DIRENT_H
 #define _GL_DIRENT_H

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

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

 #ifdef __cplusplus
 extern "C" {
@@ -50,10 +49,10 @@ extern int dirfd (DIR const *dir) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef dirfd
-# define dirfd(d) \
-    (GL_LINK_WARNING ("dirfd is unportable - " \
-                      "use gnulib module dirfd for portability"), \
-     dirfd (d))
+# if HAVE_DECL_DIRFD
+_GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
+                 "use gnulib module dirfd for portability");
+# endif
 #endif

 #if @GNULIB_FDOPENDIR@
@@ -71,10 +70,10 @@ extern DIR *fdopendir (int fd);
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef fdopendir
-# define fdopendir(f) \
-    (GL_LINK_WARNING ("fdopendir is unportable - " \
-                      "use gnulib module fdopendir for portability"), \
-     fdopendir (f))
+# if HAVE_DECL_FDOPENDIR
+_GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
+                 "use gnulib module fdopendir for portability");
+# endif
 #endif

 #if @REPLACE_OPENDIR@
@@ -95,10 +94,10 @@ extern int scandir (const char *dir, struct dirent 
***namelist,
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef scandir
-# define scandir(d,n,f,c) \
-    (GL_LINK_WARNING ("scandir is unportable - " \
-                      "use gnulib module scandir for portability"), \
-     scandir (d, n, f, c))
+# if HAVE_DECL_SCANDIR
+_GL_WARN_ON_USE (scandir, "scandir is unportable - "
+                 "use gnulib module scandir for portability");
+# endif
 #endif

 #if @GNULIB_ALPHASORT@
@@ -109,10 +108,10 @@ extern int alphasort (const struct dirent **, const 
struct dirent **)
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef alphasort
-# define alphasort(a,b) \
-    (GL_LINK_WARNING ("alphasort is unportable - " \
-                      "use gnulib module alphasort for portability"), \
-     alphasort (a, b))
+# if HAVE_DECL_ALPHASORT
+_GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
+                 "use gnulib module alphasort for portability");
+# endif
 #endif

 #ifdef __cplusplus
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 1a4602b..c8c9ae6 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -44,10 +44,10 @@
 #define _GL_FCNTL_H


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

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

 /* Declare overridden functions.  */

@@ -65,10 +65,10 @@ extern int fcntl (int fd, int action, ...);
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef fcntl
-# define fcntl \
-    (GL_LINK_WARNING ("fcntl is not always POSIX compliant - " \
-                      "use gnulib module fcntl for portability"), \
-     fcntl)
+# if HAVE_DECL_FCNTL
+_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
+                 "use gnulib module fcntl for portability");
+# endif
 #endif

 #if @GNULIB_OPEN@
@@ -79,10 +79,9 @@ extern int open (const char *filename, int flags, ...) 
_GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef open
-# define open \
-    (GL_LINK_WARNING ("open is not always POSIX compliant - " \
-                      "use gnulib module open for portability"), \
-     open)
+/* Assume open is always declared.  */
+_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
+                 "use gnulib module open for portability");
 #endif

 #if @GNULIB_OPENAT@
@@ -96,10 +95,10 @@ extern int openat (int fd, char const *file, int flags, /* 
mode_t mode */ ...)
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef openat
-# define openat \
-    (GL_LINK_WARNING ("openat is not portable - " \
-                      "use gnulib module openat for portability"), \
-     openat)
+# if HAVE_DECL_OPENAT
+_GL_WARN_ON_USE (openat, "openat is not portable - "
+                 "use gnulib module openat for portability");
+# endif
 #endif

 #ifdef __cplusplus
diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4
index a6e63df..5b892b9 100644
--- a/m4/arpa_inet_h.m4
+++ b/m4/arpa_inet_h.m4
@@ -1,5 +1,5 @@
-# arpa_inet_h.m4 serial 5
-dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+# arpa_inet_h.m4 serial 6
+dnl Copyright (C) 2006, 2008, 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.
@@ -23,6 +23,11 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
   dnl Execute this unconditionally, because ARPA_INET_H may be set by other
   dnl modules, after this code is executed.
   gl_CHECK_NEXT_HEADERS([arpa/inet.h])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module was not in use.
+  AC_CHECK_DECLS_ONCE([inet_ntop])
+  AC_CHECK_DECLS_ONCE([inet_pton])
 ])

 dnl Unconditionally enables the replacement of <arpa/inet.h>.
diff --git a/m4/ctype.m4 b/m4/ctype.m4
index 51e5333..3d6fd15 100644
--- a/m4/ctype.m4
+++ b/m4/ctype.m4
@@ -1,4 +1,4 @@
-# ctype_h.m4 serial 1
+# ctype_h.m4 serial 2
 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,
@@ -10,6 +10,10 @@ AC_DEFUN([gl_CTYPE_H],
   dnl Execute this unconditionally, because CTYPE_H may be set by other
   dnl modules, after this code is executed.
   gl_CHECK_NEXT_HEADERS([ctype.h])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module was not in use.
+  AC_CHECK_DECLS_ONCE([isblank])
 ])

 AC_DEFUN([gl_CTYPE_MODULE_INDICATOR],
diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4
index 481212b..f5b68c6 100644
--- a/m4/dirent_h.m4
+++ b/m4/dirent_h.m4
@@ -1,4 +1,4 @@
-# dirent_h.m4 serial 7
+# dirent_h.m4 serial 8
 dnl Copyright (C) 2008-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,
@@ -15,6 +15,13 @@ AC_DEFUN([gl_DIRENT_H],
   dnl Execute this unconditionally, because DIRENT_H may be set by other
   dnl modules, after this code is executed.
   gl_CHECK_NEXT_HEADERS([dirent.h])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module was not in use.
+  AC_CHECK_DECLS_ONCE([alphasort])
+  AC_CHECK_DECLS_ONCE([dirfd])
+  AC_CHECK_DECLS_ONCE([fdopendir])
+  AC_CHECK_DECLS_ONCE([scandir])
 ])

 dnl Unconditionally enables the replacement of <dirent.h>.
diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4
index 12e435e..8793b2a 100644
--- a/m4/fcntl_h.m4
+++ b/m4/fcntl_h.m4
@@ -1,4 +1,4 @@
-# serial 8
+# serial 9
 # Configure fcntl.h.
 dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -12,6 +12,11 @@ AC_DEFUN([gl_FCNTL_H],
   AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
   AC_REQUIRE([gl_FCNTL_O_FLAGS])
   gl_CHECK_NEXT_HEADERS([fcntl.h])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module was not in use.
+  AC_CHECK_DECLS_ONCE([fcntl])
+  AC_CHECK_DECLS_ONCE([openat])
 ])

 # Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
diff --git a/modules/arpa_inet b/modules/arpa_inet
index e76c7e4..011fba2 100644
--- a/modules/arpa_inet
+++ b/modules/arpa_inet
@@ -6,10 +6,10 @@ lib/arpa_inet.in.h
 m4/arpa_inet_h.m4

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

 configure.ac:
 gl_HEADER_ARPA_INET
@@ -20,7 +20,7 @@ BUILT_SOURCES += $(ARPA_INET_H)

 # We need the following in order to create <arpa/inet.h> when the system
 # doesn't have one.
-arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
        $(AM_V_at)$(MKDIR_P) arpa
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -32,8 +32,8 @@ arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
              -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
              -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
              -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|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)/arpa_inet.in.h; \
        } > address@hidden && \
        mv address@hidden $@
diff --git a/modules/ctype b/modules/ctype
index b0ebf1b..146b831 100644
--- a/modules/ctype
+++ b/modules/ctype
@@ -7,6 +7,7 @@ m4/ctype.m4

 Depends-on:
 include_next
+warn-on-use

 configure.ac:
 gl_CTYPE_H
@@ -16,7 +17,7 @@ BUILT_SOURCES += $(CTYPE_H)

 # We need the following in order to create <ctype.h> when the system
 # doesn't have one that works with the given compiler.
-ctype.h: ctype.in.h
+ctype.h: ctype.in.h $(WARN_ON_USE_H)
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -24,6 +25,7 @@ ctype.h: ctype.in.h
              -e 's|@''NEXT_CTYPE_H''@|$(NEXT_CTYPE_H)|g' \
              -e 's/@''GNULIB_ISBLANK''@/$(GNULIB_ISBLANK)/g' \
              -e 's/@''HAVE_ISBLANK''@/$(HAVE_ISBLANK)/g' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/ctype.in.h; \
        } > address@hidden && \
        mv address@hidden $@
diff --git a/modules/dirent b/modules/dirent
index aed61e4..891e7d1 100644
--- a/modules/dirent
+++ b/modules/dirent
@@ -7,9 +7,9 @@ m4/dirent_h.m4
 m4/unistd_h.m4

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

 configure.ac:
 gl_DIRENT_H
@@ -19,7 +19,7 @@ BUILT_SOURCES += $(DIRENT_H)

 # We need the following in order to create <dirent.h> when the system
 # doesn't have one that works with the given compiler.
-dirent.h: dirent.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+dirent.h: dirent.in.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' \
@@ -36,8 +36,8 @@ dirent.h: dirent.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
              -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
              -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
              -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|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)/dirent.in.h; \
        } > address@hidden && \
        mv address@hidden $@
diff --git a/modules/fcntl-h b/modules/fcntl-h
index aa6d8a0..ae90495 100644
--- a/modules/fcntl-h
+++ b/modules/fcntl-h
@@ -6,11 +6,11 @@ lib/fcntl.in.h
 m4/fcntl_h.m4

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

 configure.ac:
 gl_FCNTL_H
@@ -20,7 +20,7 @@ BUILT_SOURCES += fcntl.h

 # We need the following in order to create <fcntl.h> when the system
 # doesn't have one that works with the given compiler.
-fcntl.h: fcntl.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+fcntl.h: fcntl.in.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' \
@@ -34,8 +34,8 @@ fcntl.h: fcntl.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
              -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
              -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
              -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|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)/fcntl.in.h; \
        } > address@hidden && \
        mv address@hidden $@
-- 
1.6.4.2







reply via email to

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