compat_defs.h revision 1.23 1 1.23 lukem /* $NetBSD: compat_defs.h,v 1.23 2002/11/29 13:00:22 lukem Exp $ */
2 1.1 thorpej
3 1.1 thorpej #ifndef __NETBSD_COMPAT_DEFS_H__
4 1.1 thorpej #define __NETBSD_COMPAT_DEFS_H__
5 1.1 thorpej
6 1.4 tv /* Work around some complete brain damage. */
7 1.4 tv
8 1.4 tv /*
9 1.4 tv * Linux: <features.h> turns on _POSIX_SOURCE by default, even though the
10 1.4 tv * program (not the OS) should do that. Preload <features.h> to keep any
11 1.4 tv * of this crap from being pulled in, and undefine _POSIX_SOURCE.
12 1.4 tv */
13 1.4 tv
14 1.4 tv #if defined(__linux__) && HAVE_FEATURES_H
15 1.4 tv #include <features.h>
16 1.4 tv #endif
17 1.4 tv
18 1.4 tv #undef _POSIX_SOURCE
19 1.4 tv #undef _POSIX_C_SOURCE
20 1.4 tv
21 1.1 thorpej /* System headers needed for (re)definitions below. */
22 1.1 thorpej
23 1.1 thorpej #include <sys/types.h>
24 1.3 tv #include <sys/mman.h>
25 1.3 tv #include <sys/param.h>
26 1.3 tv #include <sys/stat.h>
27 1.4 tv #include <sys/time.h>
28 1.1 thorpej #include <errno.h>
29 1.1 thorpej #include <fcntl.h>
30 1.2 lukem #include <grp.h>
31 1.1 thorpej #include <limits.h>
32 1.1 thorpej #include <paths.h>
33 1.3 tv #include <stdarg.h>
34 1.1 thorpej #include <stdio.h>
35 1.3 tv #include <stdlib.h>
36 1.1 thorpej #include <string.h>
37 1.1 thorpej
38 1.3 tv #if HAVE_SYS_CDEFS_H
39 1.3 tv #include <sys/cdefs.h>
40 1.3 tv #endif
41 1.6 tv #if HAVE_SYS_SYSLIMITS_H
42 1.6 tv #include <sys/syslimits.h>
43 1.6 tv #endif
44 1.3 tv #if HAVE_SYS_SYSMACROS_H
45 1.3 tv /* major(), minor() on SVR4 */
46 1.3 tv #include <sys/sysmacros.h>
47 1.3 tv #endif
48 1.1 thorpej #if HAVE_INTTYPES_H
49 1.1 thorpej #include <inttypes.h>
50 1.1 thorpej #endif
51 1.1 thorpej #if HAVE_STDDEF_H
52 1.1 thorpej #include <stddef.h>
53 1.1 thorpej #endif
54 1.3 tv
55 1.3 tv /* We don't include <pwd.h> here, so that "compat_pwd.h" works. */
56 1.3 tv struct passwd;
57 1.3 tv
58 1.3 tv /* Assume an ANSI compiler for the host. */
59 1.3 tv
60 1.3 tv #undef __P
61 1.3 tv #define __P(x) x
62 1.3 tv
63 1.3 tv #ifndef __BEGIN_DECLS
64 1.3 tv #define __BEGIN_DECLS
65 1.3 tv #endif
66 1.3 tv #ifndef __END_DECLS
67 1.3 tv #define __END_DECLS
68 1.3 tv #endif
69 1.3 tv
70 1.4 tv /* Some things usually in BSD <sys/cdefs.h>. */
71 1.3 tv
72 1.12 bjh21 #ifndef __CONCAT
73 1.12 bjh21 #define __CONCAT(x,y) x ## y
74 1.12 bjh21 #endif
75 1.1 thorpej #if !defined(__attribute__) && !defined(__GNUC__)
76 1.1 thorpej #define __attribute__(x)
77 1.1 thorpej #endif
78 1.3 tv #ifndef __RENAME
79 1.3 tv #define __RENAME(x)
80 1.3 tv #endif
81 1.3 tv #undef __aconst
82 1.3 tv #define __aconst
83 1.3 tv #undef __dead
84 1.3 tv #define __dead
85 1.17 bjh21 #undef __restrict
86 1.17 bjh21 #define __restrict
87 1.3 tv
88 1.3 tv /* Dirent support. */
89 1.3 tv
90 1.3 tv #if HAVE_DIRENT_H
91 1.3 tv # include <dirent.h>
92 1.3 tv # define NAMLEN(dirent) (strlen((dirent)->d_name))
93 1.3 tv #else
94 1.3 tv # define dirent direct
95 1.3 tv # define NAMLEN(dirent) ((dirent)->d_namlen)
96 1.3 tv # if HAVE_SYS_NDIR_H
97 1.3 tv # include <sys/ndir.h>
98 1.3 tv # endif
99 1.3 tv # if HAVE_SYS_DIR_H
100 1.3 tv # include <sys/dir.h>
101 1.3 tv # endif
102 1.3 tv # if HAVE_NDIR_H
103 1.3 tv # include <ndir.h>
104 1.3 tv # endif
105 1.3 tv #endif
106 1.3 tv
107 1.1 thorpej /* Type substitutes. */
108 1.1 thorpej
109 1.1 thorpej #if !HAVE_ID_T
110 1.1 thorpej typedef unsigned long id_t;
111 1.1 thorpej #endif
112 1.1 thorpej
113 1.1 thorpej /* Prototypes for replacement functions. */
114 1.1 thorpej
115 1.3 tv #if !HAVE_ASPRINTF
116 1.3 tv int asprintf(char **, const char *, ...);
117 1.3 tv #endif
118 1.3 tv
119 1.3 tv #if !HAVE_ASNPRINTF
120 1.3 tv int asnprintf(char **, size_t, const char *, ...);
121 1.3 tv #endif
122 1.3 tv
123 1.1 thorpej #if !HAVE_BASENAME
124 1.1 thorpej char *basename(char *);
125 1.1 thorpej #endif
126 1.1 thorpej
127 1.4 tv #if !HAVE_DECL_OPTIND
128 1.4 tv int getopt(int, char *const *, const char *);
129 1.4 tv extern char *optarg;
130 1.4 tv extern int optind, opterr, optopt;
131 1.4 tv #endif
132 1.4 tv
133 1.1 thorpej #if !HAVE_DIRNAME
134 1.1 thorpej char *dirname(char *);
135 1.1 thorpej #endif
136 1.1 thorpej
137 1.3 tv #if !HAVE_DIRFD
138 1.3 tv #if HAVE_DIR_DD_FD
139 1.3 tv #define dirfd(dirp) ((dirp)->dd_fd)
140 1.3 tv #else
141 1.3 tv #error cannot figure out how to turn a DIR * into a fd
142 1.3 tv #endif
143 1.3 tv #endif
144 1.3 tv
145 1.1 thorpej #if !HAVE_ERR_H
146 1.3 tv void err(int, const char *, ...);
147 1.3 tv void errx(int, const char *, ...);
148 1.1 thorpej void warn(const char *, ...);
149 1.1 thorpej void warnx(const char *, ...);
150 1.1 thorpej #endif
151 1.1 thorpej
152 1.1 thorpej #if !HAVE_FGETLN
153 1.1 thorpej char *fgetln(FILE *, size_t *);
154 1.1 thorpej #endif
155 1.1 thorpej
156 1.1 thorpej #if !HAVE_FLOCK
157 1.1 thorpej # define LOCK_SH 0x01
158 1.1 thorpej # define LOCK_EX 0x02
159 1.1 thorpej # define LOCK_NB 0x04
160 1.1 thorpej # define LOCK_UN 0x08
161 1.1 thorpej int flock(int, int);
162 1.1 thorpej #endif
163 1.1 thorpej
164 1.1 thorpej #if !HAVE_FPARSELN
165 1.1 thorpej # define FPARSELN_UNESCESC 0x01
166 1.1 thorpej # define FPARSELN_UNESCCONT 0x02
167 1.1 thorpej # define FPARSELN_UNESCCOMM 0x04
168 1.1 thorpej # define FPARSELN_UNESCREST 0x08
169 1.1 thorpej # define FPARSELN_UNESCALL 0x0f
170 1.1 thorpej char *fparseln(FILE *, size_t *, size_t *, const char [3], int);
171 1.10 bjh21 #endif
172 1.10 bjh21
173 1.10 bjh21 #if !HAVE_ISSETUGID
174 1.10 bjh21 int issetugid(void);
175 1.1 thorpej #endif
176 1.1 thorpej
177 1.3 tv #if !HAVE_ISBLANK && !defined(isblank)
178 1.3 tv #define isblank(x) ((x) == ' ' || (x) == '\t')
179 1.21 lukem #endif
180 1.21 lukem
181 1.21 lukem #if !HAVE_LCHFLAGS
182 1.21 lukem int lchflags(const char *, u_long);
183 1.21 lukem #endif
184 1.21 lukem
185 1.21 lukem #if !HAVE_LCHMOD
186 1.21 lukem int lchmod(const char *, mode_t);
187 1.21 lukem #endif
188 1.21 lukem
189 1.21 lukem #if !HAVE_LCHOWN
190 1.21 lukem int lchown(const char *, uid_t, gid_t);
191 1.1 thorpej #endif
192 1.1 thorpej
193 1.4 tv #if !HAVE_MACHINE_BSWAP_H
194 1.4 tv #define bswap16(x) ((((x) << 8) & 0xff00) | (((x) >> 8) & 0x00ff))
195 1.4 tv
196 1.4 tv #define bswap32(x) ((((x) << 24) & 0xff000000) | \
197 1.4 tv (((x) << 8) & 0x00ff0000) | \
198 1.4 tv (((x) >> 8) & 0x0000ff00) | \
199 1.4 tv (((x) >> 24) & 0x000000ff))
200 1.4 tv
201 1.4 tv #define bswap64(x) (((u_int64_t)bswap32((x)) << 32) | \
202 1.4 tv ((u_int64_t)bswap32((x) >> 32)))
203 1.18 thorpej #endif
204 1.18 thorpej
205 1.18 thorpej #if !HAVE_MKSTEMP
206 1.18 thorpej int mkstemp(char *);
207 1.18 thorpej #endif
208 1.18 thorpej
209 1.18 thorpej #if !HAVE_MKDTEMP
210 1.18 thorpej char *mkdtemp(char *);
211 1.18 thorpej #endif
212 1.18 thorpej
213 1.18 thorpej #if !HAVE_MKSTEMP || !HAVE_MKDTEMP
214 1.18 thorpej /* This is a prototype for the internal function. */
215 1.18 thorpej int gettemp(char *, int *, int);
216 1.4 tv #endif
217 1.4 tv
218 1.1 thorpej #if !HAVE_PREAD
219 1.1 thorpej ssize_t pread(int, void *, size_t, off_t);
220 1.2 lukem #endif
221 1.2 lukem
222 1.2 lukem #if !HAVE_PWCACHE_USERDB
223 1.2 lukem int uid_from_user(const char *, uid_t *);
224 1.2 lukem int pwcache_userdb(int (*)(int), void (*)(void),
225 1.2 lukem struct passwd * (*)(const char *), struct passwd * (*)(uid_t));
226 1.2 lukem int gid_from_group(const char *, gid_t *);
227 1.2 lukem int pwcache_groupdb(int (*)(int), void (*)(void),
228 1.2 lukem struct group * (*)(const char *), struct group * (*)(gid_t));
229 1.1 thorpej #endif
230 1.1 thorpej
231 1.1 thorpej #if !HAVE_PWRITE
232 1.1 thorpej ssize_t pwrite(int, const void *, size_t, off_t);
233 1.1 thorpej #endif
234 1.1 thorpej
235 1.3 tv #if !HAVE_SETENV
236 1.3 tv int setenv(const char *, const char *, int);
237 1.3 tv #endif
238 1.3 tv
239 1.6 tv #if !HAVE_DECL_SETGROUPENT
240 1.3 tv int setgroupent(int);
241 1.3 tv #endif
242 1.3 tv
243 1.6 tv #if !HAVE_DECL_SETPASSENT
244 1.3 tv int setpassent(int);
245 1.3 tv #endif
246 1.3 tv
247 1.3 tv #if !HAVE_SETPROGNAME
248 1.3 tv const char *getprogname(void);
249 1.3 tv void setprogname(const char *);
250 1.3 tv #endif
251 1.3 tv
252 1.3 tv #if !HAVE_SNPRINTF
253 1.3 tv int snprintf(char *, size_t, const char *, ...);
254 1.3 tv #endif
255 1.3 tv
256 1.3 tv #if !HAVE_STRLCAT
257 1.3 tv size_t strlcat(char *, const char *, size_t);
258 1.3 tv #endif
259 1.3 tv
260 1.3 tv #if !HAVE_STRLCPY
261 1.3 tv size_t strlcpy(char *, const char *, size_t);
262 1.3 tv #endif
263 1.3 tv
264 1.3 tv #if !HAVE_STRSEP
265 1.3 tv char *strsep(char **, const char *);
266 1.23 lukem #endif
267 1.23 lukem
268 1.23 lukem #if !HAVE_STRSUFTOLL
269 1.23 lukem long long strsuftoll(const char *, const char *, long long, long long);
270 1.23 lukem long long strsuftollx(const char *, const char *,
271 1.23 lukem long long, long long, char *, size_t);
272 1.16 pooka #endif
273 1.16 pooka
274 1.20 lukem #if !HAVE_STRTOLL
275 1.20 lukem long long strtoll(const char *, char **, int);
276 1.20 lukem #endif
277 1.20 lukem
278 1.16 pooka #if !HAVE_USER_FROM_UID
279 1.16 pooka const char *user_from_uid(uid_t, int);
280 1.16 pooka const char *group_from_gid(gid_t, int);
281 1.3 tv #endif
282 1.3 tv
283 1.3 tv #if !HAVE_VASPRINTF
284 1.3 tv int vasprintf(char **, const char *, va_list);
285 1.3 tv #endif
286 1.3 tv
287 1.3 tv #if !HAVE_VASNPRINTF
288 1.3 tv int vasnprintf(char **, size_t, const char *, va_list);
289 1.3 tv #endif
290 1.3 tv
291 1.3 tv #if !HAVE_VSNPRINTF
292 1.3 tv int vsnprintf(char *, size_t, const char *, va_list);
293 1.3 tv #endif
294 1.3 tv
295 1.1 thorpej /*
296 1.1 thorpej * getmode() and setmode() are always defined, as these function names
297 1.1 thorpej * exist but with very different meanings on other OS's. The compat
298 1.1 thorpej * versions here simply accept an octal mode number; the "u+x,g-w" type
299 1.1 thorpej * of syntax is not accepted.
300 1.1 thorpej */
301 1.1 thorpej
302 1.1 thorpej #define getmode __nbcompat_getmode
303 1.1 thorpej #define setmode __nbcompat_setmode
304 1.1 thorpej
305 1.1 thorpej mode_t getmode(const void *, mode_t);
306 1.1 thorpej void *setmode(const char *);
307 1.1 thorpej
308 1.3 tv /* Eliminate assertions embedded in binaries. */
309 1.1 thorpej
310 1.1 thorpej #undef _DIAGASSERT
311 1.3 tv #define _DIAGASSERT(x)
312 1.4 tv
313 1.4 tv /* Heimdal expects this one. */
314 1.4 tv
315 1.3 tv #undef RCSID
316 1.3 tv #define RCSID(x)
317 1.1 thorpej
318 1.3 tv /* Some definitions not available on all systems. */
319 1.1 thorpej
320 1.4 tv /* <errno.h> */
321 1.4 tv
322 1.4 tv #ifndef EFTYPE
323 1.4 tv #define EFTYPE EIO
324 1.4 tv #endif
325 1.4 tv
326 1.4 tv /* <fcntl.h> */
327 1.4 tv
328 1.4 tv #ifndef O_EXLOCK
329 1.4 tv #define O_EXLOCK 0
330 1.4 tv #endif
331 1.4 tv #ifndef O_SHLOCK
332 1.4 tv #define O_SHLOCK 0
333 1.4 tv #endif
334 1.4 tv
335 1.8 bjh21 /* <limits.h> */
336 1.4 tv
337 1.4 tv #ifndef UID_MAX
338 1.4 tv #define UID_MAX 32767
339 1.4 tv #endif
340 1.4 tv #ifndef GID_MAX
341 1.4 tv #define GID_MAX UID_MAX
342 1.4 tv #endif
343 1.4 tv
344 1.4 tv #ifndef UQUAD_MAX
345 1.4 tv #define UQUAD_MAX ((u_quad_t)-1)
346 1.4 tv #endif
347 1.4 tv #ifndef QUAD_MAX
348 1.4 tv #define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1))
349 1.4 tv #endif
350 1.4 tv #ifndef QUAD_MIN
351 1.4 tv #define QUAD_MIN ((quad_t)(~QUAD_MAX))
352 1.4 tv #endif
353 1.4 tv #ifndef ULLONG_MAX
354 1.4 tv #define ULLONG_MAX ((unsigned long long)-1)
355 1.4 tv #endif
356 1.4 tv #ifndef LLONG_MAX
357 1.4 tv #define LLONG_MAX ((long long)(ULLONG_MAX >> 1))
358 1.4 tv #endif
359 1.4 tv #ifndef LLONG_MIN
360 1.4 tv #define LLONG_MIN ((long long)(~LLONG_MAX))
361 1.3 tv #endif
362 1.1 thorpej
363 1.4 tv /* <paths.h> */
364 1.4 tv
365 1.3 tv #ifndef _PATH_BSHELL
366 1.15 bjh21 #define _PATH_BSHELL PATH_BSHELL
367 1.1 thorpej #endif
368 1.1 thorpej #ifndef _PATH_DEFPATH
369 1.1 thorpej #define _PATH_DEFPATH "/usr/bin:/bin:/usr/local/bin"
370 1.1 thorpej #endif
371 1.1 thorpej #ifndef _PATH_DEV
372 1.1 thorpej #define _PATH_DEV "/dev/"
373 1.1 thorpej #endif
374 1.1 thorpej #ifndef _PATH_DEVNULL
375 1.1 thorpej #define _PATH_DEVNULL _PATH_DEV "null"
376 1.1 thorpej #endif
377 1.1 thorpej #ifndef _PATH_TMP
378 1.1 thorpej #define _PATH_TMP "/tmp/"
379 1.22 christos #endif
380 1.22 christos #ifndef _PATH_DEFTAPE
381 1.22 christos #define _PATH_DEFTAPE "/dev/nrst0"
382 1.1 thorpej #endif
383 1.1 thorpej
384 1.4 tv /* <stdarg.h> */
385 1.3 tv
386 1.4 tv #ifndef _BSD_VA_LIST_
387 1.4 tv #define _BSD_VA_LIST_ va_list
388 1.9 bjh21 #endif
389 1.9 bjh21
390 1.13 bjh21 /* <stdint.h> */
391 1.13 bjh21
392 1.13 bjh21 #ifndef UINT32_MAX
393 1.13 bjh21 #define UINT32_MAX 0xffffffffU
394 1.14 bjh21 #endif
395 1.14 bjh21
396 1.14 bjh21 /* <stdlib.h> */
397 1.14 bjh21
398 1.14 bjh21 #ifndef __GNUC__
399 1.14 bjh21 # if HAVE_ALLOCA_H
400 1.14 bjh21 # include <alloca.h>
401 1.14 bjh21 # else
402 1.14 bjh21 # ifndef alloca /* predefined by HP cc +Olibcalls */
403 1.14 bjh21 char *alloca ();
404 1.14 bjh21 # endif
405 1.14 bjh21 # endif
406 1.13 bjh21 #endif
407 1.13 bjh21
408 1.9 bjh21 /* <sys/endian.h> */
409 1.9 bjh21
410 1.9 bjh21 #ifndef HAVE_SYS_ENDIAN_H
411 1.9 bjh21 #if WORDS_BIGENDIAN
412 1.9 bjh21 #define htobe16(x) (x)
413 1.9 bjh21 #define htobe32(x) (x)
414 1.9 bjh21 #define htobe64(x) (x)
415 1.9 bjh21 #define htole16(x) bswap16((u_int16_t)(x))
416 1.9 bjh21 #define htole32(x) bswap32((u_int32_t)(x))
417 1.9 bjh21 #define htole64(x) bswap64((u_int64_t)(x))
418 1.9 bjh21 #else
419 1.9 bjh21 #define htobe16(x) bswap16((u_int16_t)(x))
420 1.9 bjh21 #define htobe32(x) bswap32((u_int32_t)(x))
421 1.9 bjh21 #define htobe64(x) bswap64((u_int64_t)(x))
422 1.9 bjh21 #define htole16(x) (x)
423 1.9 bjh21 #define htole32(x) (x)
424 1.9 bjh21 #define htole64(x) (x)
425 1.9 bjh21 #endif
426 1.9 bjh21 #define be16toh(x) htobe16(x)
427 1.9 bjh21 #define be32toh(x) htobe32(x)
428 1.9 bjh21 #define be64toh(x) htobe64(x)
429 1.9 bjh21 #define le16toh(x) htole16(x)
430 1.9 bjh21 #define le32toh(x) htole32(x)
431 1.9 bjh21 #define le64toh(x) htole64(x)
432 1.1 thorpej #endif
433 1.1 thorpej
434 1.4 tv /* <sys/mman.h> */
435 1.3 tv
436 1.3 tv #ifndef MAP_FILE
437 1.3 tv #define MAP_FILE 0
438 1.19 lukem #endif
439 1.19 lukem
440 1.19 lukem /* HP-UX has MAP_ANONYMOUS but not MAP_ANON */
441 1.19 lukem #ifndef MAP_ANON
442 1.19 lukem #ifdef MAP_ANONYMOUS
443 1.19 lukem #define MAP_ANON MAP_ANONYMOUS
444 1.19 lukem #endif
445 1.3 tv #endif
446 1.3 tv
447 1.4 tv /* <sys/param.h> */
448 1.4 tv
449 1.4 tv #undef BIG_ENDIAN
450 1.4 tv #undef LITTLE_ENDIAN
451 1.4 tv #define BIG_ENDIAN 4321
452 1.4 tv #define LITTLE_ENDIAN 1234
453 1.4 tv
454 1.4 tv #undef BYTE_ORDER
455 1.4 tv #if WORDS_BIGENDIAN
456 1.4 tv #define BYTE_ORDER BIG_ENDIAN
457 1.4 tv #else
458 1.4 tv #define BYTE_ORDER LITTLE_ENDIAN
459 1.4 tv #endif
460 1.4 tv
461 1.7 tv #ifndef DEV_BSIZE
462 1.7 tv #define DEV_BSIZE (1 << 9)
463 1.7 tv #endif
464 1.7 tv
465 1.4 tv #undef MIN
466 1.4 tv #undef MAX
467 1.4 tv #define MIN(a,b) ((a) < (b) ? (a) : (b))
468 1.4 tv #define MAX(a,b) ((a) > (b) ? (a) : (b))
469 1.4 tv
470 1.1 thorpej #ifndef MAXBSIZE
471 1.1 thorpej #define MAXBSIZE (64 * 1024)
472 1.1 thorpej #endif
473 1.4 tv #ifndef MAXFRAG
474 1.4 tv #define MAXFRAG 8
475 1.1 thorpej #endif
476 1.4 tv #ifndef MAXPHYS
477 1.4 tv #define MAXPHYS (64 * 1024)
478 1.3 tv #endif
479 1.4 tv
480 1.6 tv /* XXX needed by makefs; this should be done in a better way */
481 1.6 tv #undef btodb
482 1.6 tv #define btodb(x) ((x) << 9)
483 1.6 tv
484 1.6 tv #undef setbit
485 1.6 tv #undef clrbit
486 1.6 tv #undef isset
487 1.6 tv #undef isclr
488 1.6 tv #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
489 1.6 tv #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
490 1.6 tv #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
491 1.6 tv #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
492 1.6 tv
493 1.4 tv #ifndef powerof2
494 1.4 tv #define powerof2(x) ((((x)-1)&(x))==0)
495 1.3 tv #endif
496 1.7 tv
497 1.7 tv #undef roundup
498 1.7 tv #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
499 1.3 tv
500 1.4 tv /* <sys/stat.h> */
501 1.4 tv
502 1.4 tv #ifndef ALLPERMS
503 1.4 tv #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
504 1.4 tv #endif
505 1.4 tv #ifndef DEFFILEMODE
506 1.4 tv #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
507 1.4 tv #endif
508 1.3 tv #ifndef S_ISTXT
509 1.3 tv #ifdef S_ISVTX
510 1.3 tv #define S_ISTXT S_ISVTX
511 1.3 tv #else
512 1.3 tv #define S_ISTXT 0
513 1.3 tv #endif
514 1.6 tv #endif
515 1.6 tv
516 1.6 tv /* <sys/syslimits.h> */
517 1.6 tv
518 1.6 tv #ifndef LINE_MAX
519 1.6 tv #define LINE_MAX 2048
520 1.4 tv #endif
521 1.4 tv
522 1.4 tv /* <sys/time.h> */
523 1.4 tv
524 1.4 tv #ifndef timercmp
525 1.4 tv #define timercmp(tvp, uvp, cmp) \
526 1.4 tv (((tvp)->tv_sec == (uvp)->tv_sec) ? \
527 1.4 tv ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
528 1.4 tv ((tvp)->tv_sec cmp (uvp)->tv_sec))
529 1.4 tv #endif
530 1.4 tv #ifndef timeradd
531 1.4 tv #define timeradd(tvp, uvp, vvp) \
532 1.4 tv do { \
533 1.4 tv (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
534 1.4 tv (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
535 1.4 tv if ((vvp)->tv_usec >= 1000000) { \
536 1.4 tv (vvp)->tv_sec++; \
537 1.4 tv (vvp)->tv_usec -= 1000000; \
538 1.4 tv } \
539 1.4 tv } while (/* CONSTCOND */ 0)
540 1.4 tv #endif
541 1.4 tv #ifndef timersub
542 1.4 tv #define timersub(tvp, uvp, vvp) \
543 1.4 tv do { \
544 1.4 tv (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
545 1.4 tv (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
546 1.4 tv if ((vvp)->tv_usec < 0) { \
547 1.4 tv (vvp)->tv_sec--; \
548 1.4 tv (vvp)->tv_usec += 1000000; \
549 1.4 tv } \
550 1.4 tv } while (/* CONSTCOND */ 0)
551 1.4 tv #endif
552 1.4 tv
553 1.4 tv /* <sys/types.h> */
554 1.4 tv
555 1.4 tv #if !HAVE_U_QUAD_T
556 1.4 tv /* #define, not typedef, as quad_t exists as a struct on some systems */
557 1.4 tv #define quad_t long long
558 1.4 tv #define u_quad_t unsigned long long
559 1.20 lukem #define strtoq strtoll
560 1.4 tv #define strtouq strtoull
561 1.1 thorpej #endif
562 1.1 thorpej
563 1.1 thorpej #endif /* !__NETBSD_COMPAT_DEFS_H__ */
564