1 /* $NetBSD: private.h,v 1.24 2003/12/20 00:12:05 kleink Exp $ */
7 #define TM_GMTOFF tm_gmtoff
8 #define TM_ZONE tm_zone
10 #define HAVE_LONG_DOUBLE 1
12 /* For when we build zic as a host tool. */
13 #if HAVE_NBTOOL_CONFIG_H
14 #include "nbtool_config.h"
18 ** This file is in the public domain, so clarified as of
19 ** 1996-06-05 by Arthur David Olson.
23 ** This header is for use ONLY with the time conversion code.
24 ** There is no guarantee that it will remain unchanged,
25 ** or that it will remain at all.
26 ** Do NOT copy it to any system include directory.
37 static char privatehid
[] = "@(#)private.h 8.6";
39 #endif /* !defined NOID */
40 #endif /* !defined lint */
42 #define GRANDPARENTED "Local time zone must be set--see zic manual page"
45 ** Defaults for preprocessor symbols.
46 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
50 #define HAVE_ADJTIME 1
51 #endif /* !defined HAVE_ADJTIME */
54 #define HAVE_GETTEXT 0
55 #endif /* !defined HAVE_GETTEXT */
57 #ifndef HAVE_INCOMPATIBLE_CTIME_R
58 #define HAVE_INCOMPATIBLE_CTIME_R 0
59 #endif /* !defined INCOMPATIBLE_CTIME_R */
61 #ifndef HAVE_SETTIMEOFDAY
62 #define HAVE_SETTIMEOFDAY 3
63 #endif /* !defined HAVE_SETTIMEOFDAY */
66 #define HAVE_SYMLINK 1
67 #endif /* !defined HAVE_SYMLINK */
69 #ifndef HAVE_SYS_STAT_H
70 #define HAVE_SYS_STAT_H 1
71 #endif /* !defined HAVE_SYS_STAT_H */
73 #ifndef HAVE_SYS_WAIT_H
74 #define HAVE_SYS_WAIT_H 1
75 #endif /* !defined HAVE_SYS_WAIT_H */
78 #define HAVE_UNISTD_H 1
79 #endif /* !defined HAVE_UNISTD_H */
82 #define HAVE_UTMPX_H 0
83 #endif /* !defined HAVE_UTMPX_H */
86 #undef LOCALE_HOME /* not to be handled by tzcode itself */
87 #endif /* defined LOCALE_HOME */
89 #if HAVE_INCOMPATIBLE_CTIME_R
90 #define asctime_r _incompatible_asctime_r
91 #define ctime_r _incompatible_ctime_r
92 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
98 #include "sys/types.h" /* for time_t */
102 #include "limits.h" /* for CHAR_BIT et al. */
108 #endif /* HAVE_GETTEXT */
111 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
112 #endif /* HAVE_SYS_WAIT_H */
115 #define WIFEXITED(status) (((status) & 0xff) == 0)
116 #endif /* !defined WIFEXITED */
118 #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
119 #endif /* !defined WEXITSTATUS */
122 #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
123 #endif /* HAVE_UNISTD_H */
127 #endif /* !defined F_OK */
130 #endif /* !defined R_OK */
132 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
133 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
136 ** Define HAVE_STDINT_H's default value here, rather than at the
137 ** start, since __GLIBC__'s value depends on previously-included
139 ** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
141 #ifndef HAVE_STDINT_H
142 #define HAVE_STDINT_H \
143 (199901 <= __STDC_VERSION__ || \
144 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
145 #endif /* !defined HAVE_STDINT_H */
149 #endif /* !HAVE_STDINT_H */
151 #ifndef INT_FAST64_MAX
152 /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
153 #if defined LLONG_MAX || defined __LONG_LONG_MAX__
154 typedef long long int_fast64_t;
155 #else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
156 #if (LONG_MAX >> 31) < 0xffffffff
157 Please use a compiler that supports a
64-bit integer
type (or wider
);
158 you may need to compile with
"-DHAVE_STDINT_H".
159 #endif /* (LONG_MAX >> 31) < 0xffffffff */
160 typedef long int_fast64_t;
161 #endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
162 #endif /* !defined INT_FAST64_MAX */
165 #define INT32_MAX 0x7fffffff
166 #endif /* !defined INT32_MAX */
168 #define INT32_MIN (-1 - INT32_MAX)
169 #endif /* !defined INT32_MIN */
172 ** Workarounds for compilers/systems.
176 ** Some time.h implementations don't declare asctime_r.
177 ** Others might define it as a macro.
178 ** Fix the former without affecting the latter.
182 extern char * asctime_r(struct tm
const *, char *);
186 ** Private function declarations.
189 char * icalloc(int nelem
, int elsize
);
190 char * icatalloc(char * old
, const char * new);
191 char * icpyalloc(const char * string
);
192 char * imalloc(int n
);
193 void * irealloc(void * pointer
, int size
);
194 void icfree(char * pointer
);
195 void ifree(char * pointer
);
196 const char * scheck(const char * string
, const char * format
);
199 ** Finally, some convenience items.
204 #endif /* !defined TRUE */
208 #endif /* !defined FALSE */
211 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
212 #endif /* !defined TYPE_BIT */
215 #define TYPE_SIGNED(type) (((type) -1) < 0)
216 #endif /* !defined TYPE_SIGNED */
219 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
220 ** it cannot be used in preprocessor directives.
223 #ifndef TYPE_INTEGRAL
224 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
225 #endif /* !defined TYPE_INTEGRAL */
227 #ifndef INT_STRLEN_MAXIMUM
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.
234 #define INT_STRLEN_MAXIMUM(type) \
235 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
236 1 + TYPE_SIGNED(type))
237 #endif /* !defined INT_STRLEN_MAXIMUM */
246 #endif /* defined lint */
250 #endif /* defined __GNUC__ */
251 #endif /* !defined lint */
252 #endif /* !defined GNUC_or_lint */
256 #define INITIALIZE(x) ((x) = 0)
257 #endif /* defined GNUC_or_lint */
259 #define INITIALIZE(x)
260 #endif /* !defined GNUC_or_lint */
261 #endif /* !defined INITIALIZE */
264 ** For the benefit of GNU folk...
265 ** `_(MSGID)' uses the current locale's message library string for MSGID.
266 ** The default is to use gettext if available, and use MSGID otherwise.
271 #define _(msgid) gettext(msgid)
272 #else /* !HAVE_GETTEXT */
273 #define _(msgid) msgid
274 #endif /* !HAVE_GETTEXT */
275 #endif /* !defined _ */
278 #define TZ_DOMAIN "tz"
279 #endif /* !defined TZ_DOMAIN */
281 #if HAVE_INCOMPATIBLE_CTIME_R
284 char *asctime_r(struct tm
const *, char *);
285 char *ctime_r(time_t const *, char *);
286 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
288 #ifndef YEARSPERREPEAT
289 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
290 #endif /* !defined YEARSPERREPEAT */
293 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
296 #ifndef AVGSECSPERYEAR
297 #define AVGSECSPERYEAR 31556952L
298 #endif /* !defined AVGSECSPERYEAR */
300 #ifndef SECSPERREPEAT
301 #define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
302 #endif /* !defined SECSPERREPEAT */
304 #ifndef SECSPERREPEAT_BITS
305 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
306 #endif /* !defined SECSPERREPEAT_BITS */
309 ** UNIX was a registered trademark of The Open Group in 2003.
312 #endif /* !defined PRIVATE_H */