nrelease - fix/improve livecd
[dragonfly.git] / lib / libc / stdtime / private.h
1 /*
2  * $FreeBSD: head/contrib/tzcode/stdtime/private.h 192625 2009-05-23 06:31:50Z edwin $
3  */
4
5 #ifndef PRIVATE_H
6
7 #define PRIVATE_H
8 /*
9 ** This file is in the public domain, so clarified as of
10 ** 1996-06-05 by Arthur David Olson.
11 */
12
13 /* Stuff moved from Makefile.inc to reduce clutter */
14 #ifndef TM_GMTOFF
15 #define TM_GMTOFF       tm_gmtoff
16 #define TM_ZONE         tm_zone
17 #define TZDIR           "/usr/share/zoneinfo"
18 #endif /* ndef TM_GMTOFF */
19
20 /*
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.
25 ** Thank you!
26 */
27
28 #define GRANDPARENTED   "Local time zone must be set--see zic manual page"
29
30 /*
31 ** Defaults for preprocessor symbols.
32 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
33 */
34
35 #ifndef HAVE_GETTEXT
36 #define HAVE_GETTEXT            0
37 #endif /* !defined HAVE_GETTEXT */
38
39 /*
40 ** Nested includes
41 */
42
43 #include "sys/types.h"  /* for time_t */
44 #include "stdio.h"
45 #include "errno.h"
46 #include "string.h"
47 #include "limits.h"     /* for CHAR_BIT et al. */
48 #include "time.h"
49 #include "stdlib.h"
50
51 #if HAVE_GETTEXT
52 #include "libintl.h"
53 #endif /* HAVE_GETTEXT */
54
55 #include <sys/wait.h>   /* for WIFEXITED and WEXITSTATUS */
56
57 #include "unistd.h"     /* for F_OK, R_OK, and other POSIX goodness */
58
59 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
60 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
61
62 #include "stdint.h"
63 #include <inttypes.h>
64
65 /*
66 ** Private function declarations.
67 */
68
69 char *          icatalloc(char * old, const char * new);
70 char *          icpyalloc(const char * string);
71 const char *    scheck(const char * string, const char * format);
72
73 /*
74 ** Finally, some convenience items.
75 */
76
77 #ifndef TRUE
78 #define TRUE    1
79 #endif /* !defined TRUE */
80
81 #ifndef FALSE
82 #define FALSE   0
83 #endif /* !defined FALSE */
84
85 #ifndef TYPE_BIT
86 #define TYPE_BIT(type)  (sizeof (type) * CHAR_BIT)
87 #endif /* !defined TYPE_BIT */
88
89 #ifndef TYPE_SIGNED
90 #define TYPE_SIGNED(type) (((type) -1) < 0)
91 #endif /* !defined TYPE_SIGNED */
92
93 /* The minimum and maximum finite time values.  */
94 static time_t const time_t_min =
95   (TYPE_SIGNED(time_t)
96    ? (time_t) -1 << (CHAR_BIT * sizeof (time_t) - 1)
97    : 0);
98 static time_t const time_t_max =
99   (TYPE_SIGNED(time_t)
100    ? - (~ 0 < 0) - ((time_t) -1 << (CHAR_BIT * sizeof (time_t) - 1))
101    : -1);
102
103 /*
104 ** Since the definition of TYPE_INTEGRAL contains floating point numbers,
105 ** it cannot be used in preprocessor directives.
106 */
107
108 #ifndef TYPE_INTEGRAL
109 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
110 #endif /* !defined TYPE_INTEGRAL */
111
112 #ifndef INT_STRLEN_MAXIMUM
113 /*
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.
118 */
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 */
123
124 /*
125 ** INITIALIZE(x)
126 */
127
128 #ifndef GNUC_or_lint
129 #ifdef lint
130 #define GNUC_or_lint
131 #endif /* defined lint */
132 #ifndef lint
133 #ifdef __GNUC__
134 #define GNUC_or_lint
135 #endif /* defined __GNUC__ */
136 #endif /* !defined lint */
137 #endif /* !defined GNUC_or_lint */
138
139 #ifndef INITIALIZE
140 #ifdef GNUC_or_lint
141 #define INITIALIZE(x)   ((x) = 0)
142 #endif /* defined GNUC_or_lint */
143 #ifndef GNUC_or_lint
144 #define INITIALIZE(x)
145 #endif /* !defined GNUC_or_lint */
146 #endif /* !defined INITIALIZE */
147
148 /*
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.
152 */
153
154 #ifndef _
155 #if HAVE_GETTEXT
156 #define _(msgid) gettext(msgid)
157 #else /* !HAVE_GETTEXT */
158 #define _(msgid) msgid
159 #endif /* !HAVE_GETTEXT */
160 #endif /* !defined _ */
161
162 #ifndef TZ_DOMAIN
163 #define TZ_DOMAIN "tz"
164 #endif /* !defined TZ_DOMAIN */
165
166 #ifndef YEARSPERREPEAT
167 #define YEARSPERREPEAT          400     /* years before a Gregorian repeat */
168 #endif /* !defined YEARSPERREPEAT */
169
170 /*
171 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
172 */
173
174 #ifndef AVGSECSPERYEAR
175 #define AVGSECSPERYEAR          31556952L
176 #endif /* !defined AVGSECSPERYEAR */
177
178 #ifndef SECSPERREPEAT
179 #define SECSPERREPEAT           ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
180 #endif /* !defined SECSPERREPEAT */
181
182 #ifndef SECSPERREPEAT_BITS
183 #define SECSPERREPEAT_BITS      34      /* ceil(log2(SECSPERREPEAT)) */
184 #endif /* !defined SECSPERREPEAT_BITS */
185
186 /*
187 ** UNIX was a registered trademark of The Open Group in 2003.
188 */
189
190 #endif /* !defined PRIVATE_H */