3 * $FreeBSD: src/lib/libc/stdtime/private.h,v 1.6.8.1 2000/08/23 00:19:15 jhb Exp $
4 * $DragonFly: src/usr.sbin/zic/private.h,v 1.4 2008/10/19 20:15:58 swildner Exp $
11 ** This file is in the public domain, so clarified as of
12 ** 1996-06-05 by Arthur David Olson.
15 /* Stuff moved from Makefile.inc to reduce clutter */
17 #define TM_GMTOFF tm_gmtoff
18 #define TM_ZONE tm_zone
19 #define STD_INSPIRED 1
21 #define HAVE_LONG_DOUBLE 1
22 #define HAVE_STRERROR 1
23 #define HAVE_UNISTD_H 1
24 #define LOCALE_HOME _PATH_LOCALE
25 #define TZDIR "/usr/share/zoneinfo"
26 #endif /* ndef TM_GMTOFF */
29 ** This header is for use ONLY with the time conversion code.
30 ** There is no guarantee that it will remain unchanged,
31 ** or that it will remain at all.
32 ** Do NOT copy it to any system include directory.
36 #define GRANDPARENTED "Local time zone must be set--see zic manual page"
39 ** Defaults for preprocessor symbols.
40 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
44 #define HAVE_ADJTIME 1
45 #endif /* !defined HAVE_ADJTIME */
48 #define HAVE_GETTEXT 0
49 #endif /* !defined HAVE_GETTEXT */
51 #ifndef HAVE_INCOMPATIBLE_CTIME_R
52 #define HAVE_INCOMPATIBLE_CTIME_R 0
53 #endif /* !defined INCOMPATIBLE_CTIME_R */
55 #ifndef HAVE_SETTIMEOFDAY
56 #define HAVE_SETTIMEOFDAY 3
57 #endif /* !defined HAVE_SETTIMEOFDAY */
60 #define HAVE_SYMLINK 1
61 #endif /* !defined HAVE_SYMLINK */
63 #ifndef HAVE_SYS_STAT_H
64 #define HAVE_SYS_STAT_H 1
65 #endif /* !defined HAVE_SYS_STAT_H */
67 #ifndef HAVE_SYS_WAIT_H
68 #define HAVE_SYS_WAIT_H 1
69 #endif /* !defined HAVE_SYS_WAIT_H */
72 #define HAVE_UNISTD_H 1
73 #endif /* !defined HAVE_UNISTD_H */
76 #define HAVE_UTMPX_H 0
77 #endif /* !defined HAVE_UTMPX_H */
80 #define LOCALE_HOME "/usr/lib/locale"
81 #endif /* !defined LOCALE_HOME */
83 #if HAVE_INCOMPATIBLE_CTIME_R
84 #define asctime_r _incompatible_asctime_r
85 #define ctime_r _incompatible_ctime_r
86 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
92 #include "sys/types.h" /* for time_t */
96 #include "limits.h" /* for CHAR_BIT et al. */
102 #endif /* HAVE_GETTEXT */
105 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
106 #endif /* HAVE_SYS_WAIT_H */
109 #define WIFEXITED(status) (((status) & 0xff) == 0)
110 #endif /* !defined WIFEXITED */
112 #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
113 #endif /* !defined WEXITSTATUS */
116 #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
117 #endif /* HAVE_UNISTD_H */
121 #endif /* !defined F_OK */
124 #endif /* !defined R_OK */
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 ** Define HAVE_STDINT_H's default value here, rather than at the
131 ** start, since __GLIBC__'s value depends on previously-included
133 ** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
135 #ifndef HAVE_STDINT_H
136 #define HAVE_STDINT_H \
137 (199901 <= __STDC_VERSION__ || \
138 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
139 #endif /* !defined HAVE_STDINT_H */
143 #endif /* !HAVE_STDINT_H */
145 #ifndef INT_FAST64_MAX
146 /* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
147 #if defined LLONG_MAX || defined __LONG_LONG_MAX__
148 typedef long long int_fast64_t;
149 #else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
150 #if (LONG_MAX >> 31) < 0xffffffff
151 Please use a compiler that supports a
64-bit integer
type (or wider
);
152 you may need to compile with
"-DHAVE_STDINT_H".
153 #endif /* (LONG_MAX >> 31) < 0xffffffff */
154 typedef long int_fast64_t;
155 #endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
156 #endif /* !defined INT_FAST64_MAX */
159 #define INT32_MAX 0x7fffffff
160 #endif /* !defined INT32_MAX */
162 #define INT32_MIN (-1 - INT32_MAX)
163 #endif /* !defined INT32_MIN */
166 ** Workarounds for compilers/systems.
170 ** Some time.h implementations don't declare asctime_r.
171 ** Others might define it as a macro.
172 ** Fix the former without affecting the latter.
176 extern char * asctime_r(struct tm
const *, char *);
180 ** Private function declarations.
183 char * icalloc(int nelem
, int elsize
);
184 char * icatalloc(char * old
, const char * new);
185 char * icpyalloc(const char * string
);
186 char * imalloc(int n
);
187 void * irealloc(void * pointer
, int size
);
188 void icfree(char * pointer
);
189 void ifree(char * pointer
);
190 const char * scheck(const char * string
, const char * format
);
193 ** Finally, some convenience items.
198 #endif /* !defined TRUE */
202 #endif /* !defined FALSE */
205 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
206 #endif /* !defined TYPE_BIT */
209 #define TYPE_SIGNED(type) (((type) -1) < 0)
210 #endif /* !defined TYPE_SIGNED */
213 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
214 ** it cannot be used in preprocessor directives.
217 #ifndef TYPE_INTEGRAL
218 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
219 #endif /* !defined TYPE_INTEGRAL */
221 #ifndef INT_STRLEN_MAXIMUM
223 ** 302 / 1000 is log10(2.0) rounded up.
224 ** Subtract one for the sign bit if the type is signed;
225 ** add one for integer division truncation;
226 ** add one more for a minus sign if the type is signed.
228 #define INT_STRLEN_MAXIMUM(type) \
229 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
230 1 + TYPE_SIGNED(type))
231 #endif /* !defined INT_STRLEN_MAXIMUM */
240 #endif /* defined lint */
244 #endif /* defined __GNUC__ */
245 #endif /* !defined lint */
246 #endif /* !defined GNUC_or_lint */
250 #define INITIALIZE(x) ((x) = 0)
251 #endif /* defined GNUC_or_lint */
253 #define INITIALIZE(x)
254 #endif /* !defined GNUC_or_lint */
255 #endif /* !defined INITIALIZE */
258 ** For the benefit of GNU folk...
259 ** `_(MSGID)' uses the current locale's message library string for MSGID.
260 ** The default is to use gettext if available, and use MSGID otherwise.
265 #define _(msgid) gettext(msgid)
266 #else /* !(HAVE_GETTEXT) */
267 #define _(msgid) msgid
268 #endif /* !(HAVE_GETTEXT) */
269 #endif /* !defined _ */
272 #define TZ_DOMAIN "tz"
273 #endif /* !defined TZ_DOMAIN */
275 #if HAVE_INCOMPATIBLE_CTIME_R
278 char *asctime_r(struct tm
const *, char *);
279 char *ctime_r(time_t const *, char *);
280 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
282 #ifndef YEARSPERREPEAT
283 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
284 #endif /* !defined YEARSPERREPEAT */
287 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
290 #ifndef AVGSECSPERYEAR
291 #define AVGSECSPERYEAR 31556952L
292 #endif /* !defined AVGSECSPERYEAR */
294 #ifndef SECSPERREPEAT
295 #define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
296 #endif /* !defined SECSPERREPEAT */
298 #ifndef SECSPERREPEAT_BITS
299 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
300 #endif /* !defined SECSPERREPEAT_BITS */
303 ** UNIX was a registered trademark of The Open Group in 2003.
306 #endif /* !defined PRIVATE_H */