[BZ #4439]
[glibc/pb-stable.git] / timezone / private.h
blobd64c724ef64dc63696e6c6d5d7be32bc7301f3ce
1 #ifndef PRIVATE_H
3 #define PRIVATE_H
5 /*
6 ** This file is in the public domain, so clarified as of
7 ** 1996-06-05 by Arthur David Olson.
8 */
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!
19 ** ID
22 #ifndef lint
23 #ifndef NOID
24 static char privatehid[] = "@(#)private.h 8.3";
25 #endif /* !defined NOID */
26 #endif /* !defined lint */
28 #define GRANDPARENTED "Local time zone must be set--see zic manual page"
31 ** Defaults for preprocessor symbols.
32 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
35 #ifndef HAVE_ADJTIME
36 #define HAVE_ADJTIME 1
37 #endif /* !defined HAVE_ADJTIME */
39 #ifndef HAVE_GETTEXT
40 #define HAVE_GETTEXT 0
41 #endif /* !defined HAVE_GETTEXT */
43 #ifndef HAVE_INCOMPATIBLE_CTIME_R
44 #define HAVE_INCOMPATIBLE_CTIME_R 0
45 #endif /* !defined INCOMPATIBLE_CTIME_R */
47 #ifndef HAVE_SETTIMEOFDAY
48 #define HAVE_SETTIMEOFDAY 3
49 #endif /* !defined HAVE_SETTIMEOFDAY */
51 #ifndef HAVE_STRERROR
52 #define HAVE_STRERROR 1
53 #endif /* !defined HAVE_STRERROR */
55 #ifndef HAVE_SYMLINK
56 #define HAVE_SYMLINK 1
57 #endif /* !defined HAVE_SYMLINK */
59 #ifndef HAVE_SYS_STAT_H
60 #define HAVE_SYS_STAT_H 1
61 #endif /* !defined HAVE_SYS_STAT_H */
63 #ifndef HAVE_SYS_WAIT_H
64 #define HAVE_SYS_WAIT_H 1
65 #endif /* !defined HAVE_SYS_WAIT_H */
67 #ifndef HAVE_UNISTD_H
68 #define HAVE_UNISTD_H 1
69 #endif /* !defined HAVE_UNISTD_H */
71 #ifndef HAVE_UTMPX_H
72 #define HAVE_UTMPX_H 0
73 #endif /* !defined HAVE_UTMPX_H */
75 #ifndef LOCALE_HOME
76 #define LOCALE_HOME "/usr/lib/locale"
77 #endif /* !defined LOCALE_HOME */
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 */
85 ** Nested includes
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"
96 #if HAVE_GETTEXT
97 #include "libintl.h"
98 #endif /* HAVE_GETTEXT */
100 #if HAVE_SYS_WAIT_H
101 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
102 #endif /* HAVE_SYS_WAIT_H */
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 */
111 #if HAVE_UNISTD_H
112 #include "unistd.h" /* for F_OK and R_OK */
113 #endif /* HAVE_UNISTD_H */
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 */
124 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
125 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
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.)
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 */
139 #if HAVE_STDINT_H
140 #include "stdint.h"
141 #endif /* !HAVE_STDINT_H */
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 */
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 */
164 ** Workarounds for compilers/systems.
168 ** If your compiler lacks prototypes, "#define P(x) ()".
171 #ifndef P
172 #define P(x) x
173 #endif /* !defined P */
176 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
179 #ifndef EXIT_SUCCESS
180 #define EXIT_SUCCESS 0
181 #endif /* !defined EXIT_SUCCESS */
184 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
187 #ifndef EXIT_FAILURE
188 #define EXIT_FAILURE 1
189 #endif /* !defined EXIT_FAILURE */
192 ** SunOS 4.1.1 headers lack FILENAME_MAX.
195 #ifndef FILENAME_MAX
197 #ifndef MAXPATHLEN
198 #ifdef unix
199 #include "sys/param.h"
200 #endif /* defined unix */
201 #endif /* !defined MAXPATHLEN */
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 */
210 #endif /* !defined FILENAME_MAX */
213 ** SunOS 4.1.1 libraries lack remove.
216 #ifndef remove
217 extern int unlink P((const char * filename));
218 #define remove unlink
219 #endif /* !defined remove */
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.
227 #ifndef errno
228 extern int errno;
229 #endif /* !defined errno */
232 ** Some time.h implementations don't declare asctime_r.
233 ** Others might define it as a macro.
234 ** Fix the former without affecting the latter.
237 #ifndef asctime_r
238 extern char * asctime_r();
239 #endif
242 ** Private function declarations.
245 char * icalloc P((int nelem, int elsize));
246 char * icatalloc P((char * old, const char * new));
247 char * icpyalloc P((const char * string));
248 char * imalloc P((int n));
249 void * irealloc P((void * pointer, int size));
250 void icfree P((char * pointer));
251 void ifree P((char * pointer));
252 const char * scheck P((const char * string, const char * format));
255 ** Finally, some convenience items.
258 #ifndef TRUE
259 #define TRUE 1
260 #endif /* !defined TRUE */
262 #ifndef FALSE
263 #define FALSE 0
264 #endif /* !defined FALSE */
266 #ifndef TYPE_BIT
267 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
268 #endif /* !defined TYPE_BIT */
270 #ifndef TYPE_SIGNED
271 #define TYPE_SIGNED(type) (((type) -1) < 0)
272 #endif /* !defined TYPE_SIGNED */
275 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
276 ** it cannot be used in preprocessor directives.
279 #ifndef TYPE_INTEGRAL
280 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
281 #endif /* !defined TYPE_INTEGRAL */
283 #ifndef INT_STRLEN_MAXIMUM
285 ** 302 / 1000 is log10(2.0) rounded up.
286 ** Subtract one for the sign bit if the type is signed;
287 ** add one for integer division truncation;
288 ** add one more for a minus sign if the type is signed.
290 #define INT_STRLEN_MAXIMUM(type) \
291 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
292 1 + TYPE_SIGNED(type))
293 #endif /* !defined INT_STRLEN_MAXIMUM */
296 ** INITIALIZE(x)
299 #ifndef GNUC_or_lint
300 #ifdef lint
301 #define GNUC_or_lint
302 #endif /* defined lint */
303 #ifndef lint
304 #ifdef __GNUC__
305 #define GNUC_or_lint
306 #endif /* defined __GNUC__ */
307 #endif /* !defined lint */
308 #endif /* !defined GNUC_or_lint */
310 #ifndef INITIALIZE
311 #ifdef GNUC_or_lint
312 #define INITIALIZE(x) ((x) = 0)
313 #endif /* defined GNUC_or_lint */
314 #ifndef GNUC_or_lint
315 #define INITIALIZE(x)
316 #endif /* !defined GNUC_or_lint */
317 #endif /* !defined INITIALIZE */
320 ** For the benefit of GNU folk...
321 ** `_(MSGID)' uses the current locale's message library string for MSGID.
322 ** The default is to use gettext if available, and use MSGID otherwise.
325 #ifndef _
326 #if HAVE_GETTEXT
327 #define _(msgid) gettext(msgid)
328 #else /* !HAVE_GETTEXT */
329 #define _(msgid) msgid
330 #endif /* !HAVE_GETTEXT */
331 #endif /* !defined _ */
333 #ifndef TZ_DOMAIN
334 #define TZ_DOMAIN "tz"
335 #endif /* !defined TZ_DOMAIN */
337 #if HAVE_INCOMPATIBLE_CTIME_R
338 #undef asctime_r
339 #undef ctime_r
340 char *asctime_r P((struct tm const *, char *));
341 char *ctime_r P((time_t const *, char *));
342 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
344 #ifndef YEARSPERREPEAT
345 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
346 #endif /* !defined YEARSPERREPEAT */
349 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
352 #ifndef AVGSECSPERYEAR
353 #define AVGSECSPERYEAR 31556952L
354 #endif /* !defined AVGSECSPERYEAR */
356 #ifndef SECSPERREPEAT
357 #define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
358 #endif /* !defined SECSPERREPEAT */
360 #ifndef SECSPERREPEAT_BITS
361 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
362 #endif /* !defined SECSPERREPEAT_BITS */
365 ** UNIX was a registered trademark of The Open Group in 2003.
368 #endif /* !defined PRIVATE_H */