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