]> granicus.if.org Git - postgresql/blob - src/timezone/private.h
Allow timezone to compile under Unix by blocking 'timezone' conflict with
[postgresql] / src / timezone / private.h
1 #ifndef PRIVATE_H
2
3 #define PRIVATE_H
4
5 /*
6 ** This file is in the public domain, so clarified as of
7 ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
8 */
9
10 /*
11 ** This header is for use ONLY with the time conversion code.
12 ** There is no guarantee that it will remain unchanged,
13 ** or that it will remain at all.
14 ** Do NOT copy it to any system include directory.
15 ** Thank you!
16 */
17
18 /*
19 ** ID
20 */
21
22 #ifndef lint
23 #ifndef NOID
24 static char     privatehid[] = "@(#)private.h   7.53";
25 #endif /* !defined NOID */
26 #endif /* !defined lint */
27
28 /*
29 ** Defaults for preprocessor symbols.
30 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
31 */
32
33 #ifndef HAVE_ADJTIME
34 #define HAVE_ADJTIME            1
35 #endif /* !defined HAVE_ADJTIME */
36
37 #ifndef HAVE_GETTEXT
38 #define HAVE_GETTEXT            0
39 #endif /* !defined HAVE_GETTEXT */
40
41 #ifndef HAVE_INCOMPATIBLE_CTIME_R
42 #define HAVE_INCOMPATIBLE_CTIME_R       0
43 #endif /* !defined INCOMPATIBLE_CTIME_R */
44
45 #ifndef HAVE_SETTIMEOFDAY
46 #define HAVE_SETTIMEOFDAY       3
47 #endif /* !defined HAVE_SETTIMEOFDAY */
48
49 #ifndef HAVE_STRERROR
50 #define HAVE_STRERROR           1
51 #endif /* !defined HAVE_STRERROR */
52
53 #ifndef HAVE_SYMLINK
54 #define HAVE_SYMLINK            1
55 #endif /* !defined HAVE_SYMLINK */
56
57 #ifndef HAVE_SYS_STAT_H
58 #define HAVE_SYS_STAT_H         1
59 #endif /* !defined HAVE_SYS_STAT_H */
60
61 #ifndef HAVE_SYS_WAIT_H
62 #define HAVE_SYS_WAIT_H         1
63 #endif /* !defined HAVE_SYS_WAIT_H */
64
65 #ifndef HAVE_UNISTD_H
66 #define HAVE_UNISTD_H           1
67 #endif /* !defined HAVE_UNISTD_H */
68
69 #ifndef HAVE_UTMPX_H
70 #define HAVE_UTMPX_H            0
71 #endif /* !defined HAVE_UTMPX_H */
72
73 #ifndef LOCALE_HOME
74 #define LOCALE_HOME             "/usr/lib/locale"
75 #endif /* !defined LOCALE_HOME */
76
77 #if HAVE_INCOMPATIBLE_CTIME_R
78 #define asctime_r _incompatible_asctime_r
79 #define ctime_r _incompatible_ctime_r
80 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
81
82 /*
83 ** Nested includes
84 */
85
86 #include "sys/types.h"  /* for time_t */
87 #include "stdio.h"
88 #include "errno.h"
89 #include "string.h"
90 #include "limits.h"     /* for CHAR_BIT */
91 #define _timezone timezone
92 #undef timezone
93 #include "time.h"
94 #define timezone _timezone
95 #undef _timezone
96 #include "stdlib.h"
97
98 #if HAVE_GETTEXT - 0
99 #include "libintl.h"
100 #endif /* HAVE_GETTEXT - 0 */
101
102 #if HAVE_SYS_WAIT_H - 0
103 #include <sys/wait.h>   /* for WIFEXITED and WEXITSTATUS */
104 #endif /* HAVE_SYS_WAIT_H - 0 */
105
106 #ifndef WIFEXITED
107 #define WIFEXITED(status)       (((status) & 0xff) == 0)
108 #endif /* !defined WIFEXITED */
109 #ifndef WEXITSTATUS
110 #define WEXITSTATUS(status)     (((status) >> 8) & 0xff)
111 #endif /* !defined WEXITSTATUS */
112
113 #if HAVE_UNISTD_H - 0
114 #include "unistd.h"     /* for F_OK and R_OK */
115 #endif /* HAVE_UNISTD_H - 0 */
116
117 #if !(HAVE_UNISTD_H - 0)
118 #ifndef F_OK
119 #define F_OK    0
120 #endif /* !defined F_OK */
121 #ifndef R_OK
122 #define R_OK    4
123 #endif /* !defined R_OK */
124 #endif /* !(HAVE_UNISTD_H - 0) */
125
126 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
127 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
128
129 /*
130 ** Workarounds for compilers/systems.
131 */
132
133 /*
134 ** SunOS 4.1.1 cc lacks prototypes.
135 */
136
137 #ifndef P
138 #ifdef __STDC__
139 #define P(x)    x
140 #endif /* defined __STDC__ */
141 #ifndef __STDC__
142 #define P(x)    ()
143 #endif /* !defined __STDC__ */
144 #endif /* !defined P */
145
146 /*
147 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
148 */
149
150 #ifndef EXIT_SUCCESS
151 #define EXIT_SUCCESS    0
152 #endif /* !defined EXIT_SUCCESS */
153
154 /*
155 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
156 */
157
158 #ifndef EXIT_FAILURE
159 #define EXIT_FAILURE    1
160 #endif /* !defined EXIT_FAILURE */
161
162 /*
163 ** SunOS 4.1.1 headers lack FILENAME_MAX.
164 */
165
166 #ifndef FILENAME_MAX
167
168 #ifndef MAXPATHLEN
169 #ifdef unix
170 #include "sys/param.h"
171 #endif /* defined unix */
172 #endif /* !defined MAXPATHLEN */
173
174 #ifdef MAXPATHLEN
175 #define FILENAME_MAX    MAXPATHLEN
176 #endif /* defined MAXPATHLEN */
177 #ifndef MAXPATHLEN
178 #define FILENAME_MAX    1024            /* Pure guesswork */
179 #endif /* !defined MAXPATHLEN */
180
181 #endif /* !defined FILENAME_MAX */
182
183 /*
184 ** SunOS 4.1.1 libraries lack remove.
185 */
186
187 #ifndef remove
188 extern int      unlink P((const char * filename));
189 #define remove  unlink
190 #endif /* !defined remove */
191
192 /*
193 ** Some ancient errno.h implementations don't declare errno.
194 ** But some newer errno.h implementations define it as a macro.
195 ** Fix the former without affecting the latter.
196 */
197 #ifndef errno
198 extern int errno;
199 #endif /* !defined errno */
200
201 /*
202 ** Private function declarations.
203 */
204 char *  icalloc P((int nelem, int elsize));
205 char *  icatalloc P((char * old, const char * new));
206 char *  icpyalloc P((const char * string));
207 char *  imalloc P((int n));
208 void *  irealloc P((void * pointer, int size));
209 void    icfree P((char * pointer));
210 void    ifree P((char * pointer));
211 char *  scheck P((const char *string, const char *format));
212
213
214 /*
215 ** Finally, some convenience items.
216 */
217
218 #ifndef TRUE
219 #define TRUE    1
220 #endif /* !defined TRUE */
221
222 #ifndef FALSE
223 #define FALSE   0
224 #endif /* !defined FALSE */
225
226 #ifndef TYPE_BIT
227 #define TYPE_BIT(type)  (sizeof (type) * CHAR_BIT)
228 #endif /* !defined TYPE_BIT */
229
230 #ifndef TYPE_SIGNED
231 #define TYPE_SIGNED(type) (((type) -1) < 0)
232 #endif /* !defined TYPE_SIGNED */
233
234 #ifndef INT_STRLEN_MAXIMUM
235 /*
236 ** 302 / 1000 is log10(2.0) rounded up.
237 ** Subtract one for the sign bit if the type is signed;
238 ** add one for integer division truncation;
239 ** add one more for a minus sign if the type is signed.
240 */
241 #define INT_STRLEN_MAXIMUM(type) \
242     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
243 #endif /* !defined INT_STRLEN_MAXIMUM */
244
245 /*
246 ** INITIALIZE(x)
247 */
248
249 #ifndef GNUC_or_lint
250 #ifdef lint
251 #define GNUC_or_lint
252 #endif /* defined lint */
253 #ifndef lint
254 #ifdef __GNUC__
255 #define GNUC_or_lint
256 #endif /* defined __GNUC__ */
257 #endif /* !defined lint */
258 #endif /* !defined GNUC_or_lint */
259
260 #ifndef INITIALIZE
261 #ifdef GNUC_or_lint
262 #define INITIALIZE(x)   ((x) = 0)
263 #endif /* defined GNUC_or_lint */
264 #ifndef GNUC_or_lint
265 #define INITIALIZE(x)
266 #endif /* !defined GNUC_or_lint */
267 #endif /* !defined INITIALIZE */
268
269 /*
270 ** For the benefit of GNU folk...
271 ** `_(MSGID)' uses the current locale's message library string for MSGID.
272 ** The default is to use gettext if available, and use MSGID otherwise.
273 */
274
275 #ifndef _
276 #if HAVE_GETTEXT - 0
277 #define _(msgid) gettext(msgid)
278 #else /* !(HAVE_GETTEXT - 0) */
279 #define _(msgid) msgid
280 #endif /* !(HAVE_GETTEXT - 0) */
281 #endif /* !defined _ */
282
283 #ifndef TZ_DOMAIN
284 #define TZ_DOMAIN "tz"
285 #endif /* !defined TZ_DOMAIN */
286
287 #if HAVE_INCOMPATIBLE_CTIME_R
288 #undef asctime_r
289 #undef ctime_r
290 char *asctime_r P((struct tm const *, char *));
291 char *ctime_r P((time_t const *, char *));
292 #endif /* HAVE_INCOMPATIBLE_CTIME_R */
293
294 /*
295 ** UNIX was a registered trademark of The Open Group in 2003.
296 */
297
298 #endif /* !defined PRIVATE_H */