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