Add time_r module. Change timegm, mktime, and strftime to use localtime_r
[gnulib.git] / m4 / time_r.m4
1 dnl Reentrant time functions like localtime_r.
2
3 dnl Copyright (C) 2003 Free Software Foundation, Inc.
4
5 dnl This file is free software, distributed under the terms of the GNU
6 dnl General Public License.  As a special exception to the GNU General
7 dnl Public License, this file may be distributed as part of a program
8 dnl that contains a configuration script generated by Autoconf, under
9 dnl the same distribution terms as the rest of that program.
10
11 dnl Written by Paul Eggert.
12
13 AC_DEFUN([gl_TIME_R],
14 [
15   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16   AC_REQUIRE([gl_C_RESTRICT])
17
18   AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
19     [gl_cv_time_r_posix],
20     [AC_TRY_COMPILE(
21        [#include <time.h>],
22        [/* We don't need to append 'restrict's to the argument types,
23            even though the POSIX signature has the 'restrict's,
24            since C99 says they can't affect type compatibility.  */
25         struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;],
26        [gl_cv_time_r_posix=yes],
27        [gl_cv_time_r_posix=no])])
28   if test $gl_cv_time_r_posix = yes; then
29     AC_DEFINE([HAVE_TIME_R_POSIX], 1,
30       [Define to 1 if localtime_r, etc. have the type signatures that
31        POSIX requires.])
32   else
33     AC_LIBOBJ([time_r])
34     gl_PREREQ_TIME_R
35   fi
36 ])
37
38 # Prerequisites of lib/time_r.c.
39 AC_DEFUN([gl_PREREQ_TIME_R], [
40   :
41 ])