Header And Logo

PostgreSQL
| The world's most advanced open source database.

private.h

Go to the documentation of this file.
00001 #ifndef PRIVATE_H
00002 #define PRIVATE_H
00003 
00004 /*
00005  * This file is in the public domain, so clarified as of
00006  * 1996-06-05 by Arthur David Olson.
00007  *
00008  * IDENTIFICATION
00009  *    src/timezone/private.h
00010  */
00011 
00012 /*
00013  * This header is for use ONLY with the time conversion code.
00014  * There is no guarantee that it will remain unchanged,
00015  * or that it will remain at all.
00016  * Do NOT copy it to any system include directory.
00017  * Thank you!
00018  */
00019 
00020 #include <limits.h>             /* for CHAR_BIT et al. */
00021 #include <sys/wait.h>           /* for WIFEXITED and WEXITSTATUS */
00022 #include <unistd.h>             /* for F_OK and R_OK */
00023 
00024 #include "pgtime.h"
00025 
00026 #define GRANDPARENTED   "Local time zone must be set--see zic manual page"
00027 
00028 #ifndef WIFEXITED
00029 #define WIFEXITED(status)   (((status) & 0xff) == 0)
00030 #endif   /* !defined WIFEXITED */
00031 #ifndef WEXITSTATUS
00032 #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
00033 #endif   /* !defined WEXITSTATUS */
00034 
00035 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
00036 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
00037 
00038 /*
00039  * SunOS 4.1.1 libraries lack remove.
00040  */
00041 
00042 #ifndef remove
00043 extern int  unlink(const char *filename);
00044 
00045 #define remove  unlink
00046 #endif   /* !defined remove */
00047 
00048 /*
00049  * Private function declarations.
00050  */
00051 extern char *icalloc(int nelem, int elsize);
00052 extern char *icatalloc(char *old, const char *new);
00053 extern char *icpyalloc(const char *string);
00054 extern char *imalloc(int n);
00055 extern void *irealloc(void *pointer, int size);
00056 extern void icfree(char *pointer);
00057 extern void ifree(char *pointer);
00058 extern const char *scheck(const char *string, const char *format);
00059 
00060 
00061 /*
00062  * Finally, some convenience items.
00063  */
00064 
00065 #ifndef TRUE
00066 #define TRUE    1
00067 #endif   /* !defined TRUE */
00068 
00069 #ifndef FALSE
00070 #define FALSE   0
00071 #endif   /* !defined FALSE */
00072 
00073 #ifndef TYPE_BIT
00074 #define TYPE_BIT(type)  (sizeof (type) * CHAR_BIT)
00075 #endif   /* !defined TYPE_BIT */
00076 
00077 #ifndef TYPE_SIGNED
00078 #define TYPE_SIGNED(type) (((type) -1) < 0)
00079 #endif   /* !defined TYPE_SIGNED */
00080 
00081 /*
00082  * Since the definition of TYPE_INTEGRAL contains floating point numbers,
00083  * it cannot be used in preprocessor directives.
00084  */
00085 
00086 #ifndef TYPE_INTEGRAL
00087 #define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
00088 #endif   /* !defined TYPE_INTEGRAL */
00089 
00090 #ifndef INT_STRLEN_MAXIMUM
00091 /*
00092  * 302 / 1000 is log10(2.0) rounded up.
00093  * Subtract one for the sign bit if the type is signed;
00094  * add one for integer division truncation;
00095  * add one more for a minus sign if the type is signed.
00096  */
00097 #define INT_STRLEN_MAXIMUM(type) \
00098     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
00099 #endif   /* !defined INT_STRLEN_MAXIMUM */
00100 
00101 #undef _
00102 #define _(msgid) (msgid)
00103 
00104 #ifndef YEARSPERREPEAT
00105 #define YEARSPERREPEAT          400     /* years before a Gregorian repeat */
00106 #endif   /* !defined YEARSPERREPEAT */
00107 
00108 /*
00109 ** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
00110 */
00111 
00112 #ifndef AVGSECSPERYEAR
00113 #define AVGSECSPERYEAR          31556952L
00114 #endif   /* !defined AVGSECSPERYEAR */
00115 
00116 #ifndef SECSPERREPEAT
00117 #define SECSPERREPEAT           ((int64) YEARSPERREPEAT * (int64) AVGSECSPERYEAR)
00118 #endif   /* !defined SECSPERREPEAT */
00119 
00120 #ifndef SECSPERREPEAT_BITS
00121 #define SECSPERREPEAT_BITS      34      /* ceil(log2(SECSPERREPEAT)) */
00122 #endif   /* !defined SECSPERREPEAT_BITS */
00123 
00124 /*
00125  * UNIX was a registered trademark of The Open Group in 2003.
00126  */
00127 
00128 #endif   /* !defined PRIVATE_H */