diff options
Diffstat (limited to 'gl/m4/time_r.m4')
-rw-r--r-- | gl/m4/time_r.m4 | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/gl/m4/time_r.m4 b/gl/m4/time_r.m4 index c871b56d..9e82d39f 100644 --- a/gl/m4/time_r.m4 +++ b/gl/m4/time_r.m4 | |||
@@ -1,6 +1,6 @@ | |||
1 | dnl Reentrant time functions like localtime_r. | 1 | dnl Reentrant time functions: localtime_r, gmtime_r. |
2 | 2 | ||
3 | dnl Copyright (C) 2003, 2006, 2007, 2008 Free Software Foundation, Inc. | 3 | dnl Copyright (C) 2003, 2006-2010 Free Software Foundation, Inc. |
4 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
5 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
6 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
@@ -9,29 +9,40 @@ dnl Written by Paul Eggert. | |||
9 | 9 | ||
10 | AC_DEFUN([gl_TIME_R], | 10 | AC_DEFUN([gl_TIME_R], |
11 | [ | 11 | [ |
12 | dnl Persuade glibc and Solaris <time.h> to declare localtime_r. | 12 | dnl Persuade glibc and Solaris <time.h> to declare localtime_r. |
13 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | 13 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
14 | 14 | ||
15 | AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) | 15 | AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) |
16 | AC_REQUIRE([AC_C_RESTRICT]) | 16 | AC_REQUIRE([AC_C_RESTRICT]) |
17 | 17 | ||
18 | AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature], | 18 | AC_CHECK_FUNCS_ONCE([localtime_r]) |
19 | [gl_cv_time_r_posix], | 19 | if test $ac_cv_func_localtime_r = yes; then |
20 | [AC_TRY_COMPILE( | 20 | AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature], |
21 | [#include <time.h>], | 21 | [gl_cv_time_r_posix], |
22 | [/* We don't need to append 'restrict's to the argument types, | 22 | [AC_COMPILE_IFELSE( |
23 | even though the POSIX signature has the 'restrict's, | 23 | [AC_LANG_PROGRAM( |
24 | since C99 says they can't affect type compatibility. */ | 24 | [[#include <time.h>]], |
25 | struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r; | 25 | [[/* We don't need to append 'restrict's to the argument types, |
26 | if (ptr) return 0; | 26 | even though the POSIX signature has the 'restrict's, |
27 | /* Check the return type is a pointer. On HP-UX 10 it is 'int'. */ | 27 | since C99 says they can't affect type compatibility. */ |
28 | *localtime_r (0, 0);], | 28 | struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r; |
29 | [gl_cv_time_r_posix=yes], | 29 | if (ptr) return 0; |
30 | [gl_cv_time_r_posix=no])]) | 30 | /* Check the return type is a pointer. |
31 | if test $gl_cv_time_r_posix = yes; then | 31 | On HP-UX 10 it is 'int'. */ |
32 | REPLACE_LOCALTIME_R=0 | 32 | *localtime_r (0, 0);]]) |
33 | ], | ||
34 | [gl_cv_time_r_posix=yes], | ||
35 | [gl_cv_time_r_posix=no]) | ||
36 | ]) | ||
37 | if test $gl_cv_time_r_posix = yes; then | ||
38 | REPLACE_LOCALTIME_R=0 | ||
39 | else | ||
40 | REPLACE_LOCALTIME_R=1 | ||
41 | fi | ||
33 | else | 42 | else |
34 | REPLACE_LOCALTIME_R=1 | 43 | HAVE_LOCALTIME_R=0 |
44 | fi | ||
45 | if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then | ||
35 | AC_LIBOBJ([time_r]) | 46 | AC_LIBOBJ([time_r]) |
36 | gl_PREREQ_TIME_R | 47 | gl_PREREQ_TIME_R |
37 | fi | 48 | fi |