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