xref: /openbsd-src/lib/libc/time/private.h (revision c90a81c56dcebd6a1b73fe4aff9b03385b8e63b3)
1 /*	$OpenBSD: private.h,v 1.38 2015/10/24 18:13:18 guenther Exp $	*/
2 #ifndef PRIVATE_H
3 
4 #define PRIVATE_H
5 
6 /*
7 ** This file is in the public domain, so clarified as of
8 ** 1996-06-05 by Arthur David Olson.
9 */
10 
11 /* OpenBSD defaults */
12 #define TM_GMTOFF		tm_gmtoff
13 #define TM_ZONE			tm_zone
14 #define PCTS			1
15 #define ALL_STATE		1
16 #define STD_INSPIRED		1
17 #define USG_COMPAT		1
18 
19 /*
20 ** This header is for use ONLY with the time conversion code.
21 ** There is no guarantee that it will remain unchanged,
22 ** or that it will remain at all.
23 ** Do NOT copy it to any system include directory.
24 ** Thank you!
25 */
26 
27 #define GRANDPARENTED	"Local time zone must be set--see zic manual page"
28 
29 /*
30 ** Nested includes
31 */
32 
33 #include <limits.h>	/* for CHAR_BIT et al. */
34 #include <time.h>
35 
36 /*
37 ** Finally, some convenience items.
38 */
39 
40 #ifndef TRUE
41 #define TRUE	1
42 #endif /* !defined TRUE */
43 
44 #ifndef FALSE
45 #define FALSE	0
46 #endif /* !defined FALSE */
47 
48 #ifndef TYPE_BIT
49 #define TYPE_BIT(type)	(sizeof (type) * CHAR_BIT)
50 #endif /* !defined TYPE_BIT */
51 
52 #ifndef TYPE_SIGNED
53 #define TYPE_SIGNED(type) (((type) -1) < 0)
54 #endif /* !defined TYPE_SIGNED */
55 
56 #ifndef INT_STRLEN_MAXIMUM
57 /*
58 ** 302 / 1000 is log10(2.0) rounded up.
59 ** Subtract one for the sign bit if the type is signed;
60 ** add one for integer division truncation;
61 ** add one more for a minus sign if the type is signed.
62 */
63 #define INT_STRLEN_MAXIMUM(type) \
64 	((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
65 	1 + TYPE_SIGNED(type))
66 #endif /* !defined INT_STRLEN_MAXIMUM */
67 
68 #define _(msgid) msgid
69 
70 #ifndef TZ_DOMAIN
71 #define TZ_DOMAIN "tz"
72 #endif /* !defined TZ_DOMAIN */
73 
74 #ifndef YEARSPERREPEAT
75 #define YEARSPERREPEAT		400	/* years before a Gregorian repeat */
76 #endif /* !defined YEARSPERREPEAT */
77 
78 /*
79 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
80 */
81 
82 #ifndef AVGSECSPERYEAR
83 #define AVGSECSPERYEAR		31556952L
84 #endif /* !defined AVGSECSPERYEAR */
85 
86 #ifndef SECSPERREPEAT
87 #define SECSPERREPEAT		((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
88 #endif /* !defined SECSPERREPEAT */
89 
90 #ifndef SECSPERREPEAT_BITS
91 #define SECSPERREPEAT_BITS	34	/* ceil(log2(SECSPERREPEAT)) */
92 #endif /* !defined SECSPERREPEAT_BITS */
93 
94 #endif /* !defined PRIVATE_H */
95