Add libnpcommon.a file to .gitignore
[monitoring-plugins.git] / gl / time.in.h
blob6fb4fd7176457d983e75f54883168fcfbb148acc
1 /* A more-standard <time.h>.
3 Copyright (C) 2007-2010 Free Software Foundation, Inc.
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.
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.
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. */
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
23 /* Don't get in the way of glibc when it includes time.h merely to
24 declare a few standard symbols, rather than to declare all the
25 symbols. Also, Solaris 8 <time.h> eventually includes itself
26 recursively; if that is happening, just include the system <time.h>
27 without adding our own declarations. */
28 #if (defined __need_time_t || defined __need_clock_t \
29 || defined __need_timespec \
30 || defined _GL_TIME_H)
32 # @INCLUDE_NEXT@ @NEXT_TIME_H@
34 #else
36 # define _GL_TIME_H
38 # @INCLUDE_NEXT@ @NEXT_TIME_H@
40 /* NetBSD 5.0 mis-defines NULL. */
41 # include <stddef.h>
43 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
45 /* The definition of _GL_ARG_NONNULL is copied here. */
47 /* The definition of _GL_WARN_ON_USE is copied here. */
49 /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
50 Or they define it with the wrong member names or define it in <sys/time.h>
51 (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the
52 pthreads-win32 library defines it in <pthread.h>. */
53 # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
54 # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
55 # include <sys/time.h>
56 # elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
57 # include <pthread.h>
58 /* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */
59 # undef asctime_r
60 # undef ctime_r
61 # undef gmtime_r
62 # undef localtime_r
63 # undef rand_r
64 # undef strtok_r
65 # else
67 # ifdef __cplusplus
68 extern "C" {
69 # endif
71 # undef timespec
72 # define timespec rpl_timespec
73 struct timespec
75 time_t tv_sec;
76 long int tv_nsec;
79 # ifdef __cplusplus
81 # endif
83 # endif
84 # endif
86 /* Sleep for at least RQTP seconds unless interrupted, If interrupted,
87 return -1 and store the remaining time into RMTP. See
88 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
89 # if @GNULIB_NANOSLEEP@
90 # if @REPLACE_NANOSLEEP@
91 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
92 # define nanosleep rpl_nanosleep
93 # endif
94 _GL_FUNCDECL_RPL (nanosleep, int,
95 (struct timespec const *__rqtp, struct timespec *__rmtp)
96 _GL_ARG_NONNULL ((1)));
97 _GL_CXXALIAS_RPL (nanosleep, int,
98 (struct timespec const *__rqtp, struct timespec *__rmtp));
99 # else
100 # if ! @HAVE_NANOSLEEP@
101 _GL_FUNCDECL_SYS (nanosleep, int,
102 (struct timespec const *__rqtp, struct timespec *__rmtp)
103 _GL_ARG_NONNULL ((1)));
104 # endif
105 _GL_CXXALIAS_SYS (nanosleep, int,
106 (struct timespec const *__rqtp, struct timespec *__rmtp));
107 # endif
108 _GL_CXXALIASWARN (nanosleep);
109 # endif
111 /* Return the 'time_t' representation of TP and normalize TP. */
112 # if @GNULIB_MKTIME@
113 # if @REPLACE_MKTIME@
114 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
115 # define mktime rpl_mktime
116 # endif
117 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
118 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
119 # else
120 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
121 # endif
122 _GL_CXXALIASWARN (mktime);
123 # endif
125 /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
126 <http://www.opengroup.org/susv3xsh/localtime_r.html> and
127 <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
128 # if @GNULIB_TIME_R@
129 # if @REPLACE_LOCALTIME_R@
130 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
131 # undef localtime_r
132 # define localtime_r rpl_localtime_r
133 # endif
134 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
135 struct tm *restrict __result)
136 _GL_ARG_NONNULL ((1, 2)));
137 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
138 struct tm *restrict __result));
139 # else
140 # if ! @HAVE_LOCALTIME_R@
141 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
142 struct tm *restrict __result)
143 _GL_ARG_NONNULL ((1, 2)));
144 # endif
145 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
146 struct tm *restrict __result));
147 # endif
148 _GL_CXXALIASWARN (localtime_r);
149 # if @REPLACE_LOCALTIME_R@
150 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
151 # undef gmtime_r
152 # define gmtime_r rpl_gmtime_r
153 # endif
154 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
155 struct tm *restrict __result)
156 _GL_ARG_NONNULL ((1, 2)));
157 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
158 struct tm *restrict __result));
159 # else
160 # if ! @HAVE_LOCALTIME_R@
161 _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
162 struct tm *restrict __result)
163 _GL_ARG_NONNULL ((1, 2)));
164 # endif
165 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
166 struct tm *restrict __result));
167 # endif
168 _GL_CXXALIASWARN (gmtime_r);
169 # endif
171 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
172 the resulting broken-down time into TM. See
173 <http://www.opengroup.org/susv3xsh/strptime.html>. */
174 # if @GNULIB_STRPTIME@
175 # if ! @HAVE_STRPTIME@
176 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
177 char const *restrict __format,
178 struct tm *restrict __tm)
179 _GL_ARG_NONNULL ((1, 2, 3)));
180 # endif
181 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
182 char const *restrict __format,
183 struct tm *restrict __tm));
184 _GL_CXXALIASWARN (strptime);
185 # endif
187 /* Convert TM to a time_t value, assuming UTC. */
188 # if @GNULIB_TIMEGM@
189 # if @REPLACE_TIMEGM@
190 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
191 # undef timegm
192 # define timegm rpl_timegm
193 # endif
194 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
195 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
196 # else
197 # if ! @HAVE_TIMEGM@
198 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
199 # endif
200 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
201 # endif
202 _GL_CXXALIASWARN (timegm);
203 # endif
205 /* Encourage applications to avoid unsafe functions that can overrun
206 buffers when given outlandish struct tm values. Portable
207 applications should use strftime (or even sprintf) instead. */
208 # if defined GNULIB_POSIXCHECK
209 # undef asctime
210 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
211 "better use strftime (or even sprintf) instead");
212 # endif
213 # if defined GNULIB_POSIXCHECK
214 # undef asctime_r
215 _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
216 "better use strftime (or even sprintf) instead");
217 # endif
218 # if defined GNULIB_POSIXCHECK
219 # undef ctime
220 _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
221 "better use strftime (or even sprintf) instead");
222 # endif
223 # if defined GNULIB_POSIXCHECK
224 # undef ctime_r
225 _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
226 "better use strftime (or even sprintf) instead");
227 # endif
229 #endif