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