75b3cb183164f085350f408a2df4b9b27af50817
[platform/upstream/glibc.git] / timezone / 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 (arthur_david_olson@nih.gov).
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     privatehid[] = "@(#)private.h   7.49";
25 #endif /* !defined NOID */
26 #endif /* !defined lint */
27
28 /*
29 ** Defaults for preprocessor symbols.
30 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
31 */
32
33 #ifndef HAVE_ADJTIME
34 #define HAVE_ADJTIME            1
35 #endif /* !defined HAVE_ADJTIME */
36
37 #ifndef HAVE_GETTEXT
38 #define HAVE_GETTEXT            0
39 #endif /* !defined HAVE_GETTEXT */
40
41 #ifndef HAVE_SETTIMEOFDAY
42 #define HAVE_SETTIMEOFDAY       3
43 #endif /* !defined HAVE_SETTIMEOFDAY */
44
45 #ifndef HAVE_STRERROR
46 #define HAVE_STRERROR           0
47 #endif /* !defined HAVE_STRERROR */
48
49 #ifndef HAVE_SYMLINK
50 #define HAVE_SYMLINK            1
51 #endif /* !defined HAVE_SYMLINK */
52
53 #ifndef HAVE_SYS_WAIT_H
54 #define HAVE_SYS_WAIT_H         1
55 #endif /* !defined HAVE_SYS_WAIT_H */
56
57 #ifndef HAVE_UNISTD_H
58 #define HAVE_UNISTD_H           1
59 #endif /* !defined HAVE_UNISTD_H */
60
61 #ifndef HAVE_UTMPX_H
62 #define HAVE_UTMPX_H            0
63 #endif /* !defined HAVE_UTMPX_H */
64
65 #ifndef LOCALE_HOME
66 #define LOCALE_HOME             "/usr/lib/locale"
67 #endif /* !defined LOCALE_HOME */
68
69 /*
70 ** Nested includes
71 */
72
73 #include "sys/types.h"  /* for time_t */
74 #include "stdio.h"
75 #include "errno.h"
76 #include "string.h"
77 #include "limits.h"     /* for CHAR_BIT */
78 #include "time.h"
79 #include "stdlib.h"
80
81 #if HAVE_GETTEXT - 0
82 #include "libintl.h"
83 #endif /* HAVE_GETTEXT - 0 */
84
85 #if HAVE_SYS_WAIT_H - 0
86 #include <sys/wait.h>   /* for WIFEXITED and WEXITSTATUS */
87 #endif /* HAVE_SYS_WAIT_H - 0 */
88
89 #ifndef WIFEXITED
90 #define WIFEXITED(status)       (((status) & 0xff) == 0)
91 #endif /* !defined WIFEXITED */
92 #ifndef WEXITSTATUS
93 #define WEXITSTATUS(status)     (((status) >> 8) & 0xff)
94 #endif /* !defined WEXITSTATUS */
95
96 #if HAVE_UNISTD_H - 0
97 #include "unistd.h"     /* for F_OK and R_OK */
98 #endif /* HAVE_UNISTD_H - 0 */
99
100 #if !(HAVE_UNISTD_H - 0)
101 #ifndef F_OK
102 #define F_OK    0
103 #endif /* !defined F_OK */
104 #ifndef R_OK
105 #define R_OK    4
106 #endif /* !defined R_OK */
107 #endif /* !(HAVE_UNISTD_H - 0) */
108
109 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
110 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
111
112 /*
113 ** Workarounds for compilers/systems.
114 */
115
116 /*
117 ** SunOS 4.1.1 cc lacks const.
118 */
119
120 #ifndef const
121 #ifndef __STDC__
122 #define const
123 #endif /* !defined __STDC__ */
124 #endif /* !defined const */
125
126 /*
127 ** SunOS 4.1.1 cc lacks prototypes.
128 */
129
130 #ifndef P
131 #ifdef __STDC__
132 #define P(x)    x
133 #endif /* defined __STDC__ */
134 #ifndef __STDC__
135 #define P(x)    ()
136 #endif /* !defined __STDC__ */
137 #endif /* !defined P */
138
139 /*
140 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
141 */
142
143 #ifndef EXIT_SUCCESS
144 #define EXIT_SUCCESS    0
145 #endif /* !defined EXIT_SUCCESS */
146
147 /*
148 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
149 */
150
151 #ifndef EXIT_FAILURE
152 #define EXIT_FAILURE    1
153 #endif /* !defined EXIT_FAILURE */
154
155 /*
156 ** SunOS 4.1.1 headers lack FILENAME_MAX.
157 */
158
159 #ifndef FILENAME_MAX
160
161 #ifndef MAXPATHLEN
162 #ifdef unix
163 #include "sys/param.h"
164 #endif /* defined unix */
165 #endif /* !defined MAXPATHLEN */
166
167 #ifdef MAXPATHLEN
168 #define FILENAME_MAX    MAXPATHLEN
169 #endif /* defined MAXPATHLEN */
170 #ifndef MAXPATHLEN
171 #define FILENAME_MAX    1024            /* Pure guesswork */
172 #endif /* !defined MAXPATHLEN */
173
174 #endif /* !defined FILENAME_MAX */
175
176 /*
177 ** SunOS 4.1.1 libraries lack remove.
178 */
179
180 #ifndef remove
181 extern int      unlink P((const char * filename));
182 #define remove  unlink
183 #endif /* !defined remove */
184
185 /*
186 ** Some ancient errno.h implementations don't declare errno.
187 ** But some newer errno.h implementations define it as a macro.
188 ** Fix the former without affecting the latter.
189 */
190 #ifndef errno
191 extern int errno;
192 #endif /* !defined errno */
193
194 /*
195 ** Private function declarations.
196 */
197 char *  icalloc P((int nelem, int elsize));
198 char *  icatalloc P((char * old, const char * new));
199 char *  icpyalloc P((const char * string));
200 char *  imalloc P((int n));
201 void *  irealloc P((void * pointer, int size));
202 void    icfree P((char * pointer));
203 void    ifree P((char * pointer));
204 char *  scheck P((const char *string, const char *format));
205
206
207 /*
208 ** Finally, some convenience items.
209 */
210
211 #ifndef TRUE
212 #define TRUE    1
213 #endif /* !defined TRUE */
214
215 #ifndef FALSE
216 #define FALSE   0
217 #endif /* !defined FALSE */
218
219 #ifndef TYPE_BIT
220 #define TYPE_BIT(type)  (sizeof (type) * CHAR_BIT)
221 #endif /* !defined TYPE_BIT */
222
223 #ifndef TYPE_SIGNED
224 #define TYPE_SIGNED(type) (((type) -1) < 0)
225 #endif /* !defined TYPE_SIGNED */
226
227 #ifndef INT_STRLEN_MAXIMUM
228 /*
229 ** 302 / 1000 is log10(2.0) rounded up.
230 ** Subtract one for the sign bit if the type is signed;
231 ** add one for integer division truncation;
232 ** add one more for a minus sign if the type is signed.
233 */
234 #define INT_STRLEN_MAXIMUM(type) \
235     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
236 #endif /* !defined INT_STRLEN_MAXIMUM */
237
238 /*
239 ** INITIALIZE(x)
240 */
241
242 #ifndef GNUC_or_lint
243 #ifdef lint
244 #define GNUC_or_lint
245 #endif /* defined lint */
246 #ifndef lint
247 #ifdef __GNUC__
248 #define GNUC_or_lint
249 #endif /* defined __GNUC__ */
250 #endif /* !defined lint */
251 #endif /* !defined GNUC_or_lint */
252
253 #ifndef INITIALIZE
254 #ifdef GNUC_or_lint
255 #define INITIALIZE(x)   ((x) = 0)
256 #endif /* defined GNUC_or_lint */
257 #ifndef GNUC_or_lint
258 #define INITIALIZE(x)
259 #endif /* !defined GNUC_or_lint */
260 #endif /* !defined INITIALIZE */
261
262 /*
263 ** For the benefit of GNU folk...
264 ** `_(MSGID)' uses the current locale's message library string for MSGID.
265 ** The default is to use gettext if available, and use MSGID otherwise.
266 */
267
268 #ifndef _
269 #if HAVE_GETTEXT - 0
270 #define _(msgid) gettext(msgid)
271 #else /* !(HAVE_GETTEXT - 0) */
272 #define _(msgid) msgid
273 #endif /* !(HAVE_GETTEXT - 0) */
274 #endif /* !defined _ */
275
276 #ifndef TZ_DOMAIN
277 #define TZ_DOMAIN "tz"
278 #endif /* !defined TZ_DOMAIN */
279
280 /*
281 ** UNIX was a registered trademark of UNIX System Laboratories in 1993.
282 */
283
284 #endif /* !defined PRIVATE_H */