From e7100ae48702b41167615d0dba263125114216ef Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 31 Dec 2009 16:20:15 -0700 Subject: [PATCH] headers: make check of system header explicit 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 --- ChangeLog | 15 +++++++++++++++ m4/inttypes.m4 | 3 ++- m4/netdb_h.m4 | 3 ++- m4/search_h.m4 | 3 ++- m4/sys_select_h.m4 | 3 ++- m4/sys_time_h.m4 | 2 ++ m4/wchar.m4 | 36 +++++++++++++++++------------------- 7 files changed, 42 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 345dbc4c8..49857413a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010-01-01 Eric Blake + + 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 ChangeLog: tweak to eliminate unnecessary copyright line diff --git a/m4/inttypes.m4 b/m4/inttypes.m4 index b19e30d53..3892e6063 100644 --- a/m4/inttypes.m4 +++ b/m4/inttypes.m4 @@ -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]) diff --git a/m4/netdb_h.m4 b/m4/netdb_h.m4 index 8711b809c..84afce6e5 100644 --- a/m4/netdb_h.m4 +++ b/m4/netdb_h.m4 @@ -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( diff --git a/m4/search_h.m4 b/m4/search_h.m4 index 9074dd45e..0dd0d4bc5 100644 --- a/m4/search_h.m4 +++ b/m4/search_h.m4 @@ -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 diff --git a/m4/sys_select_h.m4 b/m4/sys_select_h.m4 index c2fd5ab19..6ce09dbd4 100644 --- a/m4/sys_select_h.m4 +++ b/m4/sys_select_h.m4 @@ -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 diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 index 06ea33a5a..9c1648795 100644 --- a/m4/sys_time_h.m4 +++ b/m4/sys_time_h.m4 @@ -1,4 +1,5 @@ # Configure a replacement for . +# 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 diff --git a/m4/wchar.m4 b/m4/wchar.m4 index 072f466ee..fd8a38746 100644 --- a/m4/wchar.m4 +++ b/m4/wchar.m4 @@ -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 is standalone], - [gl_cv_header_wchar_h_standalone], - [AC_COMPILE_IFELSE([[#include -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 . - dnl Do it always: WCHAR_H may be empty here but can be set later. dnl Check for (missing in Linux uClibc when built without wide dnl character support). + dnl 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 is standalone], + [gl_cv_header_wchar_h_standalone], + [AC_COMPILE_IFELSE([[#include +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 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 is usable at all. -- 2.11.0