aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-01-08 22:57:07 -0800
committerPaul Eggert2011-01-08 22:57:07 -0800
commit1fd182f01815629114a83d6987568dce72cc6bf5 (patch)
tree17148e38af034214416d362909d5a3ec8c4e6c4a
parente84aba69759680c3d2461570168aabf52c5e12aa (diff)
downloademacs-1fd182f01815629114a83d6987568dce72cc6bf5.tar.gz
emacs-1fd182f01815629114a83d6987568dce72cc6bf5.zip
Regenerate.
-rw-r--r--ChangeLog22
-rw-r--r--aclocal.m48
-rw-r--r--arg-nonnull.h26
-rw-r--r--c++defs.h271
-rwxr-xr-xconfigure1552
-rw-r--r--lib/Makefile.in138
-rw-r--r--lib/gnulib.mk152
-rw-r--r--lib/mktime-internal.h4
-rw-r--r--lib/mktime.c669
-rw-r--r--lib/stddef.in.h87
-rw-r--r--lib/time.h555
-rw-r--r--lib/time.in.h243
-rw-r--r--lib/time_r.c45
-rw-r--r--m4/extensions.m4118
-rw-r--r--m4/gnulib-cache.m43
-rw-r--r--m4/gnulib-comp.m445
-rw-r--r--m4/include_next.m4217
-rw-r--r--m4/mktime.m4238
-rw-r--r--m4/multiarch.m465
-rw-r--r--m4/stddef_h.m445
-rw-r--r--m4/time_h.m4109
-rw-r--r--m4/time_r.m462
-rw-r--r--m4/warn-on-use.m445
-rw-r--r--m4/wchar_t.m424
-rw-r--r--src/config.in108
-rw-r--r--warn-on-use.h109
26 files changed, 4486 insertions, 474 deletions
diff --git a/ChangeLog b/ChangeLog
index ad18cf10a39..7680a11e6bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
12011-01-09 Paul Eggert <eggert@cs.ucla.edu> 12011-01-09 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Regenerate.
4 * arg-nonnull.h, c++defs.h, lib/mktime-internal.h, lib/mktime.c:
5 * lib/stddef.in.h, lib/time.h, lib/time.in.h, lib/time_r.c:
6 * m4/extensions.m4, m4/include_next.m4, m4/mktime.m4:
7 * m4/multiarch.m4, m4/stddef_h.m4, m4/time_h.m4, m4/time_r.m4:
8 * m4/extensions.m4, m4/include_next.m4, m4/mktime.m4, m4/multiarch.m4:
9 * m4/stddef_h.m4, m4/time_h.m4, m4/time_r.m4, m4/warn-on-use.m4:
10 * m4/wchar_t.m4, warn-on-use.h:
11 New files, copied from gnulib by gnulib-tool.
12 * aclocal.m4, configure, lib/Makefile.in, lib/gnulib.mk:
13 * m4/gnulib-cache.m4, m4/gnulib-comp.m4, src/config.in:
14 Regenerate.
15
3 Use gnulib's mktime module. 16 Use gnulib's mktime module.
4 * Makefile.in (GNULIB_MODULES): Add mktime. 17 * Makefile.in (GNULIB_MODULES): Add mktime.
5 * configure.in: Remove code no longer needed, as gnulib now does it. 18 * configure.in: Remove code no longer needed, as gnulib now does it.
@@ -11,6 +24,15 @@
11 (mktime): Remove. 24 (mktime): Remove.
12 * make-dist: Put gnulib-generated files arg-nonnull.h, c++defs.h, 25 * make-dist: Put gnulib-generated files arg-nonnull.h, c++defs.h,
13 and warn-on-use.h into the distribution. 26 and warn-on-use.h into the distribution.
27
28 Regenerate.
29 * lib/dtoastr.c, lib/ftoastr.c, lib/ftoastr.h, lib/intprops.h:
30 * lib/ldtoastr.c, m4/c-strtod.m4:
31 New files, copied from gnulib by gnulib-tool.
32 * lib/dummy.c: Remove.
33 * aclocal.m4, configure, lib/Makefile.in, lib/gnulib.mk:
34 * m4/gnulib-cache.m4, m4/gnulib-comp.m4, src/config.in:
35 Regenerate.
14 36
15 Use gnulib's ftoastr module. 37 Use gnulib's ftoastr module.
16 * Makefile.in (GNULIB_MODULES): Add ftoastr. Remove dummy. 38 * Makefile.in (GNULIB_MODULES): Add ftoastr. Remove dummy.
diff --git a/aclocal.m4 b/aclocal.m4
index 4f728365ef9..39d41f8c282 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -986,5 +986,13 @@ AC_SUBST([am__untar])
986 986
987m4_include([m4/00gnulib.m4]) 987m4_include([m4/00gnulib.m4])
988m4_include([m4/c-strtod.m4]) 988m4_include([m4/c-strtod.m4])
989m4_include([m4/extensions.m4])
989m4_include([m4/gnulib-common.m4]) 990m4_include([m4/gnulib-common.m4])
990m4_include([m4/gnulib-comp.m4]) 991m4_include([m4/gnulib-comp.m4])
992m4_include([m4/include_next.m4])
993m4_include([m4/mktime.m4])
994m4_include([m4/multiarch.m4])
995m4_include([m4/stddef_h.m4])
996m4_include([m4/time_h.m4])
997m4_include([m4/time_r.m4])
998m4_include([m4/wchar_t.m4])
diff --git a/arg-nonnull.h b/arg-nonnull.h
new file mode 100644
index 00000000000..226d1a86998
--- /dev/null
+++ b/arg-nonnull.h
@@ -0,0 +1,26 @@
1/* A C macro for declaring that specific arguments must not be NULL.
2 Copyright (C) 2009-2011 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
18 that the values passed as arguments n, ..., m must be non-NULL pointers.
19 n = 1 stands for the first argument, n = 2 for the second argument etc. */
20#ifndef _GL_ARG_NONNULL
21# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
22# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
23# else
24# define _GL_ARG_NONNULL(params)
25# endif
26#endif
diff --git a/c++defs.h b/c++defs.h
new file mode 100644
index 00000000000..d521417069a
--- /dev/null
+++ b/c++defs.h
@@ -0,0 +1,271 @@
1/* C++ compatible function declaration macros.
2 Copyright (C) 2010-2011 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef _GL_CXXDEFS_H
18#define _GL_CXXDEFS_H
19
20/* The three most frequent use cases of these macros are:
21
22 * For providing a substitute for a function that is missing on some
23 platforms, but is declared and works fine on the platforms on which
24 it exists:
25
26 #if @GNULIB_FOO@
27 # if !@HAVE_FOO@
28 _GL_FUNCDECL_SYS (foo, ...);
29 # endif
30 _GL_CXXALIAS_SYS (foo, ...);
31 _GL_CXXALIASWARN (foo);
32 #elif defined GNULIB_POSIXCHECK
33 ...
34 #endif
35
36 * For providing a replacement for a function that exists on all platforms,
37 but is broken/insufficient and needs to be replaced on some platforms:
38
39 #if @GNULIB_FOO@
40 # if @REPLACE_FOO@
41 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
42 # undef foo
43 # define foo rpl_foo
44 # endif
45 _GL_FUNCDECL_RPL (foo, ...);
46 _GL_CXXALIAS_RPL (foo, ...);
47 # else
48 _GL_CXXALIAS_SYS (foo, ...);
49 # endif
50 _GL_CXXALIASWARN (foo);
51 #elif defined GNULIB_POSIXCHECK
52 ...
53 #endif
54
55 * For providing a replacement for a function that exists on some platforms
56 but is broken/insufficient and needs to be replaced on some of them and
57 is additionally either missing or undeclared on some other platforms:
58
59 #if @GNULIB_FOO@
60 # if @REPLACE_FOO@
61 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
62 # undef foo
63 # define foo rpl_foo
64 # endif
65 _GL_FUNCDECL_RPL (foo, ...);
66 _GL_CXXALIAS_RPL (foo, ...);
67 # else
68 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
69 _GL_FUNCDECL_SYS (foo, ...);
70 # endif
71 _GL_CXXALIAS_SYS (foo, ...);
72 # endif
73 _GL_CXXALIASWARN (foo);
74 #elif defined GNULIB_POSIXCHECK
75 ...
76 #endif
77*/
78
79/* _GL_EXTERN_C declaration;
80 performs the declaration with C linkage. */
81#if defined __cplusplus
82# define _GL_EXTERN_C extern "C"
83#else
84# define _GL_EXTERN_C extern
85#endif
86
87/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
88 declares a replacement function, named rpl_func, with the given prototype,
89 consisting of return type, parameters, and attributes.
90 Example:
91 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
92 _GL_ARG_NONNULL ((1)));
93 */
94#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
95 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
96#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
97 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
98
99/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
100 declares the system function, named func, with the given prototype,
101 consisting of return type, parameters, and attributes.
102 Example:
103 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
104 _GL_ARG_NONNULL ((1)));
105 */
106#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
107 _GL_EXTERN_C rettype func parameters_and_attributes
108
109/* _GL_CXXALIAS_RPL (func, rettype, parameters);
110 declares a C++ alias called GNULIB_NAMESPACE::func
111 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
112 Example:
113 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
114 */
115#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
116 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
117#if defined __cplusplus && defined GNULIB_NAMESPACE
118# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
119 namespace GNULIB_NAMESPACE \
120 { \
121 rettype (*const func) parameters = ::rpl_func; \
122 } \
123 _GL_EXTERN_C int _gl_cxxalias_dummy
124#else
125# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
126 _GL_EXTERN_C int _gl_cxxalias_dummy
127#endif
128
129/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
130 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
131 except that the C function rpl_func may have a slightly different
132 declaration. A cast is used to silence the "invalid conversion" error
133 that would otherwise occur. */
134#if defined __cplusplus && defined GNULIB_NAMESPACE
135# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
136 namespace GNULIB_NAMESPACE \
137 { \
138 rettype (*const func) parameters = \
139 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
140 } \
141 _GL_EXTERN_C int _gl_cxxalias_dummy
142#else
143# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
144 _GL_EXTERN_C int _gl_cxxalias_dummy
145#endif
146
147/* _GL_CXXALIAS_SYS (func, rettype, parameters);
148 declares a C++ alias called GNULIB_NAMESPACE::func
149 that redirects to the system provided function func, if GNULIB_NAMESPACE
150 is defined.
151 Example:
152 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
153 */
154#if defined __cplusplus && defined GNULIB_NAMESPACE
155 /* If we were to write
156 rettype (*const func) parameters = ::func;
157 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
158 better (remove an indirection through a 'static' pointer variable),
159 but then the _GL_CXXALIASWARN macro below would cause a warning not only
160 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
161# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
162 namespace GNULIB_NAMESPACE \
163 { \
164 static rettype (*func) parameters = ::func; \
165 } \
166 _GL_EXTERN_C int _gl_cxxalias_dummy
167#else
168# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
169 _GL_EXTERN_C int _gl_cxxalias_dummy
170#endif
171
172/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
173 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
174 except that the C function func may have a slightly different declaration.
175 A cast is used to silence the "invalid conversion" error that would
176 otherwise occur. */
177#if defined __cplusplus && defined GNULIB_NAMESPACE
178# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
179 namespace GNULIB_NAMESPACE \
180 { \
181 static rettype (*func) parameters = \
182 reinterpret_cast<rettype(*)parameters>(::func); \
183 } \
184 _GL_EXTERN_C int _gl_cxxalias_dummy
185#else
186# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
187 _GL_EXTERN_C int _gl_cxxalias_dummy
188#endif
189
190/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
191 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
192 except that the C function is picked among a set of overloaded functions,
193 namely the one with rettype2 and parameters2. Two consecutive casts
194 are used to silence the "cannot find a match" and "invalid conversion"
195 errors that would otherwise occur. */
196#if defined __cplusplus && defined GNULIB_NAMESPACE
197 /* The outer cast must be a reinterpret_cast.
198 The inner cast: When the function is defined as a set of overloaded
199 functions, it works as a static_cast<>, choosing the designated variant.
200 When the function is defined as a single variant, it works as a
201 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
202# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
203 namespace GNULIB_NAMESPACE \
204 { \
205 static rettype (*func) parameters = \
206 reinterpret_cast<rettype(*)parameters>( \
207 (rettype2(*)parameters2)(::func)); \
208 } \
209 _GL_EXTERN_C int _gl_cxxalias_dummy
210#else
211# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
212 _GL_EXTERN_C int _gl_cxxalias_dummy
213#endif
214
215/* _GL_CXXALIASWARN (func);
216 causes a warning to be emitted when ::func is used but not when
217 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
218 variants. */
219#if defined __cplusplus && defined GNULIB_NAMESPACE
220# define _GL_CXXALIASWARN(func) \
221 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
222# define _GL_CXXALIASWARN_1(func,namespace) \
223 _GL_CXXALIASWARN_2 (func, namespace)
224/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
225 we enable the warning only when not optimizing. */
226# if !__OPTIMIZE__
227# define _GL_CXXALIASWARN_2(func,namespace) \
228 _GL_WARN_ON_USE (func, \
229 "The symbol ::" #func " refers to the system function. " \
230 "Use " #namespace "::" #func " instead.")
231# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
232# define _GL_CXXALIASWARN_2(func,namespace) \
233 extern __typeof__ (func) func
234# else
235# define _GL_CXXALIASWARN_2(func,namespace) \
236 _GL_EXTERN_C int _gl_cxxalias_dummy
237# endif
238#else
239# define _GL_CXXALIASWARN(func) \
240 _GL_EXTERN_C int _gl_cxxalias_dummy
241#endif
242
243/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
244 causes a warning to be emitted when the given overloaded variant of ::func
245 is used but not when GNULIB_NAMESPACE::func is used. */
246#if defined __cplusplus && defined GNULIB_NAMESPACE
247# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
248 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
249 GNULIB_NAMESPACE)
250# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
251 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
252/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
253 we enable the warning only when not optimizing. */
254# if !__OPTIMIZE__
255# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
256 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
257 "The symbol ::" #func " refers to the system function. " \
258 "Use " #namespace "::" #func " instead.")
259# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
260# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
261 extern __typeof__ (func) func
262# else
263# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
264 _GL_EXTERN_C int _gl_cxxalias_dummy
265# endif
266#else
267# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
268 _GL_EXTERN_C int _gl_cxxalias_dummy
269#endif
270
271#endif /* _GL_CXXDEFS_H */
diff --git a/configure b/configure
index 7ddac56a48f..25282b1db14 100755
--- a/configure
+++ b/configure
@@ -667,6 +667,34 @@ LIBS_TERMCAP
667LIBGNU_LTLIBDEPS 667LIBGNU_LTLIBDEPS
668LIBGNU_LIBDEPS 668LIBGNU_LIBDEPS
669gltests_WITNESS 669gltests_WITNESS
670PTHREAD_H_DEFINES_STRUCT_TIMESPEC
671SYS_TIME_H_DEFINES_STRUCT_TIMESPEC
672TIME_H_DEFINES_STRUCT_TIMESPEC
673NEXT_AS_FIRST_DIRECTIVE_TIME_H
674NEXT_TIME_H
675NEXT_AS_FIRST_DIRECTIVE_STDDEF_H
676NEXT_STDDEF_H
677PRAGMA_COLUMNS
678PRAGMA_SYSTEM_HEADER
679INCLUDE_NEXT_AS_FIRST_DIRECTIVE
680INCLUDE_NEXT
681STDDEF_H
682HAVE_WCHAR_T
683REPLACE_NULL
684APPLE_UNIVERSAL_BUILD
685REPLACE_TIMEGM
686REPLACE_NANOSLEEP
687REPLACE_MKTIME
688REPLACE_LOCALTIME_R
689HAVE_TIMEGM
690HAVE_STRPTIME
691HAVE_NANOSLEEP
692HAVE_DECL_LOCALTIME_R
693GNULIB_TIME_R
694GNULIB_TIMEGM
695GNULIB_STRPTIME
696GNULIB_NANOSLEEP
697GNULIB_MKTIME
670GL_COND_LIBTOOL_FALSE 698GL_COND_LIBTOOL_FALSE
671GL_COND_LIBTOOL_TRUE 699GL_COND_LIBTOOL_TRUE
672GETOPTOBJS 700GETOPTOBJS
@@ -1731,52 +1759,6 @@ fi
1731 1759
1732} # ac_fn_c_try_compile 1760} # ac_fn_c_try_compile
1733 1761
1734# ac_fn_c_try_link LINENO
1735# -----------------------
1736# Try to link conftest.$ac_ext, and return whether this succeeded.
1737ac_fn_c_try_link ()
1738{
1739 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1740 rm -f conftest.$ac_objext conftest$ac_exeext
1741 if { { ac_try="$ac_link"
1742case "(($ac_try" in
1743 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1744 *) ac_try_echo=$ac_try;;
1745esac
1746eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1747$as_echo "$ac_try_echo"; } >&5
1748 (eval "$ac_link") 2>conftest.err
1749 ac_status=$?
1750 if test -s conftest.err; then
1751 grep -v '^ *+' conftest.err >conftest.er1
1752 cat conftest.er1 >&5
1753 mv -f conftest.er1 conftest.err
1754 fi
1755 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1756 test $ac_status = 0; } && {
1757 test -z "$ac_c_werror_flag" ||
1758 test ! -s conftest.err
1759 } && test -s conftest$ac_exeext && {
1760 test "$cross_compiling" = yes ||
1761 $as_test_x conftest$ac_exeext
1762 }; then :
1763 ac_retval=0
1764else
1765 $as_echo "$as_me: failed program was:" >&5
1766sed 's/^/| /' conftest.$ac_ext >&5
1767
1768 ac_retval=1
1769fi
1770 # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
1771 # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
1772 # interfere with the next link command; also delete a directory that is
1773 # left behind by Apple's compiler. We do this before executing the actions.
1774 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1775 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1776 as_fn_set_status $ac_retval
1777
1778} # ac_fn_c_try_link
1779
1780# ac_fn_c_try_cpp LINENO 1762# ac_fn_c_try_cpp LINENO
1781# ---------------------- 1763# ----------------------
1782# Try to preprocess conftest.$ac_ext, and return whether this succeeded. 1764# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -1974,6 +1956,52 @@ $as_echo "$ac_res" >&6; }
1974 1956
1975} # ac_fn_c_check_header_compile 1957} # ac_fn_c_check_header_compile
1976 1958
1959# ac_fn_c_try_link LINENO
1960# -----------------------
1961# Try to link conftest.$ac_ext, and return whether this succeeded.
1962ac_fn_c_try_link ()
1963{
1964 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1965 rm -f conftest.$ac_objext conftest$ac_exeext
1966 if { { ac_try="$ac_link"
1967case "(($ac_try" in
1968 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1969 *) ac_try_echo=$ac_try;;
1970esac
1971eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1972$as_echo "$ac_try_echo"; } >&5
1973 (eval "$ac_link") 2>conftest.err
1974 ac_status=$?
1975 if test -s conftest.err; then
1976 grep -v '^ *+' conftest.err >conftest.er1
1977 cat conftest.er1 >&5
1978 mv -f conftest.er1 conftest.err
1979 fi
1980 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1981 test $ac_status = 0; } && {
1982 test -z "$ac_c_werror_flag" ||
1983 test ! -s conftest.err
1984 } && test -s conftest$ac_exeext && {
1985 test "$cross_compiling" = yes ||
1986 $as_test_x conftest$ac_exeext
1987 }; then :
1988 ac_retval=0
1989else
1990 $as_echo "$as_me: failed program was:" >&5
1991sed 's/^/| /' conftest.$ac_ext >&5
1992
1993 ac_retval=1
1994fi
1995 # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
1996 # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
1997 # interfere with the next link command; also delete a directory that is
1998 # left behind by Apple's compiler. We do this before executing the actions.
1999 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
2000 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
2001 as_fn_set_status $ac_retval
2002
2003} # ac_fn_c_try_link
2004
1977# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES 2005# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
1978# --------------------------------------------- 2006# ---------------------------------------------
1979# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR 2007# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
@@ -2513,8 +2541,11 @@ fi
2513as_fn_append ac_header_list " stdlib.h" 2541as_fn_append ac_header_list " stdlib.h"
2514as_fn_append ac_header_list " unistd.h" 2542as_fn_append ac_header_list " unistd.h"
2515as_fn_append ac_header_list " sys/param.h" 2543as_fn_append ac_header_list " sys/param.h"
2516as_fn_append ac_header_list " sys/time.h"
2517as_fn_append ac_func_list " alarm" 2544as_fn_append ac_func_list " alarm"
2545as_fn_append ac_header_list " stddef.h"
2546as_fn_append ac_header_list " time.h"
2547as_fn_append ac_header_list " sys/time.h"
2548as_fn_append ac_func_list " localtime_r"
2518# Check that the precious variables saved in the cache have kept the same 2549# Check that the precious variables saved in the cache have kept the same
2519# value. 2550# value.
2520ac_cache_corrupted=false 2551ac_cache_corrupted=false
@@ -5183,80 +5214,6 @@ else
5183fi 5214fi
5184 5215
5185 5216
5186
5187 # Code from module ftoastr:
5188 # Code from module intprops:
5189
5190
5191# On Suns, sometimes $CPP names a directory.
5192if test -n "$CPP" && test -d "$CPP"; then
5193 CPP=
5194fi
5195
5196## If not using gcc, and on Solaris, and no CPP specified, see if
5197## using a Sun compiler, which needs -Xs to prevent whitespace.
5198if test x"$GCC" != xyes && test x"$emacs_check_sunpro_c" = xyes && \
5199 test x"$CPP" = x; then
5200 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using a Sun C compiler" >&5
5201$as_echo_n "checking whether we are using a Sun C compiler... " >&6; }
5202
5203if ${emacs_cv_sunpro_c+:} false; then :
5204 $as_echo_n "(cached) " >&6
5205else
5206 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5207/* end confdefs.h. */
5208
5209int
5210main ()
5211{
5212#ifndef __SUNPRO_C
5213fail;
5214#endif
5215
5216 ;
5217 return 0;
5218}
5219_ACEOF
5220if ac_fn_c_try_link "$LINENO"; then :
5221 emacs_cv_sunpro_c=yes
5222else
5223 emacs_cv_sunpro_c=no
5224fi
5225rm -f core conftest.err conftest.$ac_objext \
5226 conftest$ac_exeext conftest.$ac_ext
5227fi
5228
5229 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_sunpro_c" >&5
5230$as_echo "$emacs_cv_sunpro_c" >&6; }
5231
5232 if test x"$emacs_cv_sunpro_c" = xyes; then
5233 NON_GNU_CPP="$CC -E -Xs"
5234 fi
5235fi
5236
5237#### Some systems specify a CPP to use unless we are using GCC.
5238#### Now that we know whether we are using GCC, we can decide whether
5239#### to use that one.
5240if test "x$NON_GNU_CPP" != x && test x$GCC != xyes && test "x$CPP" = x
5241then
5242 CPP="$NON_GNU_CPP"
5243fi
5244
5245#### Some systems specify a CC to use unless we are using GCC.
5246#### Now that we know whether we are using GCC, we can decide whether
5247#### to use that one.
5248if test "x$NON_GNU_CC" != x && test x$GCC != xyes &&
5249 test x$cc_specified != xyes
5250then
5251 CC="$NON_GNU_CC"
5252fi
5253
5254if test x$GCC = xyes; then
5255 test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
5256else
5257 test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
5258fi
5259
5260ac_ext=c 5217ac_ext=c
5261ac_cpp='$CPP $CPPFLAGS' 5218ac_cpp='$CPP $CPPFLAGS'
5262ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 5219ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -5655,6 +5612,8 @@ done
5655 5612
5656 5613
5657 5614
5615
5616
5658 ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" 5617 ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
5659if test "x$ac_cv_header_minix_config_h" = xyes; then : 5618if test "x$ac_cv_header_minix_config_h" = xyes; then :
5660 MINIX=yes 5619 MINIX=yes
@@ -5675,6 +5634,14 @@ $as_echo "#define _MINIX 1" >>confdefs.h
5675 5634
5676 fi 5635 fi
5677 5636
5637 case "$host_os" in
5638 hpux*)
5639
5640$as_echo "#define _XOPEN_SOURCE 500" >>confdefs.h
5641
5642 ;;
5643 esac
5644
5678 5645
5679 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 5646 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
5680$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } 5647$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
@@ -5684,8 +5651,8 @@ else
5684 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 5651 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5685/* end confdefs.h. */ 5652/* end confdefs.h. */
5686 5653
5687# define __EXTENSIONS__ 1 5654# define __EXTENSIONS__ 1
5688 $ac_includes_default 5655 $ac_includes_default
5689int 5656int
5690main () 5657main ()
5691{ 5658{
@@ -5716,6 +5683,98 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
5716 5683
5717 5684
5718 5685
5686
5687
5688
5689
5690
5691
5692
5693 # Code from module arg-nonnull:
5694 # Code from module c++defs:
5695 # Code from module extensions:
5696
5697 # Code from module ftoastr:
5698 # Code from module include_next:
5699 # Code from module intprops:
5700 # Code from module mktime:
5701 # Code from module multiarch:
5702 # Code from module stddef:
5703 # Code from module time:
5704 # Code from module time_r:
5705 # Code from module warn-on-use:
5706
5707
5708# On Suns, sometimes $CPP names a directory.
5709if test -n "$CPP" && test -d "$CPP"; then
5710 CPP=
5711fi
5712
5713## If not using gcc, and on Solaris, and no CPP specified, see if
5714## using a Sun compiler, which needs -Xs to prevent whitespace.
5715if test x"$GCC" != xyes && test x"$emacs_check_sunpro_c" = xyes && \
5716 test x"$CPP" = x; then
5717 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using a Sun C compiler" >&5
5718$as_echo_n "checking whether we are using a Sun C compiler... " >&6; }
5719 if ${emacs_cv_sunpro_c+:} false; then :
5720 $as_echo_n "(cached) " >&6
5721else
5722 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5723/* end confdefs.h. */
5724
5725int
5726main ()
5727{
5728#ifndef __SUNPRO_C
5729fail;
5730#endif
5731
5732 ;
5733 return 0;
5734}
5735_ACEOF
5736if ac_fn_c_try_link "$LINENO"; then :
5737 emacs_cv_sunpro_c=yes
5738else
5739 emacs_cv_sunpro_c=no
5740fi
5741rm -f core conftest.err conftest.$ac_objext \
5742 conftest$ac_exeext conftest.$ac_ext
5743fi
5744
5745 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_sunpro_c" >&5
5746$as_echo "$emacs_cv_sunpro_c" >&6; }
5747
5748 if test x"$emacs_cv_sunpro_c" = xyes; then
5749 NON_GNU_CPP="$CC -E -Xs"
5750 fi
5751fi
5752
5753#### Some systems specify a CPP to use unless we are using GCC.
5754#### Now that we know whether we are using GCC, we can decide whether
5755#### to use that one.
5756if test "x$NON_GNU_CPP" != x && test x$GCC != xyes && test "x$CPP" = x
5757then
5758 CPP="$NON_GNU_CPP"
5759fi
5760
5761#### Some systems specify a CC to use unless we are using GCC.
5762#### Now that we know whether we are using GCC, we can decide whether
5763#### to use that one.
5764if test "x$NON_GNU_CC" != x && test x$GCC != xyes &&
5765 test x$cc_specified != xyes
5766then
5767 CC="$NON_GNU_CC"
5768fi
5769
5770if test x$GCC = xyes; then
5771 test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
5772else
5773 test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
5774fi
5775
5776
5777
5719### Use -Wno-pointer-sign if the compiler supports it 5778### Use -Wno-pointer-sign if the compiler supports it
5720{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc understands -Wno-pointer-sign" >&5 5779{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc understands -Wno-pointer-sign" >&5
5721$as_echo_n "checking whether gcc understands -Wno-pointer-sign... " >&6; } 5780$as_echo_n "checking whether gcc understands -Wno-pointer-sign... " >&6; }
@@ -12696,7 +12755,7 @@ esac
12696for ac_func in gethostname getdomainname dup2 \ 12755for ac_func in gethostname getdomainname dup2 \
12697rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \ 12756rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \
12698random lrand48 logb frexp fmod rint cbrt ftime setsid \ 12757random lrand48 logb frexp fmod rint cbrt ftime setsid \
12699strerror fpathconf select mktime euidaccess getpagesize tzset setlocale \ 12758strerror fpathconf select euidaccess getpagesize tzset setlocale \
12700utimes getrlimit setrlimit setpgid getcwd getwd shutdown getaddrinfo \ 12759utimes getrlimit setrlimit setpgid getcwd getwd shutdown getaddrinfo \
12701__fpending mblen mbrlen mbsinit strsignal setitimer ualarm strchr strrchr \ 12760__fpending mblen mbrlen mbsinit strsignal setitimer ualarm strchr strrchr \
12702sendto recvfrom getsockopt setsockopt getsockname getpeername \ 12761sendto recvfrom getsockopt setsockopt getsockname getpeername \
@@ -12760,256 +12819,6 @@ fi
12760done 12819done
12761 12820
12762 12821
12763
12764
12765
12766
12767
12768 for ac_func in $ac_func_list
12769do :
12770 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
12771ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
12772if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
12773 cat >>confdefs.h <<_ACEOF
12774#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
12775_ACEOF
12776
12777fi
12778done
12779
12780
12781
12782
12783
12784{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5
12785$as_echo_n "checking for working mktime... " >&6; }
12786if ${ac_cv_func_working_mktime+:} false; then :
12787 $as_echo_n "(cached) " >&6
12788else
12789 if test "$cross_compiling" = yes; then :
12790 ac_cv_func_working_mktime=no
12791else
12792 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12793/* end confdefs.h. */
12794/* Test program from Paul Eggert and Tony Leneis. */
12795#ifdef TIME_WITH_SYS_TIME
12796# include <sys/time.h>
12797# include <time.h>
12798#else
12799# ifdef HAVE_SYS_TIME_H
12800# include <sys/time.h>
12801# else
12802# include <time.h>
12803# endif
12804#endif
12805
12806#include <limits.h>
12807#include <stdlib.h>
12808
12809#ifdef HAVE_UNISTD_H
12810# include <unistd.h>
12811#endif
12812
12813#ifndef HAVE_ALARM
12814# define alarm(X) /* empty */
12815#endif
12816
12817/* Work around redefinition to rpl_putenv by other config tests. */
12818#undef putenv
12819
12820static time_t time_t_max;
12821static time_t time_t_min;
12822
12823/* Values we'll use to set the TZ environment variable. */
12824static const char *tz_strings[] = {
12825 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
12826 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
12827};
12828#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
12829
12830/* Return 0 if mktime fails to convert a date in the spring-forward gap.
12831 Based on a problem report from Andreas Jaeger. */
12832static int
12833spring_forward_gap ()
12834{
12835 /* glibc (up to about 1998-10-07) failed this test. */
12836 struct tm tm;
12837
12838 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
12839 instead of "TZ=America/Vancouver" in order to detect the bug even
12840 on systems that don't support the Olson extension, or don't have the
12841 full zoneinfo tables installed. */
12842 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
12843
12844 tm.tm_year = 98;
12845 tm.tm_mon = 3;
12846 tm.tm_mday = 5;
12847 tm.tm_hour = 2;
12848 tm.tm_min = 0;
12849 tm.tm_sec = 0;
12850 tm.tm_isdst = -1;
12851 return mktime (&tm) != (time_t) -1;
12852}
12853
12854static int
12855mktime_test1 (time_t now)
12856{
12857 struct tm *lt;
12858 return ! (lt = localtime (&now)) || mktime (lt) == now;
12859}
12860
12861static int
12862mktime_test (time_t now)
12863{
12864 return (mktime_test1 (now)
12865 && mktime_test1 ((time_t) (time_t_max - now))
12866 && mktime_test1 ((time_t) (time_t_min + now)));
12867}
12868
12869static int
12870irix_6_4_bug ()
12871{
12872 /* Based on code from Ariel Faigon. */
12873 struct tm tm;
12874 tm.tm_year = 96;
12875 tm.tm_mon = 3;
12876 tm.tm_mday = 0;
12877 tm.tm_hour = 0;
12878 tm.tm_min = 0;
12879 tm.tm_sec = 0;
12880 tm.tm_isdst = -1;
12881 mktime (&tm);
12882 return tm.tm_mon == 2 && tm.tm_mday == 31;
12883}
12884
12885static int
12886bigtime_test (int j)
12887{
12888 struct tm tm;
12889 time_t now;
12890 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
12891 now = mktime (&tm);
12892 if (now != (time_t) -1)
12893 {
12894 struct tm *lt = localtime (&now);
12895 if (! (lt
12896 && lt->tm_year == tm.tm_year
12897 && lt->tm_mon == tm.tm_mon
12898 && lt->tm_mday == tm.tm_mday
12899 && lt->tm_hour == tm.tm_hour
12900 && lt->tm_min == tm.tm_min
12901 && lt->tm_sec == tm.tm_sec
12902 && lt->tm_yday == tm.tm_yday
12903 && lt->tm_wday == tm.tm_wday
12904 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
12905 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
12906 return 0;
12907 }
12908 return 1;
12909}
12910
12911static int
12912year_2050_test ()
12913{
12914 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
12915 ignoring leap seconds. */
12916 unsigned long int answer = 2527315200UL;
12917
12918 struct tm tm;
12919 time_t t;
12920 tm.tm_year = 2050 - 1900;
12921 tm.tm_mon = 2 - 1;
12922 tm.tm_mday = 1;
12923 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
12924 tm.tm_isdst = -1;
12925
12926 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
12927 instead of "TZ=America/Vancouver" in order to detect the bug even
12928 on systems that don't support the Olson extension, or don't have the
12929 full zoneinfo tables installed. */
12930 putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
12931
12932 t = mktime (&tm);
12933
12934 /* Check that the result is either a failure, or close enough
12935 to the correct answer that we can assume the discrepancy is
12936 due to leap seconds. */
12937 return (t == (time_t) -1
12938 || (0 < t && answer - 120 <= t && t <= answer + 120));
12939}
12940
12941int
12942main ()
12943{
12944 time_t t, delta;
12945 int i, j;
12946
12947 /* This test makes some buggy mktime implementations loop.
12948 Give up after 60 seconds; a mktime slower than that
12949 isn't worth using anyway. */
12950 alarm (60);
12951
12952 for (;;)
12953 {
12954 t = (time_t_max << 1) + 1;
12955 if (t <= time_t_max)
12956 break;
12957 time_t_max = t;
12958 }
12959 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
12960
12961 delta = time_t_max / 997; /* a suitable prime number */
12962 for (i = 0; i < N_STRINGS; i++)
12963 {
12964 if (tz_strings[i])
12965 putenv ((char*) tz_strings[i]);
12966
12967 for (t = 0; t <= time_t_max - delta; t += delta)
12968 if (! mktime_test (t))
12969 return 1;
12970 if (! (mktime_test ((time_t) 1)
12971 && mktime_test ((time_t) (60 * 60))
12972 && mktime_test ((time_t) (60 * 60 * 24))))
12973 return 1;
12974
12975 for (j = 1; ; j <<= 1)
12976 if (! bigtime_test (j))
12977 return 1;
12978 else if (INT_MAX / 2 < j)
12979 break;
12980 if (! bigtime_test (INT_MAX))
12981 return 1;
12982 }
12983 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
12984}
12985_ACEOF
12986if ac_fn_c_try_run "$LINENO"; then :
12987 ac_cv_func_working_mktime=yes
12988else
12989 ac_cv_func_working_mktime=no
12990fi
12991rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
12992 conftest.$ac_objext conftest.beam conftest.$ac_ext
12993fi
12994
12995fi
12996{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5
12997$as_echo "$ac_cv_func_working_mktime" >&6; }
12998if test $ac_cv_func_working_mktime = no; then
12999 case " $LIBOBJS " in
13000 *" mktime.$ac_objext "* ) ;;
13001 *) LIBOBJS="$LIBOBJS mktime.$ac_objext"
13002 ;;
13003esac
13004
13005fi
13006
13007if test "$ac_cv_func_working_mktime" = no; then
13008
13009$as_echo "#define BROKEN_MKTIME 1" >>confdefs.h
13010
13011fi
13012
13013ac_have_func=no # yes means we've found a way to get the load average. 12822ac_have_func=no # yes means we've found a way to get the load average.
13014 12823
13015# Make sure getloadavg.c is where it belongs, at configure-time. 12824# Make sure getloadavg.c is where it belongs, at configure-time.
@@ -13790,6 +13599,499 @@ $as_echo "#define HAVE_C99_STRTOLD 1" >>confdefs.h
13790 fi 13599 fi
13791 13600
13792 13601
13602 GNULIB_MKTIME=0;
13603 GNULIB_NANOSLEEP=0;
13604 GNULIB_STRPTIME=0;
13605 GNULIB_TIMEGM=0;
13606 GNULIB_TIME_R=0;
13607 HAVE_DECL_LOCALTIME_R=1;
13608 HAVE_NANOSLEEP=1;
13609 HAVE_STRPTIME=1;
13610 HAVE_TIMEGM=1;
13611 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;
13612 REPLACE_MKTIME=GNULIB_PORTCHECK;
13613 REPLACE_NANOSLEEP=GNULIB_PORTCHECK;
13614 REPLACE_TIMEGM=GNULIB_PORTCHECK;
13615
13616
13617
13618
13619 for ac_func in $ac_func_list
13620do :
13621 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
13622ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
13623if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
13624 cat >>confdefs.h <<_ACEOF
13625#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
13626_ACEOF
13627
13628fi
13629done
13630
13631
13632
13633
13634 gl_cv_c_multiarch=no
13635 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13636/* end confdefs.h. */
13637#ifndef __APPLE_CC__
13638 not a universal capable compiler
13639 #endif
13640 typedef int dummy;
13641
13642_ACEOF
13643if ac_fn_c_try_compile "$LINENO"; then :
13644
13645 arch=
13646 prev=
13647 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
13648 if test -n "$prev"; then
13649 case $word in
13650 i?86 | x86_64 | ppc | ppc64)
13651 if test -z "$arch" || test "$arch" = "$word"; then
13652 arch="$word"
13653 else
13654 gl_cv_c_multiarch=yes
13655 fi
13656 ;;
13657 esac
13658 prev=
13659 else
13660 if test "x$word" = "x-arch"; then
13661 prev=arch
13662 fi
13663 fi
13664 done
13665
13666fi
13667rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13668 if test $gl_cv_c_multiarch = yes; then
13669
13670$as_echo "#define AA_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
13671
13672 APPLE_UNIVERSAL_BUILD=1
13673 else
13674 APPLE_UNIVERSAL_BUILD=0
13675 fi
13676
13677
13678{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
13679$as_echo_n "checking for inline... " >&6; }
13680if ${ac_cv_c_inline+:} false; then :
13681 $as_echo_n "(cached) " >&6
13682else
13683 ac_cv_c_inline=no
13684for ac_kw in inline __inline__ __inline; do
13685 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13686/* end confdefs.h. */
13687#ifndef __cplusplus
13688typedef int foo_t;
13689static $ac_kw foo_t static_foo () {return 0; }
13690$ac_kw foo_t foo () {return 0; }
13691#endif
13692
13693_ACEOF
13694if ac_fn_c_try_compile "$LINENO"; then :
13695 ac_cv_c_inline=$ac_kw
13696fi
13697rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13698 test "$ac_cv_c_inline" != no && break
13699done
13700
13701fi
13702{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
13703$as_echo "$ac_cv_c_inline" >&6; }
13704
13705case $ac_cv_c_inline in
13706 inline | yes) ;;
13707 *)
13708 case $ac_cv_c_inline in
13709 no) ac_val=;;
13710 *) ac_val=$ac_cv_c_inline;;
13711 esac
13712 cat >>confdefs.h <<_ACEOF
13713#ifndef __cplusplus
13714#define inline $ac_val
13715#endif
13716_ACEOF
13717 ;;
13718esac
13719
13720
13721 REPLACE_NULL=0;
13722 HAVE_WCHAR_T=1;
13723 STDDEF_H='';
13724
13725
13726 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t" >&5
13727$as_echo_n "checking for wchar_t... " >&6; }
13728if ${gt_cv_c_wchar_t+:} false; then :
13729 $as_echo_n "(cached) " >&6
13730else
13731 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13732/* end confdefs.h. */
13733#include <stddef.h>
13734 wchar_t foo = (wchar_t)'\0';
13735int
13736main ()
13737{
13738
13739 ;
13740 return 0;
13741}
13742_ACEOF
13743if ac_fn_c_try_compile "$LINENO"; then :
13744 gt_cv_c_wchar_t=yes
13745else
13746 gt_cv_c_wchar_t=no
13747fi
13748rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13749fi
13750{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wchar_t" >&5
13751$as_echo "$gt_cv_c_wchar_t" >&6; }
13752 if test $gt_cv_c_wchar_t = yes; then
13753
13754$as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h
13755
13756 fi
13757
13758
13759
13760 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5
13761$as_echo_n "checking whether the preprocessor supports include_next... " >&6; }
13762if ${gl_cv_have_include_next+:} false; then :
13763 $as_echo_n "(cached) " >&6
13764else
13765 rm -rf conftestd1a conftestd1b conftestd2
13766 mkdir conftestd1a conftestd1b conftestd2
13767 cat <<EOF > conftestd1a/conftest.h
13768#define DEFINED_IN_CONFTESTD1
13769#include_next <conftest.h>
13770#ifdef DEFINED_IN_CONFTESTD2
13771int foo;
13772#else
13773#error "include_next doesn't work"
13774#endif
13775EOF
13776 cat <<EOF > conftestd1b/conftest.h
13777#define DEFINED_IN_CONFTESTD1
13778#include <stdio.h>
13779#include_next <conftest.h>
13780#ifdef DEFINED_IN_CONFTESTD2
13781int foo;
13782#else
13783#error "include_next doesn't work"
13784#endif
13785EOF
13786 cat <<EOF > conftestd2/conftest.h
13787#ifndef DEFINED_IN_CONFTESTD1
13788#error "include_next test doesn't work"
13789#endif
13790#define DEFINED_IN_CONFTESTD2
13791EOF
13792 gl_save_CPPFLAGS="$CPPFLAGS"
13793 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
13794 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13795/* end confdefs.h. */
13796#include <conftest.h>
13797_ACEOF
13798if ac_fn_c_try_compile "$LINENO"; then :
13799 gl_cv_have_include_next=yes
13800else
13801 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
13802 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13803/* end confdefs.h. */
13804#include <conftest.h>
13805_ACEOF
13806if ac_fn_c_try_compile "$LINENO"; then :
13807 gl_cv_have_include_next=buggy
13808else
13809 gl_cv_have_include_next=no
13810fi
13811rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13812
13813fi
13814rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13815 CPPFLAGS="$gl_save_CPPFLAGS"
13816 rm -rf conftestd1a conftestd1b conftestd2
13817
13818fi
13819{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5
13820$as_echo "$gl_cv_have_include_next" >&6; }
13821 PRAGMA_SYSTEM_HEADER=
13822 if test $gl_cv_have_include_next = yes; then
13823 INCLUDE_NEXT=include_next
13824 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
13825 if test -n "$GCC"; then
13826 PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
13827 fi
13828 else
13829 if test $gl_cv_have_include_next = buggy; then
13830 INCLUDE_NEXT=include
13831 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
13832 else
13833 INCLUDE_NEXT=include
13834 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
13835 fi
13836 fi
13837
13838
13839
13840 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5
13841$as_echo_n "checking whether system header files limit the line length... " >&6; }
13842if ${gl_cv_pragma_columns+:} false; then :
13843 $as_echo_n "(cached) " >&6
13844else
13845 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13846/* end confdefs.h. */
13847
13848#ifdef __TANDEM
13849choke me
13850#endif
13851
13852_ACEOF
13853if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
13854 $EGREP "choke me" >/dev/null 2>&1; then :
13855 gl_cv_pragma_columns=yes
13856else
13857 gl_cv_pragma_columns=no
13858fi
13859rm -f conftest*
13860
13861
13862fi
13863{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5
13864$as_echo "$gl_cv_pragma_columns" >&6; }
13865 if test $gl_cv_pragma_columns = yes; then
13866 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
13867 else
13868 PRAGMA_COLUMNS=
13869 fi
13870
13871
13872
13873
13874{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
13875$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
13876if ${ac_cv_c_restrict+:} false; then :
13877 $as_echo_n "(cached) " >&6
13878else
13879 ac_cv_c_restrict=no
13880 # The order here caters to the fact that C++ does not require restrict.
13881 for ac_kw in __restrict __restrict__ _Restrict restrict; do
13882 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13883/* end confdefs.h. */
13884typedef int * int_ptr;
13885 int foo (int_ptr $ac_kw ip) {
13886 return ip[0];
13887 }
13888int
13889main ()
13890{
13891int s[1];
13892 int * $ac_kw t = s;
13893 t[0] = 0;
13894 return foo(t)
13895 ;
13896 return 0;
13897}
13898_ACEOF
13899if ac_fn_c_try_compile "$LINENO"; then :
13900 ac_cv_c_restrict=$ac_kw
13901fi
13902rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13903 test "$ac_cv_c_restrict" != no && break
13904 done
13905
13906fi
13907{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5
13908$as_echo "$ac_cv_c_restrict" >&6; }
13909
13910 case $ac_cv_c_restrict in
13911 restrict) ;;
13912 no) $as_echo "#define restrict /**/" >>confdefs.h
13913 ;;
13914 *) cat >>confdefs.h <<_ACEOF
13915#define restrict $ac_cv_c_restrict
13916_ACEOF
13917 ;;
13918 esac
13919
13920
13921
13922
13923
13924
13925
13926 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <time.h>" >&5
13927$as_echo_n "checking for struct timespec in <time.h>... " >&6; }
13928if ${gl_cv_sys_struct_timespec_in_time_h+:} false; then :
13929 $as_echo_n "(cached) " >&6
13930else
13931 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13932/* end confdefs.h. */
13933#include <time.h>
13934
13935int
13936main ()
13937{
13938static struct timespec x; x.tv_sec = x.tv_nsec;
13939 ;
13940 return 0;
13941}
13942_ACEOF
13943if ac_fn_c_try_compile "$LINENO"; then :
13944 gl_cv_sys_struct_timespec_in_time_h=yes
13945else
13946 gl_cv_sys_struct_timespec_in_time_h=no
13947fi
13948rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13949fi
13950{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_time_h" >&5
13951$as_echo "$gl_cv_sys_struct_timespec_in_time_h" >&6; }
13952
13953 TIME_H_DEFINES_STRUCT_TIMESPEC=0
13954 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
13955 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
13956 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
13957 TIME_H_DEFINES_STRUCT_TIMESPEC=1
13958 else
13959 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <sys/time.h>" >&5
13960$as_echo_n "checking for struct timespec in <sys/time.h>... " >&6; }
13961if ${gl_cv_sys_struct_timespec_in_sys_time_h+:} false; then :
13962 $as_echo_n "(cached) " >&6
13963else
13964 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13965/* end confdefs.h. */
13966#include <sys/time.h>
13967
13968int
13969main ()
13970{
13971static struct timespec x; x.tv_sec = x.tv_nsec;
13972 ;
13973 return 0;
13974}
13975_ACEOF
13976if ac_fn_c_try_compile "$LINENO"; then :
13977 gl_cv_sys_struct_timespec_in_sys_time_h=yes
13978else
13979 gl_cv_sys_struct_timespec_in_sys_time_h=no
13980fi
13981rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13982fi
13983{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_sys_time_h" >&5
13984$as_echo "$gl_cv_sys_struct_timespec_in_sys_time_h" >&6; }
13985 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
13986 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
13987 else
13988 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <pthread.h>" >&5
13989$as_echo_n "checking for struct timespec in <pthread.h>... " >&6; }
13990if ${gl_cv_sys_struct_timespec_in_pthread_h+:} false; then :
13991 $as_echo_n "(cached) " >&6
13992else
13993 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13994/* end confdefs.h. */
13995#include <pthread.h>
13996
13997int
13998main ()
13999{
14000static struct timespec x; x.tv_sec = x.tv_nsec;
14001 ;
14002 return 0;
14003}
14004_ACEOF
14005if ac_fn_c_try_compile "$LINENO"; then :
14006 gl_cv_sys_struct_timespec_in_pthread_h=yes
14007else
14008 gl_cv_sys_struct_timespec_in_pthread_h=no
14009fi
14010rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14011fi
14012{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_pthread_h" >&5
14013$as_echo "$gl_cv_sys_struct_timespec_in_pthread_h" >&6; }
14014 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
14015 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
14016 fi
14017 fi
14018 fi
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032 if test $gl_cv_have_include_next = yes; then
14033 gl_cv_next_time_h='<'time.h'>'
14034 else
14035 { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <time.h>" >&5
14036$as_echo_n "checking absolute name of <time.h>... " >&6; }
14037if ${gl_cv_next_time_h+:} false; then :
14038 $as_echo_n "(cached) " >&6
14039else
14040
14041 if test $ac_cv_header_time_h = yes; then
14042 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14043/* end confdefs.h. */
14044#include <time.h>
14045
14046_ACEOF
14047 case "$host_os" in
14048 aix*) gl_absname_cpp="$ac_cpp -C" ;;
14049 *) gl_absname_cpp="$ac_cpp" ;;
14050 esac
14051 gl_cv_next_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
14052 sed -n '\#/time.h#{
14053 s#.*"\(.*/time.h\)".*#\1#
14054 s#^/[^/]#//&#
14055 p
14056 q
14057 }'`'"'
14058 else
14059 gl_cv_next_time_h='<'time.h'>'
14060 fi
14061
14062fi
14063{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_time_h" >&5
14064$as_echo "$gl_cv_next_time_h" >&6; }
14065 fi
14066 NEXT_TIME_H=$gl_cv_next_time_h
14067
14068 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
14069 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
14070 gl_next_as_first_directive='<'time.h'>'
14071 else
14072 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
14073 gl_next_as_first_directive=$gl_cv_next_time_h
14074 fi
14075 NEXT_AS_FIRST_DIRECTIVE_TIME_H=$gl_next_as_first_directive
14076
14077
14078
14079
14080
14081ac_fn_c_check_decl "$LINENO" "localtime_r" "ac_cv_have_decl_localtime_r" "$ac_includes_default"
14082if test "x$ac_cv_have_decl_localtime_r" = xyes; then :
14083 ac_have_decl=1
14084else
14085 ac_have_decl=0
14086fi
14087
14088cat >>confdefs.h <<_ACEOF
14089#define HAVE_DECL_LOCALTIME_R $ac_have_decl
14090_ACEOF
14091
14092
14093
14094
13793 if false; then 14095 if false; then
13794 GL_COND_LIBTOOL_TRUE= 14096 GL_COND_LIBTOOL_TRUE=
13795 GL_COND_LIBTOOL_FALSE='#' 14097 GL_COND_LIBTOOL_FALSE='#'
@@ -13812,9 +14114,455 @@ fi
13812 14114
13813 14115
13814 gl_source_base='lib' 14116 gl_source_base='lib'
14117 # Code from module arg-nonnull:
14118 # Code from module c++defs:
14119 # Code from module extensions:
13815 # Code from module ftoastr: 14120 # Code from module ftoastr:
13816 14121
14122 # Code from module include_next:
13817 # Code from module intprops: 14123 # Code from module intprops:
14124 # Code from module mktime:
14125
14126
14127
14128
14129
14130if test $APPLE_UNIVERSAL_BUILD = 1; then
14131 # A universal build on Apple MacOS X platforms.
14132 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
14133 # But we need a configuration result that is valid in both modes.
14134 ac_cv_func_working_mktime=no
14135fi
14136{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5
14137$as_echo_n "checking for working mktime... " >&6; }
14138if ${ac_cv_func_working_mktime+:} false; then :
14139 $as_echo_n "(cached) " >&6
14140else
14141 if test "$cross_compiling" = yes; then :
14142 ac_cv_func_working_mktime=no
14143else
14144 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14145/* end confdefs.h. */
14146/* Test program from Paul Eggert and Tony Leneis. */
14147#include <limits.h>
14148#include <stdlib.h>
14149#include <time.h>
14150
14151#ifdef HAVE_UNISTD_H
14152# include <unistd.h>
14153#endif
14154
14155#ifndef HAVE_ALARM
14156# define alarm(X) /* empty */
14157#endif
14158
14159/* Work around redefinition to rpl_putenv by other config tests. */
14160#undef putenv
14161
14162static time_t time_t_max;
14163static time_t time_t_min;
14164
14165/* Values we'll use to set the TZ environment variable. */
14166static char *tz_strings[] = {
14167 (char *) 0, "TZ=GMT0", "TZ=JST-9",
14168 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
14169};
14170#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
14171
14172/* Return 0 if mktime fails to convert a date in the spring-forward gap.
14173 Based on a problem report from Andreas Jaeger. */
14174static int
14175spring_forward_gap ()
14176{
14177 /* glibc (up to about 1998-10-07) failed this test. */
14178 struct tm tm;
14179
14180 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
14181 instead of "TZ=America/Vancouver" in order to detect the bug even
14182 on systems that don't support the Olson extension, or don't have the
14183 full zoneinfo tables installed. */
14184 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
14185
14186 tm.tm_year = 98;
14187 tm.tm_mon = 3;
14188 tm.tm_mday = 5;
14189 tm.tm_hour = 2;
14190 tm.tm_min = 0;
14191 tm.tm_sec = 0;
14192 tm.tm_isdst = -1;
14193 return mktime (&tm) != (time_t) -1;
14194}
14195
14196static int
14197mktime_test1 (time_t now)
14198{
14199 struct tm *lt;
14200 return ! (lt = localtime (&now)) || mktime (lt) == now;
14201}
14202
14203static int
14204mktime_test (time_t now)
14205{
14206 return (mktime_test1 (now)
14207 && mktime_test1 ((time_t) (time_t_max - now))
14208 && mktime_test1 ((time_t) (time_t_min + now)));
14209}
14210
14211static int
14212irix_6_4_bug ()
14213{
14214 /* Based on code from Ariel Faigon. */
14215 struct tm tm;
14216 tm.tm_year = 96;
14217 tm.tm_mon = 3;
14218 tm.tm_mday = 0;
14219 tm.tm_hour = 0;
14220 tm.tm_min = 0;
14221 tm.tm_sec = 0;
14222 tm.tm_isdst = -1;
14223 mktime (&tm);
14224 return tm.tm_mon == 2 && tm.tm_mday == 31;
14225}
14226
14227static int
14228bigtime_test (int j)
14229{
14230 struct tm tm;
14231 time_t now;
14232 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
14233 now = mktime (&tm);
14234 if (now != (time_t) -1)
14235 {
14236 struct tm *lt = localtime (&now);
14237 if (! (lt
14238 && lt->tm_year == tm.tm_year
14239 && lt->tm_mon == tm.tm_mon
14240 && lt->tm_mday == tm.tm_mday
14241 && lt->tm_hour == tm.tm_hour
14242 && lt->tm_min == tm.tm_min
14243 && lt->tm_sec == tm.tm_sec
14244 && lt->tm_yday == tm.tm_yday
14245 && lt->tm_wday == tm.tm_wday
14246 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
14247 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
14248 return 0;
14249 }
14250 return 1;
14251}
14252
14253static int
14254year_2050_test ()
14255{
14256 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
14257 ignoring leap seconds. */
14258 unsigned long int answer = 2527315200UL;
14259
14260 struct tm tm;
14261 time_t t;
14262 tm.tm_year = 2050 - 1900;
14263 tm.tm_mon = 2 - 1;
14264 tm.tm_mday = 1;
14265 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
14266 tm.tm_isdst = -1;
14267
14268 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
14269 instead of "TZ=America/Vancouver" in order to detect the bug even
14270 on systems that don't support the Olson extension, or don't have the
14271 full zoneinfo tables installed. */
14272 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
14273
14274 t = mktime (&tm);
14275
14276 /* Check that the result is either a failure, or close enough
14277 to the correct answer that we can assume the discrepancy is
14278 due to leap seconds. */
14279 return (t == (time_t) -1
14280 || (0 < t && answer - 120 <= t && t <= answer + 120));
14281}
14282
14283int
14284main ()
14285{
14286 int result = 0;
14287 time_t t, delta;
14288 int i, j;
14289
14290 /* This test makes some buggy mktime implementations loop.
14291 Give up after 60 seconds; a mktime slower than that
14292 isn't worth using anyway. */
14293 alarm (60);
14294
14295 for (;;)
14296 {
14297 t = (time_t_max << 1) + 1;
14298 if (t <= time_t_max)
14299 break;
14300 time_t_max = t;
14301 }
14302 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
14303
14304 delta = time_t_max / 997; /* a suitable prime number */
14305 for (i = 0; i < N_STRINGS; i++)
14306 {
14307 if (tz_strings[i])
14308 putenv (tz_strings[i]);
14309
14310 for (t = 0; t <= time_t_max - delta; t += delta)
14311 if (! mktime_test (t))
14312 result |= 1;
14313 if (! (mktime_test ((time_t) 1)
14314 && mktime_test ((time_t) (60 * 60))
14315 && mktime_test ((time_t) (60 * 60 * 24))))
14316 result |= 2;
14317
14318 for (j = 1; ; j <<= 1)
14319 if (! bigtime_test (j))
14320 result |= 4;
14321 else if (INT_MAX / 2 < j)
14322 break;
14323 if (! bigtime_test (INT_MAX))
14324 result |= 8;
14325 }
14326 if (! irix_6_4_bug ())
14327 result |= 16;
14328 if (! spring_forward_gap ())
14329 result |= 32;
14330 if (! year_2050_test ())
14331 result |= 64;
14332 return result;
14333}
14334_ACEOF
14335if ac_fn_c_try_run "$LINENO"; then :
14336 ac_cv_func_working_mktime=yes
14337else
14338 ac_cv_func_working_mktime=no
14339fi
14340rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
14341 conftest.$ac_objext conftest.beam conftest.$ac_ext
14342fi
14343
14344fi
14345{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5
14346$as_echo "$ac_cv_func_working_mktime" >&6; }
14347if test $ac_cv_func_working_mktime = no; then
14348
14349
14350
14351
14352
14353
14354
14355
14356 gl_LIBOBJS="$gl_LIBOBJS mktime.$ac_objext"
14357
14358fi
14359
14360 if test $ac_cv_func_working_mktime = no; then
14361 REPLACE_MKTIME=1
14362
14363
14364
14365 else
14366 REPLACE_MKTIME=0
14367 fi
14368
14369
14370
14371
14372 GNULIB_MKTIME=1
14373
14374
14375
14376$as_echo "#define GNULIB_TEST_MKTIME 1" >>confdefs.h
14377
14378
14379
14380 # Code from module multiarch:
14381
14382 # Code from module stddef:
14383
14384
14385
14386 if test $gt_cv_c_wchar_t = no; then
14387 HAVE_WCHAR_T=0
14388 STDDEF_H=stddef.h
14389 fi
14390 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NULL can be used in arbitrary expressions" >&5
14391$as_echo_n "checking whether NULL can be used in arbitrary expressions... " >&6; }
14392if ${gl_cv_decl_null_works+:} false; then :
14393 $as_echo_n "(cached) " >&6
14394else
14395 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14396/* end confdefs.h. */
14397#include <stddef.h>
14398 int test[2 * (sizeof NULL == sizeof (void *)) -1];
14399
14400int
14401main ()
14402{
14403
14404 ;
14405 return 0;
14406}
14407_ACEOF
14408if ac_fn_c_try_compile "$LINENO"; then :
14409 gl_cv_decl_null_works=yes
14410else
14411 gl_cv_decl_null_works=no
14412fi
14413rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14414fi
14415{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_null_works" >&5
14416$as_echo "$gl_cv_decl_null_works" >&6; }
14417 if test $gl_cv_decl_null_works = no; then
14418 REPLACE_NULL=1
14419 STDDEF_H=stddef.h
14420 fi
14421 if test -n "$STDDEF_H"; then
14422
14423
14424
14425
14426
14427
14428 if test $gl_cv_have_include_next = yes; then
14429 gl_cv_next_stddef_h='<'stddef.h'>'
14430 else
14431 { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stddef.h>" >&5
14432$as_echo_n "checking absolute name of <stddef.h>... " >&6; }
14433if ${gl_cv_next_stddef_h+:} false; then :
14434 $as_echo_n "(cached) " >&6
14435else
14436
14437 if test $ac_cv_header_stddef_h = yes; then
14438 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14439/* end confdefs.h. */
14440#include <stddef.h>
14441
14442_ACEOF
14443 case "$host_os" in
14444 aix*) gl_absname_cpp="$ac_cpp -C" ;;
14445 *) gl_absname_cpp="$ac_cpp" ;;
14446 esac
14447 gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
14448 sed -n '\#/stddef.h#{
14449 s#.*"\(.*/stddef.h\)".*#\1#
14450 s#^/[^/]#//&#
14451 p
14452 q
14453 }'`'"'
14454 else
14455 gl_cv_next_stddef_h='<'stddef.h'>'
14456 fi
14457
14458fi
14459{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5
14460$as_echo "$gl_cv_next_stddef_h" >&6; }
14461 fi
14462 NEXT_STDDEF_H=$gl_cv_next_stddef_h
14463
14464 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
14465 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
14466 gl_next_as_first_directive='<'stddef.h'>'
14467 else
14468 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
14469 gl_next_as_first_directive=$gl_cv_next_stddef_h
14470 fi
14471 NEXT_AS_FIRST_DIRECTIVE_STDDEF_H=$gl_next_as_first_directive
14472
14473
14474
14475 fi
14476
14477 # Code from module time:
14478
14479
14480
14481 # Code from module time_r:
14482
14483
14484
14485
14486
14487
14488
14489 if test $ac_cv_have_decl_localtime_r = no; then
14490 HAVE_DECL_LOCALTIME_R=0
14491 fi
14492
14493
14494 if test $ac_cv_func_localtime_r = yes; then
14495 HAVE_LOCALTIME_R=1
14496 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether localtime_r is compatible with its POSIX signature" >&5
14497$as_echo_n "checking whether localtime_r is compatible with its POSIX signature... " >&6; }
14498if ${gl_cv_time_r_posix+:} false; then :
14499 $as_echo_n "(cached) " >&6
14500else
14501 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14502/* end confdefs.h. */
14503#include <time.h>
14504int
14505main ()
14506{
14507/* We don't need to append 'restrict's to the argument types,
14508 even though the POSIX signature has the 'restrict's,
14509 since C99 says they can't affect type compatibility. */
14510 struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
14511 if (ptr) return 0;
14512 /* Check the return type is a pointer.
14513 On HP-UX 10 it is 'int'. */
14514 *localtime_r (0, 0);
14515 ;
14516 return 0;
14517}
14518
14519_ACEOF
14520if ac_fn_c_try_compile "$LINENO"; then :
14521 gl_cv_time_r_posix=yes
14522else
14523 gl_cv_time_r_posix=no
14524fi
14525rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14526
14527fi
14528{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_time_r_posix" >&5
14529$as_echo "$gl_cv_time_r_posix" >&6; }
14530 if test $gl_cv_time_r_posix = yes; then
14531 REPLACE_LOCALTIME_R=0
14532 else
14533 REPLACE_LOCALTIME_R=1
14534 fi
14535 else
14536 HAVE_LOCALTIME_R=0
14537 fi
14538 if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
14539
14540
14541
14542
14543
14544
14545
14546
14547 gl_LIBOBJS="$gl_LIBOBJS time_r.$ac_objext"
14548
14549
14550 :
14551
14552 fi
14553
14554
14555
14556
14557 GNULIB_TIME_R=1
14558
14559
14560
14561$as_echo "#define GNULIB_TEST_TIME_R 1" >>confdefs.h
14562
14563
14564
14565 # Code from module warn-on-use:
13818 # End of code from modules 14566 # End of code from modules
13819 14567
13820 14568
@@ -13823,6 +14571,8 @@ fi
13823 14571
13824 14572
13825 14573
14574
14575
13826 gltests_libdeps= 14576 gltests_libdeps=
13827 gltests_ltlibdeps= 14577 gltests_ltlibdeps=
13828 14578
@@ -15404,60 +16154,6 @@ $as_echo "#define mbstate_t int" >>confdefs.h
15404 16154
15405 fi 16155 fi
15406 16156
15407{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C restrict keyword" >&5
15408$as_echo_n "checking for C restrict keyword... " >&6; }
15409if ${emacs_cv_c_restrict+:} false; then :
15410 $as_echo_n "(cached) " >&6
15411else
15412 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15413/* end confdefs.h. */
15414void fred (int *restrict x);
15415int
15416main ()
15417{
15418
15419 ;
15420 return 0;
15421}
15422_ACEOF
15423if ac_fn_c_try_compile "$LINENO"; then :
15424 emacs_cv_c_restrict=yes
15425else
15426 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15427/* end confdefs.h. */
15428void fred (int *__restrict x);
15429int
15430main ()
15431{
15432
15433 ;
15434 return 0;
15435}
15436_ACEOF
15437if ac_fn_c_try_compile "$LINENO"; then :
15438 emacs_cv_c_restrict=__restrict
15439else
15440 emacs_cv_c_restrict=no
15441fi
15442rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15443fi
15444rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15445fi
15446{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_c_restrict" >&5
15447$as_echo "$emacs_cv_c_restrict" >&6; }
15448case "$emacs_cv_c_restrict" in
15449 yes) emacs_restrict=restrict;;
15450 no) emacs_restrict="";;
15451 *) emacs_restrict="$emacs_cv_c_restrict";;
15452esac
15453if test "$emacs_restrict" != __restrict; then
15454
15455cat >>confdefs.h <<_ACEOF
15456#define __restrict $emacs_restrict
15457_ACEOF
15458
15459fi
15460
15461{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C restricted array declarations" >&5 16157{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C restricted array declarations" >&5
15462$as_echo_n "checking for C restricted array declarations... " >&6; } 16158$as_echo_n "checking for C restricted array declarations... " >&6; }
15463if ${emacs_cv_c_restrict_arr+:} false; then : 16159if ${emacs_cv_c_restrict_arr+:} false; then :
diff --git a/lib/Makefile.in b/lib/Makefile.in
index d1d6e4f8417..40254045808 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -24,7 +24,7 @@
24# the same distribution terms as the rest of that program. 24# the same distribution terms as the rest of that program.
25# 25#
26# Generated by gnulib-tool. 26# Generated by gnulib-tool.
27# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr 27# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr mktime
28 28
29VPATH = @srcdir@ 29VPATH = @srcdir@
30pkgdatadir = $(datadir)/@PACKAGE@ 30pkgdatadir = $(datadir)/@PACKAGE@
@@ -50,8 +50,13 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
50subdir = lib 50subdir = lib
51ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 51ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
52am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ 52am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
53 $(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/gnulib-common.m4 \ 53 $(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/extensions.m4 \
54 $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/getopt.m4 \ 54 $(top_srcdir)/m4/gnulib-common.m4 \
55 $(top_srcdir)/m4/gnulib-comp.m4 \
56 $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/mktime.m4 \
57 $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/stddef_h.m4 \
58 $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \
59 $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/getopt.m4 \
55 $(top_srcdir)/configure.in 60 $(top_srcdir)/configure.in
56am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 61am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
57 $(ACLOCAL_M4) 62 $(ACLOCAL_M4)
@@ -84,6 +89,7 @@ ALLOCA = @ALLOCA@
84ALSA_CFLAGS = @ALSA_CFLAGS@ 89ALSA_CFLAGS = @ALSA_CFLAGS@
85ALSA_LIBS = @ALSA_LIBS@ 90ALSA_LIBS = @ALSA_LIBS@
86AMTAR = @AMTAR@ 91AMTAR = @AMTAR@
92APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
87AUTOCONF = @AUTOCONF@ 93AUTOCONF = @AUTOCONF@
88AUTOHEADER = @AUTOHEADER@ 94AUTOHEADER = @AUTOHEADER@
89AUTOMAKE = @AUTOMAKE@ 95AUTOMAKE = @AUTOMAKE@
@@ -129,6 +135,11 @@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
129GETOPTOBJS = @GETOPTOBJS@ 135GETOPTOBJS = @GETOPTOBJS@
130GETOPT_H = @GETOPT_H@ 136GETOPT_H = @GETOPT_H@
131GMALLOC_OBJ = @GMALLOC_OBJ@ 137GMALLOC_OBJ = @GMALLOC_OBJ@
138GNULIB_MKTIME = @GNULIB_MKTIME@
139GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@
140GNULIB_STRPTIME = @GNULIB_STRPTIME@
141GNULIB_TIMEGM = @GNULIB_TIMEGM@
142GNULIB_TIME_R = @GNULIB_TIME_R@
132GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@ 143GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@
133GREP = @GREP@ 144GREP = @GREP@
134GTK_CFLAGS = @GTK_CFLAGS@ 145GTK_CFLAGS = @GTK_CFLAGS@
@@ -136,10 +147,17 @@ GTK_LIBS = @GTK_LIBS@
136GTK_OBJ = @GTK_OBJ@ 147GTK_OBJ = @GTK_OBJ@
137GZIP_INFO = @GZIP_INFO@ 148GZIP_INFO = @GZIP_INFO@
138GZIP_PROG = @GZIP_PROG@ 149GZIP_PROG = @GZIP_PROG@
150HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@
139HAVE_MAKEINFO = @HAVE_MAKEINFO@ 151HAVE_MAKEINFO = @HAVE_MAKEINFO@
152HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
153HAVE_STRPTIME = @HAVE_STRPTIME@
154HAVE_TIMEGM = @HAVE_TIMEGM@
155HAVE_WCHAR_T = @HAVE_WCHAR_T@
140HAVE_XSERVER = @HAVE_XSERVER@ 156HAVE_XSERVER = @HAVE_XSERVER@
141IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@ 157IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@
142IMAGEMAGICK_LIBS = @IMAGEMAGICK_LIBS@ 158IMAGEMAGICK_LIBS = @IMAGEMAGICK_LIBS@
159INCLUDE_NEXT = @INCLUDE_NEXT@
160INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@
143INSTALL = @INSTALL@ 161INSTALL = @INSTALL@
144INSTALL_DATA = @INSTALL_DATA@ 162INSTALL_DATA = @INSTALL_DATA@
145INSTALL_INFO = @INSTALL_INFO@ 163INSTALL_INFO = @INSTALL_INFO@
@@ -198,6 +216,10 @@ MKDIR_P = @MKDIR_P@
198MOUSE_SUPPORT = @MOUSE_SUPPORT@ 216MOUSE_SUPPORT = @MOUSE_SUPPORT@
199M_FILE = @M_FILE@ 217M_FILE = @M_FILE@
200NEED_SETGID = @NEED_SETGID@ 218NEED_SETGID = @NEED_SETGID@
219NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
220NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
221NEXT_STDDEF_H = @NEXT_STDDEF_H@
222NEXT_TIME_H = @NEXT_TIME_H@
201NS_OBJ = @NS_OBJ@ 223NS_OBJ = @NS_OBJ@
202NS_SUPPORT = @NS_SUPPORT@ 224NS_SUPPORT = @NS_SUPPORT@
203OBJEXT = @OBJEXT@ 225OBJEXT = @OBJEXT@
@@ -215,19 +237,30 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
215PATH_SEPARATOR = @PATH_SEPARATOR@ 237PATH_SEPARATOR = @PATH_SEPARATOR@
216PKG_CONFIG = @PKG_CONFIG@ 238PKG_CONFIG = @PKG_CONFIG@
217POST_ALLOC_OBJ = @POST_ALLOC_OBJ@ 239POST_ALLOC_OBJ = @POST_ALLOC_OBJ@
240PRAGMA_COLUMNS = @PRAGMA_COLUMNS@
241PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@
218PRE_ALLOC_OBJ = @PRE_ALLOC_OBJ@ 242PRE_ALLOC_OBJ = @PRE_ALLOC_OBJ@
219PROFILING_CFLAGS = @PROFILING_CFLAGS@ 243PROFILING_CFLAGS = @PROFILING_CFLAGS@
244PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
220RALLOC_OBJ = @RALLOC_OBJ@ 245RALLOC_OBJ = @RALLOC_OBJ@
221RANLIB = @RANLIB@ 246RANLIB = @RANLIB@
247REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@
248REPLACE_MKTIME = @REPLACE_MKTIME@
249REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
250REPLACE_NULL = @REPLACE_NULL@
251REPLACE_TIMEGM = @REPLACE_TIMEGM@
222RSVG_CFLAGS = @RSVG_CFLAGS@ 252RSVG_CFLAGS = @RSVG_CFLAGS@
223RSVG_LIBS = @RSVG_LIBS@ 253RSVG_LIBS = @RSVG_LIBS@
224SET_MAKE = @SET_MAKE@ 254SET_MAKE = @SET_MAKE@
225SHELL = @SHELL@ 255SHELL = @SHELL@
226START_FILES = @START_FILES@ 256START_FILES = @START_FILES@
257STDDEF_H = @STDDEF_H@
227STRIP = @STRIP@ 258STRIP = @STRIP@
259SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
228S_FILE = @S_FILE@ 260S_FILE = @S_FILE@
229TEMACS_LDFLAGS2 = @TEMACS_LDFLAGS2@ 261TEMACS_LDFLAGS2 = @TEMACS_LDFLAGS2@
230TERMCAP_OBJ = @TERMCAP_OBJ@ 262TERMCAP_OBJ = @TERMCAP_OBJ@
263TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
231TOOLKIT_LIBW = @TOOLKIT_LIBW@ 264TOOLKIT_LIBW = @TOOLKIT_LIBW@
232TOOLTIP_SUPPORT = @TOOLTIP_SUPPORT@ 265TOOLTIP_SUPPORT = @TOOLTIP_SUPPORT@
233UNEXEC_OBJ = @UNEXEC_OBJ@ 266UNEXEC_OBJ = @UNEXEC_OBJ@
@@ -313,15 +346,33 @@ top_builddir = @top_builddir@
313top_srcdir = @top_srcdir@ 346top_srcdir = @top_srcdir@
314version = @version@ 347version = @version@
315x_default_search_path = @x_default_search_path@ 348x_default_search_path = @x_default_search_path@
316BUILT_SOURCES = 349
317EXTRA_DIST = intprops.h 350# The BUILT_SOURCES created by this Makefile snippet are not used via #include
318MOSTLYCLEANFILES = core *.stackdump 351# statements but through direct file reference. Therefore this snippet must be
352# present in all Makefile.am that need it. This is ensured by the applicability
353# 'all' defined above.
354
355# The BUILT_SOURCES created by this Makefile snippet are not used via #include
356# statements but through direct file reference. Therefore this snippet must be
357# present in all Makefile.am that need it. This is ensured by the applicability
358# 'all' defined above.
359BUILT_SOURCES = arg-nonnull.h c++defs.h $(STDDEF_H) time.h \
360 warn-on-use.h
361EXTRA_DIST = $(top_srcdir)/./arg-nonnull.h $(top_srcdir)/./c++defs.h \
362 intprops.h mktime-internal.h mktime.c stddef.in.h time.in.h \
363 time_r.c $(top_srcdir)/./warn-on-use.h
364MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \
365 c++defs.h c++defs.h-t stddef.h stddef.h-t time.h time.h-t \
366 warn-on-use.h warn-on-use.h-t
319noinst_LIBRARIES = libgnu.a 367noinst_LIBRARIES = libgnu.a
320DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src 368DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src
321libgnu_a_SOURCES = ftoastr.h ftoastr.c dtoastr.c ldtoastr.c 369libgnu_a_SOURCES = ftoastr.h ftoastr.c dtoastr.c ldtoastr.c
322libgnu_a_LIBADD = $(gl_LIBOBJS) 370libgnu_a_LIBADD = $(gl_LIBOBJS)
323libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 371libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
324EXTRA_libgnu_a_SOURCES = 372EXTRA_libgnu_a_SOURCES = mktime.c time_r.c
373ARG_NONNULL_H = arg-nonnull.h
374CXXDEFS_H = c++defs.h
375WARN_ON_USE_H = warn-on-use.h
325all: $(BUILT_SOURCES) 376all: $(BUILT_SOURCES)
326 $(MAKE) $(AM_MAKEFLAGS) all-am 377 $(MAKE) $(AM_MAKEFLAGS) all-am
327 378
@@ -374,6 +425,8 @@ distclean-compile:
374@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@ 425@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@
375@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@ 426@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@
376@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ldtoastr.Po@am__quote@ 427@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ldtoastr.Po@am__quote@
428@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.Po@am__quote@
429@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time_r.Po@am__quote@
377 430
378.c.o: 431.c.o:
379@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 432@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -589,6 +642,77 @@ uninstall-am:
589 mostlyclean-generic mostlyclean-local pdf pdf-am ps ps-am tags \ 642 mostlyclean-generic mostlyclean-local pdf pdf-am ps ps-am tags \
590 uninstall uninstall-am 643 uninstall uninstall-am
591 644
645# The arg-nonnull.h that gets inserted into generated .h files is the same as
646# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
647arg-nonnull.h: $(top_srcdir)/./arg-nonnull.h
648 $(AM_V_GEN)rm -f $@-t $@ && \
649 sed -n -e '/GL_ARG_NONNULL/,$$p' \
650 < $(top_srcdir)/./arg-nonnull.h \
651 > $@-t && \
652 mv $@-t $@
653# The c++defs.h that gets inserted into generated .h files is the same as
654# build-aux/c++defs.h, except that it has the copyright header cut off.
655c++defs.h: $(top_srcdir)/./c++defs.h
656 $(AM_V_GEN)rm -f $@-t $@ && \
657 sed -n -e '/_GL_CXXDEFS/,$$p' \
658 < $(top_srcdir)/./c++defs.h \
659 > $@-t && \
660 mv $@-t $@
661
662# We need the following in order to create <stddef.h> when the system
663# doesn't have one that works with the given compiler.
664stddef.h: stddef.in.h
665 $(AM_V_GEN)rm -f $@-t $@ && \
666 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
667 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
668 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
669 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
670 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
671 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
672 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
673 < $(srcdir)/stddef.in.h; \
674 } > $@-t && \
675 mv $@-t $@
676
677# We need the following in order to create <time.h> when the system
678# doesn't have one that works with the given compiler.
679time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
680 $(AM_V_GEN)rm -f $@-t $@ && \
681 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
682 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
683 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
684 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
685 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
686 -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \
687 -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \
688 -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
689 -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
690 -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
691 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
692 -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
693 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
694 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
695 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
696 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
697 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
698 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
699 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
700 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
701 -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
702 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
703 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
704 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
705 < $(srcdir)/time.in.h; \
706 } > $@-t && \
707 mv $@-t $@
708# The warn-on-use.h that gets inserted into generated .h files is the same as
709# build-aux/warn-on-use.h, except that it has the copyright header cut off.
710warn-on-use.h: $(top_srcdir)/./warn-on-use.h
711 $(AM_V_GEN)rm -f $@-t $@ && \
712 sed -n -e '/^.ifndef/,$$p' \
713 < $(top_srcdir)/./warn-on-use.h \
714 > $@-t && \
715 mv $@-t $@
592 716
593mostlyclean-local: mostlyclean-generic 717mostlyclean-local: mostlyclean-generic
594 @for dir in '' $(MOSTLYCLEANDIRS); do \ 718 @for dir in '' $(MOSTLYCLEANDIRS); do \
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 78d89d99281..a091e399be1 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -9,7 +9,7 @@
9# the same distribution terms as the rest of that program. 9# the same distribution terms as the rest of that program.
10# 10#
11# Generated by gnulib-tool. 11# Generated by gnulib-tool.
12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr 12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr mktime
13 13
14 14
15MOSTLYCLEANFILES += core *.stackdump 15MOSTLYCLEANFILES += core *.stackdump
@@ -21,6 +21,54 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
21libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 21libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
22EXTRA_libgnu_a_SOURCES = 22EXTRA_libgnu_a_SOURCES =
23 23
24## begin gnulib module arg-nonnull
25
26# The BUILT_SOURCES created by this Makefile snippet are not used via #include
27# statements but through direct file reference. Therefore this snippet must be
28# present in all Makefile.am that need it. This is ensured by the applicability
29# 'all' defined above.
30
31BUILT_SOURCES += arg-nonnull.h
32# The arg-nonnull.h that gets inserted into generated .h files is the same as
33# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
34arg-nonnull.h: $(top_srcdir)/./arg-nonnull.h
35 $(AM_V_GEN)rm -f $@-t $@ && \
36 sed -n -e '/GL_ARG_NONNULL/,$$p' \
37 < $(top_srcdir)/./arg-nonnull.h \
38 > $@-t && \
39 mv $@-t $@
40MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
41
42ARG_NONNULL_H=arg-nonnull.h
43
44EXTRA_DIST += $(top_srcdir)/./arg-nonnull.h
45
46## end gnulib module arg-nonnull
47
48## begin gnulib module c++defs
49
50# The BUILT_SOURCES created by this Makefile snippet are not used via #include
51# statements but through direct file reference. Therefore this snippet must be
52# present in all Makefile.am that need it. This is ensured by the applicability
53# 'all' defined above.
54
55BUILT_SOURCES += c++defs.h
56# The c++defs.h that gets inserted into generated .h files is the same as
57# build-aux/c++defs.h, except that it has the copyright header cut off.
58c++defs.h: $(top_srcdir)/./c++defs.h
59 $(AM_V_GEN)rm -f $@-t $@ && \
60 sed -n -e '/_GL_CXXDEFS/,$$p' \
61 < $(top_srcdir)/./c++defs.h \
62 > $@-t && \
63 mv $@-t $@
64MOSTLYCLEANFILES += c++defs.h c++defs.h-t
65
66CXXDEFS_H=c++defs.h
67
68EXTRA_DIST += $(top_srcdir)/./c++defs.h
69
70## end gnulib module c++defs
71
24## begin gnulib module ftoastr 72## begin gnulib module ftoastr
25 73
26libgnu_a_SOURCES += ftoastr.h ftoastr.c dtoastr.c ldtoastr.c 74libgnu_a_SOURCES += ftoastr.h ftoastr.c dtoastr.c ldtoastr.c
@@ -34,6 +82,108 @@ EXTRA_DIST += intprops.h
34 82
35## end gnulib module intprops 83## end gnulib module intprops
36 84
85## begin gnulib module mktime
86
87
88EXTRA_DIST += mktime-internal.h mktime.c
89
90EXTRA_libgnu_a_SOURCES += mktime.c
91
92## end gnulib module mktime
93
94## begin gnulib module stddef
95
96BUILT_SOURCES += $(STDDEF_H)
97
98# We need the following in order to create <stddef.h> when the system
99# doesn't have one that works with the given compiler.
100stddef.h: stddef.in.h
101 $(AM_V_GEN)rm -f $@-t $@ && \
102 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
103 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
104 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
105 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
106 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
107 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
108 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
109 < $(srcdir)/stddef.in.h; \
110 } > $@-t && \
111 mv $@-t $@
112MOSTLYCLEANFILES += stddef.h stddef.h-t
113
114EXTRA_DIST += stddef.in.h
115
116## end gnulib module stddef
117
118## begin gnulib module time
119
120BUILT_SOURCES += time.h
121
122# We need the following in order to create <time.h> when the system
123# doesn't have one that works with the given compiler.
124time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
125 $(AM_V_GEN)rm -f $@-t $@ && \
126 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
127 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
128 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
129 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
130 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
131 -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \
132 -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \
133 -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
134 -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
135 -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
136 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
137 -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
138 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
139 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
140 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
141 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
142 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
143 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
144 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
145 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
146 -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
147 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
148 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
149 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
150 < $(srcdir)/time.in.h; \
151 } > $@-t && \
152 mv $@-t $@
153MOSTLYCLEANFILES += time.h time.h-t
154
155EXTRA_DIST += time.in.h
156
157## end gnulib module time
158
159## begin gnulib module time_r
160
161
162EXTRA_DIST += time_r.c
163
164EXTRA_libgnu_a_SOURCES += time_r.c
165
166## end gnulib module time_r
167
168## begin gnulib module warn-on-use
169
170BUILT_SOURCES += warn-on-use.h
171# The warn-on-use.h that gets inserted into generated .h files is the same as
172# build-aux/warn-on-use.h, except that it has the copyright header cut off.
173warn-on-use.h: $(top_srcdir)/./warn-on-use.h
174 $(AM_V_GEN)rm -f $@-t $@ && \
175 sed -n -e '/^.ifndef/,$$p' \
176 < $(top_srcdir)/./warn-on-use.h \
177 > $@-t && \
178 mv $@-t $@
179MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
180
181WARN_ON_USE_H=warn-on-use.h
182
183EXTRA_DIST += $(top_srcdir)/./warn-on-use.h
184
185## end gnulib module warn-on-use
186
37 187
38mostlyclean-local: mostlyclean-generic 188mostlyclean-local: mostlyclean-generic
39 @for dir in '' $(MOSTLYCLEANDIRS); do \ 189 @for dir in '' $(MOSTLYCLEANDIRS); do \
diff --git a/lib/mktime-internal.h b/lib/mktime-internal.h
new file mode 100644
index 00000000000..4287acf4aca
--- /dev/null
+++ b/lib/mktime-internal.h
@@ -0,0 +1,4 @@
1#include <time.h>
2time_t mktime_internal (struct tm *,
3 struct tm * (*) (time_t const *, struct tm *),
4 time_t *);
diff --git a/lib/mktime.c b/lib/mktime.c
new file mode 100644
index 00000000000..f77330564fc
--- /dev/null
+++ b/lib/mktime.c
@@ -0,0 +1,669 @@
1/* Convert a `struct tm' to a time_t value.
2 Copyright (C) 1993-1999, 2002-2007, 2009-2011 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@twinsun.com>.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20/* Define this to have a standalone program to test this implementation of
21 mktime. */
22/* #define DEBUG 1 */
23
24#ifndef _LIBC
25# include <config.h>
26#endif
27
28/* Assume that leap seconds are possible, unless told otherwise.
29 If the host has a `zic' command with a `-L leapsecondfilename' option,
30 then it supports leap seconds; otherwise it probably doesn't. */
31#ifndef LEAP_SECONDS_POSSIBLE
32# define LEAP_SECONDS_POSSIBLE 1
33#endif
34
35#include <time.h>
36
37#include <limits.h>
38
39#include <string.h> /* For the real memcpy prototype. */
40
41#if DEBUG
42# include <stdio.h>
43# include <stdlib.h>
44/* Make it work even if the system's libc has its own mktime routine. */
45# define mktime my_mktime
46#endif /* DEBUG */
47
48/* Shift A right by B bits portably, by dividing A by 2**B and
49 truncating towards minus infinity. A and B should be free of side
50 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
51 INT_BITS is the number of useful bits in an int. GNU code can
52 assume that INT_BITS is at least 32.
53
54 ISO C99 says that A >> B is implementation-defined if A < 0. Some
55 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
56 right in the usual way when A < 0, so SHR falls back on division if
57 ordinary A >> B doesn't seem to be the usual signed shift. */
58#define SHR(a, b) \
59 (-1 >> 1 == -1 \
60 ? (a) >> (b) \
61 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
62
63/* The extra casts in the following macros work around compiler bugs,
64 e.g., in Cray C 5.0.3.0. */
65
66/* True if the arithmetic type T is an integer type. bool counts as
67 an integer. */
68#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
69
70/* True if negative values of the signed integer type T use two's
71 complement, ones' complement, or signed magnitude representation,
72 respectively. Much GNU code assumes two's complement, but some
73 people like to be portable to all possible C hosts. */
74#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
75#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
76#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
77
78/* True if the arithmetic type T is signed. */
79#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
80
81/* The maximum and minimum values for the integer type T. These
82 macros have undefined behavior if T is signed and has padding bits.
83 If this is a problem for you, please let us know how to fix it for
84 your host. */
85#define TYPE_MINIMUM(t) \
86 ((t) (! TYPE_SIGNED (t) \
87 ? (t) 0 \
88 : TYPE_SIGNED_MAGNITUDE (t) \
89 ? ~ (t) 0 \
90 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
91#define TYPE_MAXIMUM(t) \
92 ((t) (! TYPE_SIGNED (t) \
93 ? (t) -1 \
94 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
95
96#ifndef TIME_T_MIN
97# define TIME_T_MIN TYPE_MINIMUM (time_t)
98#endif
99#ifndef TIME_T_MAX
100# define TIME_T_MAX TYPE_MAXIMUM (time_t)
101#endif
102#define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1)
103
104/* Verify a requirement at compile-time (unlike assert, which is runtime). */
105#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
106
107verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
108verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
109/* The code also assumes that signed integer overflow silently wraps
110 around, but this assumption can't be stated without causing a
111 diagnostic on some hosts. */
112
113#define EPOCH_YEAR 1970
114#define TM_YEAR_BASE 1900
115verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0);
116
117/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */
118static inline int
119leapyear (long int year)
120{
121 /* Don't add YEAR to TM_YEAR_BASE, as that might overflow.
122 Also, work even if YEAR is negative. */
123 return
124 ((year & 3) == 0
125 && (year % 100 != 0
126 || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3)));
127}
128
129/* How many days come before each month (0-12). */
130#ifndef _LIBC
131static
132#endif
133const unsigned short int __mon_yday[2][13] =
134 {
135 /* Normal years. */
136 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
137 /* Leap years. */
138 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
139 };
140
141
142#ifndef _LIBC
143/* Portable standalone applications should supply a <time.h> that
144 declares a POSIX-compliant localtime_r, for the benefit of older
145 implementations that lack localtime_r or have a nonstandard one.
146 See the gnulib time_r module for one way to implement this. */
147# undef __localtime_r
148# define __localtime_r localtime_r
149# define __mktime_internal mktime_internal
150# include "mktime-internal.h"
151#endif
152
153/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
154 (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks
155 were not adjusted between the time stamps.
156
157 The YEAR values uses the same numbering as TP->tm_year. Values
158 need not be in the usual range. However, YEAR1 must not be less
159 than 2 * INT_MIN or greater than 2 * INT_MAX.
160
161 The result may overflow. It is the caller's responsibility to
162 detect overflow. */
163
164static inline time_t
165ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1,
166 int year0, int yday0, int hour0, int min0, int sec0)
167{
168 verify (C99_integer_division, -1 / 2 == 0);
169#if 0 /* This assertion fails on 32-bit systems with 64-bit time_t, such as
170 NetBSD 5 on i386. */
171 verify (long_int_year_and_yday_are_wide_enough,
172 INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX);
173#endif
174
175 /* Compute intervening leap days correctly even if year is negative.
176 Take care to avoid integer overflow here. */
177 int a4 = SHR (year1, 2) + SHR (TM_YEAR_BASE, 2) - ! (year1 & 3);
178 int b4 = SHR (year0, 2) + SHR (TM_YEAR_BASE, 2) - ! (year0 & 3);
179 int a100 = a4 / 25 - (a4 % 25 < 0);
180 int b100 = b4 / 25 - (b4 % 25 < 0);
181 int a400 = SHR (a100, 2);
182 int b400 = SHR (b100, 2);
183 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
184
185 /* Compute the desired time in time_t precision. Overflow might
186 occur here. */
187 time_t tyear1 = year1;
188 time_t years = tyear1 - year0;
189 time_t days = 365 * years + yday1 - yday0 + intervening_leap_days;
190 time_t hours = 24 * days + hour1 - hour0;
191 time_t minutes = 60 * hours + min1 - min0;
192 time_t seconds = 60 * minutes + sec1 - sec0;
193 return seconds;
194}
195
196
197/* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC),
198 assuming that *T corresponds to *TP and that no clock adjustments
199 occurred between *TP and the desired time.
200 If TP is null, return a value not equal to *T; this avoids false matches.
201 If overflow occurs, yield the minimal or maximal value, except do not
202 yield a value equal to *T. */
203static time_t
204guess_time_tm (long int year, long int yday, int hour, int min, int sec,
205 const time_t *t, const struct tm *tp)
206{
207 if (tp)
208 {
209 time_t d = ydhms_diff (year, yday, hour, min, sec,
210 tp->tm_year, tp->tm_yday,
211 tp->tm_hour, tp->tm_min, tp->tm_sec);
212 time_t t1 = *t + d;
213 if ((t1 < *t) == (TYPE_SIGNED (time_t) ? d < 0 : TIME_T_MAX / 2 < d))
214 return t1;
215 }
216
217 /* Overflow occurred one way or another. Return the nearest result
218 that is actually in range, except don't report a zero difference
219 if the actual difference is nonzero, as that would cause a false
220 match; and don't oscillate between two values, as that would
221 confuse the spring-forward gap detector. */
222 return (*t < TIME_T_MIDPOINT
223 ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN)
224 : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX));
225}
226
227/* Use CONVERT to convert *T to a broken down time in *TP.
228 If *T is out of range for conversion, adjust it so that
229 it is the nearest in-range value and then convert that. */
230static struct tm *
231ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
232 time_t *t, struct tm *tp)
233{
234 struct tm *r = convert (t, tp);
235
236 if (!r && *t)
237 {
238 time_t bad = *t;
239 time_t ok = 0;
240
241 /* BAD is a known unconvertible time_t, and OK is a known good one.
242 Use binary search to narrow the range between BAD and OK until
243 they differ by 1. */
244 while (bad != ok + (bad < 0 ? -1 : 1))
245 {
246 time_t mid = *t = (bad < 0
247 ? bad + ((ok - bad) >> 1)
248 : ok + ((bad - ok) >> 1));
249 r = convert (t, tp);
250 if (r)
251 ok = mid;
252 else
253 bad = mid;
254 }
255
256 if (!r && ok)
257 {
258 /* The last conversion attempt failed;
259 revert to the most recent successful attempt. */
260 *t = ok;
261 r = convert (t, tp);
262 }
263 }
264
265 return r;
266}
267
268
269/* Convert *TP to a time_t value, inverting
270 the monotonic and mostly-unit-linear conversion function CONVERT.
271 Use *OFFSET to keep track of a guess at the offset of the result,
272 compared to what the result would be for UTC without leap seconds.
273 If *OFFSET's guess is correct, only one CONVERT call is needed.
274 This function is external because it is used also by timegm.c. */
275time_t
276__mktime_internal (struct tm *tp,
277 struct tm *(*convert) (const time_t *, struct tm *),
278 time_t *offset)
279{
280 time_t t, gt, t0, t1, t2;
281 struct tm tm;
282
283 /* The maximum number of probes (calls to CONVERT) should be enough
284 to handle any combinations of time zone rule changes, solar time,
285 leap seconds, and oscillations around a spring-forward gap.
286 POSIX.1 prohibits leap seconds, but some hosts have them anyway. */
287 int remaining_probes = 6;
288
289 /* Time requested. Copy it in case CONVERT modifies *TP; this can
290 occur if TP is localtime's returned value and CONVERT is localtime. */
291 int sec = tp->tm_sec;
292 int min = tp->tm_min;
293 int hour = tp->tm_hour;
294 int mday = tp->tm_mday;
295 int mon = tp->tm_mon;
296 int year_requested = tp->tm_year;
297 /* Normalize the value. */
298 int isdst = ((tp->tm_isdst >> (8 * sizeof (tp->tm_isdst) - 1))
299 | (tp->tm_isdst != 0));
300
301 /* 1 if the previous probe was DST. */
302 int dst2;
303
304 /* Ensure that mon is in range, and set year accordingly. */
305 int mon_remainder = mon % 12;
306 int negative_mon_remainder = mon_remainder < 0;
307 int mon_years = mon / 12 - negative_mon_remainder;
308 long int lyear_requested = year_requested;
309 long int year = lyear_requested + mon_years;
310
311 /* The other values need not be in range:
312 the remaining code handles minor overflows correctly,
313 assuming int and time_t arithmetic wraps around.
314 Major overflows are caught at the end. */
315
316 /* Calculate day of year from year, month, and day of month.
317 The result need not be in range. */
318 int mon_yday = ((__mon_yday[leapyear (year)]
319 [mon_remainder + 12 * negative_mon_remainder])
320 - 1);
321 long int lmday = mday;
322 long int yday = mon_yday + lmday;
323
324 time_t guessed_offset = *offset;
325
326 int sec_requested = sec;
327
328 if (LEAP_SECONDS_POSSIBLE)
329 {
330 /* Handle out-of-range seconds specially,
331 since ydhms_tm_diff assumes every minute has 60 seconds. */
332 if (sec < 0)
333 sec = 0;
334 if (59 < sec)
335 sec = 59;
336 }
337
338 /* Invert CONVERT by probing. First assume the same offset as last
339 time. */
340
341 t0 = ydhms_diff (year, yday, hour, min, sec,
342 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset);
343
344 if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3)
345 {
346 /* time_t isn't large enough to rule out overflows, so check
347 for major overflows. A gross check suffices, since if t0
348 has overflowed, it is off by a multiple of TIME_T_MAX -
349 TIME_T_MIN + 1. So ignore any component of the difference
350 that is bounded by a small value. */
351
352 /* Approximate log base 2 of the number of time units per
353 biennium. A biennium is 2 years; use this unit instead of
354 years to avoid integer overflow. For example, 2 average
355 Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds,
356 which is 63113904 seconds, and rint (log2 (63113904)) is
357 26. */
358 int ALOG2_SECONDS_PER_BIENNIUM = 26;
359 int ALOG2_MINUTES_PER_BIENNIUM = 20;
360 int ALOG2_HOURS_PER_BIENNIUM = 14;
361 int ALOG2_DAYS_PER_BIENNIUM = 10;
362 int LOG2_YEARS_PER_BIENNIUM = 1;
363
364 int approx_requested_biennia =
365 (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM)
366 - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM)
367 + SHR (mday, ALOG2_DAYS_PER_BIENNIUM)
368 + SHR (hour, ALOG2_HOURS_PER_BIENNIUM)
369 + SHR (min, ALOG2_MINUTES_PER_BIENNIUM)
370 + (LEAP_SECONDS_POSSIBLE
371 ? 0
372 : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM)));
373
374 int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM);
375 int diff = approx_biennia - approx_requested_biennia;
376 int abs_diff = diff < 0 ? - diff : diff;
377
378 /* IRIX 4.0.5 cc miscaculates TIME_T_MIN / 3: it erroneously
379 gives a positive value of 715827882. Setting a variable
380 first then doing math on it seems to work.
381 (ghazi@caip.rutgers.edu) */
382 time_t time_t_max = TIME_T_MAX;
383 time_t time_t_min = TIME_T_MIN;
384 time_t overflow_threshold =
385 (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM;
386
387 if (overflow_threshold < abs_diff)
388 {
389 /* Overflow occurred. Try repairing it; this might work if
390 the time zone offset is enough to undo the overflow. */
391 time_t repaired_t0 = -1 - t0;
392 approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM);
393 diff = approx_biennia - approx_requested_biennia;
394 abs_diff = diff < 0 ? - diff : diff;
395 if (overflow_threshold < abs_diff)
396 return -1;
397 guessed_offset += repaired_t0 - t0;
398 t0 = repaired_t0;
399 }
400 }
401
402 /* Repeatedly use the error to improve the guess. */
403
404 for (t = t1 = t2 = t0, dst2 = 0;
405 (gt = guess_time_tm (year, yday, hour, min, sec, &t,
406 ranged_convert (convert, &t, &tm)),
407 t != gt);
408 t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0)
409 if (t == t1 && t != t2
410 && (tm.tm_isdst < 0
411 || (isdst < 0
412 ? dst2 <= (tm.tm_isdst != 0)
413 : (isdst != 0) != (tm.tm_isdst != 0))))
414 /* We can't possibly find a match, as we are oscillating
415 between two values. The requested time probably falls
416 within a spring-forward gap of size GT - T. Follow the common
417 practice in this case, which is to return a time that is GT - T
418 away from the requested time, preferring a time whose
419 tm_isdst differs from the requested value. (If no tm_isdst
420 was requested and only one of the two values has a nonzero
421 tm_isdst, prefer that value.) In practice, this is more
422 useful than returning -1. */
423 goto offset_found;
424 else if (--remaining_probes == 0)
425 return -1;
426
427 /* We have a match. Check whether tm.tm_isdst has the requested
428 value, if any. */
429 if (isdst != tm.tm_isdst && 0 <= isdst && 0 <= tm.tm_isdst)
430 {
431 /* tm.tm_isdst has the wrong value. Look for a neighboring
432 time with the right value, and use its UTC offset.
433
434 Heuristic: probe the adjacent timestamps in both directions,
435 looking for the desired isdst. This should work for all real
436 time zone histories in the tz database. */
437
438 /* Distance between probes when looking for a DST boundary. In
439 tzdata2003a, the shortest period of DST is 601200 seconds
440 (e.g., America/Recife starting 2000-10-08 01:00), and the
441 shortest period of non-DST surrounded by DST is 694800
442 seconds (Africa/Tunis starting 1943-04-17 01:00). Use the
443 minimum of these two values, so we don't miss these short
444 periods when probing. */
445 int stride = 601200;
446
447 /* The longest period of DST in tzdata2003a is 536454000 seconds
448 (e.g., America/Jujuy starting 1946-10-01 01:00). The longest
449 period of non-DST is much longer, but it makes no real sense
450 to search for more than a year of non-DST, so use the DST
451 max. */
452 int duration_max = 536454000;
453
454 /* Search in both directions, so the maximum distance is half
455 the duration; add the stride to avoid off-by-1 problems. */
456 int delta_bound = duration_max / 2 + stride;
457
458 int delta, direction;
459
460 for (delta = stride; delta < delta_bound; delta += stride)
461 for (direction = -1; direction <= 1; direction += 2)
462 {
463 time_t ot = t + delta * direction;
464 if ((ot < t) == (direction < 0))
465 {
466 struct tm otm;
467 ranged_convert (convert, &ot, &otm);
468 if (otm.tm_isdst == isdst)
469 {
470 /* We found the desired tm_isdst.
471 Extrapolate back to the desired time. */
472 t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm);
473 ranged_convert (convert, &t, &tm);
474 goto offset_found;
475 }
476 }
477 }
478 }
479
480 offset_found:
481 *offset = guessed_offset + t - t0;
482
483 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
484 {
485 /* Adjust time to reflect the tm_sec requested, not the normalized value.
486 Also, repair any damage from a false match due to a leap second. */
487 int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec;
488 t1 = t + sec_requested;
489 t2 = t1 + sec_adjustment;
490 if (((t1 < t) != (sec_requested < 0))
491 | ((t2 < t1) != (sec_adjustment < 0))
492 | ! convert (&t2, &tm))
493 return -1;
494 t = t2;
495 }
496
497 *tp = tm;
498 return t;
499}
500
501
502/* FIXME: This should use a signed type wide enough to hold any UTC
503 offset in seconds. 'int' should be good enough for GNU code. We
504 can't fix this unilaterally though, as other modules invoke
505 __mktime_internal. */
506static time_t localtime_offset;
507
508/* Convert *TP to a time_t value. */
509time_t
510mktime (struct tm *tp)
511{
512#ifdef _LIBC
513 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the
514 time zone names contained in the external variable `tzname' shall
515 be set as if the tzset() function had been called. */
516 __tzset ();
517#endif
518
519 return __mktime_internal (tp, __localtime_r, &localtime_offset);
520}
521
522#ifdef weak_alias
523weak_alias (mktime, timelocal)
524#endif
525
526#ifdef _LIBC
527libc_hidden_def (mktime)
528libc_hidden_weak (timelocal)
529#endif
530
531#if DEBUG
532
533static int
534not_equal_tm (const struct tm *a, const struct tm *b)
535{
536 return ((a->tm_sec ^ b->tm_sec)
537 | (a->tm_min ^ b->tm_min)
538 | (a->tm_hour ^ b->tm_hour)
539 | (a->tm_mday ^ b->tm_mday)
540 | (a->tm_mon ^ b->tm_mon)
541 | (a->tm_year ^ b->tm_year)
542 | (a->tm_yday ^ b->tm_yday)
543 | (a->tm_isdst ^ b->tm_isdst));
544}
545
546static void
547print_tm (const struct tm *tp)
548{
549 if (tp)
550 printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
551 tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
552 tp->tm_hour, tp->tm_min, tp->tm_sec,
553 tp->tm_yday, tp->tm_wday, tp->tm_isdst);
554 else
555 printf ("0");
556}
557
558static int
559check_result (time_t tk, struct tm tmk, time_t tl, const struct tm *lt)
560{
561 if (tk != tl || !lt || not_equal_tm (&tmk, lt))
562 {
563 printf ("mktime (");
564 print_tm (lt);
565 printf (")\nyields (");
566 print_tm (&tmk);
567 printf (") == %ld, should be %ld\n", (long int) tk, (long int) tl);
568 return 1;
569 }
570
571 return 0;
572}
573
574int
575main (int argc, char **argv)
576{
577 int status = 0;
578 struct tm tm, tmk, tml;
579 struct tm *lt;
580 time_t tk, tl, tl1;
581 char trailer;
582
583 if ((argc == 3 || argc == 4)
584 && (sscanf (argv[1], "%d-%d-%d%c",
585 &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
586 == 3)
587 && (sscanf (argv[2], "%d:%d:%d%c",
588 &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
589 == 3))
590 {
591 tm.tm_year -= TM_YEAR_BASE;
592 tm.tm_mon--;
593 tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]);
594 tmk = tm;
595 tl = mktime (&tmk);
596 lt = localtime (&tl);
597 if (lt)
598 {
599 tml = *lt;
600 lt = &tml;
601 }
602 printf ("mktime returns %ld == ", (long int) tl);
603 print_tm (&tmk);
604 printf ("\n");
605 status = check_result (tl, tmk, tl, lt);
606 }
607 else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0))
608 {
609 time_t from = atol (argv[1]);
610 time_t by = atol (argv[2]);
611 time_t to = atol (argv[3]);
612
613 if (argc == 4)
614 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
615 {
616 lt = localtime (&tl);
617 if (lt)
618 {
619 tmk = tml = *lt;
620 tk = mktime (&tmk);
621 status |= check_result (tk, tmk, tl, &tml);
622 }
623 else
624 {
625 printf ("localtime (%ld) yields 0\n", (long int) tl);
626 status = 1;
627 }
628 tl1 = tl + by;
629 if ((tl1 < tl) != (by < 0))
630 break;
631 }
632 else
633 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
634 {
635 /* Null benchmark. */
636 lt = localtime (&tl);
637 if (lt)
638 {
639 tmk = tml = *lt;
640 tk = tl;
641 status |= check_result (tk, tmk, tl, &tml);
642 }
643 else
644 {
645 printf ("localtime (%ld) yields 0\n", (long int) tl);
646 status = 1;
647 }
648 tl1 = tl + by;
649 if ((tl1 < tl) != (by < 0))
650 break;
651 }
652 }
653 else
654 printf ("Usage:\
655\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
656\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
657\t%s FROM BY TO - # Do not test those values (for benchmark).\n",
658 argv[0], argv[0], argv[0]);
659
660 return status;
661}
662
663#endif /* DEBUG */
664
665/*
666Local Variables:
667compile-command: "gcc -DDEBUG -Wall -W -O -g mktime.c -o mktime"
668End:
669*/
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
new file mode 100644
index 00000000000..62a91a7a6a3
--- /dev/null
+++ b/lib/stddef.in.h
@@ -0,0 +1,87 @@
1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
2
3 Copyright (C) 2009-2011 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19/* Written by Eric Blake. */
20
21/*
22 * POSIX 2008 <stddef.h> for platforms that have issues.
23 * <http://www.opengroup.org/susv3xbd/stddef.h.html>
24 */
25
26#if __GNUC__ >= 3
27@PRAGMA_SYSTEM_HEADER@
28#endif
29@PRAGMA_COLUMNS@
30
31#if defined __need_wchar_t || defined __need_size_t \
32 || defined __need_ptrdiff_t || defined __need_NULL \
33 || defined __need_wint_t
34/* Special invocation convention inside gcc header files. In
35 particular, gcc provides a version of <stddef.h> that blindly
36 redefines NULL even when __need_wint_t was defined, even though
37 wint_t is not normally provided by <stddef.h>. Hence, we must
38 remember if special invocation has ever been used to obtain wint_t,
39 in which case we need to clean up NULL yet again. */
40
41# if !(defined _GL_STDDEF_H && defined _GL_STDDEF_WINT_T)
42# ifdef __need_wint_t
43# undef _GL_STDDEF_H
44# define _GL_STDDEF_WINT_T
45# endif
46# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
47# endif
48
49#else
50/* Normal invocation convention. */
51
52# ifndef _GL_STDDEF_H
53
54/* The include_next requires a split double-inclusion guard. */
55
56# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
57
58# ifndef _GL_STDDEF_H
59# define _GL_STDDEF_H
60
61/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
62#if @REPLACE_NULL@
63# undef NULL
64# ifdef __cplusplus
65 /* ISO C++ says that the macro NULL must expand to an integer constant
66 expression, hence '((void *) 0)' is not allowed in C++. */
67# if __GNUG__ >= 3
68 /* GNU C++ has a __null macro that behaves like an integer ('int' or
69 'long') but has the same size as a pointer. Use that, to avoid
70 warnings. */
71# define NULL __null
72# else
73# define NULL 0L
74# endif
75# else
76# define NULL ((void *) 0)
77# endif
78#endif
79
80/* Some platforms lack wchar_t. */
81#if !@HAVE_WCHAR_T@
82# define wchar_t int
83#endif
84
85# endif /* _GL_STDDEF_H */
86# endif /* _GL_STDDEF_H */
87#endif /* __need_XXX */
diff --git a/lib/time.h b/lib/time.h
new file mode 100644
index 00000000000..fea68685438
--- /dev/null
+++ b/lib/time.h
@@ -0,0 +1,555 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* A more-standard <time.h>.
3
4 Copyright (C) 2007-2011 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20#if __GNUC__ >= 3
21#pragma GCC system_header
22#endif
23
24
25/* Don't get in the way of glibc when it includes time.h merely to
26 declare a few standard symbols, rather than to declare all the
27 symbols. Also, Solaris 8 <time.h> eventually includes itself
28 recursively; if that is happening, just include the system <time.h>
29 without adding our own declarations. */
30#if (defined __need_time_t || defined __need_clock_t \
31 || defined __need_timespec \
32 || defined _GL_TIME_H)
33
34# include_next <time.h>
35
36#else
37
38# define _GL_TIME_H
39
40# include_next <time.h>
41
42/* NetBSD 5.0 mis-defines NULL. */
43# include <stddef.h>
44
45/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
46#ifndef _GL_CXXDEFS_H
47#define _GL_CXXDEFS_H
48
49/* The three most frequent use cases of these macros are:
50
51 * For providing a substitute for a function that is missing on some
52 platforms, but is declared and works fine on the platforms on which
53 it exists:
54
55 #if @GNULIB_FOO@
56 # if !@HAVE_FOO@
57 _GL_FUNCDECL_SYS (foo, ...);
58 # endif
59 _GL_CXXALIAS_SYS (foo, ...);
60 _GL_CXXALIASWARN (foo);
61 #elif defined GNULIB_POSIXCHECK
62 ...
63 #endif
64
65 * For providing a replacement for a function that exists on all platforms,
66 but is broken/insufficient and needs to be replaced on some platforms:
67
68 #if @GNULIB_FOO@
69 # if @REPLACE_FOO@
70 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
71 # undef foo
72 # define foo rpl_foo
73 # endif
74 _GL_FUNCDECL_RPL (foo, ...);
75 _GL_CXXALIAS_RPL (foo, ...);
76 # else
77 _GL_CXXALIAS_SYS (foo, ...);
78 # endif
79 _GL_CXXALIASWARN (foo);
80 #elif defined GNULIB_POSIXCHECK
81 ...
82 #endif
83
84 * For providing a replacement for a function that exists on some platforms
85 but is broken/insufficient and needs to be replaced on some of them and
86 is additionally either missing or undeclared on some other platforms:
87
88 #if @GNULIB_FOO@
89 # if @REPLACE_FOO@
90 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
91 # undef foo
92 # define foo rpl_foo
93 # endif
94 _GL_FUNCDECL_RPL (foo, ...);
95 _GL_CXXALIAS_RPL (foo, ...);
96 # else
97 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
98 _GL_FUNCDECL_SYS (foo, ...);
99 # endif
100 _GL_CXXALIAS_SYS (foo, ...);
101 # endif
102 _GL_CXXALIASWARN (foo);
103 #elif defined GNULIB_POSIXCHECK
104 ...
105 #endif
106*/
107
108/* _GL_EXTERN_C declaration;
109 performs the declaration with C linkage. */
110#if defined __cplusplus
111# define _GL_EXTERN_C extern "C"
112#else
113# define _GL_EXTERN_C extern
114#endif
115
116/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
117 declares a replacement function, named rpl_func, with the given prototype,
118 consisting of return type, parameters, and attributes.
119 Example:
120 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
121 _GL_ARG_NONNULL ((1)));
122 */
123#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
124 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
125#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
126 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
127
128/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
129 declares the system function, named func, with the given prototype,
130 consisting of return type, parameters, and attributes.
131 Example:
132 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
133 _GL_ARG_NONNULL ((1)));
134 */
135#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
136 _GL_EXTERN_C rettype func parameters_and_attributes
137
138/* _GL_CXXALIAS_RPL (func, rettype, parameters);
139 declares a C++ alias called GNULIB_NAMESPACE::func
140 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
141 Example:
142 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
143 */
144#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
145 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
146#if defined __cplusplus && defined GNULIB_NAMESPACE
147# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
148 namespace GNULIB_NAMESPACE \
149 { \
150 rettype (*const func) parameters = ::rpl_func; \
151 } \
152 _GL_EXTERN_C int _gl_cxxalias_dummy
153#else
154# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
155 _GL_EXTERN_C int _gl_cxxalias_dummy
156#endif
157
158/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
159 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
160 except that the C function rpl_func may have a slightly different
161 declaration. A cast is used to silence the "invalid conversion" error
162 that would otherwise occur. */
163#if defined __cplusplus && defined GNULIB_NAMESPACE
164# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
165 namespace GNULIB_NAMESPACE \
166 { \
167 rettype (*const func) parameters = \
168 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
169 } \
170 _GL_EXTERN_C int _gl_cxxalias_dummy
171#else
172# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
173 _GL_EXTERN_C int _gl_cxxalias_dummy
174#endif
175
176/* _GL_CXXALIAS_SYS (func, rettype, parameters);
177 declares a C++ alias called GNULIB_NAMESPACE::func
178 that redirects to the system provided function func, if GNULIB_NAMESPACE
179 is defined.
180 Example:
181 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
182 */
183#if defined __cplusplus && defined GNULIB_NAMESPACE
184 /* If we were to write
185 rettype (*const func) parameters = ::func;
186 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
187 better (remove an indirection through a 'static' pointer variable),
188 but then the _GL_CXXALIASWARN macro below would cause a warning not only
189 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
190# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
191 namespace GNULIB_NAMESPACE \
192 { \
193 static rettype (*func) parameters = ::func; \
194 } \
195 _GL_EXTERN_C int _gl_cxxalias_dummy
196#else
197# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
198 _GL_EXTERN_C int _gl_cxxalias_dummy
199#endif
200
201/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
202 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
203 except that the C function func may have a slightly different declaration.
204 A cast is used to silence the "invalid conversion" error that would
205 otherwise occur. */
206#if defined __cplusplus && defined GNULIB_NAMESPACE
207# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
208 namespace GNULIB_NAMESPACE \
209 { \
210 static rettype (*func) parameters = \
211 reinterpret_cast<rettype(*)parameters>(::func); \
212 } \
213 _GL_EXTERN_C int _gl_cxxalias_dummy
214#else
215# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
216 _GL_EXTERN_C int _gl_cxxalias_dummy
217#endif
218
219/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
220 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
221 except that the C function is picked among a set of overloaded functions,
222 namely the one with rettype2 and parameters2. Two consecutive casts
223 are used to silence the "cannot find a match" and "invalid conversion"
224 errors that would otherwise occur. */
225#if defined __cplusplus && defined GNULIB_NAMESPACE
226 /* The outer cast must be a reinterpret_cast.
227 The inner cast: When the function is defined as a set of overloaded
228 functions, it works as a static_cast<>, choosing the designated variant.
229 When the function is defined as a single variant, it works as a
230 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
231# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
232 namespace GNULIB_NAMESPACE \
233 { \
234 static rettype (*func) parameters = \
235 reinterpret_cast<rettype(*)parameters>( \
236 (rettype2(*)parameters2)(::func)); \
237 } \
238 _GL_EXTERN_C int _gl_cxxalias_dummy
239#else
240# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
241 _GL_EXTERN_C int _gl_cxxalias_dummy
242#endif
243
244/* _GL_CXXALIASWARN (func);
245 causes a warning to be emitted when ::func is used but not when
246 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
247 variants. */
248#if defined __cplusplus && defined GNULIB_NAMESPACE
249# define _GL_CXXALIASWARN(func) \
250 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
251# define _GL_CXXALIASWARN_1(func,namespace) \
252 _GL_CXXALIASWARN_2 (func, namespace)
253/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
254 we enable the warning only when not optimizing. */
255# if !__OPTIMIZE__
256# define _GL_CXXALIASWARN_2(func,namespace) \
257 _GL_WARN_ON_USE (func, \
258 "The symbol ::" #func " refers to the system function. " \
259 "Use " #namespace "::" #func " instead.")
260# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
261# define _GL_CXXALIASWARN_2(func,namespace) \
262 extern __typeof__ (func) func
263# else
264# define _GL_CXXALIASWARN_2(func,namespace) \
265 _GL_EXTERN_C int _gl_cxxalias_dummy
266# endif
267#else
268# define _GL_CXXALIASWARN(func) \
269 _GL_EXTERN_C int _gl_cxxalias_dummy
270#endif
271
272/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
273 causes a warning to be emitted when the given overloaded variant of ::func
274 is used but not when GNULIB_NAMESPACE::func is used. */
275#if defined __cplusplus && defined GNULIB_NAMESPACE
276# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
277 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
278 GNULIB_NAMESPACE)
279# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
280 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
281/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
282 we enable the warning only when not optimizing. */
283# if !__OPTIMIZE__
284# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
285 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
286 "The symbol ::" #func " refers to the system function. " \
287 "Use " #namespace "::" #func " instead.")
288# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
289# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
290 extern __typeof__ (func) func
291# else
292# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
293 _GL_EXTERN_C int _gl_cxxalias_dummy
294# endif
295#else
296# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
297 _GL_EXTERN_C int _gl_cxxalias_dummy
298#endif
299
300#endif /* _GL_CXXDEFS_H */
301
302/* The definition of _GL_ARG_NONNULL is copied here. */
303/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
304 that the values passed as arguments n, ..., m must be non-NULL pointers.
305 n = 1 stands for the first argument, n = 2 for the second argument etc. */
306#ifndef _GL_ARG_NONNULL
307# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
308# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
309# else
310# define _GL_ARG_NONNULL(params)
311# endif
312#endif
313
314/* The definition of _GL_WARN_ON_USE is copied here. */
315#ifndef _GL_WARN_ON_USE
316
317# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
318/* A compiler attribute is available in gcc versions 4.3.0 and later. */
319# define _GL_WARN_ON_USE(function, message) \
320extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
321# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
322/* Verify the existence of the function. */
323# define _GL_WARN_ON_USE(function, message) \
324extern __typeof__ (function) function
325# else /* Unsupported. */
326# define _GL_WARN_ON_USE(function, message) \
327_GL_WARN_EXTERN_C int _gl_warn_on_use
328# endif
329#endif
330
331/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
332 is like _GL_WARN_ON_USE (function, "string"), except that the function is
333 declared with the given prototype, consisting of return type, parameters,
334 and attributes.
335 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
336 not work in this case. */
337#ifndef _GL_WARN_ON_USE_CXX
338# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
339# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
340extern rettype function parameters_and_attributes \
341 __attribute__ ((__warning__ (msg)))
342# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
343/* Verify the existence of the function. */
344# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
345extern rettype function parameters_and_attributes
346# else /* Unsupported. */
347# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
348_GL_WARN_EXTERN_C int _gl_warn_on_use
349# endif
350#endif
351
352/* _GL_WARN_EXTERN_C declaration;
353 performs the declaration with C linkage. */
354#ifndef _GL_WARN_EXTERN_C
355# if defined __cplusplus
356# define _GL_WARN_EXTERN_C extern "C"
357# else
358# define _GL_WARN_EXTERN_C extern
359# endif
360#endif
361
362/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
363 Or they define it with the wrong member names or define it in <sys/time.h>
364 (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the
365 pthreads-win32 library defines it in <pthread.h>. */
366# if ! 1
367# if 0
368# include <sys/time.h>
369# elif 0
370# include <pthread.h>
371/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */
372# undef asctime_r
373# undef ctime_r
374# undef gmtime_r
375# undef localtime_r
376# undef rand_r
377# undef strtok_r
378# else
379
380# ifdef __cplusplus
381extern "C" {
382# endif
383
384# undef timespec
385# define timespec rpl_timespec
386struct timespec
387{
388 time_t tv_sec;
389 long int tv_nsec;
390};
391
392# ifdef __cplusplus
393}
394# endif
395
396# endif
397# endif
398
399/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
400 time_t to be an integer type, even though C99 permits floating
401 point. We don't know of any implementation that uses floating
402 point, and it is much easier to write code that doesn't have to
403 worry about that corner case, so we force the issue. */
404struct __time_t_must_be_integral {
405 unsigned int __floating_time_t_unsupported : (time_t) 1;
406};
407
408/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
409 return -1 and store the remaining time into RMTP. See
410 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
411# if 0
412# if GNULIB_PORTCHECK
413# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
414# define nanosleep rpl_nanosleep
415# endif
416_GL_FUNCDECL_RPL (nanosleep, int,
417 (struct timespec const *__rqtp, struct timespec *__rmtp)
418 _GL_ARG_NONNULL ((1)));
419_GL_CXXALIAS_RPL (nanosleep, int,
420 (struct timespec const *__rqtp, struct timespec *__rmtp));
421# else
422# if ! 1
423_GL_FUNCDECL_SYS (nanosleep, int,
424 (struct timespec const *__rqtp, struct timespec *__rmtp)
425 _GL_ARG_NONNULL ((1)));
426# endif
427_GL_CXXALIAS_SYS (nanosleep, int,
428 (struct timespec const *__rqtp, struct timespec *__rmtp));
429# endif
430_GL_CXXALIASWARN (nanosleep);
431# endif
432
433/* Return the 'time_t' representation of TP and normalize TP. */
434# if 1
435# if 0
436# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
437# define mktime rpl_mktime
438# endif
439_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
440_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
441# else
442_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
443# endif
444_GL_CXXALIASWARN (mktime);
445# endif
446
447/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
448 <http://www.opengroup.org/susv3xsh/localtime_r.html> and
449 <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
450# if 1
451# if 0
452# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
453# undef localtime_r
454# define localtime_r rpl_localtime_r
455# endif
456_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
457 struct tm *restrict __result)
458 _GL_ARG_NONNULL ((1, 2)));
459_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
460 struct tm *restrict __result));
461# else
462# if ! 0
463_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
464 struct tm *restrict __result)
465 _GL_ARG_NONNULL ((1, 2)));
466# endif
467_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
468 struct tm *restrict __result));
469# endif
470# if 0
471_GL_CXXALIASWARN (localtime_r);
472# endif
473# if 0
474# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
475# undef gmtime_r
476# define gmtime_r rpl_gmtime_r
477# endif
478_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
479 struct tm *restrict __result)
480 _GL_ARG_NONNULL ((1, 2)));
481_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
482 struct tm *restrict __result));
483# else
484# if ! 0
485_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
486 struct tm *restrict __result)
487 _GL_ARG_NONNULL ((1, 2)));
488# endif
489_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
490 struct tm *restrict __result));
491# endif
492# if 0
493_GL_CXXALIASWARN (gmtime_r);
494# endif
495# endif
496
497/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
498 the resulting broken-down time into TM. See
499 <http://www.opengroup.org/susv3xsh/strptime.html>. */
500# if 0
501# if ! 1
502_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
503 char const *restrict __format,
504 struct tm *restrict __tm)
505 _GL_ARG_NONNULL ((1, 2, 3)));
506# endif
507_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
508 char const *restrict __format,
509 struct tm *restrict __tm));
510_GL_CXXALIASWARN (strptime);
511# endif
512
513/* Convert TM to a time_t value, assuming UTC. */
514# if 0
515# if GNULIB_PORTCHECK
516# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
517# undef timegm
518# define timegm rpl_timegm
519# endif
520_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
521_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
522# else
523# if ! 1
524_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
525# endif
526_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
527# endif
528_GL_CXXALIASWARN (timegm);
529# endif
530
531/* Encourage applications to avoid unsafe functions that can overrun
532 buffers when given outlandish struct tm values. Portable
533 applications should use strftime (or even sprintf) instead. */
534# if defined GNULIB_POSIXCHECK
535# undef asctime
536_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
537 "better use strftime (or even sprintf) instead");
538# endif
539# if defined GNULIB_POSIXCHECK
540# undef asctime_r
541_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
542 "better use strftime (or even sprintf) instead");
543# endif
544# if defined GNULIB_POSIXCHECK
545# undef ctime
546_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
547 "better use strftime (or even sprintf) instead");
548# endif
549# if defined GNULIB_POSIXCHECK
550# undef ctime_r
551_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
552 "better use strftime (or even sprintf) instead");
553# endif
554
555#endif
diff --git a/lib/time.in.h b/lib/time.in.h
new file mode 100644
index 00000000000..2d6da7161fb
--- /dev/null
+++ b/lib/time.in.h
@@ -0,0 +1,243 @@
1/* A more-standard <time.h>.
2
3 Copyright (C) 2007-2011 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@
21#endif
22@PRAGMA_COLUMNS@
23
24/* Don't get in the way of glibc when it includes time.h merely to
25 declare a few standard symbols, rather than to declare all the
26 symbols. Also, Solaris 8 <time.h> eventually includes itself
27 recursively; if that is happening, just include the system <time.h>
28 without adding our own declarations. */
29#if (defined __need_time_t || defined __need_clock_t \
30 || defined __need_timespec \
31 || defined _GL_TIME_H)
32
33# @INCLUDE_NEXT@ @NEXT_TIME_H@
34
35#else
36
37# define _GL_TIME_H
38
39# @INCLUDE_NEXT@ @NEXT_TIME_H@
40
41/* NetBSD 5.0 mis-defines NULL. */
42# include <stddef.h>
43
44/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
45
46/* The definition of _GL_ARG_NONNULL is copied here. */
47
48/* The definition of _GL_WARN_ON_USE is copied here. */
49
50/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
51 Or they define it with the wrong member names or define it in <sys/time.h>
52 (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the
53 pthreads-win32 library defines it in <pthread.h>. */
54# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
55# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
56# include <sys/time.h>
57# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
58# include <pthread.h>
59/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */
60# undef asctime_r
61# undef ctime_r
62# undef gmtime_r
63# undef localtime_r
64# undef rand_r
65# undef strtok_r
66# else
67
68# ifdef __cplusplus
69extern "C" {
70# endif
71
72# undef timespec
73# define timespec rpl_timespec
74struct timespec
75{
76 time_t tv_sec;
77 long int tv_nsec;
78};
79
80# ifdef __cplusplus
81}
82# endif
83
84# endif
85# endif
86
87/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
88 time_t to be an integer type, even though C99 permits floating
89 point. We don't know of any implementation that uses floating
90 point, and it is much easier to write code that doesn't have to
91 worry about that corner case, so we force the issue. */
92struct __time_t_must_be_integral {
93 unsigned int __floating_time_t_unsupported : (time_t) 1;
94};
95
96/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
97 return -1 and store the remaining time into RMTP. See
98 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
99# if @GNULIB_NANOSLEEP@
100# if @REPLACE_NANOSLEEP@
101# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
102# define nanosleep rpl_nanosleep
103# endif
104_GL_FUNCDECL_RPL (nanosleep, int,
105 (struct timespec const *__rqtp, struct timespec *__rmtp)
106 _GL_ARG_NONNULL ((1)));
107_GL_CXXALIAS_RPL (nanosleep, int,
108 (struct timespec const *__rqtp, struct timespec *__rmtp));
109# else
110# if ! @HAVE_NANOSLEEP@
111_GL_FUNCDECL_SYS (nanosleep, int,
112 (struct timespec const *__rqtp, struct timespec *__rmtp)
113 _GL_ARG_NONNULL ((1)));
114# endif
115_GL_CXXALIAS_SYS (nanosleep, int,
116 (struct timespec const *__rqtp, struct timespec *__rmtp));
117# endif
118_GL_CXXALIASWARN (nanosleep);
119# endif
120
121/* Return the 'time_t' representation of TP and normalize TP. */
122# if @GNULIB_MKTIME@
123# if @REPLACE_MKTIME@
124# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
125# define mktime rpl_mktime
126# endif
127_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
128_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
129# else
130_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
131# endif
132_GL_CXXALIASWARN (mktime);
133# endif
134
135/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
136 <http://www.opengroup.org/susv3xsh/localtime_r.html> and
137 <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
138# if @GNULIB_TIME_R@
139# if @REPLACE_LOCALTIME_R@
140# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
141# undef localtime_r
142# define localtime_r rpl_localtime_r
143# endif
144_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
145 struct tm *restrict __result)
146 _GL_ARG_NONNULL ((1, 2)));
147_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
148 struct tm *restrict __result));
149# else
150# if ! @HAVE_DECL_LOCALTIME_R@
151_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
152 struct tm *restrict __result)
153 _GL_ARG_NONNULL ((1, 2)));
154# endif
155_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
156 struct tm *restrict __result));
157# endif
158# if @HAVE_DECL_LOCALTIME_R@
159_GL_CXXALIASWARN (localtime_r);
160# endif
161# if @REPLACE_LOCALTIME_R@
162# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163# undef gmtime_r
164# define gmtime_r rpl_gmtime_r
165# endif
166_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
167 struct tm *restrict __result)
168 _GL_ARG_NONNULL ((1, 2)));
169_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
170 struct tm *restrict __result));
171# else
172# if ! @HAVE_DECL_LOCALTIME_R@
173_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
174 struct tm *restrict __result)
175 _GL_ARG_NONNULL ((1, 2)));
176# endif
177_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
178 struct tm *restrict __result));
179# endif
180# if @HAVE_DECL_LOCALTIME_R@
181_GL_CXXALIASWARN (gmtime_r);
182# endif
183# endif
184
185/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
186 the resulting broken-down time into TM. See
187 <http://www.opengroup.org/susv3xsh/strptime.html>. */
188# if @GNULIB_STRPTIME@
189# if ! @HAVE_STRPTIME@
190_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
191 char const *restrict __format,
192 struct tm *restrict __tm)
193 _GL_ARG_NONNULL ((1, 2, 3)));
194# endif
195_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
196 char const *restrict __format,
197 struct tm *restrict __tm));
198_GL_CXXALIASWARN (strptime);
199# endif
200
201/* Convert TM to a time_t value, assuming UTC. */
202# if @GNULIB_TIMEGM@
203# if @REPLACE_TIMEGM@
204# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
205# undef timegm
206# define timegm rpl_timegm
207# endif
208_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
209_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
210# else
211# if ! @HAVE_TIMEGM@
212_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
213# endif
214_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
215# endif
216_GL_CXXALIASWARN (timegm);
217# endif
218
219/* Encourage applications to avoid unsafe functions that can overrun
220 buffers when given outlandish struct tm values. Portable
221 applications should use strftime (or even sprintf) instead. */
222# if defined GNULIB_POSIXCHECK
223# undef asctime
224_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
225 "better use strftime (or even sprintf) instead");
226# endif
227# if defined GNULIB_POSIXCHECK
228# undef asctime_r
229_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
230 "better use strftime (or even sprintf) instead");
231# endif
232# if defined GNULIB_POSIXCHECK
233# undef ctime
234_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
235 "better use strftime (or even sprintf) instead");
236# endif
237# if defined GNULIB_POSIXCHECK
238# undef ctime_r
239_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
240 "better use strftime (or even sprintf) instead");
241# endif
242
243#endif
diff --git a/lib/time_r.c b/lib/time_r.c
new file mode 100644
index 00000000000..31d010e437b
--- /dev/null
+++ b/lib/time_r.c
@@ -0,0 +1,45 @@
1/* Reentrant time functions like localtime_r.
2
3 Copyright (C) 2003, 2006-2007, 2010-2011 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19/* Written by Paul Eggert. */
20
21#include <config.h>
22
23#include <time.h>
24
25static struct tm *
26copy_tm_result (struct tm *dest, struct tm const *src)
27{
28 if (! src)
29 return 0;
30 *dest = *src;
31 return dest;
32}
33
34
35struct tm *
36gmtime_r (time_t const * restrict t, struct tm * restrict tp)
37{
38 return copy_tm_result (tp, gmtime (t));
39}
40
41struct tm *
42localtime_r (time_t const * restrict t, struct tm * restrict tp)
43{
44 return copy_tm_result (tp, localtime (t));
45}
diff --git a/m4/extensions.m4 b/m4/extensions.m4
new file mode 100644
index 00000000000..1330503f0d7
--- /dev/null
+++ b/m4/extensions.m4
@@ -0,0 +1,118 @@
1# serial 9 -*- Autoconf -*-
2# Enable extensions on systems that normally disable them.
3
4# Copyright (C) 2003, 2006-2011 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
10# Autoconf. Perhaps we can remove this once we can assume Autoconf
11# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
12# enough in this area it's likely we'll need to redefine
13# AC_USE_SYSTEM_EXTENSIONS for quite some time.
14
15# If autoconf reports a warning
16# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
17# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
18# the fix is
19# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
20# but always AC_REQUIREd,
21# 2) to ensure that for each occurrence of
22# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
23# or
24# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
25# the corresponding gnulib module description has 'extensions' among
26# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
27# invocation occurs in gl_EARLY, not in gl_INIT.
28
29# AC_USE_SYSTEM_EXTENSIONS
30# ------------------------
31# Enable extensions on systems that normally disable them,
32# typically due to standards-conformance issues.
33# Remember that #undef in AH_VERBATIM gets replaced with #define by
34# AC_DEFINE. The goal here is to define all known feature-enabling
35# macros, then, if reports of conflicts are made, disable macros that
36# cause problems on some platforms (such as __EXTENSIONS__).
37AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
38[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
39AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
40
41 AC_REQUIRE([AC_CANONICAL_HOST])
42
43 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
44 if test "$MINIX" = yes; then
45 AC_DEFINE([_POSIX_SOURCE], [1],
46 [Define to 1 if you need to in order for `stat' and other
47 things to work.])
48 AC_DEFINE([_POSIX_1_SOURCE], [2],
49 [Define to 2 if the system does not provide POSIX.1 features
50 except with this defined.])
51 AC_DEFINE([_MINIX], [1],
52 [Define to 1 if on MINIX.])
53 fi
54
55 dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
56 dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
57 dnl provided.
58 case "$host_os" in
59 hpux*)
60 AC_DEFINE([_XOPEN_SOURCE], [500],
61 [Define to 500 only on HP-UX.])
62 ;;
63 esac
64
65 AH_VERBATIM([__EXTENSIONS__],
66[/* Enable extensions on AIX 3, Interix. */
67#ifndef _ALL_SOURCE
68# undef _ALL_SOURCE
69#endif
70/* Enable GNU extensions on systems that have them. */
71#ifndef _GNU_SOURCE
72# undef _GNU_SOURCE
73#endif
74/* Enable threading extensions on Solaris. */
75#ifndef _POSIX_PTHREAD_SEMANTICS
76# undef _POSIX_PTHREAD_SEMANTICS
77#endif
78/* Enable extensions on HP NonStop. */
79#ifndef _TANDEM_SOURCE
80# undef _TANDEM_SOURCE
81#endif
82/* Enable general extensions on Solaris. */
83#ifndef __EXTENSIONS__
84# undef __EXTENSIONS__
85#endif
86])
87 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
88 [ac_cv_safe_to_define___extensions__],
89 [AC_COMPILE_IFELSE(
90 [AC_LANG_PROGRAM([[
91# define __EXTENSIONS__ 1
92 ]AC_INCLUDES_DEFAULT])],
93 [ac_cv_safe_to_define___extensions__=yes],
94 [ac_cv_safe_to_define___extensions__=no])])
95 test $ac_cv_safe_to_define___extensions__ = yes &&
96 AC_DEFINE([__EXTENSIONS__])
97 AC_DEFINE([_ALL_SOURCE])
98 AC_DEFINE([_GNU_SOURCE])
99 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
100 AC_DEFINE([_TANDEM_SOURCE])
101])# AC_USE_SYSTEM_EXTENSIONS
102
103# gl_USE_SYSTEM_EXTENSIONS
104# ------------------------
105# Enable extensions on systems that normally disable them,
106# typically due to standards-conformance issues.
107AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
108[
109 dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
110 dnl gnulib does not need it. But if it gets required by third-party macros
111 dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
112 dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
113 dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
114 dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
115 AC_REQUIRE([AC_GNU_SOURCE])
116
117 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
118])
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 104536eba99..fc6e8c76acb 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,12 +15,13 @@
15 15
16 16
17# Specification in the form of a command-line invocation: 17# Specification in the form of a command-line invocation:
18# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr 18# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr mktime
19 19
20# Specification in the form of a few gnulib-tool.m4 macro invocations: 20# Specification in the form of a few gnulib-tool.m4 macro invocations:
21gl_LOCAL_DIR([]) 21gl_LOCAL_DIR([])
22gl_MODULES([ 22gl_MODULES([
23 ftoastr 23 ftoastr
24 mktime
24]) 25])
25gl_AVOID([]) 26gl_AVOID([])
26gl_SOURCE_BASE([lib]) 27gl_SOURCE_BASE([lib])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 6995e1b0098..7fdec4a503c 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -26,8 +26,19 @@ AC_DEFUN([gl_EARLY],
26 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable 26 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
27 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable 27 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
28 AC_REQUIRE([AC_PROG_RANLIB]) 28 AC_REQUIRE([AC_PROG_RANLIB])
29 # Code from module arg-nonnull:
30 # Code from module c++defs:
31 # Code from module extensions:
32 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
29 # Code from module ftoastr: 33 # Code from module ftoastr:
34 # Code from module include_next:
30 # Code from module intprops: 35 # Code from module intprops:
36 # Code from module mktime:
37 # Code from module multiarch:
38 # Code from module stddef:
39 # Code from module time:
40 # Code from module time_r:
41 # Code from module warn-on-use:
31]) 42])
32 43
33# This macro should be invoked from ./configure.in, in the section 44# This macro should be invoked from ./configure.in, in the section
@@ -46,9 +57,26 @@ AC_DEFUN([gl_INIT],
46 m4_pushdef([gl_LIBSOURCES_DIR], []) 57 m4_pushdef([gl_LIBSOURCES_DIR], [])
47 gl_COMMON 58 gl_COMMON
48 gl_source_base='lib' 59 gl_source_base='lib'
60 # Code from module arg-nonnull:
61 # Code from module c++defs:
62 # Code from module extensions:
49 # Code from module ftoastr: 63 # Code from module ftoastr:
50 AC_REQUIRE([gl_C99_STRTOLD]) 64 AC_REQUIRE([gl_C99_STRTOLD])
65 # Code from module include_next:
51 # Code from module intprops: 66 # Code from module intprops:
67 # Code from module mktime:
68 gl_FUNC_MKTIME
69 gl_TIME_MODULE_INDICATOR([mktime])
70 # Code from module multiarch:
71 gl_MULTIARCH
72 # Code from module stddef:
73 gl_STDDEF_H
74 # Code from module time:
75 gl_HEADER_TIME_H
76 # Code from module time_r:
77 gl_TIME_R
78 gl_TIME_MODULE_INDICATOR([time_r])
79 # Code from module warn-on-use:
52 # End of code from modules 80 # End of code from modules
53 m4_ifval(gl_LIBSOURCES_LIST, [ 81 m4_ifval(gl_LIBSOURCES_LIST, [
54 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || 82 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
@@ -189,12 +217,29 @@ AC_DEFUN([gltests_LIBSOURCES], [
189# This macro records the list of files which have been installed by 217# This macro records the list of files which have been installed by
190# gnulib-tool and may be removed by future gnulib-tool invocations. 218# gnulib-tool and may be removed by future gnulib-tool invocations.
191AC_DEFUN([gl_FILE_LIST], [ 219AC_DEFUN([gl_FILE_LIST], [
220 build-aux/arg-nonnull.h
221 build-aux/c++defs.h
222 build-aux/warn-on-use.h
192 lib/dtoastr.c 223 lib/dtoastr.c
193 lib/ftoastr.c 224 lib/ftoastr.c
194 lib/ftoastr.h 225 lib/ftoastr.h
195 lib/intprops.h 226 lib/intprops.h
196 lib/ldtoastr.c 227 lib/ldtoastr.c
228 lib/mktime-internal.h
229 lib/mktime.c
230 lib/stddef.in.h
231 lib/time.in.h
232 lib/time_r.c
197 m4/00gnulib.m4 233 m4/00gnulib.m4
198 m4/c-strtod.m4 234 m4/c-strtod.m4
235 m4/extensions.m4
199 m4/gnulib-common.m4 236 m4/gnulib-common.m4
237 m4/include_next.m4
238 m4/mktime.m4
239 m4/multiarch.m4
240 m4/stddef_h.m4
241 m4/time_h.m4
242 m4/time_r.m4
243 m4/warn-on-use.m4
244 m4/wchar_t.m4
200]) 245])
diff --git a/m4/include_next.m4 b/m4/include_next.m4
new file mode 100644
index 00000000000..ed05e1de964
--- /dev/null
+++ b/m4/include_next.m4
@@ -0,0 +1,217 @@
1# include_next.m4 serial 16
2dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert and Derek Price.
8
9dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
10dnl
11dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
12dnl 'include' otherwise.
13dnl
14dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
15dnl supports it in the special case that it is the first include directive in
16dnl the given file, or to 'include' otherwise.
17dnl
18dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
19dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
20dnl '#pragma GCC system_header' has the same effect as if the file was found
21dnl through the include search path specified with '-isystem' options (as
22dnl opposed to the search path specified with '-I' options). Namely, gcc
23dnl does not warn about some things, and on some systems (Solaris and Interix)
24dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
25dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
26dnl of plain '__STDC__'.
27dnl
28dnl PRAGMA_COLUMNS can be used in files that override system header files, so
29dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
30dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
31dnl has the effect of truncating the lines of that file and all files that it
32dnl includes to 80 columns) and the gnulib file has lines longer than 80
33dnl columns.
34
35AC_DEFUN([gl_INCLUDE_NEXT],
36[
37 AC_LANG_PREPROC_REQUIRE()
38 AC_CACHE_CHECK([whether the preprocessor supports include_next],
39 [gl_cv_have_include_next],
40 [rm -rf conftestd1a conftestd1b conftestd2
41 mkdir conftestd1a conftestd1b conftestd2
42 dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on
43 dnl AIX 6.1 support include_next when used as first preprocessor directive
44 dnl in a file, but not when preceded by another include directive. Check
45 dnl for this bug by including <stdio.h>.
46 dnl Additionally, with this same compiler, include_next is a no-op when
47 dnl used in a header file that was included by specifying its absolute
48 dnl file name. Despite these two bugs, include_next is used in the
49 dnl compiler's <math.h>. By virtue of the second bug, we need to use
50 dnl include_next as well in this case.
51 cat <<EOF > conftestd1a/conftest.h
52#define DEFINED_IN_CONFTESTD1
53#include_next <conftest.h>
54#ifdef DEFINED_IN_CONFTESTD2
55int foo;
56#else
57#error "include_next doesn't work"
58#endif
59EOF
60 cat <<EOF > conftestd1b/conftest.h
61#define DEFINED_IN_CONFTESTD1
62#include <stdio.h>
63#include_next <conftest.h>
64#ifdef DEFINED_IN_CONFTESTD2
65int foo;
66#else
67#error "include_next doesn't work"
68#endif
69EOF
70 cat <<EOF > conftestd2/conftest.h
71#ifndef DEFINED_IN_CONFTESTD1
72#error "include_next test doesn't work"
73#endif
74#define DEFINED_IN_CONFTESTD2
75EOF
76 gl_save_CPPFLAGS="$CPPFLAGS"
77 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
78dnl We intentionally avoid using AC_LANG_SOURCE here.
79 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
80 [gl_cv_have_include_next=yes],
81 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
82 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
83 [gl_cv_have_include_next=buggy],
84 [gl_cv_have_include_next=no])
85 ])
86 CPPFLAGS="$gl_save_CPPFLAGS"
87 rm -rf conftestd1a conftestd1b conftestd2
88 ])
89 PRAGMA_SYSTEM_HEADER=
90 if test $gl_cv_have_include_next = yes; then
91 INCLUDE_NEXT=include_next
92 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
93 if test -n "$GCC"; then
94 PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
95 fi
96 else
97 if test $gl_cv_have_include_next = buggy; then
98 INCLUDE_NEXT=include
99 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
100 else
101 INCLUDE_NEXT=include
102 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
103 fi
104 fi
105 AC_SUBST([INCLUDE_NEXT])
106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
107 AC_SUBST([PRAGMA_SYSTEM_HEADER])
108 AC_CACHE_CHECK([whether system header files limit the line length],
109 [gl_cv_pragma_columns],
110 [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
111 AC_EGREP_CPP([choke me],
112 [
113#ifdef __TANDEM
114choke me
115#endif
116 ],
117 [gl_cv_pragma_columns=yes],
118 [gl_cv_pragma_columns=no])
119 ])
120 if test $gl_cv_pragma_columns = yes; then
121 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
122 else
123 PRAGMA_COLUMNS=
124 fi
125 AC_SUBST([PRAGMA_COLUMNS])
126])
127
128# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
129# ------------------------------------------
130# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
131# '<foo.h>'; otherwise define it to be
132# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
133# Also, if #include_next works as first preprocessing directive in a file,
134# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to
135# be
136# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
137# That way, a header file with the following line:
138# #@INCLUDE_NEXT@ @NEXT_FOO_H@
139# or
140# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
141# behaves (after sed substitution) as if it contained
142# #include_next <foo.h>
143# even if the compiler does not support include_next.
144# The three "///" are to pacify Sun C 5.8, which otherwise would say
145# "warning: #include of /usr/include/... may be non-portable".
146# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
147# Note: This macro assumes that the header file is not empty after
148# preprocessing, i.e. it does not only define preprocessor macros but also
149# provides some type/enum definitions or function/variable declarations.
150AC_DEFUN([gl_CHECK_NEXT_HEADERS],
151[
152 AC_REQUIRE([gl_INCLUDE_NEXT])
153 AC_REQUIRE([AC_CANONICAL_HOST])
154 AC_CHECK_HEADERS_ONCE([$1])
155
156 m4_foreach_w([gl_HEADER_NAME], [$1],
157 [AS_VAR_PUSHDEF([gl_next_header],
158 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
159 if test $gl_cv_have_include_next = yes; then
160 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
161 else
162 AC_CACHE_CHECK(
163 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
164 m4_defn([gl_next_header]),
165 [AS_VAR_PUSHDEF([gl_header_exists],
166 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
167 if test AS_VAR_GET(gl_header_exists) = yes; then
168 AC_LANG_CONFTEST(
169 [AC_LANG_SOURCE(
170 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
171 )])
172 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
173 dnl that contain only a #include of other header files and no
174 dnl non-comment tokens of their own. This leads to a failure to
175 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
176 dnl and others. The workaround is to force preservation of comments
177 dnl through option -C. This ensures all necessary #line directives
178 dnl are present. GCC supports option -C as well.
179 case "$host_os" in
180 aix*) gl_absname_cpp="$ac_cpp -C" ;;
181 *) gl_absname_cpp="$ac_cpp" ;;
182 esac
183 dnl eval is necessary to expand gl_absname_cpp.
184 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
185 dnl so use subshell.
186 AS_VAR_SET([gl_next_header],
187 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
188 sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
189 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
190 s#^/[^/]#//&#
191 p
192 q
193 }'`'"'])
194 else
195 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
196 fi
197 AS_VAR_POPDEF([gl_header_exists])])
198 fi
199 AC_SUBST(
200 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
201 [AS_VAR_GET([gl_next_header])])
202 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
203 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
204 gl_next_as_first_directive='<'gl_HEADER_NAME'>'
205 else
206 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
207 gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
208 fi
209 AC_SUBST(
210 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
211 [$gl_next_as_first_directive])
212 AS_VAR_POPDEF([gl_next_header])])
213])
214
215# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE;
216# this fallback is safe for all earlier autoconf versions.
217m4_define_default([AC_LANG_DEFINES_PROVIDED])
diff --git a/m4/mktime.m4 b/m4/mktime.m4
new file mode 100644
index 00000000000..f2b131ba456
--- /dev/null
+++ b/m4/mktime.m4
@@ -0,0 +1,238 @@
1# serial 17
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl From Jim Meyering.
9
10# Redefine AC_FUNC_MKTIME, because it is no longer maintained in Autoconf.
11# AC_FUNC_MKTIME
12# --------------
13AC_DEFUN([AC_FUNC_MKTIME],
14[AC_CHECK_HEADERS_ONCE([unistd.h])
15AC_CHECK_FUNCS_ONCE([alarm])
16AC_REQUIRE([gl_MULTIARCH])
17if test $APPLE_UNIVERSAL_BUILD = 1; then
18 # A universal build on Apple MacOS X platforms.
19 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
20 # But we need a configuration result that is valid in both modes.
21 ac_cv_func_working_mktime=no
22fi
23AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime],
24[AC_RUN_IFELSE([AC_LANG_SOURCE(
25[[/* Test program from Paul Eggert and Tony Leneis. */
26#include <limits.h>
27#include <stdlib.h>
28#include <time.h>
29
30#ifdef HAVE_UNISTD_H
31# include <unistd.h>
32#endif
33
34#ifndef HAVE_ALARM
35# define alarm(X) /* empty */
36#endif
37
38/* Work around redefinition to rpl_putenv by other config tests. */
39#undef putenv
40
41static time_t time_t_max;
42static time_t time_t_min;
43
44/* Values we'll use to set the TZ environment variable. */
45static char *tz_strings[] = {
46 (char *) 0, "TZ=GMT0", "TZ=JST-9",
47 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
48};
49#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
50
51/* Return 0 if mktime fails to convert a date in the spring-forward gap.
52 Based on a problem report from Andreas Jaeger. */
53static int
54spring_forward_gap ()
55{
56 /* glibc (up to about 1998-10-07) failed this test. */
57 struct tm tm;
58
59 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
60 instead of "TZ=America/Vancouver" in order to detect the bug even
61 on systems that don't support the Olson extension, or don't have the
62 full zoneinfo tables installed. */
63 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
64
65 tm.tm_year = 98;
66 tm.tm_mon = 3;
67 tm.tm_mday = 5;
68 tm.tm_hour = 2;
69 tm.tm_min = 0;
70 tm.tm_sec = 0;
71 tm.tm_isdst = -1;
72 return mktime (&tm) != (time_t) -1;
73}
74
75static int
76mktime_test1 (time_t now)
77{
78 struct tm *lt;
79 return ! (lt = localtime (&now)) || mktime (lt) == now;
80}
81
82static int
83mktime_test (time_t now)
84{
85 return (mktime_test1 (now)
86 && mktime_test1 ((time_t) (time_t_max - now))
87 && mktime_test1 ((time_t) (time_t_min + now)));
88}
89
90static int
91irix_6_4_bug ()
92{
93 /* Based on code from Ariel Faigon. */
94 struct tm tm;
95 tm.tm_year = 96;
96 tm.tm_mon = 3;
97 tm.tm_mday = 0;
98 tm.tm_hour = 0;
99 tm.tm_min = 0;
100 tm.tm_sec = 0;
101 tm.tm_isdst = -1;
102 mktime (&tm);
103 return tm.tm_mon == 2 && tm.tm_mday == 31;
104}
105
106static int
107bigtime_test (int j)
108{
109 struct tm tm;
110 time_t now;
111 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
112 now = mktime (&tm);
113 if (now != (time_t) -1)
114 {
115 struct tm *lt = localtime (&now);
116 if (! (lt
117 && lt->tm_year == tm.tm_year
118 && lt->tm_mon == tm.tm_mon
119 && lt->tm_mday == tm.tm_mday
120 && lt->tm_hour == tm.tm_hour
121 && lt->tm_min == tm.tm_min
122 && lt->tm_sec == tm.tm_sec
123 && lt->tm_yday == tm.tm_yday
124 && lt->tm_wday == tm.tm_wday
125 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
126 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
127 return 0;
128 }
129 return 1;
130}
131
132static int
133year_2050_test ()
134{
135 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
136 ignoring leap seconds. */
137 unsigned long int answer = 2527315200UL;
138
139 struct tm tm;
140 time_t t;
141 tm.tm_year = 2050 - 1900;
142 tm.tm_mon = 2 - 1;
143 tm.tm_mday = 1;
144 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
145 tm.tm_isdst = -1;
146
147 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
148 instead of "TZ=America/Vancouver" in order to detect the bug even
149 on systems that don't support the Olson extension, or don't have the
150 full zoneinfo tables installed. */
151 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
152
153 t = mktime (&tm);
154
155 /* Check that the result is either a failure, or close enough
156 to the correct answer that we can assume the discrepancy is
157 due to leap seconds. */
158 return (t == (time_t) -1
159 || (0 < t && answer - 120 <= t && t <= answer + 120));
160}
161
162int
163main ()
164{
165 int result = 0;
166 time_t t, delta;
167 int i, j;
168
169 /* This test makes some buggy mktime implementations loop.
170 Give up after 60 seconds; a mktime slower than that
171 isn't worth using anyway. */
172 alarm (60);
173
174 for (;;)
175 {
176 t = (time_t_max << 1) + 1;
177 if (t <= time_t_max)
178 break;
179 time_t_max = t;
180 }
181 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
182
183 delta = time_t_max / 997; /* a suitable prime number */
184 for (i = 0; i < N_STRINGS; i++)
185 {
186 if (tz_strings[i])
187 putenv (tz_strings[i]);
188
189 for (t = 0; t <= time_t_max - delta; t += delta)
190 if (! mktime_test (t))
191 result |= 1;
192 if (! (mktime_test ((time_t) 1)
193 && mktime_test ((time_t) (60 * 60))
194 && mktime_test ((time_t) (60 * 60 * 24))))
195 result |= 2;
196
197 for (j = 1; ; j <<= 1)
198 if (! bigtime_test (j))
199 result |= 4;
200 else if (INT_MAX / 2 < j)
201 break;
202 if (! bigtime_test (INT_MAX))
203 result |= 8;
204 }
205 if (! irix_6_4_bug ())
206 result |= 16;
207 if (! spring_forward_gap ())
208 result |= 32;
209 if (! year_2050_test ())
210 result |= 64;
211 return result;
212}]])],
213 [ac_cv_func_working_mktime=yes],
214 [ac_cv_func_working_mktime=no],
215 [ac_cv_func_working_mktime=no])])
216if test $ac_cv_func_working_mktime = no; then
217 AC_LIBOBJ([mktime])
218fi
219])# AC_FUNC_MKTIME
220
221AC_DEFUN([gl_FUNC_MKTIME],
222[
223 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
224 AC_FUNC_MKTIME
225 dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]).
226 if test $ac_cv_func_working_mktime = no; then
227 REPLACE_MKTIME=1
228 gl_PREREQ_MKTIME
229 else
230 REPLACE_MKTIME=0
231 fi
232])
233
234# Prerequisites of lib/mktime.c.
235AC_DEFUN([gl_PREREQ_MKTIME],
236[
237 AC_REQUIRE([AC_C_INLINE])
238])
diff --git a/m4/multiarch.m4 b/m4/multiarch.m4
new file mode 100644
index 00000000000..47e3e63a3ed
--- /dev/null
+++ b/m4/multiarch.m4
@@ -0,0 +1,65 @@
1# multiarch.m4 serial 5
2dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# Determine whether the compiler is or may be producing universal binaries.
8#
9# On MacOS X 10.5 and later systems, the user can create libraries and
10# executables that work on multiple system types--known as "fat" or
11# "universal" binaries--by specifying multiple '-arch' options to the
12# compiler but only a single '-arch' option to the preprocessor. Like
13# this:
14#
15# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
16# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
17# CPP="gcc -E" CXXCPP="g++ -E"
18#
19# Detect this situation and set the macro AA_APPLE_UNIVERSAL_BUILD at the
20# beginning of config.h and set APPLE_UNIVERSAL_BUILD accordingly.
21
22AC_DEFUN_ONCE([gl_MULTIARCH],
23[
24 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
25 gl_cv_c_multiarch=no
26 AC_COMPILE_IFELSE(
27 [AC_LANG_SOURCE(
28 [[#ifndef __APPLE_CC__
29 not a universal capable compiler
30 #endif
31 typedef int dummy;
32 ]])],
33 [
34 dnl Check for potential -arch flags. It is not universal unless
35 dnl there are at least two -arch flags with different values.
36 arch=
37 prev=
38 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
39 if test -n "$prev"; then
40 case $word in
41 i?86 | x86_64 | ppc | ppc64)
42 if test -z "$arch" || test "$arch" = "$word"; then
43 arch="$word"
44 else
45 gl_cv_c_multiarch=yes
46 fi
47 ;;
48 esac
49 prev=
50 else
51 if test "x$word" = "x-arch"; then
52 prev=arch
53 fi
54 fi
55 done
56 ])
57 if test $gl_cv_c_multiarch = yes; then
58 AC_DEFINE([AA_APPLE_UNIVERSAL_BUILD], [1],
59 [Define if the compiler is building for multiple architectures of Apple platforms at once.])
60 APPLE_UNIVERSAL_BUILD=1
61 else
62 APPLE_UNIVERSAL_BUILD=0
63 fi
64 AC_SUBST([APPLE_UNIVERSAL_BUILD])
65])
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4
new file mode 100644
index 00000000000..3a5ecc57117
--- /dev/null
+++ b/m4/stddef_h.m4
@@ -0,0 +1,45 @@
1dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
2# stddef_h.m4 serial 2
3dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_STDDEF_H],
9[
10 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
11 AC_REQUIRE([gt_TYPE_WCHAR_T])
12 if test $gt_cv_c_wchar_t = no; then
13 HAVE_WCHAR_T=0
14 STDDEF_H=stddef.h
15 fi
16 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
17 [gl_cv_decl_null_works],
18 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
19 int test[2 * (sizeof NULL == sizeof (void *)) -1];
20]])],
21 [gl_cv_decl_null_works=yes],
22 [gl_cv_decl_null_works=no])])
23 if test $gl_cv_decl_null_works = no; then
24 REPLACE_NULL=1
25 STDDEF_H=stddef.h
26 fi
27 if test -n "$STDDEF_H"; then
28 gl_CHECK_NEXT_HEADERS([stddef.h])
29 fi
30])
31
32AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
33[
34 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
35 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
36 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
37])
38
39AC_DEFUN([gl_STDDEF_H_DEFAULTS],
40[
41 dnl Assume proper GNU behavior unless another module says otherwise.
42 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
43 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
44 STDDEF_H=''; AC_SUBST([STDDEF_H])
45])
diff --git a/m4/time_h.m4 b/m4/time_h.m4
new file mode 100644
index 00000000000..dc601c574ae
--- /dev/null
+++ b/m4/time_h.m4
@@ -0,0 +1,109 @@
1# Configure a more-standard replacement for <time.h>.
2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc.
4
5# serial 3
6
7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# Written by Paul Eggert and Jim Meyering.
12
13AC_DEFUN([gl_HEADER_TIME_H],
14[
15 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
16 dnl once only, before all statements that occur in other macros.
17 AC_REQUIRE([gl_HEADER_TIME_H_BODY])
18])
19
20AC_DEFUN([gl_HEADER_TIME_H_BODY],
21[
22 AC_REQUIRE([AC_C_RESTRICT])
23 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
24 gl_CHECK_NEXT_HEADERS([time.h])
25 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
26])
27
28dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
29dnl in time.h, sys/time.h, or pthread.h.
30
31AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
32[
33 AC_CHECK_HEADERS_ONCE([sys/time.h])
34 AC_CACHE_CHECK([for struct timespec in <time.h>],
35 [gl_cv_sys_struct_timespec_in_time_h],
36 [AC_COMPILE_IFELSE(
37 [AC_LANG_PROGRAM(
38 [[#include <time.h>
39 ]],
40 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
41 [gl_cv_sys_struct_timespec_in_time_h=yes],
42 [gl_cv_sys_struct_timespec_in_time_h=no])])
43
44 TIME_H_DEFINES_STRUCT_TIMESPEC=0
45 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
46 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
47 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
48 TIME_H_DEFINES_STRUCT_TIMESPEC=1
49 else
50 AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
51 [gl_cv_sys_struct_timespec_in_sys_time_h],
52 [AC_COMPILE_IFELSE(
53 [AC_LANG_PROGRAM(
54 [[#include <sys/time.h>
55 ]],
56 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
57 [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
58 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
59 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
60 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
61 else
62 AC_CACHE_CHECK([for struct timespec in <pthread.h>],
63 [gl_cv_sys_struct_timespec_in_pthread_h],
64 [AC_COMPILE_IFELSE(
65 [AC_LANG_PROGRAM(
66 [[#include <pthread.h>
67 ]],
68 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
69 [gl_cv_sys_struct_timespec_in_pthread_h=yes],
70 [gl_cv_sys_struct_timespec_in_pthread_h=no])])
71 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
72 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
73 fi
74 fi
75 fi
76 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
77 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
78 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
79])
80
81AC_DEFUN([gl_TIME_MODULE_INDICATOR],
82[
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
84 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88])
89
90AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
91[
92 GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
93 GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
94 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
97 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
99 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
100 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
101 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
102 dnl If another module says to replace or to not replace, do that.
103 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
104 dnl this lets maintainers check for portability.
105 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
106 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
107 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
108 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
109])
diff --git a/m4/time_r.m4 b/m4/time_r.m4
new file mode 100644
index 00000000000..9bb28005fc0
--- /dev/null
+++ b/m4/time_r.m4
@@ -0,0 +1,62 @@
1dnl Reentrant time functions: localtime_r, gmtime_r.
2
3dnl Copyright (C) 2003, 2006-2011 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Paul Eggert.
9
10AC_DEFUN([gl_TIME_R],
11[
12 dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14
15 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
16 AC_REQUIRE([AC_C_RESTRICT])
17
18 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
19 dnl not defined.
20 AC_CHECK_DECLS_ONCE([localtime_r])
21 if test $ac_cv_have_decl_localtime_r = no; then
22 HAVE_DECL_LOCALTIME_R=0
23 fi
24
25 AC_CHECK_FUNCS_ONCE([localtime_r])
26 if test $ac_cv_func_localtime_r = yes; then
27 HAVE_LOCALTIME_R=1
28 AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
29 [gl_cv_time_r_posix],
30 [AC_COMPILE_IFELSE(
31 [AC_LANG_PROGRAM(
32 [[#include <time.h>]],
33 [[/* We don't need to append 'restrict's to the argument types,
34 even though the POSIX signature has the 'restrict's,
35 since C99 says they can't affect type compatibility. */
36 struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
37 if (ptr) return 0;
38 /* Check the return type is a pointer.
39 On HP-UX 10 it is 'int'. */
40 *localtime_r (0, 0);]])
41 ],
42 [gl_cv_time_r_posix=yes],
43 [gl_cv_time_r_posix=no])
44 ])
45 if test $gl_cv_time_r_posix = yes; then
46 REPLACE_LOCALTIME_R=0
47 else
48 REPLACE_LOCALTIME_R=1
49 fi
50 else
51 HAVE_LOCALTIME_R=0
52 fi
53 if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
54 AC_LIBOBJ([time_r])
55 gl_PREREQ_TIME_R
56 fi
57])
58
59# Prerequisites of lib/time_r.c.
60AC_DEFUN([gl_PREREQ_TIME_R], [
61 :
62])
diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4
new file mode 100644
index 00000000000..e0d0f276403
--- /dev/null
+++ b/m4/warn-on-use.m4
@@ -0,0 +1,45 @@
1# warn-on-use.m4 serial 2
2dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
8# ---------------------------------------
9# For each whitespace-separated element in the list of NAMES, define
10# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
11# even after being undefined as a macro.
12#
13# See warn-on-use.h for some hints on how to poison function names, as
14# well as ideas on poisoning global variables and macros. NAMES may
15# include global variables, but remember that only functions work with
16# _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single
17# header, but if the replacement header pulls in other headers because
18# some systems declare functions in the wrong header, then INCLUDES
19# should do likewise.
20#
21# If you assume C89, then it is generally safe to assume declarations
22# for functions declared in that standard (such as gets) without
23# needing gl_WARN_ON_USE_PREPARE.
24AC_DEFUN([gl_WARN_ON_USE_PREPARE],
25[
26 m4_foreach_w([gl_decl], [$2],
27 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
28 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
29 undefining macros.])])dnl
30 for gl_func in m4_flatten([$2]); do
31 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
32 AC_CACHE_CHECK([whether $gl_func is declared without a macro],
33 gl_Symbol,
34 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
35[@%:@undef $gl_func
36 (void) $gl_func;])],
37 [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
38 AS_VAR_IF(gl_Symbol, [yes],
39 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
40 dnl shortcut - if the raw declaration exists, then set a cache
41 dnl variable to allow skipping any later AC_CHECK_DECL efforts
42 eval ac_cv_have_decl_$gl_func=yes])
43 AS_VAR_POPDEF([gl_Symbol])dnl
44 done
45])
diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4
new file mode 100644
index 00000000000..d2c03c42d2b
--- /dev/null
+++ b/m4/wchar_t.m4
@@ -0,0 +1,24 @@
1# wchar_t.m4 serial 4 (gettext-0.18.2)
2dnl Copyright (C) 2002-2003, 2008-2011 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether <stddef.h> has the 'wchar_t' type.
9dnl Prerequisite: AC_PROG_CC
10
11AC_DEFUN([gt_TYPE_WCHAR_T],
12[
13 AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <stddef.h>
17 wchar_t foo = (wchar_t)'\0';]],
18 [[]])],
19 [gt_cv_c_wchar_t=yes],
20 [gt_cv_c_wchar_t=no])])
21 if test $gt_cv_c_wchar_t = yes; then
22 AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.])
23 fi
24])
diff --git a/src/config.in b/src/config.in
index e50e1e5af45..89a057fc00e 100644
--- a/src/config.in
+++ b/src/config.in
@@ -27,12 +27,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27#define EMACS_CONFIG_H 27#define EMACS_CONFIG_H
28 28
29 29
30/* Define if the compiler is building for multiple architectures of Apple
31 platforms at once. */
32#undef AA_APPLE_UNIVERSAL_BUILD
33
30/* Define if building universal (internal helper macro) */ 34/* Define if building universal (internal helper macro) */
31#undef AC_APPLE_UNIVERSAL_BUILD 35#undef AC_APPLE_UNIVERSAL_BUILD
32 36
33/* Define to 1 if the mktime function is broken. */
34#undef BROKEN_MKTIME
35
36/* Define if Emacs cannot be dumped on your system. */ 37/* Define if Emacs cannot be dumped on your system. */
37#undef CANNOT_DUMP 38#undef CANNOT_DUMP
38 39
@@ -86,6 +87,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
86/* Define to 1 if gettimeofday accepts only one argument. */ 87/* Define to 1 if gettimeofday accepts only one argument. */
87#undef GETTIMEOFDAY_ONE_ARGUMENT 88#undef GETTIMEOFDAY_ONE_ARGUMENT
88 89
90/* Define to 1 when the gnulib module mktime should be tested. */
91#undef GNULIB_TEST_MKTIME
92
93/* Define to 1 when the gnulib module time_r should be tested. */
94#undef GNULIB_TEST_TIME_R
95
89/* Define to 1 if you want to use the GNU memory allocator. */ 96/* Define to 1 if you want to use the GNU memory allocator. */
90#undef GNU_MALLOC 97#undef GNU_MALLOC
91 98
@@ -135,6 +142,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
135/* Define to 1 if you have the `dbus_watch_get_unix_fd' function. */ 142/* Define to 1 if you have the `dbus_watch_get_unix_fd' function. */
136#undef HAVE_DBUS_WATCH_GET_UNIX_FD 143#undef HAVE_DBUS_WATCH_GET_UNIX_FD
137 144
145/* Define to 1 if you have the declaration of `localtime_r', and to 0 if you
146 don't. */
147#undef HAVE_DECL_LOCALTIME_R
148
138/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you 149/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you
139 don't. */ 150 don't. */
140#undef HAVE_DECL_SYS_SIGLIST 151#undef HAVE_DECL_SYS_SIGLIST
@@ -429,6 +440,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
429/* Define to 1 if you have the <locale.h> header file. */ 440/* Define to 1 if you have the <locale.h> header file. */
430#undef HAVE_LOCALE_H 441#undef HAVE_LOCALE_H
431 442
443/* Define to 1 if you have the `localtime_r' function. */
444#undef HAVE_LOCALTIME_R
445
432/* Define to 1 if you have the `logb' function. */ 446/* Define to 1 if you have the `logb' function. */
433#undef HAVE_LOGB 447#undef HAVE_LOGB
434 448
@@ -497,9 +511,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
497/* Define to 1 if you have the `mkstemp' function. */ 511/* Define to 1 if you have the `mkstemp' function. */
498#undef HAVE_MKSTEMP 512#undef HAVE_MKSTEMP
499 513
500/* Define to 1 if you have the `mktime' function. */
501#undef HAVE_MKTIME
502
503/* Define to 1 if you have a working `mmap' system call. */ 514/* Define to 1 if you have a working `mmap' system call. */
504#undef HAVE_MMAP 515#undef HAVE_MMAP
505 516
@@ -606,6 +617,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
606/* Define to 1 if `speed_t' is declared by <termios.h>. */ 617/* Define to 1 if `speed_t' is declared by <termios.h>. */
607#undef HAVE_SPEED_T 618#undef HAVE_SPEED_T
608 619
620/* Define to 1 if you have the <stddef.h> header file. */
621#undef HAVE_STDDEF_H
622
609/* Define to 1 if you have the <stdint.h> header file. */ 623/* Define to 1 if you have the <stdint.h> header file. */
610#undef HAVE_STDINT_H 624#undef HAVE_STDINT_H
611 625
@@ -720,6 +734,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
720/* Define to 1 if `struct timeval' is declared by <sys/time.h>. */ 734/* Define to 1 if `struct timeval' is declared by <sys/time.h>. */
721#undef HAVE_TIMEVAL 735#undef HAVE_TIMEVAL
722 736
737/* Define to 1 if you have the <time.h> header file. */
738#undef HAVE_TIME_H
739
723/* Define to 1 if `tm_gmtoff' is member of `struct tm'. */ 740/* Define to 1 if `tm_gmtoff' is member of `struct tm'. */
724#undef HAVE_TM_GMTOFF 741#undef HAVE_TM_GMTOFF
725 742
@@ -761,6 +778,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
761/* Define to 1 if you have the <vfork.h> header file. */ 778/* Define to 1 if you have the <vfork.h> header file. */
762#undef HAVE_VFORK_H 779#undef HAVE_VFORK_H
763 780
781/* Define if you have the 'wchar_t' type. */
782#undef HAVE_WCHAR_T
783
764/* Define if you have a window system. */ 784/* Define if you have a window system. */
765#undef HAVE_WINDOW_SYSTEM 785#undef HAVE_WINDOW_SYSTEM
766 786
@@ -966,28 +986,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
966/* Define to 1 if using the Motif X toolkit. */ 986/* Define to 1 if using the Motif X toolkit. */
967#undef USE_MOTIF 987#undef USE_MOTIF
968 988
969/* Enable extensions on AIX 3, Interix. */
970#ifndef _ALL_SOURCE
971# undef _ALL_SOURCE
972#endif
973/* Enable GNU extensions on systems that have them. */
974#ifndef _GNU_SOURCE
975# undef _GNU_SOURCE
976#endif
977/* Enable threading extensions on Solaris. */
978#ifndef _POSIX_PTHREAD_SEMANTICS
979# undef _POSIX_PTHREAD_SEMANTICS
980#endif
981/* Enable extensions on HP NonStop. */
982#ifndef _TANDEM_SOURCE
983# undef _TANDEM_SOURCE
984#endif
985/* Enable general extensions on Solaris. */
986#ifndef __EXTENSIONS__
987# undef __EXTENSIONS__
988#endif
989
990
991/* Define to 1 if we should use toolkit scroll bars. */ 989/* Define to 1 if we should use toolkit scroll bars. */
992#undef USE_TOOLKIT_SCROLL_BARS 990#undef USE_TOOLKIT_SCROLL_BARS
993 991
@@ -1038,6 +1036,31 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1038/* Define to 1 if you need to in order for `stat' and other things to work. */ 1036/* Define to 1 if you need to in order for `stat' and other things to work. */
1039#undef _POSIX_SOURCE 1037#undef _POSIX_SOURCE
1040 1038
1039/* Define to 500 only on HP-UX. */
1040#undef _XOPEN_SOURCE
1041
1042/* Enable extensions on AIX 3, Interix. */
1043#ifndef _ALL_SOURCE
1044# undef _ALL_SOURCE
1045#endif
1046/* Enable GNU extensions on systems that have them. */
1047#ifndef _GNU_SOURCE
1048# undef _GNU_SOURCE
1049#endif
1050/* Enable threading extensions on Solaris. */
1051#ifndef _POSIX_PTHREAD_SEMANTICS
1052# undef _POSIX_PTHREAD_SEMANTICS
1053#endif
1054/* Enable extensions on HP NonStop. */
1055#ifndef _TANDEM_SOURCE
1056# undef _TANDEM_SOURCE
1057#endif
1058/* Enable general extensions on Solaris. */
1059#ifndef __EXTENSIONS__
1060# undef __EXTENSIONS__
1061#endif
1062
1063
1041/* Define to rpl_ if the getopt replacement functions and variables should be 1064/* Define to rpl_ if the getopt replacement functions and variables should be
1042 used. */ 1065 used. */
1043#undef __GETOPT_PREFIX 1066#undef __GETOPT_PREFIX
@@ -1045,10 +1068,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1045/* Define like PROTOTYPES; this can be used by system headers. */ 1068/* Define like PROTOTYPES; this can be used by system headers. */
1046#undef __PROTOTYPES 1069#undef __PROTOTYPES
1047 1070
1048/* Define to compiler's equivalent of C99 restrict keyword. Don't define if
1049 equivalent is `__restrict'. */
1050#undef __restrict
1051
1052/* Define to compiler's equivalent of C99 restrict keyword in array 1071/* Define to compiler's equivalent of C99 restrict keyword in array
1053 declarations. Define as empty for no equivalent. */ 1072 declarations. Define as empty for no equivalent. */
1054#undef __restrict_arr 1073#undef __restrict_arr
@@ -1062,6 +1081,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1062/* Define to empty if `const' does not conform to ANSI C. */ 1081/* Define to empty if `const' does not conform to ANSI C. */
1063#undef const 1082#undef const
1064 1083
1084/* Define to `__inline__' or `__inline' if that's what the C compiler
1085 calls it, or to nothing if 'inline' is not supported under any name. */
1086#ifndef __cplusplus
1087#undef inline
1088#endif
1089
1065/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports 1090/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
1066 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of 1091 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
1067 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. 1092 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
@@ -1078,6 +1103,20 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1078/* Define to `int' if <sys/types.h> does not define. */ 1103/* Define to `int' if <sys/types.h> does not define. */
1079#undef pid_t 1104#undef pid_t
1080 1105
1106/* Define to the equivalent of the C99 'restrict' keyword, or to
1107 nothing if this is not supported. Do not define if restrict is
1108 supported directly. */
1109#undef restrict
1110/* Work around a bug in Sun C++: it does not support _Restrict or
1111 __restrict__, even though the corresponding Sun C compiler ends up with
1112 "#define restrict _Restrict" or "#define restrict __restrict__" in the
1113 previous line. Perhaps some future version of Sun C++ will work with
1114 restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
1115#if defined __SUNPRO_CC && !defined __RESTRICT
1116# define _Restrict
1117# define __restrict__
1118#endif
1119
1081/* Define to `unsigned int' if <sys/types.h> does not define. */ 1120/* Define to `unsigned int' if <sys/types.h> does not define. */
1082#undef size_t 1121#undef size_t
1083 1122
@@ -1161,11 +1200,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1161#endif 1200#endif
1162#endif 1201#endif
1163 1202
1164/* Avoid link-time collision with system mktime if we will use our own. */
1165#if ! HAVE_MKTIME || BROKEN_MKTIME
1166#define mktime emacs_mktime
1167#endif
1168
1169#define my_strftime nstrftime /* for strftime.c */ 1203#define my_strftime nstrftime /* for strftime.c */
1170 1204
1171/* These default definitions are good for almost all machines. 1205/* These default definitions are good for almost all machines.
diff --git a/warn-on-use.h b/warn-on-use.h
new file mode 100644
index 00000000000..fdf250e9f40
--- /dev/null
+++ b/warn-on-use.h
@@ -0,0 +1,109 @@
1/* A C macro for emitting warnings if a function is used.
2 Copyright (C) 2010-2011 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
18 for FUNCTION which will then trigger a compiler warning containing
19 the text of "literal string" anywhere that function is called, if
20 supported by the compiler. If the compiler does not support this
21 feature, the macro expands to an unused extern declaration.
22
23 This macro is useful for marking a function as a potential
24 portability trap, with the intent that "literal string" include
25 instructions on the replacement function that should be used
26 instead. However, one of the reasons that a function is a
27 portability trap is if it has the wrong signature. Declaring
28 FUNCTION with a different signature in C is a compilation error, so
29 this macro must use the same type as any existing declaration so
30 that programs that avoid the problematic FUNCTION do not fail to
31 compile merely because they included a header that poisoned the
32 function. But this implies that _GL_WARN_ON_USE is only safe to
33 use if FUNCTION is known to already have a declaration. Use of
34 this macro implies that there must not be any other macro hiding
35 the declaration of FUNCTION; but undefining FUNCTION first is part
36 of the poisoning process anyway (although for symbols that are
37 provided only via a macro, the result is a compilation error rather
38 than a warning containing "literal string"). Also note that in
39 C++, it is only safe to use if FUNCTION has no overloads.
40
41 For an example, it is possible to poison 'getline' by:
42 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
43 [getline]) in configure.ac, which potentially defines
44 HAVE_RAW_DECL_GETLINE
45 - adding this code to a header that wraps the system <stdio.h>:
46 #undef getline
47 #if HAVE_RAW_DECL_GETLINE
48 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
49 "not universally present; use the gnulib module getline");
50 #endif
51
52 It is not possible to directly poison global variables. But it is
53 possible to write a wrapper accessor function, and poison that
54 (less common usage, like &environ, will cause a compilation error
55 rather than issue the nice warning, but the end result of informing
56 the developer about their portability problem is still achieved):
57 #if HAVE_RAW_DECL_ENVIRON
58 static inline char ***rpl_environ (void) { return &environ; }
59 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
60 # undef environ
61 # define environ (*rpl_environ ())
62 #endif
63 */
64#ifndef _GL_WARN_ON_USE
65
66# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
67/* A compiler attribute is available in gcc versions 4.3.0 and later. */
68# define _GL_WARN_ON_USE(function, message) \
69extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
70# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
71/* Verify the existence of the function. */
72# define _GL_WARN_ON_USE(function, message) \
73extern __typeof__ (function) function
74# else /* Unsupported. */
75# define _GL_WARN_ON_USE(function, message) \
76_GL_WARN_EXTERN_C int _gl_warn_on_use
77# endif
78#endif
79
80/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
81 is like _GL_WARN_ON_USE (function, "string"), except that the function is
82 declared with the given prototype, consisting of return type, parameters,
83 and attributes.
84 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
85 not work in this case. */
86#ifndef _GL_WARN_ON_USE_CXX
87# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
88# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
89extern rettype function parameters_and_attributes \
90 __attribute__ ((__warning__ (msg)))
91# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
92/* Verify the existence of the function. */
93# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
94extern rettype function parameters_and_attributes
95# else /* Unsupported. */
96# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
97_GL_WARN_EXTERN_C int _gl_warn_on_use
98# endif
99#endif
100
101/* _GL_WARN_EXTERN_C declaration;
102 performs the declaration with C linkage. */
103#ifndef _GL_WARN_EXTERN_C
104# if defined __cplusplus
105# define _GL_WARN_EXTERN_C extern "C"
106# else
107# define _GL_WARN_EXTERN_C extern
108# endif
109#endif