]>
Commit | Line | Data |
---|---|---|
9e15ef05 DL |
1 | dnl Check: |
2 | dnl * If we have gettimeofday; | |
3 | dnl * If we have struct timezone for use in calling it; | |
4 | dnl * If calling it with a timezone pointer actually works -- this is deemed | |
5 | dnl obsolete or undefined on some systems which say you should use a null | |
6 | dnl pointer -- and undefine HAVE_TIMEZONE if so; | |
7 | dnl * Whether it only takes one arg. | |
8 | AC_DEFUN(LIBU77_GETTIMEOFDAY, [ | |
9 | AC_CHECK_FUNCS(gettimeofday) | |
10 | if test "$ac_cv_func_gettimeofday" = yes; then | |
11 | AC_CACHE_CHECK([for struct timezone], g77_cv_struct_timezone, | |
12 | [AC_TRY_COMPILE([#include <sys/time.h>], | |
13 | [struct timezone tz;], | |
14 | g77_cv_struct_timezone=yes, g77_cv_struct_timezone=no)]) | |
15 | if test $g77_cv_struct_timezone = yes; then | |
16 | dnl It may be that we can't call gettimeofday with a non-null pointer. | |
17 | dnl In that case we'll lie about struct timezone. | |
18 | AC_TRY_RUN([ | |
19 | #ifdef TIME_WITH_SYS_TIME | |
20 | #include <sys/time.h> | |
21 | #include <time.h> | |
22 | #else | |
23 | #ifdef HAVE_SYS_TIME_H | |
24 | #include <sys/time.h> | |
25 | #else | |
26 | #include <time.h> | |
27 | #endif | |
28 | #endif | |
29 | main () | |
30 | { | |
31 | struct timeval time; | |
32 | struct timezone dummy; | |
33 | if (gettimeofday (&time, &dummy)) | |
34 | exit (1); | |
35 | else | |
36 | exit (0); | |
37 | }], | |
38 | [AC_DEFINE(HAVE_TIMEZONE)], ,[AC_DEFINE(HAVE_TIMEZONE)]) | |
39 | fi | |
40 | AC_REQUIRE([AC_HEADER_TIME]) | |
41 | AC_CACHE_CHECK(whether gettimeofday can accept two arguments, | |
42 | emacs_cv_gettimeofday_two_arguments, | |
43 | AC_TRY_LINK([ | |
44 | #ifdef TIME_WITH_SYS_TIME | |
45 | #include <sys/time.h> | |
46 | #include <time.h> | |
47 | #else | |
48 | #ifdef HAVE_SYS_TIME_H | |
49 | #include <sys/time.h> | |
50 | #else | |
51 | #include <time.h> | |
52 | #endif | |
53 | #endif | |
54 | ], | |
55 | [ | |
56 | struct timeval time; | |
57 | struct timezone dummy; | |
58 | gettimeofday (&time, &dummy);], | |
59 | emacs_cv_gettimeofday_two_arguments=yes, | |
60 | emacs_cv_gettimeofday_two_arguments=no)) | |
61 | if test $emacs_cv_gettimeofday_two_arguments = no; then | |
62 | AC_DEFINE(GETTIMEOFDAY_ONE_ARGUMENT) | |
63 | fi | |
64 | fi]) |