Home | History | Annotate | Line # | Download | only in time
private.h revision 1.16
      1 /*	$NetBSD: private.h,v 1.16 2000/12/10 03:56:31 christos Exp $	*/
      2 
      3 #ifndef PRIVATE_H
      4 #define PRIVATE_H
      5 
      6 /* NetBSD defaults */
      7 #define TM_GMTOFF	tm_gmtoff
      8 #define TM_ZONE		tm_zone
      9 #define STD_INSPIRED	1
     10 #define HAVE_LONG_DOUBLE 1
     11 
     12 /*
     13 ** This file is in the public domain, so clarified as of
     14 ** 1996-06-05 by Arthur David Olson (arthur_david_olson (at) nih.gov).
     15 */
     16 
     17 /*
     18 ** This header is for use ONLY with the time conversion code.
     19 ** There is no guarantee that it will remain unchanged,
     20 ** or that it will remain at all.
     21 ** Do NOT copy it to any system include directory.
     22 ** Thank you!
     23 */
     24 
     25 /*
     26 ** ID
     27 */
     28 
     29 #ifndef lint
     30 #ifndef NOID
     31 #if 0
     32 static char	privatehid[] = "@(#)private.h	7.49";
     33 #endif
     34 #endif /* !defined NOID */
     35 #endif /* !defined lint */
     36 
     37 /*
     38 ** Defaults for preprocessor symbols.
     39 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
     40 */
     41 
     42 #ifndef HAVE_ADJTIME
     43 #define HAVE_ADJTIME		1
     44 #endif /* !defined HAVE_ADJTIME */
     45 
     46 #ifndef HAVE_GETTEXT
     47 #define HAVE_GETTEXT		0
     48 #endif /* !defined HAVE_GETTEXT */
     49 
     50 #ifndef HAVE_SETTIMEOFDAY
     51 #define HAVE_SETTIMEOFDAY	3
     52 #endif /* !defined HAVE_SETTIMEOFDAY */
     53 
     54 #ifndef HAVE_STRERROR
     55 #define HAVE_STRERROR		1
     56 #endif /* !defined HAVE_STRERROR */
     57 
     58 #ifndef HAVE_SYMLINK
     59 #define HAVE_SYMLINK		1
     60 #endif /* !defined HAVE_SYMLINK */
     61 
     62 #ifndef HAVE_SYS_WAIT_H
     63 #define HAVE_SYS_WAIT_H		1
     64 #endif /* !defined HAVE_SYS_WAIT_H */
     65 
     66 #ifndef HAVE_UNISTD_H
     67 #define HAVE_UNISTD_H		1
     68 #endif /* !defined HAVE_UNISTD_H */
     69 
     70 #ifndef HAVE_UTMPX_H
     71 #define HAVE_UTMPX_H		0
     72 #endif /* !defined HAVE_UTMPX_H */
     73 
     74 #ifndef LOCALE_HOME
     75 #define LOCALE_HOME		"/usr/lib/locale"
     76 #endif /* !defined LOCALE_HOME */
     77 
     78 /*
     79 ** Nested includes
     80 */
     81 
     82 #include "sys/types.h"	/* for time_t */
     83 #include "stdio.h"
     84 #include "errno.h"
     85 #include "string.h"
     86 #include "limits.h"	/* for CHAR_BIT */
     87 #include "time.h"
     88 #include "stdlib.h"
     89 
     90 #if HAVE_GETTEXT - 0
     91 #include "libintl.h"
     92 #endif /* HAVE_GETTEXT - 0 */
     93 
     94 #if HAVE_SYS_WAIT_H - 0
     95 #include <sys/wait.h>	/* for WIFEXITED and WEXITSTATUS */
     96 #endif /* HAVE_SYS_WAIT_H - 0 */
     97 
     98 #ifndef WIFEXITED
     99 #define WIFEXITED(status)	(((status) & 0xff) == 0)
    100 #endif /* !defined WIFEXITED */
    101 #ifndef WEXITSTATUS
    102 #define WEXITSTATUS(status)	(((status) >> 8) & 0xff)
    103 #endif /* !defined WEXITSTATUS */
    104 
    105 #if HAVE_UNISTD_H - 0
    106 #include "unistd.h"	/* for F_OK and R_OK */
    107 #endif /* HAVE_UNISTD_H - 0 */
    108 
    109 #if !(HAVE_UNISTD_H - 0)
    110 #ifndef F_OK
    111 #define F_OK	0
    112 #endif /* !defined F_OK */
    113 #ifndef R_OK
    114 #define R_OK	4
    115 #endif /* !defined R_OK */
    116 #endif /* !(HAVE_UNISTD_H - 0) */
    117 
    118 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
    119 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
    120 
    121 /*
    122 ** Workarounds for compilers/systems.
    123 */
    124 
    125 /*
    126 ** SunOS 4.1.1 cc lacks const.
    127 */
    128 
    129 #ifndef const
    130 #ifndef __STDC__
    131 #define const
    132 #endif /* !defined __STDC__ */
    133 #endif /* !defined const */
    134 
    135 /*
    136 ** SunOS 4.1.1 cc lacks prototypes.
    137 */
    138 
    139 #ifndef P
    140 #ifdef __STDC__
    141 #define P(x)	x
    142 #endif /* defined __STDC__ */
    143 #ifndef __STDC__
    144 #define P(x)	()
    145 #endif /* !defined __STDC__ */
    146 #endif /* !defined P */
    147 
    148 /*
    149 ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
    150 */
    151 
    152 #ifndef EXIT_SUCCESS
    153 #define EXIT_SUCCESS	0
    154 #endif /* !defined EXIT_SUCCESS */
    155 
    156 /*
    157 ** SunOS 4.1.1 headers lack EXIT_FAILURE.
    158 */
    159 
    160 #ifndef EXIT_FAILURE
    161 #define EXIT_FAILURE	1
    162 #endif /* !defined EXIT_FAILURE */
    163 
    164 /*
    165 ** SunOS 4.1.1 headers lack FILENAME_MAX.
    166 */
    167 
    168 #ifndef FILENAME_MAX
    169 
    170 #ifndef MAXPATHLEN
    171 #ifdef unix
    172 #include "sys/param.h"
    173 #endif /* defined unix */
    174 #endif /* !defined MAXPATHLEN */
    175 
    176 #ifdef MAXPATHLEN
    177 #define FILENAME_MAX	MAXPATHLEN
    178 #endif /* defined MAXPATHLEN */
    179 #ifndef MAXPATHLEN
    180 #define FILENAME_MAX	1024		/* Pure guesswork */
    181 #endif /* !defined MAXPATHLEN */
    182 
    183 #endif /* !defined FILENAME_MAX */
    184 
    185 /*
    186 ** SunOS 4.1.1 libraries lack remove.
    187 */
    188 
    189 #ifndef __NetBSD__
    190 #ifndef remove
    191 extern int	unlink P((const char * filename));
    192 #define remove	unlink
    193 #endif /* !defined remove */
    194 #endif
    195 
    196 /*
    197 ** Some ancient errno.h implementations don't declare errno.
    198 ** But some newer errno.h implementations define it as a macro.
    199 ** Fix the former without affecting the latter.
    200 */
    201 #ifndef errno
    202 extern int errno;
    203 #endif /* !defined errno */
    204 
    205 /*
    206 ** Private function declarations.
    207 */
    208 char *	icalloc P((int nelem, int elsize));
    209 char *	icatalloc P((char * old, const char * new));
    210 char *	icpyalloc P((const char * string));
    211 char *	imalloc P((int n));
    212 void *	irealloc P((void * pointer, int size));
    213 void	icfree P((char * pointer));
    214 void	ifree P((char * pointer));
    215 char *	scheck P((const char *string, const char *format))
    216 	__attribute__((__format_arg__(2)));
    217 
    218 
    219 /*
    220 ** Finally, some convenience items.
    221 */
    222 
    223 #ifndef TRUE
    224 #define TRUE	1
    225 #endif /* !defined TRUE */
    226 
    227 #ifndef FALSE
    228 #define FALSE	0
    229 #endif /* !defined FALSE */
    230 
    231 #ifndef TYPE_BIT
    232 #define TYPE_BIT(type)	(sizeof (type) * CHAR_BIT)
    233 #endif /* !defined TYPE_BIT */
    234 
    235 #ifndef TYPE_SIGNED
    236 #define TYPE_SIGNED(type) (((type) -1) < 0)
    237 #endif /* !defined TYPE_SIGNED */
    238 
    239 #ifndef INT_STRLEN_MAXIMUM
    240 /*
    241 ** 302 / 1000 is log10(2.0) rounded up.
    242 ** Subtract one for the sign bit if the type is signed;
    243 ** add one for integer division truncation;
    244 ** add one more for a minus sign if the type is signed.
    245 */
    246 #define INT_STRLEN_MAXIMUM(type) \
    247     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
    248 #endif /* !defined INT_STRLEN_MAXIMUM */
    249 
    250 /*
    251 ** INITIALIZE(x)
    252 */
    253 
    254 #ifndef GNUC_or_lint
    255 #ifdef lint
    256 #define GNUC_or_lint
    257 #endif /* defined lint */
    258 #ifndef lint
    259 #ifdef __GNUC__
    260 #define GNUC_or_lint
    261 #endif /* defined __GNUC__ */
    262 #endif /* !defined lint */
    263 #endif /* !defined GNUC_or_lint */
    264 
    265 #ifndef INITIALIZE
    266 #ifdef GNUC_or_lint
    267 #define INITIALIZE(x)	((x) = 0)
    268 #endif /* defined GNUC_or_lint */
    269 #ifndef GNUC_or_lint
    270 #define INITIALIZE(x)
    271 #endif /* !defined GNUC_or_lint */
    272 #endif /* !defined INITIALIZE */
    273 
    274 /*
    275 ** For the benefit of GNU folk...
    276 ** `_(MSGID)' uses the current locale's message library string for MSGID.
    277 ** The default is to use gettext if available, and use MSGID otherwise.
    278 */
    279 
    280 #ifndef _
    281 #if HAVE_GETTEXT - 0
    282 #define _(msgid) gettext(msgid)
    283 #else /* !(HAVE_GETTEXT - 0) */
    284 #define _(msgid) msgid
    285 #endif /* !(HAVE_GETTEXT - 0) */
    286 #endif /* !defined _ */
    287 
    288 #ifndef TZ_DOMAIN
    289 #define TZ_DOMAIN "tz"
    290 #endif /* !defined TZ_DOMAIN */
    291 
    292 /*
    293 ** UNIX was a registered trademark of UNIX System Laboratories in 1993.
    294 */
    295 
    296 #endif /* !defined PRIVATE_H */
    297