]> git.cworth.org Git - tar/blob - m4/parse-datetime.m4
Imported Upstream version 1.24
[tar] / m4 / parse-datetime.m4
1 # parse-datetime.m4 serial 18
2 dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl Define HAVE_COMPOUND_LITERALS if the C compiler supports compound literals
8 dnl as in ISO C99.
9 dnl Note that compound literals such as (struct s) { 3, 4 } can be used for
10 dnl initialization of stack-allocated variables, but are not constant
11 dnl expressions and therefore cannot be used as initializer for global or
12 dnl static variables (even though gcc supports this in pre-C99 mode).
13 AC_DEFUN([gl_C_COMPOUND_LITERALS],
14 [
15   AC_CACHE_CHECK([for compound literals], [gl_cv_compound_literals],
16   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[struct s { int i, j; };]],
17       [[struct s t = (struct s) { 3, 4 };
18         if (t.i != 0) return 0;]])],
19     gl_cv_compound_literals=yes,
20     gl_cv_compound_literals=no)])
21   if test $gl_cv_compound_literals = yes; then
22     AC_DEFINE([HAVE_COMPOUND_LITERALS], [1],
23       [Define if you have compound literals.])
24   fi
25 ])
26
27 AC_DEFUN([gl_PARSE_DATETIME],
28 [
29   dnl Prerequisites of lib/parse-datetime.h.
30   AC_REQUIRE([AM_STDBOOL_H])
31   AC_REQUIRE([gl_TIMESPEC])
32
33   dnl Prerequisites of lib/parse-datetime.y.
34   AC_REQUIRE([gl_BISON])
35   AC_REQUIRE([gl_C_COMPOUND_LITERALS])
36   AC_STRUCT_TIMEZONE
37   AC_REQUIRE([gl_CLOCK_TIME])
38   AC_REQUIRE([gl_TM_GMTOFF])
39   AC_COMPILE_IFELSE(
40     [AC_LANG_SOURCE([[
41 #include <time.h> /* for time_t */
42 #include <limits.h> /* for CHAR_BIT, LONG_MIN, LONG_MAX */
43 #define TYPE_MINIMUM(t) \
44   ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
45 #define TYPE_MAXIMUM(t) \
46   ((t) ((t) 0 < (t) -1 ? (t) -1 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
47 typedef int verify_min[2 * (LONG_MIN <= TYPE_MINIMUM (time_t)) - 1];
48 typedef int verify_max[2 * (TYPE_MAXIMUM (time_t) <= LONG_MAX) - 1];
49        ]])],
50     [AC_DEFINE([TIME_T_FITS_IN_LONG_INT], [1],
51        [Define to 1 if all 'time_t' values fit in a 'long int'.])
52     ])
53 ])