xref: /dragonfly/lib/libc/stdtime/private.h (revision 984263bc)
1 /* $FreeBSD: src/lib/libc/stdtime/private.h,v 1.6.8.1 2000/08/23 00:19:15 jhb Exp $ */
2 
3 #ifndef PRIVATE_H
4 
5 #define PRIVATE_H
6 /*
7 ** This file is in the public domain, so clarified as of
8 ** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
9 */
10 
11 /* Stuff moved from Makefile.inc to reduce clutter */
12 #ifndef TM_GMTOFF
13 #define TM_GMTOFF	tm_gmtoff
14 #define TM_ZONE		tm_zone
15 #define STD_INSPIRED	1
16 #define PCTS		1
17 #define HAVE_LONG_DOUBLE 1
18 #define HAVE_STRERROR	1
19 #define	HAVE_UNISTD_H	1
20 #define	LOCALE_HOME	_PATH_LOCALE
21 #define TZDIR		"/usr/share/zoneinfo"
22 #endif /* ndef TM_GMTOFF */
23 
24 /*
25 ** This header is for use ONLY with the time conversion code.
26 ** There is no guarantee that it will remain unchanged,
27 ** or that it will remain at all.
28 ** Do NOT copy it to any system include directory.
29 ** Thank you!
30 */
31 
32 /*
33 ** ID
34 */
35 
36 #ifndef lint
37 #ifndef NOID
38 /*
39 static char	privatehid[] = "@(#)private.h	7.43";
40 */
41 #endif /* !defined NOID */
42 #endif /* !defined lint */
43 
44 /*
45 ** Defaults for preprocessor symbols.
46 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
47 */
48 
49 #ifndef HAVE_ADJTIME
50 #define HAVE_ADJTIME		1
51 #endif /* !defined HAVE_ADJTIME */
52 
53 #ifndef HAVE_GETTEXT
54 #define HAVE_GETTEXT		0
55 #endif /* !defined HAVE_GETTEXT */
56 
57 #ifndef HAVE_SETTIMEOFDAY
58 #define HAVE_SETTIMEOFDAY	3
59 #endif /* !defined HAVE_SETTIMEOFDAY */
60 
61 #ifndef HAVE_STRERROR
62 #define HAVE_STRERROR		0
63 #endif /* !defined HAVE_STRERROR */
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 /*
78 ** Nested includes
79 */
80 
81 #include "sys/types.h"	/* for time_t */
82 #include "stdio.h"
83 #include "errno.h"
84 #include "string.h"
85 #include "limits.h"	/* for CHAR_BIT */
86 #include "time.h"
87 #include "stdlib.h"
88 
89 #if HAVE_GETTEXT - 0
90 #include "libintl.h"
91 #endif /* HAVE_GETTEXT - 0 */
92 
93 #if HAVE_UNISTD_H - 0
94 #include "unistd.h"	/* for F_OK and R_OK */
95 #endif /* HAVE_UNISTD_H - 0 */
96 
97 #if !(HAVE_UNISTD_H - 0)
98 #ifndef F_OK
99 #define F_OK	0
100 #endif /* !defined F_OK */
101 #ifndef R_OK
102 #define R_OK	4
103 #endif /* !defined R_OK */
104 #endif /* !(HAVE_UNISTD_H - 0) */
105 
106 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
107 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
108 
109 /*
110 ** Workarounds for compilers/systems.
111 */
112 
113 #ifndef P
114 #ifdef __STDC__
115 #define P(x)	x
116 #endif /* defined __STDC__ */
117 #ifndef __STDC__
118 #define P(x)	()
119 #endif /* !defined __STDC__ */
120 #endif /* !defined P */
121 
122 /*
123 ** SunOS 4.1.1 headers lack FILENAME_MAX.
124 */
125 
126 #ifndef FILENAME_MAX
127 
128 #ifndef MAXPATHLEN
129 #ifdef unix
130 #include "sys/param.h"
131 #endif /* defined unix */
132 #endif /* !defined MAXPATHLEN */
133 
134 #ifdef MAXPATHLEN
135 #define FILENAME_MAX	MAXPATHLEN
136 #endif /* defined MAXPATHLEN */
137 #ifndef MAXPATHLEN
138 #define FILENAME_MAX	1024		/* Pure guesswork */
139 #endif /* !defined MAXPATHLEN */
140 
141 #endif /* !defined FILENAME_MAX */
142 
143 /*
144 ** Finally, some convenience items.
145 */
146 
147 #ifndef TRUE
148 #define TRUE	1
149 #endif /* !defined TRUE */
150 
151 #ifndef FALSE
152 #define FALSE	0
153 #endif /* !defined FALSE */
154 
155 #ifndef TYPE_BIT
156 #define TYPE_BIT(type)	(sizeof (type) * CHAR_BIT)
157 #endif /* !defined TYPE_BIT */
158 
159 #ifndef TYPE_SIGNED
160 #define TYPE_SIGNED(type) (((type) -1) < 0)
161 #endif /* !defined TYPE_SIGNED */
162 
163 #ifndef INT_STRLEN_MAXIMUM
164 /*
165 ** 302 / 1000 is log10(2.0) rounded up.
166 ** Subtract one for the sign bit if the type is signed;
167 ** add one for integer division truncation;
168 ** add one more for a minus sign if the type is signed.
169 */
170 #define INT_STRLEN_MAXIMUM(type) \
171     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
172 #endif /* !defined INT_STRLEN_MAXIMUM */
173 
174 /*
175 ** INITIALIZE(x)
176 */
177 
178 #ifndef GNUC_or_lint
179 #ifdef lint
180 #define GNUC_or_lint
181 #endif /* defined lint */
182 #ifndef lint
183 #ifdef __GNUC__
184 #define GNUC_or_lint
185 #endif /* defined __GNUC__ */
186 #endif /* !defined lint */
187 #endif /* !defined GNUC_or_lint */
188 
189 #ifndef INITIALIZE
190 #ifdef GNUC_or_lint
191 #define INITIALIZE(x)	((x) = 0)
192 #endif /* defined GNUC_or_lint */
193 #ifndef GNUC_or_lint
194 #define INITIALIZE(x)
195 #endif /* !defined GNUC_or_lint */
196 #endif /* !defined INITIALIZE */
197 
198 /*
199 ** For the benefit of GNU folk...
200 ** `_(MSGID)' uses the current locale's message library string for MSGID.
201 ** The default is to use gettext if available, and use MSGID otherwise.
202 */
203 
204 #ifndef _
205 #if HAVE_GETTEXT - 0
206 #define _(msgid) gettext(msgid)
207 #else /* !(HAVE_GETTEXT - 0) */
208 #define _(msgid) msgid
209 #endif /* !(HAVE_GETTEXT - 0) */
210 #endif /* !defined _ */
211 
212 #ifndef TZ_DOMAIN
213 #define TZ_DOMAIN "tz"
214 #endif /* !defined TZ_DOMAIN */
215 
216 /*
217 ** UNIX was a registered trademark of UNIX System Laboratories in 1993.
218 */
219 
220 #endif /* !defined PRIVATE_H */
221