Mercurial > hg > octave-lojdl > gnulib-hg
annotate m4/gettimeofday.m4 @ 8057:d5ba49b9b586
* m4/string_h.m4 (gl_STRING_MODULE_INDICATOR): Correct m4 usage
bug.
* modules/string (Makefile.am): Remove redundant replacement.
* modules/regex (Depends-on): Add mempcpy.
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Thu, 01 Feb 2007 05:01:17 +0000 |
parents | d12a7f6db481 |
children | 039bedae1345 |
rev | line source |
---|---|
7902
5fa14d8c0b45
Replace HAVE_GETTIMEOFDAY_POSIX_SIGNATURE and GETTIMEOFDAY_CLOBBERS_LOCALTIME
Bruno Haible <bruno@clisp.org>
parents:
7901
diff
changeset
|
1 #serial 11 |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4694
diff
changeset
|
2 |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
3 # Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc. |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4694
diff
changeset
|
4 # This file is free software; the Free Software Foundation |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4694
diff
changeset
|
5 # gives unlimited permission to copy and/or distribute it, |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4694
diff
changeset
|
6 # with or without modifications, as long as this notice is preserved. |
3295 | 7 |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
8 dnl From Jim Meyering. |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
9 |
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
10 AC_DEFUN([gl_FUNC_GETTIMEOFDAY], |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
11 [ |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
12 AC_REQUIRE([AC_C_RESTRICT]) |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
13 AC_REQUIRE([gl_HEADER_SYS_TIME_H]) |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
14 AC_CHECK_FUNCS_ONCE([gettimeofday]) |
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
15 |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
16 AC_CACHE_CHECK([for gettimeofday with POSIX signature], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
17 [gl_cv_func_gettimeofday_posix_signature], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
18 [AC_COMPILE_IFELSE( |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
19 [AC_LANG_PROGRAM( |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
20 [[#include <sys/time.h> |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
21 struct timeval c; |
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
22 ]], |
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
23 [[ |
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
24 int (*f) (struct timeval *restrict, void *restrict) = gettimeofday; |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
25 int x = f (&c, 0); |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
26 return !(x | c.tv_sec | c.tv_usec); |
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
27 ]])], |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
28 [gl_cv_func_gettimeofday_posix_signature=yes], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
29 [gl_cv_func_gettimeofday_posix_signature=no])]) |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
30 |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
31 gl_FUNC_GETTIMEOFDAY_CLOBBER |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
32 |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
33 if test $gl_cv_func_gettimeofday_posix_signature != yes; then |
7902
5fa14d8c0b45
Replace HAVE_GETTIMEOFDAY_POSIX_SIGNATURE and GETTIMEOFDAY_CLOBBERS_LOCALTIME
Bruno Haible <bruno@clisp.org>
parents:
7901
diff
changeset
|
34 GETTIMEOFDAY_REPLACEMENT=1 |
8043
d12a7f6db481
* modules/sys_time (Makefile.am): Build sys/time.h only when it's the
Jim Meyering <jim@meyering.net>
parents:
7902
diff
changeset
|
35 SYS_TIME_H=sys/time.h |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
36 if test $gl_cv_func_gettimeofday_clobber != yes; then |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
37 AC_LIBOBJ(gettimeofday) |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
38 gl_PREREQ_GETTIMEOFDAY |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
39 fi |
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
40 fi |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
41 ]) |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
42 |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
43 |
3295 | 44 dnl See if gettimeofday clobbers the static buffer that localtime uses |
5611
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4694
diff
changeset
|
45 dnl for its return value. The gettimeofday function from Mac OS X 10.0.4 |
87c42e194f4a
Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4694
diff
changeset
|
46 dnl (i.e., Darwin 1.3.7) has this problem. |
3295 | 47 dnl |
3856
16a28d7390aa
(AC_FUNC_GETTIMEOFDAY_CLOBBER): Also replace localtime.
Jim Meyering <jim@meyering.net>
parents:
3486
diff
changeset
|
48 dnl If it does, then arrange to use gettimeofday and localtime only via |
16a28d7390aa
(AC_FUNC_GETTIMEOFDAY_CLOBBER): Also replace localtime.
Jim Meyering <jim@meyering.net>
parents:
3486
diff
changeset
|
49 dnl the wrapper functions that work around the problem. |
3295 | 50 |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
51 AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], |
3295 | 52 [ |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
53 AC_REQUIRE([gl_HEADER_SYS_TIME_H]) |
3295 | 54 |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
55 AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
56 [gl_cv_func_gettimeofday_clobber], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
57 [AC_RUN_IFELSE( |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
58 [AC_LANG_PROGRAM( |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
59 [[#include <string.h> |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
60 #include <sys/time.h> |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
61 #include <time.h> |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
62 #include <stdlib.h> |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
63 ]], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
64 [[ |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
65 time_t t = 0; |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
66 struct tm *lt; |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
67 struct tm saved_lt; |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
68 struct timeval tv; |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
69 lt = localtime (&t); |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
70 saved_lt = *lt; |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
71 gettimeofday (&tv, NULL); |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
72 return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
73 ]])], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
74 [gl_cv_func_gettimeofday_clobber=no], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
75 [gl_cv_func_gettimeofday_clobber=yes], |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
76 dnl When crosscompiling, assume it is broken. |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
77 [gl_cv_func_gettimeofday_clobber=yes])]) |
3295 | 78 |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
79 if test $gl_cv_func_gettimeofday_clobber = yes; then |
7902
5fa14d8c0b45
Replace HAVE_GETTIMEOFDAY_POSIX_SIGNATURE and GETTIMEOFDAY_CLOBBERS_LOCALTIME
Bruno Haible <bruno@clisp.org>
parents:
7901
diff
changeset
|
80 GETTIMEOFDAY_REPLACEMENT=1 |
8043
d12a7f6db481
* modules/sys_time (Makefile.am): Build sys/time.h only when it's the
Jim Meyering <jim@meyering.net>
parents:
7902
diff
changeset
|
81 SYS_TIME_H=sys/time.h |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
82 gl_GETTIMEOFDAY_REPLACE_LOCALTIME |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
83 AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], 1, |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
84 [Define if gettimeofday clobbers the localtime buffer.]) |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
85 fi |
3295 | 86 ]) |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3856
diff
changeset
|
87 |
4540
fa39e8b4a0c2
Add wrappers for gmtime and tzset, too.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4108
diff
changeset
|
88 AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [ |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
89 AC_LIBOBJ(gettimeofday) |
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
90 gl_PREREQ_GETTIMEOFDAY |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
91 AC_DEFINE([gmtime], [rpl_gmtime], |
4540
fa39e8b4a0c2
Add wrappers for gmtime and tzset, too.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4108
diff
changeset
|
92 [Define to rpl_gmtime if the replacement function should be used.]) |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
93 AC_DEFINE([localtime], [rpl_localtime], |
4540
fa39e8b4a0c2
Add wrappers for gmtime and tzset, too.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4108
diff
changeset
|
94 [Define to rpl_localtime if the replacement function should be used.]) |
fa39e8b4a0c2
Add wrappers for gmtime and tzset, too.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4108
diff
changeset
|
95 ]) |
fa39e8b4a0c2
Add wrappers for gmtime and tzset, too.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4108
diff
changeset
|
96 |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3856
diff
changeset
|
97 # Prerequisites of lib/gettimeofday.c. |
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3856
diff
changeset
|
98 AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [ |
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
99 AC_CHECK_HEADERS([sys/timeb.h]) |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
5868
diff
changeset
|
100 AC_CHECK_FUNCS([_ftime]) |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3856
diff
changeset
|
101 ]) |