nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | # Configure a replacement for <sys/time.h>. |
2 | # serial 8 |
||
3 | |||
4 | # Copyright (C) 2007, 2009-2016 Free Software Foundation, Inc. |
||
5 | # This file is free software; the Free Software Foundation |
||
6 | # gives unlimited permission to copy and/or distribute it, |
||
7 | # with or without modifications, as long as this notice is preserved. |
||
8 | |||
9 | # Written by Paul Eggert and Martin Lambers. |
||
10 | |||
11 | AC_DEFUN([gl_HEADER_SYS_TIME_H], |
||
12 | [ |
||
13 | dnl Use AC_REQUIRE here, so that the REPLACE_GETTIMEOFDAY=0 statement |
||
14 | dnl below is expanded once only, before all REPLACE_GETTIMEOFDAY=1 |
||
15 | dnl statements that occur in other macros. |
||
16 | AC_REQUIRE([gl_HEADER_SYS_TIME_H_BODY]) |
||
17 | ]) |
||
18 | |||
19 | AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], |
||
20 | [ |
||
21 | AC_REQUIRE([AC_C_RESTRICT]) |
||
22 | AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) |
||
23 | AC_CHECK_HEADERS_ONCE([sys/time.h]) |
||
24 | gl_CHECK_NEXT_HEADERS([sys/time.h]) |
||
25 | |||
26 | if test $ac_cv_header_sys_time_h != yes; then |
||
27 | HAVE_SYS_TIME_H=0 |
||
28 | fi |
||
29 | |||
30 | dnl On native Windows with MSVC, 'struct timeval' is defined in <winsock2.h> |
||
31 | dnl only. So include that header in the list. |
||
32 | gl_PREREQ_SYS_H_WINSOCK2 |
||
33 | AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], |
||
34 | [AC_COMPILE_IFELSE( |
||
35 | [AC_LANG_PROGRAM( |
||
36 | [[#if HAVE_SYS_TIME_H |
||
37 | #include <sys/time.h> |
||
38 | #endif |
||
39 | #include <time.h> |
||
40 | #if HAVE_WINSOCK2_H |
||
41 | # include <winsock2.h> |
||
42 | #endif |
||
43 | ]], |
||
44 | [[static struct timeval x; x.tv_sec = x.tv_usec;]])], |
||
45 | [gl_cv_sys_struct_timeval=yes], |
||
46 | [gl_cv_sys_struct_timeval=no]) |
||
47 | ]) |
||
48 | if test $gl_cv_sys_struct_timeval != yes; then |
||
49 | HAVE_STRUCT_TIMEVAL=0 |
||
50 | else |
||
51 | dnl On native Windows with a 64-bit 'time_t', 'struct timeval' is defined |
||
52 | dnl (in <sys/time.h> and <winsock2.h> for mingw64, in <winsock2.h> only |
||
53 | dnl for MSVC) with a tv_sec field of type 'long' (32-bit!), which is |
||
54 | dnl smaller than the 'time_t' type mandated by POSIX. |
||
55 | dnl On OpenBSD 5.1 amd64, tv_sec is 64 bits and time_t 32 bits, but |
||
56 | dnl that is good enough. |
||
57 | AC_CACHE_CHECK([for wide-enough struct timeval.tv_sec member], |
||
58 | [gl_cv_sys_struct_timeval_tv_sec], |
||
59 | [AC_COMPILE_IFELSE( |
||
60 | [AC_LANG_PROGRAM( |
||
61 | [[#if HAVE_SYS_TIME_H |
||
62 | #include <sys/time.h> |
||
63 | #endif |
||
64 | #include <time.h> |
||
65 | #if HAVE_WINSOCK2_H |
||
66 | # include <winsock2.h> |
||
67 | #endif |
||
68 | ]], |
||
69 | [[static struct timeval x; |
||
70 | typedef int verify_tv_sec_type[ |
||
71 | sizeof (time_t) <= sizeof x.tv_sec ? 1 : -1 |
||
72 | ]; |
||
73 | ]])], |
||
74 | [gl_cv_sys_struct_timeval_tv_sec=yes], |
||
75 | [gl_cv_sys_struct_timeval_tv_sec=no]) |
||
76 | ]) |
||
77 | if test $gl_cv_sys_struct_timeval_tv_sec != yes; then |
||
78 | REPLACE_STRUCT_TIMEVAL=1 |
||
79 | fi |
||
80 | fi |
||
81 | |||
82 | dnl Check for declarations of anything we want to poison if the |
||
83 | dnl corresponding gnulib module is not in use. |
||
84 | gl_WARN_ON_USE_PREPARE([[ |
||
85 | #if HAVE_SYS_TIME_H |
||
86 | # include <sys/time.h> |
||
87 | #endif |
||
88 | #include <time.h> |
||
89 | ]], [gettimeofday]) |
||
90 | ]) |
||
91 | |||
92 | AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR], |
||
93 | [ |
||
94 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. |
||
95 | AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) |
||
96 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
||
97 | dnl Define it also as a C macro, for the benefit of the unit tests. |
||
98 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
||
99 | ]) |
||
100 | |||
101 | AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS], |
||
102 | [ |
||
103 | GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY]) |
||
104 | dnl Assume POSIX behavior unless another module says otherwise. |
||
105 | HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) |
||
106 | HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) |
||
107 | HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) |
||
108 | HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T]) |
||
109 | REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) |
||
110 | REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL]) |
||
111 | ]) |