]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/tzcode/private.h
ICU-491.11.3.tar.gz
[apple/icu.git] / icuSources / tools / tzcode / private.h
CommitLineData
73c04bcf
A
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
fd0068a8 24static char privatehid[] = "@(#)private.h 8.6";
73c04bcf
A
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
73c04bcf
A
51#ifndef HAVE_SYMLINK
52#define HAVE_SYMLINK 1
53#endif /* !defined HAVE_SYMLINK */
54
55#ifndef HAVE_SYS_STAT_H
56#define HAVE_SYS_STAT_H 1
57#endif /* !defined HAVE_SYS_STAT_H */
58
59#ifndef HAVE_SYS_WAIT_H
60#define HAVE_SYS_WAIT_H 1
61#endif /* !defined HAVE_SYS_WAIT_H */
62
63#ifndef HAVE_UNISTD_H
64#define HAVE_UNISTD_H 1
65#endif /* !defined HAVE_UNISTD_H */
66
67#ifndef HAVE_UTMPX_H
68#define HAVE_UTMPX_H 0
69#endif /* !defined HAVE_UTMPX_H */
70
71#ifndef LOCALE_HOME
72#define LOCALE_HOME "/usr/lib/locale"
73#endif /* !defined LOCALE_HOME */
74
75#if HAVE_INCOMPATIBLE_CTIME_R
76#define asctime_r _incompatible_asctime_r
77#define ctime_r _incompatible_ctime_r
78#endif /* HAVE_INCOMPATIBLE_CTIME_R */
79
80/*
81** Nested includes
82*/
83
84#include "sys/types.h" /* for time_t */
85#include "stdio.h"
86#include "errno.h"
87#include "string.h"
88#include "limits.h" /* for CHAR_BIT et al. */
89#include "time.h"
90#include "stdlib.h"
91
92#if HAVE_GETTEXT
93#include "libintl.h"
94#endif /* HAVE_GETTEXT */
95
96#if HAVE_SYS_WAIT_H
97#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
98#endif /* HAVE_SYS_WAIT_H */
99
100#ifndef WIFEXITED
101#define WIFEXITED(status) (((status) & 0xff) == 0)
102#endif /* !defined WIFEXITED */
103#ifndef WEXITSTATUS
104#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
105#endif /* !defined WEXITSTATUS */
106
107#if HAVE_UNISTD_H
fd0068a8 108#include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
73c04bcf
A
109#endif /* HAVE_UNISTD_H */
110
73c04bcf
A
111#ifndef F_OK
112#define F_OK 0
113#endif /* !defined F_OK */
114#ifndef R_OK
115#define R_OK 4
116#endif /* !defined R_OK */
73c04bcf
A
117
118/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
119#define is_digit(c) ((unsigned)(c) - '0' <= 9)
120
121/*
122** Define HAVE_STDINT_H's default value here, rather than at the
123** start, since __GLIBC__'s value depends on previously-included
124** files.
125** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
126*/
127#ifndef HAVE_STDINT_H
128#define HAVE_STDINT_H \
129 (199901 <= __STDC_VERSION__ || \
130 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
131#endif /* !defined HAVE_STDINT_H */
132
133#if HAVE_STDINT_H
134#include "stdint.h"
135#endif /* !HAVE_STDINT_H */
136
137#ifndef INT_FAST64_MAX
138/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
139#if defined LLONG_MAX || defined __LONG_LONG_MAX__
140typedef long long int_fast64_t;
141#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
142#if (LONG_MAX >> 31) < 0xffffffff
143Please use a compiler that supports a 64-bit integer type (or wider);
144you may need to compile with "-DHAVE_STDINT_H".
145#endif /* (LONG_MAX >> 31) < 0xffffffff */
146typedef long int_fast64_t;
147#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
148#endif /* !defined INT_FAST64_MAX */
149
150#ifndef INT32_MAX
151#define INT32_MAX 0x7fffffff
152#endif /* !defined INT32_MAX */
153#ifndef INT32_MIN
154#define INT32_MIN (-1 - INT32_MAX)
155#endif /* !defined INT32_MIN */
156
157/*
158** Workarounds for compilers/systems.
159*/
160
73c04bcf
A
161/*
162** Some time.h implementations don't declare asctime_r.
163** Others might define it as a macro.
164** Fix the former without affecting the latter.
165*/
166
167#ifndef asctime_r
fd0068a8 168extern char * asctime_r(struct tm const *, char *);
73c04bcf
A
169#endif
170
171/*
172** Private function declarations.
173*/
174
fd0068a8
A
175char * icalloc(int nelem, int elsize);
176char * icatalloc(char * old, const char * new);
177char * icpyalloc(const char * string);
178char * imalloc(int n);
179void * irealloc(void * pointer, int size);
180void icfree(char * pointer);
181void ifree(char * pointer);
182const char * scheck(const char * string, const char * format);
73c04bcf
A
183
184/*
185** Finally, some convenience items.
186*/
187
188#ifndef TRUE
189#define TRUE 1
190#endif /* !defined TRUE */
191
192#ifndef FALSE
193#define FALSE 0
194#endif /* !defined FALSE */
195
196#ifndef TYPE_BIT
197#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
198#endif /* !defined TYPE_BIT */
199
200#ifndef TYPE_SIGNED
201#define TYPE_SIGNED(type) (((type) -1) < 0)
202#endif /* !defined TYPE_SIGNED */
203
204/*
205** Since the definition of TYPE_INTEGRAL contains floating point numbers,
206** it cannot be used in preprocessor directives.
207*/
208
209#ifndef TYPE_INTEGRAL
210#define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
211#endif /* !defined TYPE_INTEGRAL */
212
213#ifndef INT_STRLEN_MAXIMUM
214/*
215** 302 / 1000 is log10(2.0) rounded up.
216** Subtract one for the sign bit if the type is signed;
217** add one for integer division truncation;
218** add one more for a minus sign if the type is signed.
219*/
220#define INT_STRLEN_MAXIMUM(type) \
221 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
222 1 + TYPE_SIGNED(type))
223#endif /* !defined INT_STRLEN_MAXIMUM */
224
225/*
226** INITIALIZE(x)
227*/
228
229#ifndef GNUC_or_lint
230#ifdef lint
231#define GNUC_or_lint
232#endif /* defined lint */
233#ifndef lint
234#ifdef __GNUC__
235#define GNUC_or_lint
236#endif /* defined __GNUC__ */
237#endif /* !defined lint */
238#endif /* !defined GNUC_or_lint */
239
240#ifndef INITIALIZE
241#ifdef GNUC_or_lint
242#define INITIALIZE(x) ((x) = 0)
243#endif /* defined GNUC_or_lint */
244#ifndef GNUC_or_lint
245#define INITIALIZE(x)
246#endif /* !defined GNUC_or_lint */
247#endif /* !defined INITIALIZE */
248
249/*
250** For the benefit of GNU folk...
251** `_(MSGID)' uses the current locale's message library string for MSGID.
252** The default is to use gettext if available, and use MSGID otherwise.
253*/
254
255#ifndef _
256#if HAVE_GETTEXT
257#define _(msgid) gettext(msgid)
258#else /* !HAVE_GETTEXT */
259#define _(msgid) msgid
260#endif /* !HAVE_GETTEXT */
261#endif /* !defined _ */
262
263#ifndef TZ_DOMAIN
264#define TZ_DOMAIN "tz"
265#endif /* !defined TZ_DOMAIN */
266
267#if HAVE_INCOMPATIBLE_CTIME_R
268#undef asctime_r
269#undef ctime_r
fd0068a8
A
270char *asctime_r(struct tm const *, char *);
271char *ctime_r(time_t const *, char *);
73c04bcf
A
272#endif /* HAVE_INCOMPATIBLE_CTIME_R */
273
274#ifndef YEARSPERREPEAT
275#define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
276#endif /* !defined YEARSPERREPEAT */
277
278/*
279** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
280*/
281
282#ifndef AVGSECSPERYEAR
283#define AVGSECSPERYEAR 31556952L
284#endif /* !defined AVGSECSPERYEAR */
285
286#ifndef SECSPERREPEAT
287#define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
288#endif /* !defined SECSPERREPEAT */
fd0068a8 289
73c04bcf
A
290#ifndef SECSPERREPEAT_BITS
291#define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
292#endif /* !defined SECSPERREPEAT_BITS */
293
294/*
295** UNIX was a registered trademark of The Open Group in 2003.
296*/
297
298#endif /* !defined PRIVATE_H */