kernel: new DEBUG_RACE option. try to provoke race conditions between processes.
[minix.git] / commands / zoneinfo / private.h
blob85ad102ad6c60c889dc924996abb5b5224e2fe53
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 7.55";
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 */
84 void logwtmp(char *, char *, char *);
87 ** Nested includes
90 #include "sys/types.h" /* for time_t */
91 #include "stdio.h"
92 #include "errno.h"
93 #include "string.h"
94 #include "limits.h" /* for CHAR_BIT */
95 #include "time.h"
96 #include "stdlib.h"
98 #if HAVE_GETTEXT
99 #include "libintl.h"
100 #endif /* HAVE_GETTEXT */
102 #if HAVE_SYS_WAIT_H
103 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
104 #endif /* HAVE_SYS_WAIT_H */
106 #ifndef WIFEXITED
107 #define WIFEXITED(status) (((status) & 0xff) == 0)
108 #endif /* !defined WIFEXITED */
109 #ifndef WEXITSTATUS
110 #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
111 #endif /* !defined WEXITSTATUS */
113 #if HAVE_UNISTD_H
114 #include "unistd.h" /* for F_OK and R_OK */
115 #endif /* HAVE_UNISTD_H */
117 #if !HAVE_UNISTD_H
118 #ifndef F_OK
119 #define F_OK 0
120 #endif /* !defined F_OK */
121 #ifndef R_OK
122 #define R_OK 4
123 #endif /* !defined R_OK */
124 #endif /* !HAVE_UNISTD_H */
126 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
127 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
130 ** Workarounds for compilers/systems.
134 ** SunOS 4.1.1 cc lacks prototypes.
137 #ifndef P
138 #if __STDC__
139 #define P(x) x
140 #else /* !__STDC__ */
141 #define P(x) ()
142 #endif /* !__STDC__ */
143 #endif /* !defined P */
146 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
149 #ifndef EXIT_SUCCESS
150 #define EXIT_SUCCESS 0
151 #endif /* !defined EXIT_SUCCESS */
154 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
157 #ifndef EXIT_FAILURE
158 #define EXIT_FAILURE 1
159 #endif /* !defined EXIT_FAILURE */
162 ** SunOS 4.1.1 headers lack FILENAME_MAX.
165 #ifndef FILENAME_MAX
167 #ifndef MAXPATHLEN
168 #ifdef unix
169 #include "sys/param.h"
170 #endif /* defined unix */
171 #endif /* !defined MAXPATHLEN */
173 #ifdef MAXPATHLEN
174 #define FILENAME_MAX MAXPATHLEN
175 #endif /* defined MAXPATHLEN */
176 #ifndef MAXPATHLEN
177 #define FILENAME_MAX 1024 /* Pure guesswork */
178 #endif /* !defined MAXPATHLEN */
180 #endif /* !defined FILENAME_MAX */
183 ** SunOS 4.1.1 libraries lack remove.
186 #ifndef remove
187 extern int unlink P((const char * filename));
188 #define remove unlink
189 #endif /* !defined remove */
192 ** Some ancient errno.h implementations don't declare errno.
193 ** But some newer errno.h implementations define it as a macro.
194 ** Fix the former without affecting the latter.
197 #ifndef errno
198 extern int errno;
199 #endif /* !defined errno */
202 ** Some time.h implementations don't declare asctime_r.
203 ** Others might define it as a macro.
204 ** Fix the former without affecting the latter.
207 #ifndef asctime_r
208 extern char * asctime_r(register const struct tm *, char *);
209 #endif
212 ** Private function declarations.
215 char * icalloc P((int nelem, int elsize));
216 char * icatalloc P((char * old, const char * new));
217 char * icpyalloc P((const char * string));
218 char * imalloc P((int n));
219 void * irealloc P((void * pointer, int size));
220 void icfree P((char * pointer));
221 void ifree P((char * pointer));
222 const char *scheck P((const char *string, const char *format));
225 ** Finally, some convenience items.
228 #ifndef TRUE
229 #define TRUE 1
230 #endif /* !defined TRUE */
232 #ifndef FALSE
233 #define FALSE 0
234 #endif /* !defined FALSE */
236 #ifndef TYPE_BIT
237 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
238 #endif /* !defined TYPE_BIT */
240 #ifndef TYPE_SIGNED
241 #define TYPE_SIGNED(type) (((type) -1) < 0)
242 #endif /* !defined TYPE_SIGNED */
245 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
246 ** it cannot be used in preprocessor directives.
249 #ifndef TYPE_INTEGRAL
250 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
251 #endif /* !defined TYPE_INTEGRAL */
253 #ifndef INT_STRLEN_MAXIMUM
255 ** 302 / 1000 is log10(2.0) rounded up.
256 ** Subtract one for the sign bit if the type is signed;
257 ** add one for integer division truncation;
258 ** add one more for a minus sign if the type is signed.
260 #define INT_STRLEN_MAXIMUM(type) \
261 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
262 1 + TYPE_SIGNED(type))
263 #endif /* !defined INT_STRLEN_MAXIMUM */
266 ** INITIALIZE(x)
269 #ifndef GNUC_or_lint
270 #ifdef lint
271 #define GNUC_or_lint
272 #endif /* defined lint */
273 #ifndef lint
274 #ifdef __GNUC__
275 #define GNUC_or_lint
276 #endif /* defined __GNUC__ */
277 #endif /* !defined lint */
278 #endif /* !defined GNUC_or_lint */
280 #ifndef INITIALIZE
281 #ifdef GNUC_or_lint
282 #define INITIALIZE(x) ((x) = 0)
283 #endif /* defined GNUC_or_lint */
284 #ifndef GNUC_or_lint
285 #define INITIALIZE(x)
286 #endif /* !defined GNUC_or_lint */
287 #endif /* !defined INITIALIZE */
290 ** For the benefit of GNU folk...
291 ** `_(MSGID)' uses the current locale's message library string for MSGID.
292 ** The default is to use gettext if available, and use MSGID otherwise.
295 #ifndef _
296 #if HAVE_GETTEXT
297 #define _(msgid) gettext(msgid)
298 #else /* !HAVE_GETTEXT */
299 #define _(msgid) msgid
300 #endif /* !HAVE_GETTEXT */
301 #endif /* !defined _ */
303 #ifndef TZ_DOMAIN
304 #define TZ_DOMAIN "tz"
305 #endif /* !defined TZ_DOMAIN */
307 #if HAVE_INCOMPATIBLE_CTIME_R
308 #undef asctime_r
309 #undef ctime_r
310 char *asctime_r P((struct tm const *, char *));
311 char *ctime_r P((time_t const *, char *));
312 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
315 ** UNIX was a registered trademark of The Open Group in 2003.
318 #endif /* !defined PRIVATE_H */