6 ** This file is in the public domain, so clarified as of
7 ** 1996-06-05 by Arthur David Olson.
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
16 * $FreeBSD: head/contrib/tzcode/zic/private.h 207590 2010-05-03 22:32:26Z emaste $
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.
33 static const char privatehid
[] = "@(#)private.h 8.6";
34 #endif /* !defined NOID */
35 #endif /* !defined lint */
37 #define GRANDPARENTED "Local time zone must be set--use tzsetup"
40 ** Defaults for preprocessor symbols.
41 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
45 #define HAVE_GETTEXT 0
46 #endif /* !defined HAVE_GETTEXT */
49 #define HAVE_SYMLINK 1
50 #endif /* !defined HAVE_SYMLINK */
52 #ifndef HAVE_SYS_STAT_H
53 #define HAVE_SYS_STAT_H 1
54 #endif /* !defined HAVE_SYS_STAT_H */
56 #ifndef HAVE_SYS_WAIT_H
57 #define HAVE_SYS_WAIT_H 1
58 #endif /* !defined HAVE_SYS_WAIT_H */
61 #define HAVE_UNISTD_H 1
62 #endif /* !defined HAVE_UNISTD_H */
68 #include "sys/types.h" /* for time_t */
72 #include "limits.h" /* for CHAR_BIT et al. */
78 #endif /* HAVE_GETTEXT */
81 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
82 #endif /* HAVE_SYS_WAIT_H */
85 #include "unistd.h" /* for F_OK and R_OK, and other POSIX goodness */
86 #endif /* HAVE_UNISTD_H */
90 #endif /* !defined F_OK */
93 #endif /* !defined R_OK */
95 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
96 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
99 ** Define HAVE_STDINT_H's default value here, rather than at the
100 ** start, since __GLIBC__'s value depends on previously-included
102 ** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
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 */
112 #endif /* !HAVE_STDINT_H */
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 */
128 #define INT32_MAX 0x7fffffff
129 #endif /* !defined INT32_MAX */
131 #define INT32_MIN (-1 - INT32_MAX)
132 #endif /* !defined INT32_MIN */
135 ** Workarounds for compilers/systems.
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.
144 extern char * asctime_r(struct tm
const *, char *);
150 ** Private function declarations.
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
);
162 ** Finally, some convenience items.
167 #endif /* !defined TRUE */
171 #endif /* !defined FALSE */
174 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
175 #endif /* !defined TYPE_BIT */
178 #define TYPE_SIGNED(type) (((type) -1) < 0)
179 #endif /* !defined TYPE_SIGNED */
182 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
183 ** it cannot be used in preprocessor directives.
186 #ifndef TYPE_INTEGRAL
187 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
188 #endif /* !defined TYPE_INTEGRAL */
190 #ifndef INT_STRLEN_MAXIMUM
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.
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 */
209 #endif /* defined lint */
213 #endif /* defined __GNUC__ */
214 #endif /* !defined lint */
215 #endif /* !defined GNUC_or_lint */
219 #define INITIALIZE(x) ((x) = 0)
220 #endif /* defined GNUC_or_lint */
222 #define INITIALIZE(x)
223 #endif /* !defined GNUC_or_lint */
224 #endif /* !defined INITIALIZE */
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.
234 #define _(msgid) gettext(msgid)
235 #else /* !HAVE_GETTEXT */
236 #define _(msgid) msgid
237 #endif /* !HAVE_GETTEXT */
238 #endif /* !defined _ */
241 #define TZ_DOMAIN "tz"
242 #endif /* !defined TZ_DOMAIN */
245 ** UNIX was a registered trademark of The Open Group in 2003.
248 #ifndef YEARSPERREPEAT
249 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
250 #endif /* !defined YEARSPERREPEAT */
253 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
256 #ifndef AVGSECSPERYEAR
257 #define AVGSECSPERYEAR 31556952L
258 #endif /* !defined AVGSECSPERYEAR */
260 #ifndef SECSPERREPEAT
261 #define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
262 #endif /* !defined SECSPERREPEAT */
264 #ifndef SECSPERREPEAT_BITS
265 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
266 #endif /* !defined SECSPERREPEAT_BITS */
269 ** UNIX was a registered trademark of The Open Group in 2003.
272 #endif /* !defined PRIVATE_H */