X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fsys_time_h.m4;h=3a3adc8c478a4c89c6d07c83acccdaa8e6f2384f;hb=372ef2a0e94ec6ee85b5fc4bab763154ec11420d;hp=1943abf447621837713c05f5824c90538081e1f5;hpb=e376fca6b969fd70ca281a7b74b8c3d35636ea0f;p=gnulib.git diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 index 1943abf44..3a3adc8c4 100644 --- a/m4/sys_time_h.m4 +++ b/m4/sys_time_h.m4 @@ -1,6 +1,7 @@ # Configure a replacement for . +# serial 6 -# Copyright (C) 2007 Free Software Foundation, Inc. +# Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -9,39 +10,63 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H], [ + dnl Use AC_REQUIRE here, so that the REPLACE_GETTIMEOFDAY=0 statement + dnl below is expanded once only, before all REPLACE_GETTIMEOFDAY=1 + dnl statements that occur in other macros. + AC_REQUIRE([gl_HEADER_SYS_TIME_H_BODY]) +]) + +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 - gl_ABSOLUTE_HEADER([sys/time.h]) - ABSOLUTE_SYS_TIME_H=\"$gl_cv_absolute_sys_time_h\" - HAVE_SYS_TIME_H=1 - else - ABSOLUTE_SYS_TIME_H=\"no/such/file/sys/time.h\" + if test $ac_cv_header_sys_time_h != yes; then HAVE_SYS_TIME_H=0 fi - AC_SUBST([ABSOLUTE_SYS_TIME_H]) - AC_SUBST([HAVE_SYS_TIME_H]) AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#if HAVE_SYS_TIME_H - #include - #endif - #include - ]], - [[static struct timeval x; x.tv_sec = x.tv_usec;]])], + [[#if HAVE_SYS_TIME_H + #include + #endif + #include + ]], + [[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. - GETTIMEOFDAY_REPLACEMENT=0 - AC_SUBST([GETTIMEOFDAY_REPLACEMENT]) + 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]) ])