Asterisk - The Open Source Telephony Project  18.5.0
main/stdtime/private.h
Go to the documentation of this file.
1 #ifndef PRIVATE_H
2 
3 #define PRIVATE_H
4 
5 /*
6 ** This file is in the public domain, so clarified as of
7 ** 1996-06-05 by Arthur David Olson.
8 */
9 
10 /*
11 ** This header is for use ONLY with the time conversion code.
12 ** There is no guarantee that it will remain unchanged,
13 ** or that it will remain at all.
14 ** Do NOT copy it to any system include directory.
15 ** Thank you!
16 */
17 
18 /*
19 ** ID
20 */
21 
22 #ifndef lint
23 #ifndef NOID
24 static char __attribute__((unused)) privatehid[] = "@(#)private.h 8.3";
25 #endif /* !defined NOID */
26 #endif /* !defined lint */
27 
28 #define GRANDPARENTED "Local time zone must be set--see zic manual page"
29 
30 /*
31 ** Defaults for preprocessor symbols.
32 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
33 */
34 
35 #ifndef HAVE_ADJTIME
36 #define HAVE_ADJTIME 1
37 #endif /* !defined HAVE_ADJTIME */
38 
39 #ifndef HAVE_GETTEXT
40 #define HAVE_GETTEXT 0
41 #endif /* !defined HAVE_GETTEXT */
42 
43 #ifndef HAVE_INCOMPATIBLE_CTIME_R
44 #define HAVE_INCOMPATIBLE_CTIME_R 0
45 #endif /* !defined INCOMPATIBLE_CTIME_R */
46 
47 #ifndef HAVE_SETTIMEOFDAY
48 #define HAVE_SETTIMEOFDAY 3
49 #endif /* !defined HAVE_SETTIMEOFDAY */
50 
51 #ifndef HAVE_STRERROR
52 #define HAVE_STRERROR 1
53 #endif /* !defined HAVE_STRERROR */
54 
55 #ifndef HAVE_SYMLINK
56 #define HAVE_SYMLINK 1
57 #endif /* !defined HAVE_SYMLINK */
58 
59 #ifndef HAVE_SYS_STAT_H
60 #define HAVE_SYS_STAT_H 1
61 #endif /* !defined HAVE_SYS_STAT_H */
62 
63 #ifndef HAVE_SYS_WAIT_H
64 #define HAVE_SYS_WAIT_H 1
65 #endif /* !defined HAVE_SYS_WAIT_H */
66 
67 #ifndef HAVE_UNISTD_H
68 #define HAVE_UNISTD_H 1
69 #endif /* !defined HAVE_UNISTD_H */
70 
71 #ifndef HAVE_UTMPX_H
72 #define HAVE_UTMPX_H 0
73 #endif /* !defined HAVE_UTMPX_H */
74 
75 #ifndef LOCALE_HOME
76 #define LOCALE_HOME "/usr/lib/locale"
77 #endif /* !defined LOCALE_HOME */
78 
79 #if HAVE_INCOMPATIBLE_CTIME_R
80 #define asctime_r _incompatible_asctime_r
81 #define ctime_r _incompatible_ctime_r
82 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
83 
84 /*
85 ** Nested includes
86 */
87 
88 #include "sys/types.h" /* for time_t */
89 #include "stdio.h"
90 #include "errno.h"
91 #include "string.h"
92 #include "limits.h" /* for CHAR_BIT et al. */
93 #include "time.h"
94 #include "stdlib.h"
95 
96 #if HAVE_GETTEXT
97 #include "libintl.h"
98 #endif /* HAVE_GETTEXT */
99 
100 #if HAVE_SYS_WAIT_H
101 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
102 #endif /* HAVE_SYS_WAIT_H */
103 
104 #ifndef WIFEXITED
105 #define WIFEXITED(status) (((status) & 0xff) == 0)
106 #endif /* !defined WIFEXITED */
107 #ifndef WEXITSTATUS
108 #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
109 #endif /* !defined WEXITSTATUS */
110 
111 #if HAVE_UNISTD_H
112 #include "unistd.h" /* for F_OK and R_OK */
113 #endif /* HAVE_UNISTD_H */
114 
115 #if !HAVE_UNISTD_H
116 #ifndef F_OK
117 #define F_OK 0
118 #endif /* !defined F_OK */
119 #ifndef R_OK
120 #define R_OK 4
121 #endif /* !defined R_OK */
122 #endif /* !HAVE_UNISTD_H */
123 
124 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
125 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
126 
127 /*
128 ** Define HAVE_STDINT_H's default value here, rather than at the
129 ** start, since __GLIBC__'s value depends on previously-included
130 ** files.
131 ** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
132 */
133 #ifndef HAVE_STDINT_H
134 #define HAVE_STDINT_H \
135  (199901 <= __STDC_VERSION__ || \
136  2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
137 #endif /* !defined HAVE_STDINT_H */
138 
139 #if HAVE_STDINT_H
140 #include "stdint.h"
141 #endif /* !HAVE_STDINT_H */
142 
143 #ifndef INT_FAST64_MAX
144 /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
145 #if defined LLONG_MAX || defined __LONG_LONG_MAX__
146 typedef long long int_fast64_t;
147 #else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
148 #if (LONG_MAX >> 31) < 0xffffffff
149 Please use a compiler that supports a 64-bit integer type (or wider);
150 you may need to compile with "-DHAVE_STDINT_H".
151 #endif /* (LONG_MAX >> 31) < 0xffffffff */
152 typedef long int_fast64_t;
153 #endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
154 #endif /* !defined INT_FAST64_MAX */
155 
156 #ifndef INT32_MAX
157 #define INT32_MAX 0x7fffffff
158 #endif /* !defined INT32_MAX */
159 #ifndef INT32_MIN
160 #define INT32_MIN (-1 - INT32_MAX)
161 #endif /* !defined INT32_MIN */
162 
163 /*
164 ** Workarounds for compilers/systems.
165 */
166 
167 /*
168 ** If your compiler lacks prototypes, "#define P(x) ()".
169 */
170 
171 #ifndef P
172 #define P(x) x
173 #endif /* !defined P */
174 
175 /*
176 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
177 */
178 
179 #ifndef EXIT_SUCCESS
180 #define EXIT_SUCCESS 0
181 #endif /* !defined EXIT_SUCCESS */
182 
183 /*
184 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
185 */
186 
187 #ifndef EXIT_FAILURE
188 #define EXIT_FAILURE 1
189 #endif /* !defined EXIT_FAILURE */
190 
191 /*
192 ** SunOS 4.1.1 headers lack FILENAME_MAX.
193 */
194 
195 #ifndef FILENAME_MAX
196 
197 #ifndef MAXPATHLEN
198 #ifdef unix
199 #include "sys/param.h"
200 #endif /* defined unix */
201 #endif /* !defined MAXPATHLEN */
202 
203 #ifdef MAXPATHLEN
204 #define FILENAME_MAX MAXPATHLEN
205 #endif /* defined MAXPATHLEN */
206 #ifndef MAXPATHLEN
207 #define FILENAME_MAX 1024 /* Pure guesswork */
208 #endif /* !defined MAXPATHLEN */
209 
210 #endif /* !defined FILENAME_MAX */
211 
212 /*
213 ** SunOS 4.1.1 libraries lack remove.
214 */
215 
216 #ifndef remove
217 extern int unlink P((const char * filename));
218 #define remove unlink
219 #endif /* !defined remove */
220 
221 /*
222 ** Some ancient errno.h implementations don't declare errno.
223 ** But some newer errno.h implementations define it as a macro.
224 ** Fix the former without affecting the latter.
225 */
226 
227 #ifndef errno
228 extern int errno;
229 #endif /* !defined errno */
230 
231 /*
232 ** Private function declarations.
233 */
234 
235 char * icalloc P((int nelem, int elsize));
236 char * icatalloc P((char * old, const char * new));
237 char * icpyalloc P((const char * string));
238 char * imalloc P((int n));
239 void * irealloc P((void * pointer, int size));
240 void icfree P((char * pointer));
241 void ifree P((char * pointer));
242 const char * scheck P((const char * string, const char * format));
243 
244 /*
245 ** Finally, some convenience items.
246 */
247 
248 #ifndef TRUE
249 #define TRUE 1
250 #endif /* !defined TRUE */
251 
252 #ifndef FALSE
253 #define FALSE 0
254 #endif /* !defined FALSE */
255 
256 #ifndef TYPE_BIT
257 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
258 #endif /* !defined TYPE_BIT */
259 
260 #ifndef TYPE_SIGNED
261 #define TYPE_SIGNED(type) (((type) -1) < 0)
262 #endif /* !defined TYPE_SIGNED */
263 
264 /*
265 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
266 ** it cannot be used in preprocessor directives.
267 */
268 
269 #ifndef TYPE_INTEGRAL
270 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
271 #endif /* !defined TYPE_INTEGRAL */
272 
273 #ifndef INT_STRLEN_MAXIMUM
274 /*
275 ** 302 / 1000 is log10(2.0) rounded up.
276 ** Subtract one for the sign bit if the type is signed;
277 ** add one for integer division truncation;
278 ** add one more for a minus sign if the type is signed.
279 */
280 #define INT_STRLEN_MAXIMUM(type) \
281  ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
282  1 + TYPE_SIGNED(type))
283 #endif /* !defined INT_STRLEN_MAXIMUM */
284 
285 /*
286 ** INITIALIZE(x)
287 */
288 
289 #ifndef GNUC_or_lint
290 #ifdef lint
291 #define GNUC_or_lint
292 #endif /* defined lint */
293 #ifndef lint
294 #ifdef __GNUC__
295 #define GNUC_or_lint
296 #endif /* defined __GNUC__ */
297 #endif /* !defined lint */
298 #endif /* !defined GNUC_or_lint */
299 
300 #ifndef INITIALIZE
301 #ifdef GNUC_or_lint
302 #define INITIALIZE(x) ((x) = 0)
303 #endif /* defined GNUC_or_lint */
304 #ifndef GNUC_or_lint
305 #define INITIALIZE(x)
306 #endif /* !defined GNUC_or_lint */
307 #endif /* !defined INITIALIZE */
308 
309 /*
310 ** For the benefit of GNU folk...
311 ** `_(MSGID)' uses the current locale's message library string for MSGID.
312 ** The default is to use gettext if available, and use MSGID otherwise.
313 */
314 
315 #ifndef _
316 #if HAVE_GETTEXT
317 #define _(msgid) gettext(msgid)
318 #else /* !HAVE_GETTEXT */
319 #define _(msgid) msgid
320 #endif /* !HAVE_GETTEXT */
321 #endif /* !defined _ */
322 
323 #ifndef TZ_DOMAIN
324 #define TZ_DOMAIN "tz"
325 #endif /* !defined TZ_DOMAIN */
326 
327 #if HAVE_INCOMPATIBLE_CTIME_R
328 #undef asctime_r
329 #undef ctime_r
330 char *asctime_r P((struct tm const *, char *));
331 char *ctime_r P((time_t const *, char *));
332 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
333 
334 #ifndef YEARSPERREPEAT
335 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
336 #endif /* !defined YEARSPERREPEAT */
337 
338 /*
339 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
340 */
341 
342 #ifndef AVGSECSPERYEAR
343 #define AVGSECSPERYEAR 31556952L
344 #endif /* !defined AVGSECSPERYEAR */
345 
346 #ifndef SECSPERREPEAT
347 #define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
348 #endif /* !defined SECSPERREPEAT */
349 
350 #ifndef SECSPERREPEAT_BITS
351 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
352 #endif /* !defined SECSPERREPEAT_BITS */
353 
354 /*
355 ** UNIX was a registered trademark of The Open Group in 2003.
356 */
357 
358 #endif /* !defined PRIVATE_H */
#define P(x)
Time-related functions and macros.
Please use a compiler that supports a bit integer type(or wider)
static char privatehid[]
int errno
you may need to compile with DHAVE_STDINT_H typedef long int_fast64_t
static snd_pcm_format_t format
Definition: chan_alsa.c:102
INT32 integer
Definition: lpc10.h:80
static struct test_val a