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