1 /* $NetBSD: private.h,v 1.7 1996/09/13 17:46:49 jtc 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 ** June 5, 1996 by Arthur David Olson (arthur_david_olson@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 static char privatehid[] = "@(#)private.h 7.43"; 32 #endif /* !defined NOID */ 33 #endif /* !defined lint */ 34 35 /* 36 ** Defaults for preprocessor symbols. 37 ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. 38 */ 39 40 #ifndef HAVE_ADJTIME 41 #define HAVE_ADJTIME 1 42 #endif /* !defined HAVE_ADJTIME */ 43 44 #ifndef HAVE_GETTEXT 45 #define HAVE_GETTEXT 0 46 #endif /* !defined HAVE_GETTEXT */ 47 48 #ifndef HAVE_SETTIMEOFDAY 49 #define HAVE_SETTIMEOFDAY 3 50 #endif /* !defined HAVE_SETTIMEOFDAY */ 51 52 #ifndef HAVE_STRERROR 53 #define HAVE_STRERROR 1 54 #endif /* !defined HAVE_STRERROR */ 55 56 #ifndef HAVE_UNISTD_H 57 #define HAVE_UNISTD_H 1 58 #endif /* !defined HAVE_UNISTD_H */ 59 60 #ifndef HAVE_UTMPX_H 61 #define HAVE_UTMPX_H 0 62 #endif /* !defined HAVE_UTMPX_H */ 63 64 #ifndef LOCALE_HOME 65 #define LOCALE_HOME "/usr/lib/locale" 66 #endif /* !defined LOCALE_HOME */ 67 68 /* 69 ** Nested includes 70 */ 71 72 #include "sys/types.h" /* for time_t */ 73 #include "stdio.h" 74 #include "errno.h" 75 #include "string.h" 76 #include "limits.h" /* for CHAR_BIT */ 77 #include "time.h" 78 #include "stdlib.h" 79 80 #if HAVE_GETTEXT - 0 81 #include "libintl.h" 82 #endif /* HAVE_GETTEXT - 0 */ 83 84 #if HAVE_UNISTD_H - 0 85 #include "unistd.h" /* for F_OK and R_OK */ 86 #endif /* HAVE_UNISTD_H - 0 */ 87 88 #if !(HAVE_UNISTD_H - 0) 89 #ifndef F_OK 90 #define F_OK 0 91 #endif /* !defined F_OK */ 92 #ifndef R_OK 93 #define R_OK 4 94 #endif /* !defined R_OK */ 95 #endif /* !(HAVE_UNISTD_H - 0) */ 96 97 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ 98 #define is_digit(c) ((unsigned)(c) - '0' <= 9) 99 100 /* 101 ** Workarounds for compilers/systems. 102 */ 103 104 /* 105 ** SunOS 4.1.1 cc lacks const. 106 */ 107 108 #ifndef const 109 #ifndef __STDC__ 110 #define const 111 #endif /* !defined __STDC__ */ 112 #endif /* !defined const */ 113 114 /* 115 ** SunOS 4.1.1 cc lacks prototypes. 116 */ 117 118 #ifndef P 119 #ifdef __STDC__ 120 #define P(x) x 121 #endif /* defined __STDC__ */ 122 #ifndef __STDC__ 123 #define P(x) () 124 #endif /* !defined __STDC__ */ 125 #endif /* !defined P */ 126 127 /* 128 ** SunOS 4.1.1 headers lack EXIT_SUCCESS. 129 */ 130 131 #ifndef EXIT_SUCCESS 132 #define EXIT_SUCCESS 0 133 #endif /* !defined EXIT_SUCCESS */ 134 135 /* 136 ** SunOS 4.1.1 headers lack EXIT_FAILURE. 137 */ 138 139 #ifndef EXIT_FAILURE 140 #define EXIT_FAILURE 1 141 #endif /* !defined EXIT_FAILURE */ 142 143 /* 144 ** SunOS 4.1.1 headers lack FILENAME_MAX. 145 */ 146 147 #ifndef FILENAME_MAX 148 149 #ifndef MAXPATHLEN 150 #ifdef unix 151 #include "sys/param.h" 152 #endif /* defined unix */ 153 #endif /* !defined MAXPATHLEN */ 154 155 #ifdef MAXPATHLEN 156 #define FILENAME_MAX MAXPATHLEN 157 #endif /* defined MAXPATHLEN */ 158 #ifndef MAXPATHLEN 159 #define FILENAME_MAX 1024 /* Pure guesswork */ 160 #endif /* !defined MAXPATHLEN */ 161 162 #endif /* !defined FILENAME_MAX */ 163 164 /* 165 ** SunOS 4.1.1 libraries lack remove. 166 */ 167 168 #ifndef remove 169 extern int unlink P((const char * filename)); 170 #define remove unlink 171 #endif /* !defined remove */ 172 173 /* 174 ** Some ancient errno.h implementations don't declare errno. 175 ** But some newer errno.h implementations define it as a macro. 176 ** Fix the former without affecting the latter. 177 */ 178 #ifndef errno 179 extern int errno; 180 #endif /* !defined errno */ 181 182 /* 183 ** Finally, some convenience items. 184 */ 185 186 #ifndef TRUE 187 #define TRUE 1 188 #endif /* !defined TRUE */ 189 190 #ifndef FALSE 191 #define FALSE 0 192 #endif /* !defined FALSE */ 193 194 #ifndef TYPE_BIT 195 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) 196 #endif /* !defined TYPE_BIT */ 197 198 #ifndef TYPE_SIGNED 199 #define TYPE_SIGNED(type) (((type) -1) < 0) 200 #endif /* !defined TYPE_SIGNED */ 201 202 #ifndef INT_STRLEN_MAXIMUM 203 /* 204 ** 302 / 1000 is log10(2.0) rounded up. 205 ** Subtract one for the sign bit if the type is signed; 206 ** add one for integer division truncation; 207 ** add one more for a minus sign if the type is signed. 208 */ 209 #define INT_STRLEN_MAXIMUM(type) \ 210 ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 100 + 1 + TYPE_SIGNED(type)) 211 #endif /* !defined INT_STRLEN_MAXIMUM */ 212 213 /* 214 ** INITIALIZE(x) 215 */ 216 217 #ifndef GNUC_or_lint 218 #ifdef lint 219 #define GNUC_or_lint 220 #endif /* defined lint */ 221 #ifndef lint 222 #ifdef __GNUC__ 223 #define GNUC_or_lint 224 #endif /* defined __GNUC__ */ 225 #endif /* !defined lint */ 226 #endif /* !defined GNUC_or_lint */ 227 228 #ifndef INITIALIZE 229 #ifdef GNUC_or_lint 230 #define INITIALIZE(x) ((x) = 0) 231 #endif /* defined GNUC_or_lint */ 232 #ifndef GNUC_or_lint 233 #define INITIALIZE(x) 234 #endif /* !defined GNUC_or_lint */ 235 #endif /* !defined INITIALIZE */ 236 237 /* 238 ** For the benefit of GNU folk... 239 ** `_(MSGID)' uses the current locale's message library string for MSGID. 240 ** The default is to use gettext if available, and use MSGID otherwise. 241 */ 242 243 #ifndef _ 244 #if HAVE_GETTEXT - 0 245 #define _(msgid) gettext(msgid) 246 #else /* !(HAVE_GETTEXT - 0) */ 247 #define _(msgid) msgid 248 #endif /* !(HAVE_GETTEXT - 0) */ 249 #endif /* !defined _ */ 250 251 #ifndef TZ_DOMAIN 252 #define TZ_DOMAIN "tz" 253 #endif /* !defined TZ_DOMAIN */ 254 255 /* 256 ** UNIX was a registered trademark of UNIX System Laboratories in 1993. 257 */ 258 259 #endif /* !defined PRIVATE_H */ 260