headers: make check of system header explicit
authorEric Blake <ebb9@byu.net>
Thu, 31 Dec 2009 23:20:15 +0000 (16:20 -0700)
committerEric Blake <ebb9@byu.net>
Fri, 1 Jan 2010 17:52:47 +0000 (10:52 -0700)
Exploiting knowledge of internal behavior of other macros can
be dangerous, especially since AC_CHECK_HEADERS_ONCE is designed
to be cheap on subsequent use.

* m4/netdb_h.m4 (gl_HEADER_NETDB): Don't exploit knowledge of
gl_CHECK_NEXT_HEADER internals, but call AC_CHECK_HEADERS_ONCE
ourselves.
* m4/search_h.m4 (gl_SEARCH_H): Likewise.
* m4/sys_select_h.m4 (gl_HEADER_SYS_SELECT): Likewise.
* m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_BODY): Likewise.
* m4/inttypes.m4 (gl_INTTYPES_H): Likewise, for gt_INTTYPES_PRI
internals.
* m4/wchar.m4 (gl_WCHAR_H): Skip followup test if header is
missing.
Suggested by Bruno Haible.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
m4/inttypes.m4
m4/netdb_h.m4
m4/search_h.m4
m4/sys_select_h.m4
m4/sys_time_h.m4
m4/wchar.m4

index 345dbc4..4985741 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2010-01-01  Eric Blake  <ebb9@byu.net>
+
+       headers: make check of system header explicit
+       * m4/netdb_h.m4 (gl_HEADER_NETDB): Don't exploit knowledge of
+       gl_CHECK_NEXT_HEADER internals, but call AC_CHECK_HEADERS_ONCE
+       ourselves.
+       * m4/search_h.m4 (gl_SEARCH_H): Likewise.
+       * m4/sys_select_h.m4 (gl_HEADER_SYS_SELECT): Likewise.
+       * m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_BODY): Likewise.
+       * m4/inttypes.m4 (gl_INTTYPES_H): Likewise, for gt_INTTYPES_PRI
+       internals.
+       * m4/wchar.m4 (gl_WCHAR_H): Skip followup test if header is
+       missing.
+       Suggested by Bruno Haible.
+
 2010-01-01  Jim Meyering  <meyering@redhat.com>
 
        ChangeLog: tweak to eliminate unnecessary copyright line
index b19e30d..3892e60 100644 (file)
@@ -1,4 +1,4 @@
-# inttypes.m4 serial 15
+# inttypes.m4 serial 16
 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_INTTYPES_H],
 [
   AC_REQUIRE([gl_STDINT_H])
   AC_REQUIRE([gt_INTTYPES_PRI])
+  AC_CHECK_HEADERS_ONCE([inttypes.h])
   AC_CHECK_DECLS_ONCE([imaxabs])
   AC_CHECK_DECLS_ONCE([imaxdiv])
   AC_CHECK_DECLS_ONCE([strtoimax])
index 8711b80..84afce6 100644 (file)
@@ -1,4 +1,4 @@
-# netdb_h.m4 serial 5
+# netdb_h.m4 serial 6
 dnl Copyright (C) 2008, 2009, 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_HEADER_NETDB],
 [
   AC_REQUIRE([gl_NETDB_H_DEFAULTS])
+  AC_CHECK_HEADERS_ONCE([netdb.h])
   gl_CHECK_NEXT_HEADERS([netdb.h])
   if test $ac_cv_header_netdb_h = yes; then
     AC_COMPILE_IFELSE(
index 9074dd4..0dd0d4b 100644 (file)
@@ -1,4 +1,4 @@
-# search_h.m4 serial 3
+# search_h.m4 serial 4
 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_SEARCH_H],
 [
   AC_REQUIRE([gl_SEARCH_H_DEFAULTS])
+  AC_CHECK_HEADERS_ONCE([search.h])
   gl_CHECK_NEXT_HEADERS([search.h])
   if test $ac_cv_header_search_h = yes; then
     HAVE_SEARCH_H=1
index c2fd5ab..6ce09db 100644 (file)
@@ -1,4 +1,4 @@
-# sys_select_h.m4 serial 9
+# sys_select_h.m4 serial 10
 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,
@@ -45,6 +45,7 @@ AC_DEFUN([gl_HEADER_SYS_SELECT],
           ])
       fi
     ])
+  AC_CHECK_HEADERS_ONCE([sys/select.h])
   gl_CHECK_NEXT_HEADERS([sys/select.h])
   if test $ac_cv_header_sys_select_h = yes; then
     HAVE_SYS_SELECT_H=1
index 06ea33a..9c16487 100644 (file)
@@ -1,4 +1,5 @@
 # Configure a replacement for <sys/time.h>.
+# serial 2
 
 # Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -18,6 +19,7 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H],
 AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
 [
   AC_REQUIRE([AC_C_RESTRICT])
+  AC_CHECK_HEADERS_ONCE([sys/time.h])
   gl_CHECK_NEXT_HEADERS([sys/time.h])
 
   if test $ac_cv_header_sys_time_h = yes; then
index 072f466..fd8a387 100644 (file)
@@ -7,40 +7,38 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl Written by Eric Blake.
 
-# wchar.m4 serial 28
+# wchar.m4 serial 29
 
 AC_DEFUN([gl_WCHAR_H],
 [
   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
   AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
-  AC_CACHE_CHECK([whether <wchar.h> is standalone],
-    [gl_cv_header_wchar_h_standalone],
-    [AC_COMPILE_IFELSE([[#include <wchar.h>
-wchar_t w;]],
-      [gl_cv_header_wchar_h_standalone=yes],
-      [gl_cv_header_wchar_h_standalone=no])])
-
-  AC_REQUIRE([gt_TYPE_WINT_T])
-  if test $gt_cv_c_wint_t = yes; then
-    HAVE_WINT_T=1
-  else
-    HAVE_WINT_T=0
-  fi
-  AC_SUBST([HAVE_WINT_T])
-
   dnl Prepare for creating substitute <wchar.h>.
-  dnl Do it always: WCHAR_H may be empty here but can be set later.
   dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
   dnl character support).
+  dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
   AC_CHECK_HEADERS_ONCE([wchar.h])
+  gl_CHECK_NEXT_HEADERS([wchar.h])
   if test $ac_cv_header_wchar_h = yes; then
     HAVE_WCHAR_H=1
+    AC_CACHE_CHECK([whether <wchar.h> is standalone],
+      [gl_cv_header_wchar_h_standalone],
+      [AC_COMPILE_IFELSE([[#include <wchar.h>
+wchar_t w;]],
+        [gl_cv_header_wchar_h_standalone=yes],
+        [gl_cv_header_wchar_h_standalone=no])])
   else
     HAVE_WCHAR_H=0
   fi
   AC_SUBST([HAVE_WCHAR_H])
-  dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
-  gl_CHECK_NEXT_HEADERS([wchar.h])
+
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  if test $gt_cv_c_wint_t = yes; then
+    HAVE_WINT_T=1
+  else
+    HAVE_WINT_T=0
+  fi
+  AC_SUBST([HAVE_WINT_T])
 ])
 
 dnl Check whether <wchar.h> is usable at all.