3 * $FreeBSD: src/lib/libc/stdtime/private.h,v 1.6.8.1 2000/08/23 00:19:15 jhb Exp $
4 * $DragonFly: src/lib/libc/stdtime/private.h,v 1.3 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
20 #define TZDIR "/usr/share/zoneinfo"
21 #endif /* ndef TM_GMTOFF */
24 ** This header is for use ONLY with the time conversion code.
25 ** There is no guarantee that it will remain unchanged,
26 ** or that it will remain at all.
27 ** Do NOT copy it to any system include directory.
31 #define GRANDPARENTED "Local time zone must be set--see zic manual page"
37 #include "sys/types.h" /* for time_t */
41 #include "limits.h" /* for CHAR_BIT et al. */
45 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
48 #define WIFEXITED(status) (((status) & 0xff) == 0)
49 #endif /* !defined WIFEXITED */
51 #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
52 #endif /* !defined WEXITSTATUS */
54 #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
58 #endif /* !defined F_OK */
61 #endif /* !defined R_OK */
63 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
64 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
69 ** Workarounds for compilers/systems.
73 ** Some time.h implementations don't declare asctime_r.
74 ** Others might define it as a macro.
75 ** Fix the former without affecting the latter.
79 extern char * asctime_r(struct tm const *, char *);
83 ** Private function declarations.
86 char * icalloc(int nelem, int elsize);
87 char * icatalloc(char * old, const char * new);
88 char * icpyalloc(const char * string);
89 char * imalloc(int n);
90 void * irealloc(void * pointer, int size);
91 void icfree(char * pointer);
92 void ifree(char * pointer);
93 const char * scheck(const char * string, const char * format);
96 ** Finally, some convenience items.
101 #endif /* !defined TRUE */
105 #endif /* !defined FALSE */
108 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
109 #endif /* !defined TYPE_BIT */
112 #define TYPE_SIGNED(type) (((type) -1) < 0)
113 #endif /* !defined TYPE_SIGNED */
116 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
117 ** it cannot be used in preprocessor directives.
120 #ifndef TYPE_INTEGRAL
121 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
122 #endif /* !defined TYPE_INTEGRAL */
124 #ifndef INT_STRLEN_MAXIMUM
126 ** 302 / 1000 is log10(2.0) rounded up.
127 ** Subtract one for the sign bit if the type is signed;
128 ** add one for integer division truncation;
129 ** add one more for a minus sign if the type is signed.
131 #define INT_STRLEN_MAXIMUM(type) \
132 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
133 1 + TYPE_SIGNED(type))
134 #endif /* !defined INT_STRLEN_MAXIMUM */
143 #endif /* defined lint */
147 #endif /* defined __GNUC__ */
148 #endif /* !defined lint */
149 #endif /* !defined GNUC_or_lint */
153 #define INITIALIZE(x) ((x) = 0)
154 #endif /* defined GNUC_or_lint */
156 #define INITIALIZE(x)
157 #endif /* !defined GNUC_or_lint */
158 #endif /* !defined INITIALIZE */
161 ** For the benefit of GNU folk...
162 ** `_(MSGID)' uses the current locale's message library string for MSGID.
163 ** The default is to use gettext if available, and use MSGID otherwise.
167 #define _(msgid) msgid
168 #endif /* !defined _ */
171 #define TZ_DOMAIN "tz"
172 #endif /* !defined TZ_DOMAIN */
174 #ifndef YEARSPERREPEAT
175 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
176 #endif /* !defined YEARSPERREPEAT */
179 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
182 #ifndef AVGSECSPERYEAR
183 #define AVGSECSPERYEAR 31556952L
184 #endif /* !defined AVGSECSPERYEAR */
186 #ifndef SECSPERREPEAT
187 #define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
188 #endif /* !defined SECSPERREPEAT */
190 #ifndef SECSPERREPEAT_BITS
191 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
192 #endif /* !defined SECSPERREPEAT_BITS */
195 ** UNIX was a registered trademark of The Open Group in 2003.
198 #endif /* !defined PRIVATE_H */