]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/tzcode/zic/private.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / tzcode / zic / private.h
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  * FreeBSD modifications: separate libc's privates from zic's.
12  * This makes it easier when we need to update one but not the other.
13  * I have removed all of the ifdef spaghetti which is not relevant to
14  * zic from this file.
15  *
16  * $FreeBSD$
17  */
18
19 /*
20 ** This header is for use ONLY with the time conversion code.
21 ** There is no guarantee that it will remain unchanged,
22 ** or that it will remain at all.
23 ** Do NOT copy it to any system include directory.
24 ** Thank you!
25 */
26
27 /*
28 ** ID
29 */
30
31 #ifndef lint
32 #ifndef NOID
33 static const char       privatehid[] = "@(#)private.h   8.6";
34 #endif /* !defined NOID */
35 #endif /* !defined lint */
36
37 #define GRANDPARENTED   "Local time zone must be set--use tzsetup"
38
39 /*
40 ** Defaults for preprocessor symbols.
41 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
42 */
43
44 #ifndef HAVE_GETTEXT
45 #define HAVE_GETTEXT            0
46 #endif /* !defined HAVE_GETTEXT */
47
48 #ifndef HAVE_SYMLINK
49 #define HAVE_SYMLINK            1
50 #endif /* !defined HAVE_SYMLINK */
51
52 #ifndef HAVE_SYS_STAT_H
53 #define HAVE_SYS_STAT_H         1
54 #endif /* !defined HAVE_SYS_STAT_H */
55
56 #ifndef HAVE_SYS_WAIT_H
57 #define HAVE_SYS_WAIT_H         1
58 #endif /* !defined HAVE_SYS_WAIT_H */
59
60 #ifndef HAVE_UNISTD_H
61 #define HAVE_UNISTD_H           1
62 #endif /* !defined HAVE_UNISTD_H */
63
64 /*
65 ** Nested includes
66 */
67
68 #include "sys/types.h"  /* for time_t */
69 #include "stdio.h"
70 #include "errno.h"
71 #include "string.h"
72 #include "limits.h"     /* for CHAR_BIT et al. */
73 #include "time.h"
74 #include "stdlib.h"
75
76 #if HAVE_GETTEXT
77 #include "libintl.h"
78 #endif /* HAVE_GETTEXT */
79
80 #if HAVE_SYS_WAIT_H
81 #include <sys/wait.h>   /* for WIFEXITED and WEXITSTATUS */
82 #endif /* HAVE_SYS_WAIT_H */
83
84 #if HAVE_UNISTD_H
85 #include "unistd.h"     /* for F_OK and R_OK, and other POSIX goodness */
86 #endif /* HAVE_UNISTD_H */
87
88 #ifndef F_OK
89 #define F_OK    0
90 #endif /* !defined F_OK */
91 #ifndef R_OK
92 #define R_OK    4
93 #endif /* !defined R_OK */
94
95 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
96 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
97
98 /*
99 ** Define HAVE_STDINT_H's default value here, rather than at the
100 ** start, since __GLIBC__'s value depends on previously-included
101 ** files.
102 ** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
103 */
104 #ifndef HAVE_STDINT_H
105 #define HAVE_STDINT_H \
106        (199901 <= __STDC_VERSION__ || \
107        2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
108 #endif /* !defined HAVE_STDINT_H */
109
110 #if HAVE_STDINT_H
111 #include "stdint.h"
112 #endif /* !HAVE_STDINT_H */
113
114 #ifndef INT_FAST64_MAX
115 /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX.  */
116 #if defined LLONG_MAX || defined __LONG_LONG_MAX__
117 typedef long long      int_fast64_t;
118 #else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
119 #if (LONG_MAX >> 31) < 0xffffffff
120 Please use a compiler that supports a 64-bit integer type (or wider);
121 you may need to compile with "-DHAVE_STDINT_H".
122 #endif /* (LONG_MAX >> 31) < 0xffffffff */
123 typedef long           int_fast64_t;
124 #endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
125 #endif /* !defined INT_FAST64_MAX */
126
127 #ifndef INT32_MAX
128 #define INT32_MAX 0x7fffffff
129 #endif /* !defined INT32_MAX */
130 #ifndef INT32_MIN
131 #define INT32_MIN (-1 - INT32_MAX)
132 #endif /* !defined INT32_MIN */
133
134 /*
135 ** Workarounds for compilers/systems.
136  */
137
138 /* 
139 ** Some time.h implementations don't declare asctime_r.
140 ** Others might define it as a macro.
141 ** Fix the former without affecting the latter.
142  */
143 #ifndef asctime_r
144 extern char *  asctime_r(struct tm const *, char *);
145 #endif
146
147
148
149 /*
150 ** Private function declarations.
151 */
152 char *          icalloc (int nelem, int elsize);
153 char *          icatalloc (char * old, const char * new);
154 char *          icpyalloc (const char * string);
155 char *          imalloc (int n);
156 void *          irealloc (void * pointer, int size);
157 void            icfree (char * pointer);
158 void            ifree (char * pointer);
159 const char *    scheck (const char *string, const char *format);
160
161 /*
162 ** Finally, some convenience items.
163 */
164
165 #ifndef TRUE
166 #define TRUE    1
167 #endif /* !defined TRUE */
168
169 #ifndef FALSE
170 #define FALSE   0
171 #endif /* !defined FALSE */
172
173 #ifndef TYPE_BIT
174 #define TYPE_BIT(type)  (sizeof (type) * CHAR_BIT)
175 #endif /* !defined TYPE_BIT */
176
177 #ifndef TYPE_SIGNED
178 #define TYPE_SIGNED(type) (((type) -1) < 0)
179 #endif /* !defined TYPE_SIGNED */
180
181 /*
182 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
183 ** it cannot be used in preprocessor directives.
184 */
185
186 #ifndef TYPE_INTEGRAL
187 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
188 #endif /* !defined TYPE_INTEGRAL */
189
190 #ifndef INT_STRLEN_MAXIMUM
191 /*
192 ** 302 / 1000 is log10(2.0) rounded up.
193 ** Subtract one for the sign bit if the type is signed;
194 ** add one for integer division truncation;
195 ** add one more for a minus sign if the type is signed.
196 */
197 #define INT_STRLEN_MAXIMUM(type) \
198         ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
199         1 + TYPE_SIGNED(type))
200 #endif /* !defined INT_STRLEN_MAXIMUM */
201
202 /*
203 ** INITIALIZE(x)
204 */
205
206 #ifndef GNUC_or_lint
207 #ifdef lint
208 #define GNUC_or_lint
209 #endif /* defined lint */
210 #ifndef lint
211 #ifdef __GNUC__
212 #define GNUC_or_lint
213 #endif /* defined __GNUC__ */
214 #endif /* !defined lint */
215 #endif /* !defined GNUC_or_lint */
216
217 #ifndef INITIALIZE
218 #ifdef GNUC_or_lint
219 #define INITIALIZE(x)   ((x) = 0)
220 #endif /* defined GNUC_or_lint */
221 #ifndef GNUC_or_lint
222 #define INITIALIZE(x)
223 #endif /* !defined GNUC_or_lint */
224 #endif /* !defined INITIALIZE */
225
226 /*
227 ** For the benefit of GNU folk...
228 ** `_(MSGID)' uses the current locale's message library string for MSGID.
229 ** The default is to use gettext if available, and use MSGID otherwise.
230 */
231
232 #ifndef _
233 #if HAVE_GETTEXT
234 #define _(msgid) gettext(msgid)
235 #else /* !HAVE_GETTEXT */
236 #define _(msgid) msgid
237 #endif /* !HAVE_GETTEXT */
238 #endif /* !defined _ */
239
240 #ifndef TZ_DOMAIN
241 #define TZ_DOMAIN "tz"
242 #endif /* !defined TZ_DOMAIN */
243
244 /*
245 ** UNIX was a registered trademark of The Open Group in 2003.
246 */
247
248 #ifndef YEARSPERREPEAT
249 #define YEARSPERREPEAT          400     /* years before a Gregorian repeat */
250 #endif /* !defined YEARSPERREPEAT */
251
252 /*
253 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
254 */
255
256 #ifndef AVGSECSPERYEAR
257 #define AVGSECSPERYEAR          31556952L
258 #endif /* !defined AVGSECSPERYEAR */
259
260 #ifndef SECSPERREPEAT
261 #define SECSPERREPEAT           ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
262 #endif /* !defined SECSPERREPEAT */
263
264 #ifndef SECSPERREPEAT_BITS
265 #define SECSPERREPEAT_BITS      34      /* ceil(log2(SECSPERREPEAT)) */
266 #endif /* !defined SECSPERREPEAT_BITS */
267
268   /*
269   ** UNIX was a registered trademark of The Open Group in 2003.
270   */
271
272 #endif /* !defined PRIVATE_H */