1# Configure a more-standard replacement for <time.h>. 2 3# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software 4# Foundation, Inc. 5 6# This file is free software; the Free Software Foundation 7# gives unlimited permission to copy and/or distribute it, 8# with or without modifications, as long as this notice is preserved. 9 10# Written by Paul Eggert and Jim Meyering. 11 12AC_DEFUN([gl_HEADER_TIME_H], 13[ 14 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 15 dnl once only, before all statements that occur in other macros. 16 AC_REQUIRE([gl_HEADER_TIME_H_BODY]) 17]) 18 19AC_DEFUN([gl_HEADER_TIME_H_BODY], 20[ 21 AC_REQUIRE([AC_C_RESTRICT]) 22 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 23 gl_ABSOLUTE_HEADER([time.h]) 24 ABSOLUTE_TIME_H=\"$gl_cv_absolute_time_h\" 25 AC_SUBST([ABSOLUTE_TIME_H]) 26 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) 27]) 28 29AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], 30[ 31 dnl If another module says to replace or to not replace, do that. 32 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; 33 dnl this lets maintainers check for portability. 34 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) 35 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) 36 REPLACE_STRPTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRPTIME]) 37 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) 38]) 39 40dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared 41dnl in time.h or sys/time.h. 42 43AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], 44[ 45 AC_CHECK_HEADERS_ONCE([sys/time.h]) 46 AC_CACHE_CHECK([for struct timespec in <time.h>], 47 [gl_cv_sys_struct_timespec_in_time_h], 48 [AC_COMPILE_IFELSE( 49 [AC_LANG_PROGRAM( 50 [[#include <time.h> 51 ]], 52 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], 53 [gl_cv_sys_struct_timespec_in_time_h=yes], 54 [gl_cv_sys_struct_timespec_in_time_h=no])]) 55 56 TIME_H_DEFINES_STRUCT_TIMESPEC=0 57 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 58 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then 59 TIME_H_DEFINES_STRUCT_TIMESPEC=1 60 else 61 AC_CACHE_CHECK([for struct timespec in <sys/time.h>], 62 [gl_cv_sys_struct_timespec_in_sys_time_h], 63 [AC_COMPILE_IFELSE( 64 [AC_LANG_PROGRAM( 65 [[#include <sys/time.h> 66 ]], 67 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], 68 [gl_cv_sys_struct_timespec_in_sys_time_h=yes], 69 [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) 70 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then 71 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 72 fi 73 fi 74 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) 75 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) 76]) 77