2 * $FreeBSD: head/contrib/tzcode/stdtime/private.h 192625 2009-05-23 06:31:50Z edwin $
9 ** This file is in the public domain, so clarified as of
10 ** 1996-06-05 by Arthur David Olson.
13 /* Stuff moved from Makefile.inc to reduce clutter */
15 #define TM_GMTOFF tm_gmtoff
16 #define TM_ZONE tm_zone
17 #define TZDIR "/usr/share/zoneinfo"
18 #endif /* ndef TM_GMTOFF */
21 ** This header is for use ONLY with the time conversion code.
22 ** There is no guarantee that it will remain unchanged,
23 ** or that it will remain at all.
24 ** Do NOT copy it to any system include directory.
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'.
36 #define HAVE_GETTEXT 0
37 #endif /* !defined HAVE_GETTEXT */
43 #include "sys/types.h" /* for time_t */
47 #include "limits.h" /* for CHAR_BIT et al. */
53 #endif /* HAVE_GETTEXT */
55 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
57 #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
59 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
60 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
66 ** Private function declarations.
69 char * icatalloc(char * old
, const char * new);
70 char * icpyalloc(const char * string
);
71 const char * scheck(const char * string
, const char * format
);
74 ** Finally, some convenience items.
79 #endif /* !defined TRUE */
83 #endif /* !defined FALSE */
86 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
87 #endif /* !defined TYPE_BIT */
90 #define TYPE_SIGNED(type) (((type) -1) < 0)
91 #endif /* !defined TYPE_SIGNED */
93 /* The minimum and maximum finite time values. */
94 static time_t const time_t_min
=
96 ? (time_t) -1 << (CHAR_BIT
* sizeof (time_t) - 1)
98 static time_t const time_t_max
=
100 ? - (~ 0 < 0) - ((time_t) -1 << (CHAR_BIT
* sizeof (time_t) - 1))
104 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
105 ** it cannot be used in preprocessor directives.
108 #ifndef TYPE_INTEGRAL
109 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
110 #endif /* !defined TYPE_INTEGRAL */
112 #ifndef INT_STRLEN_MAXIMUM
114 ** 302 / 1000 is log10(2.0) rounded up.
115 ** Subtract one for the sign bit if the type is signed;
116 ** add one for integer division truncation;
117 ** add one more for a minus sign if the type is signed.
119 #define INT_STRLEN_MAXIMUM(type) \
120 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
121 1 + TYPE_SIGNED(type))
122 #endif /* !defined INT_STRLEN_MAXIMUM */
131 #endif /* defined lint */
135 #endif /* defined __GNUC__ */
136 #endif /* !defined lint */
137 #endif /* !defined GNUC_or_lint */
141 #define INITIALIZE(x) ((x) = 0)
142 #endif /* defined GNUC_or_lint */
144 #define INITIALIZE(x)
145 #endif /* !defined GNUC_or_lint */
146 #endif /* !defined INITIALIZE */
149 ** For the benefit of GNU folk...
150 ** `_(MSGID)' uses the current locale's message library string for MSGID.
151 ** The default is to use gettext if available, and use MSGID otherwise.
156 #define _(msgid) gettext(msgid)
157 #else /* !HAVE_GETTEXT */
158 #define _(msgid) msgid
159 #endif /* !HAVE_GETTEXT */
160 #endif /* !defined _ */
163 #define TZ_DOMAIN "tz"
164 #endif /* !defined TZ_DOMAIN */
166 #ifndef YEARSPERREPEAT
167 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
168 #endif /* !defined YEARSPERREPEAT */
171 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
174 #ifndef AVGSECSPERYEAR
175 #define AVGSECSPERYEAR 31556952L
176 #endif /* !defined AVGSECSPERYEAR */
178 #ifndef SECSPERREPEAT
179 #define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
180 #endif /* !defined SECSPERREPEAT */
182 #ifndef SECSPERREPEAT_BITS
183 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
184 #endif /* !defined SECSPERREPEAT_BITS */
187 ** UNIX was a registered trademark of The Open Group in 2003.
190 #endif /* !defined PRIVATE_H */