Fix pg_dump bug in the database-level collation patch. "datcollate" and
[PostgreSQL.git] / src / timezone / private.h
blob362d34e52527a90b60a0d194ed935b5047d44ed1
1 #ifndef PRIVATE_H
2 #define PRIVATE_H
4 /*
5 * This file is in the public domain, so clarified as of
6 * 1996-06-05 by Arthur David Olson.
8 * IDENTIFICATION
9 * $PostgreSQL$
13 * This header is for use ONLY with the time conversion code.
14 * There is no guarantee that it will remain unchanged,
15 * or that it will remain at all.
16 * Do NOT copy it to any system include directory.
17 * Thank you!
20 #include <limits.h> /* for CHAR_BIT et al. */
21 #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
22 #include <unistd.h> /* for F_OK and R_OK */
24 #include "pgtime.h"
26 #define GRANDPARENTED "Local time zone must be set--see zic manual page"
28 #ifndef WIFEXITED
29 #define WIFEXITED(status) (((status) & 0xff) == 0)
30 #endif /* !defined WIFEXITED */
31 #ifndef WEXITSTATUS
32 #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
33 #endif /* !defined WEXITSTATUS */
35 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
36 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
39 * SunOS 4.1.1 libraries lack remove.
42 #ifndef remove
43 extern int unlink(const char *filename);
45 #define remove unlink
46 #endif /* !defined remove */
49 * Private function declarations.
51 extern char *icalloc(int nelem, int elsize);
52 extern char *icatalloc(char *old, const char *new);
53 extern char *icpyalloc(const char *string);
54 extern char *imalloc(int n);
55 extern void *irealloc(void *pointer, int size);
56 extern void icfree(char *pointer);
57 extern void ifree(char *pointer);
58 extern const char *scheck(const char *string, const char *format);
62 * Finally, some convenience items.
65 #ifndef TRUE
66 #define TRUE 1
67 #endif /* !defined TRUE */
69 #ifndef FALSE
70 #define FALSE 0
71 #endif /* !defined FALSE */
73 #ifndef TYPE_BIT
74 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
75 #endif /* !defined TYPE_BIT */
77 #ifndef TYPE_SIGNED
78 #define TYPE_SIGNED(type) (((type) -1) < 0)
79 #endif /* !defined TYPE_SIGNED */
82 * Since the definition of TYPE_INTEGRAL contains floating point numbers,
83 * it cannot be used in preprocessor directives.
86 #ifndef TYPE_INTEGRAL
87 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
88 #endif /* !defined TYPE_INTEGRAL */
90 #ifndef INT_STRLEN_MAXIMUM
92 * 302 / 1000 is log10(2.0) rounded up.
93 * Subtract one for the sign bit if the type is signed;
94 * add one for integer division truncation;
95 * add one more for a minus sign if the type is signed.
97 #define INT_STRLEN_MAXIMUM(type) \
98 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
99 #endif /* !defined INT_STRLEN_MAXIMUM */
101 #undef _
102 #define _(msgid) (msgid)
104 #ifndef YEARSPERREPEAT
105 #define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
106 #endif /* !defined YEARSPERREPEAT */
109 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
112 #ifndef AVGSECSPERYEAR
113 #define AVGSECSPERYEAR 31556952L
114 #endif /* !defined AVGSECSPERYEAR */
116 #ifndef SECSPERREPEAT
117 #define SECSPERREPEAT ((int64) YEARSPERREPEAT * (int64) AVGSECSPERYEAR)
118 #endif /* !defined SECSPERREPEAT */
120 #ifndef SECSPERREPEAT_BITS
121 #define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
122 #endif /* !defined SECSPERREPEAT_BITS */
125 * UNIX was a registered trademark of The Open Group in 2003.
128 #endif /* !defined PRIVATE_H */