Home | History | Annotate | Line # | Download | only in time
private.h revision 1.1.1.3
      1 #ifndef PRIVATE_H
      2 
      3 #define PRIVATE_H
      4 
      5 /*
      6 ** This header is for use ONLY with the time conversion code.
      7 ** There is no guarantee that it will remain unchanged,
      8 ** or that it will remain at all.
      9 ** Do NOT copy it to any system include directory.
     10 ** Thank you!
     11 */
     12 
     13 /*
     14 ** ID
     15 */
     16 
     17 #ifndef lint
     18 #ifndef NOID
     19 static char	privatehid[] = "@(#)private.h	7.39";
     20 #endif /* !defined NOID */
     21 #endif /* !defined lint */
     22 
     23 /*
     24 ** Defaults for preprocessor symbols.
     25 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
     26 */
     27 
     28 #ifndef HAVE_ADJTIME
     29 #define HAVE_ADJTIME		1
     30 #endif /* !defined HAVE_ADJTIME */
     31 
     32 #ifndef HAVE_SETTIMEOFDAY
     33 #define HAVE_SETTIMEOFDAY	3
     34 #endif /* !defined HAVE_SETTIMEOFDAY */
     35 
     36 #ifndef HAVE_UNISTD_H
     37 #define HAVE_UNISTD_H		1
     38 #endif /* !defined HAVE_UNISTD_H */
     39 
     40 #ifndef HAVE_UTMPX_H
     41 #define HAVE_UTMPX_H		0
     42 #endif /* !defined HAVE_UTMPX_H */
     43 
     44 #ifndef LOCALE_HOME
     45 #define LOCALE_HOME		"/usr/lib/locale"
     46 #endif /* !defined LOCALE_HOME */
     47 
     48 /*
     49 ** Nested includes
     50 */
     51 
     52 #include "sys/types.h"	/* for time_t */
     53 #include "stdio.h"
     54 #include "errno.h"
     55 #include "string.h"
     56 #include "limits.h"	/* for CHAR_BIT */
     57 #include "time.h"
     58 #include "stdlib.h"
     59 
     60 #if HAVE_UNISTD_H - 0
     61 #include "unistd.h"	/* for F_OK and R_OK */
     62 #endif /* HAVE_UNISTD_H - 0 */
     63 
     64 #if !(HAVE_UNISTD_H - 0)
     65 #ifndef F_OK
     66 #define F_OK	0
     67 #endif /* !defined F_OK */
     68 #ifndef R_OK
     69 #define R_OK	4
     70 #endif /* !defined R_OK */
     71 #endif /* !(HAVE_UNISTD_H - 0) */
     72 
     73 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
     74 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
     75 
     76 /*
     77 ** Workarounds for compilers/systems.
     78 */
     79 
     80 /*
     81 ** SunOS 4.1.1 cc lacks const.
     82 */
     83 
     84 #ifndef const
     85 #ifndef __STDC__
     86 #define const
     87 #endif /* !defined __STDC__ */
     88 #endif /* !defined const */
     89 
     90 /*
     91 ** SunOS 4.1.1 cc lacks prototypes.
     92 */
     93 
     94 #ifndef P
     95 #ifdef __STDC__
     96 #define P(x)	x
     97 #endif /* defined __STDC__ */
     98 #ifndef __STDC__
     99 #define P(x)	()
    100 #endif /* !defined __STDC__ */
    101 #endif /* !defined P */
    102 
    103 /*
    104 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
    105 */
    106 
    107 #ifndef EXIT_SUCCESS
    108 #define EXIT_SUCCESS	0
    109 #endif /* !defined EXIT_SUCCESS */
    110 
    111 /*
    112 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
    113 */
    114 
    115 #ifndef EXIT_FAILURE
    116 #define EXIT_FAILURE	1
    117 #endif /* !defined EXIT_FAILURE */
    118 
    119 /*
    120 ** SunOS 4.1.1 headers lack FILENAME_MAX.
    121 */
    122 
    123 #ifndef FILENAME_MAX
    124 
    125 #ifndef MAXPATHLEN
    126 #ifdef unix
    127 #include "sys/param.h"
    128 #endif /* defined unix */
    129 #endif /* !defined MAXPATHLEN */
    130 
    131 #ifdef MAXPATHLEN
    132 #define FILENAME_MAX	MAXPATHLEN
    133 #endif /* defined MAXPATHLEN */
    134 #ifndef MAXPATHLEN
    135 #define FILENAME_MAX	1024		/* Pure guesswork */
    136 #endif /* !defined MAXPATHLEN */
    137 
    138 #endif /* !defined FILENAME_MAX */
    139 
    140 /*
    141 ** SunOS 4.1.1 libraries lack remove.
    142 */
    143 
    144 #ifndef remove
    145 extern int	unlink P((const char * filename));
    146 #define remove	unlink
    147 #endif /* !defined remove */
    148 
    149 /*
    150 ** Finally, some convenience items.
    151 */
    152 
    153 #ifndef TRUE
    154 #define TRUE	1
    155 #endif /* !defined TRUE */
    156 
    157 #ifndef FALSE
    158 #define FALSE	0
    159 #endif /* !defined FALSE */
    160 
    161 #ifndef TYPE_BIT
    162 #define TYPE_BIT(type)	(sizeof (type) * CHAR_BIT)
    163 #endif /* !defined TYPE_BIT */
    164 
    165 #ifndef TYPE_SIGNED
    166 #define TYPE_SIGNED(type) (((type) -1) < 0)
    167 #endif /* !defined TYPE_SIGNED */
    168 
    169 #ifndef INT_STRLEN_MAXIMUM
    170 /*
    171 ** 302 / 1000 is log10(2.0) rounded up.
    172 ** Subtract one for the sign bit if the type is signed;
    173 ** add one for integer division truncation;
    174 ** add one more for a minus sign if the type is signed.
    175 */
    176 #define INT_STRLEN_MAXIMUM(type) \
    177     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 100 + 1 + TYPE_SIGNED(type))
    178 #endif /* !defined INT_STRLEN_MAXIMUM */
    179 
    180 /*
    181 ** INITIALIZE(x)
    182 */
    183 
    184 #ifndef GNUC_or_lint
    185 #ifdef lint
    186 #define GNUC_or_lint
    187 #endif /* defined lint */
    188 #ifndef lint
    189 #ifdef __GNUC__
    190 #define GNUC_or_lint
    191 #endif /* defined __GNUC__ */
    192 #endif /* !defined lint */
    193 #endif /* !defined GNUC_or_lint */
    194 
    195 #ifndef INITIALIZE
    196 #ifdef GNUC_or_lint
    197 #define INITIALIZE(x)	((x) = 0)
    198 #endif /* defined GNUC_or_lint */
    199 #ifndef GNUC_or_lint
    200 #define INITIALIZE(x)
    201 #endif /* !defined GNUC_or_lint */
    202 #endif /* !defined INITIALIZE */
    203 
    204 /*
    205 ** UNIX was a registered trademark of UNIX System Laboratories in 1993.
    206 */
    207 
    208 #endif /* !defined PRIVATE_H */
    209