3
# Copyright (C) 2001-2003, 2005, 2007, 2009 Free Software Foundation, Inc.
3
# Copyright (C) 2001-2003, 2005, 2007, 2009-2010 Free Software Foundation, Inc.
4
4
# This file is free software; the Free Software Foundation
5
5
# gives unlimited permission to copy and/or distribute it,
6
6
# with or without modifications, as long as this notice is preserved.
12
12
AC_REQUIRE([AC_C_RESTRICT])
13
13
AC_REQUIRE([gl_HEADER_SYS_TIME_H])
14
AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
14
15
AC_CHECK_FUNCS_ONCE([gettimeofday])
16
AC_CACHE_CHECK([for gettimeofday with POSIX signature],
17
[gl_cv_func_gettimeofday_posix_signature],
20
[[#include <sys/time.h>
24
int (*f) (struct timeval *restrict, void *restrict) = gettimeofday;
26
return !(x | c.tv_sec | c.tv_usec);
28
[gl_cv_func_gettimeofday_posix_signature=yes],
29
[gl_cv_func_gettimeofday_posix_signature=no])])
31
gl_FUNC_GETTIMEOFDAY_CLOBBER
33
if test $gl_cv_func_gettimeofday_posix_signature != yes; then
34
REPLACE_GETTIMEOFDAY=1
36
if test $gl_cv_func_gettimeofday_clobber != yes; then
17
gl_gettimeofday_timezone=void
18
if test $ac_cv_func_gettimeofday != yes; then
20
AC_LIBOBJ([gettimeofday])
21
gl_PREREQ_GETTIMEOFDAY
23
gl_FUNC_GETTIMEOFDAY_CLOBBER
24
AC_CACHE_CHECK([for gettimeofday with POSIX signature],
25
[gl_cv_func_gettimeofday_posix_signature],
28
[[#include <sys/time.h>
30
int gettimeofday (struct timeval *restrict, void *restrict);
32
[[/* glibc uses struct timezone * rather than the POSIX void *
33
if _GNU_SOURCE is defined. However, since the only portable
34
use of gettimeofday uses NULL as the second parameter, and
35
since the glibc definition is actually more typesafe, it is
36
not worth wrapping this to get a compliant signature. */
37
int (*f) (struct timeval *restrict, void *restrict)
40
return !(x | c.tv_sec | c.tv_usec);
42
[gl_cv_func_gettimeofday_posix_signature=yes],
45
[[#include <sys/time.h>
46
int gettimeofday (struct timeval *restrict, struct timezone *restrict);
48
[gl_cv_func_gettimeofday_posix_signature=almost],
49
[gl_cv_func_gettimeofday_posix_signature=no])])])
50
if test $gl_cv_func_gettimeofday_posix_signature = almost; then
51
gl_gettimeofday_timezone='struct timezone'
52
elif test $gl_cv_func_gettimeofday_posix_signature != yes; then
53
REPLACE_GETTIMEOFDAY=1
37
54
AC_LIBOBJ([gettimeofday])
38
55
gl_PREREQ_GETTIMEOFDAY
58
AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone],
59
[Define this to 'void' or 'struct timezone' to match the system's
60
declaration of the second argument to gettimeofday.])
56
76
[gl_cv_func_gettimeofday_clobber],
71
gettimeofday (&tv, NULL);
72
return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
91
gettimeofday (&tv, NULL);
92
return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
74
94
[gl_cv_func_gettimeofday_clobber=no],
75
95
[gl_cv_func_gettimeofday_clobber=yes],
76
96
dnl When crosscompiling, assume it is broken.