X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fsys_time_h.m4;h=da5752716344679a9343b7c14b62a5e771a6d582;hb=682a983ba6ec26161cf2b5c2d71830cf2928ad26;hp=06ea33a5a8ea7f00b6ab96131a584699970137a8;hpb=b2e2010c7c902235b5efb5bd3c6529f61b093aa4;p=gnulib.git diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 index 06ea33a5a..da5752716 100644 --- a/m4/sys_time_h.m4 +++ b/m4/sys_time_h.m4 @@ -1,4 +1,5 @@ # Configure a replacement for . +# serial 6 # Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -18,14 +19,13 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H], AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], [ AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) + AC_CHECK_HEADERS_ONCE([sys/time.h]) gl_CHECK_NEXT_HEADERS([sys/time.h]) - if test $ac_cv_header_sys_time_h = yes; then - HAVE_SYS_TIME_H=1 - else + if test $ac_cv_header_sys_time_h != yes; then HAVE_SYS_TIME_H=0 fi - AC_SUBST([HAVE_SYS_TIME_H]) AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], [AC_COMPILE_IFELSE( @@ -38,20 +38,35 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], [[static struct timeval x; x.tv_sec = x.tv_usec;]])], [gl_cv_sys_struct_timeval=yes], [gl_cv_sys_struct_timeval=no])]) - if test $gl_cv_sys_struct_timeval = yes; then - HAVE_STRUCT_TIMEVAL=1 - else + if test $gl_cv_sys_struct_timeval != yes; then HAVE_STRUCT_TIMEVAL=0 fi - AC_SUBST([HAVE_STRUCT_TIMEVAL]) + 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([[ +#if HAVE_SYS_TIME_H +# include +#endif +#include + ]], [gettimeofday]) +]) + +AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS], +[ + GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY]) dnl Assume POSIX behavior unless another module says otherwise. - REPLACE_GETTIMEOFDAY=0 - AC_SUBST([REPLACE_GETTIMEOFDAY]) - if test $HAVE_SYS_TIME_H = 0 || test $HAVE_STRUCT_TIMEVAL = 0; then - SYS_TIME_H=sys/time.h - else - SYS_TIME_H= - fi - AC_SUBST([SYS_TIME_H]) + HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) + HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) + HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) + REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) ])