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