* MODULES.html.sh (Support for systems lacking POSIX:2001): New
[gnulib.git] / m4 / sys_time_h.m4
1 # Configure a replacement for <sys/time.h>.
2
3 # Copyright (C) 2007 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
7
8 # Written by Paul Eggert and Martin Lambers.
9
10 AC_DEFUN([gl_HEADER_SYS_TIME_H],
11 [
12   AC_REQUIRE([AC_C_RESTRICT])
13   AC_CHECK_HEADERS_ONCE([sys/time.h])
14
15   if test $ac_cv_header_sys_time_h = yes; then
16     gl_ABSOLUTE_HEADER([sys/time.h])
17     ABSOLUTE_SYS_TIME_H=\"$gl_cv_absolute_sys_time_h\"
18     HAVE_SYS_TIME_H=1
19   else
20     ABSOLUTE_SYS_TIME_H=\"no/such/file/sys/time.h\"
21     HAVE_SYS_TIME_H=0
22   fi
23   AC_SUBST([ABSOLUTE_SYS_TIME_H])
24   AC_SUBST([HAVE_SYS_TIME_H])
25
26   AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval],
27     [AC_COMPILE_IFELSE(
28        [AC_LANG_PROGRAM(
29           [[#if HAVE_SYS_TIME_H
30              #include <sys/time.h>
31             #endif
32             #include <time.h>
33           ]],
34           [[static struct timeval x; x.tv_sec = x.tv_usec;]])],
35        [gl_cv_sys_struct_timeval=yes],
36        [gl_cv_sys_struct_timeval=no])])
37   if test $gl_cv_sys_struct_timeval = yes; then
38     HAVE_STRUCT_TIMEVAL=1
39   else
40     HAVE_STRUCT_TIMEVAL=0
41   fi
42   AC_SUBST([HAVE_STRUCT_TIMEVAL])
43
44   dnl Assume POSIX behavior unless another module says otherwise.
45   HAVE_GETTIMEOFDAY_POSIX_SIGNATURE=1
46   AC_SUBST([HAVE_GETTIMEOFDAY_POSIX_SIGNATURE])
47   GETTIMEOFDAY_CLOBBERS_LOCALTIME=0
48   AC_SUBST([GETTIMEOFDAY_CLOBBERS_LOCALTIME])
49 ])