compat_defs.h revision 1.31.2.5 1 /* $NetBSD: compat_defs.h,v 1.31.2.5 2004/06/23 17:40:25 jmc Exp $ */
2
3 #ifndef __NETBSD_COMPAT_DEFS_H__
4 #define __NETBSD_COMPAT_DEFS_H__
5
6 /* Work around some complete brain damage. */
7
8 /*
9 * Linux: <features.h> turns on _POSIX_SOURCE by default, even though the
10 * program (not the OS) should do that. Preload <features.h> to keep any
11 * of this crap from being pulled in, and undefine _POSIX_SOURCE.
12 */
13
14 #if defined(__linux__) && HAVE_FEATURES_H
15 #include <features.h>
16 #endif
17
18 /* So _NETBSD_SOURCE doesn't end up defined. Define enough to pull in standard
19 defs. Other platforms may need similiar defines. */
20 #ifdef __NetBSD__
21 #define _ISOC99_SOURCE
22 #define _POSIX_SOURCE 1
23 #define _POSIX_C_SOURCE 200112L
24 #define _XOPEN_SOURCE 600
25 #else
26 #undef _POSIX_SOURCE
27 #undef _POSIX_C_SOURCE
28 #endif
29
30 /* System headers needed for (re)definitions below. */
31
32 #include <sys/types.h>
33 #include <sys/mman.h>
34 #include <sys/param.h>
35 /* time.h needs to be pulled in first at least on netbsd w/o _NETBSD_SOURCE */
36 #include <sys/time.h>
37 #include <sys/stat.h>
38 #include <errno.h>
39 #include <fcntl.h>
40 #include <grp.h>
41 #include <limits.h>
42 #include <paths.h>
43 #include <stdarg.h>
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <string.h>
47
48 #if HAVE_SYS_CDEFS_H
49 #include <sys/cdefs.h>
50 #endif
51 #if HAVE_SYS_SYSLIMITS_H
52 #include <sys/syslimits.h>
53 #endif
54 #if HAVE_SYS_SYSMACROS_H
55 /* major(), minor() on SVR4 */
56 #include <sys/sysmacros.h>
57 #endif
58 #if HAVE_INTTYPES_H
59 #include <inttypes.h>
60 #endif
61 #if HAVE_STDDEF_H
62 #include <stddef.h>
63 #endif
64
65 /* We don't include <pwd.h> here, so that "compat_pwd.h" works. */
66 struct passwd;
67
68 /* Assume an ANSI compiler for the host. */
69
70 #undef __P
71 #define __P(x) x
72
73 #ifndef __BEGIN_DECLS
74 #define __BEGIN_DECLS
75 #endif
76 #ifndef __END_DECLS
77 #define __END_DECLS
78 #endif
79
80 /* Some things usually in BSD <sys/cdefs.h>. */
81
82 #ifndef __CONCAT
83 #define __CONCAT(x,y) x ## y
84 #endif
85 #if !defined(__attribute__) && !defined(__GNUC__)
86 #define __attribute__(x)
87 #endif
88 #if !defined(__packed)
89 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
90 #define __packed __attribute__((__packed__))
91 #else
92 #define __packed error: no __packed for this compiler
93 #endif
94 #endif /* !__packed */
95 #ifndef __RENAME
96 #define __RENAME(x)
97 #endif
98 #undef __aconst
99 #define __aconst
100 #undef __dead
101 #define __dead
102 #undef __restrict
103 #define __restrict
104
105 /* Dirent support. */
106
107 #if HAVE_DIRENT_H
108 # include <dirent.h>
109 # define NAMLEN(dirent) (strlen((dirent)->d_name))
110 #else
111 # define dirent direct
112 # define NAMLEN(dirent) ((dirent)->d_namlen)
113 # if HAVE_SYS_NDIR_H
114 # include <sys/ndir.h>
115 # endif
116 # if HAVE_SYS_DIR_H
117 # include <sys/dir.h>
118 # endif
119 # if HAVE_NDIR_H
120 # include <ndir.h>
121 # endif
122 #endif
123
124 /* Type substitutes. */
125
126 #if !HAVE_ID_T
127 typedef unsigned long id_t;
128 #endif
129
130 #if !HAVE_SOCKLEN_T
131 typedef int socklen_t;
132 #endif
133
134 #if !HAVE_U_LONG
135 typedef unsigned long u_long;
136 #endif
137
138 #if !HAVE_U_CHAR
139 typedef unsigned char u_char;
140 #endif
141
142 #if !HAVE_U_INT
143 typedef unsigned int u_int;
144 #endif
145
146 #if !HAVE_U_SHORT
147 typedef unsigned short u_short;
148 #endif
149
150 /* Prototypes for replacement functions. */
151
152 #if !HAVE_ATOLL
153 long long int atoll(const char *);
154 #endif
155
156 #if !HAVE_ASPRINTF
157 int asprintf(char **, const char *, ...);
158 #endif
159
160 #if !HAVE_ASNPRINTF
161 int asnprintf(char **, size_t, const char *, ...);
162 #endif
163
164 #if !HAVE_BASENAME
165 char *basename(char *);
166 #endif
167
168 #if !HAVE_DECL_OPTIND
169 int getopt(int, char *const *, const char *);
170 extern char *optarg;
171 extern int optind, opterr, optopt;
172 #endif
173
174 #if !HAVE_DIRNAME
175 char *dirname(char *);
176 #endif
177
178 #if !HAVE_DIRFD
179 #if HAVE_DIR_DD_FD
180 #define dirfd(dirp) ((dirp)->dd_fd)
181 #else
182 /*XXX: Very hacky but no other way to bring this into scope w/o defining
183 _NETBSD_SOURCE which we're avoiding. */
184 #ifdef __NetBSD__
185 struct _dirdesc {
186 int dd_fd; /* file descriptor associated with directory */
187 long dd_loc; /* offset in current buffer */
188 long dd_size; /* amount of data returned by getdents */
189 char *dd_buf; /* data buffer */
190 int dd_len; /* size of data buffer */
191 off_t dd_seek; /* magic cookie returned by getdents */
192 long dd_rewind; /* magic cookie for rewinding */
193 int dd_flags; /* flags for readdir */
194 void *dd_lock; /* lock for concurrent access */
195 };
196 #define dirfd(dirp) (((struct _dirdesc *)dirp)->dd_fd)
197 #else
198 #error cannot figure out how to turn a DIR * into a fd
199 #endif
200 #endif
201 #endif
202
203 #if !HAVE_ERR_H
204 void err(int, const char *, ...);
205 void errx(int, const char *, ...);
206 void warn(const char *, ...);
207 void warnx(const char *, ...);
208 #endif
209
210 #if !HAVE_FGETLN || defined(__NetBSD__)
211 char *fgetln(FILE *, size_t *);
212 #endif
213
214 #if !HAVE_FLOCK
215 # define LOCK_SH 0x01
216 # define LOCK_EX 0x02
217 # define LOCK_NB 0x04
218 # define LOCK_UN 0x08
219 int flock(int, int);
220 #endif
221
222 #if !HAVE_FPARSELN || defined(__NetBSD__)
223 # define FPARSELN_UNESCESC 0x01
224 # define FPARSELN_UNESCCONT 0x02
225 # define FPARSELN_UNESCCOMM 0x04
226 # define FPARSELN_UNESCREST 0x08
227 # define FPARSELN_UNESCALL 0x0f
228 char *fparseln(FILE *, size_t *, size_t *, const char [3], int);
229 #endif
230
231 #if !HAVE_ISSETUGID
232 int issetugid(void);
233 #endif
234
235 #if !HAVE_ISBLANK && !defined(isblank)
236 #define isblank(x) ((x) == ' ' || (x) == '\t')
237 #endif
238
239 #if !HAVE_LCHFLAGS
240 int lchflags(const char *, u_long);
241 #endif
242
243 #if !HAVE_LCHMOD
244 int lchmod(const char *, mode_t);
245 #endif
246
247 #if !HAVE_LCHOWN
248 int lchown(const char *, uid_t, gid_t);
249 #endif
250
251 #define __nbcompat_bswap16(x) ((((x) << 8) & 0xff00) | (((x) >> 8) & 0x00ff))
252
253 #define __nbcompat_bswap32(x) ((((x) << 24) & 0xff000000) | \
254 (((x) << 8) & 0x00ff0000) | \
255 (((x) >> 8) & 0x0000ff00) | \
256 (((x) >> 24) & 0x000000ff))
257
258 #define __nbcompat_bswap64(x) (((u_int64_t)bswap32((x)) << 32) | \
259 ((u_int64_t)bswap32((x) >> 32)))
260
261 #if !HAVE_BSWAP16
262 #ifdef bswap16
263 #undef bswap16
264 #endif
265 #define bswap16(x) __nbcompat_bswap16(x)
266 #endif
267 #if !HAVE_BSWAP32
268 #ifdef bswap32
269 #undef bswap32
270 #endif
271 #define bswap32(x) __nbcompat_bswap32(x)
272 #endif
273 #if !HAVE_BSWAP64
274 #ifdef bswap64
275 #undef bswap64
276 #endif
277 #define bswap64(x) __nbcompat_bswap64(x)
278 #endif
279
280 #if !HAVE_MKSTEMP
281 int mkstemp(char *);
282 #endif
283
284 #if !HAVE_MKDTEMP
285 char *mkdtemp(char *);
286 #endif
287
288 #if !HAVE_MKSTEMP || !HAVE_MKDTEMP
289 /* This is a prototype for the internal function. */
290 int gettemp(char *, int *, int);
291 #endif
292
293 #if !HAVE_PREAD
294 ssize_t pread(int, void *, size_t, off_t);
295 #endif
296
297 #if !HAVE_PWCACHE_USERDB
298 int uid_from_user(const char *, uid_t *);
299 int pwcache_userdb(int (*)(int), void (*)(void),
300 struct passwd * (*)(const char *), struct passwd * (*)(uid_t));
301 int gid_from_group(const char *, gid_t *);
302 int pwcache_groupdb(int (*)(int), void (*)(void),
303 struct group * (*)(const char *), struct group * (*)(gid_t));
304 #endif
305 /* Make them use our version */
306 # define user_from_uid __nbcompat_user_from_uid
307 /* Make them use our version */
308 # define group_from_gid __nbcompat_group_from_gid
309
310 #if !HAVE_PWRITE
311 ssize_t pwrite(int, const void *, size_t, off_t);
312 #endif
313
314 #if !HAVE_SETENV
315 int setenv(const char *, const char *, int);
316 #endif
317
318 #if !HAVE_DECL_SETGROUPENT
319 int setgroupent(int);
320 #endif
321
322 #if !HAVE_DECL_SETPASSENT
323 int setpassent(int);
324 #endif
325
326 #if !HAVE_SETPROGNAME || defined(__NetBSD__)
327 const char *getprogname(void);
328 void setprogname(const char *);
329 #endif
330
331 #if !HAVE_SNPRINTF
332 int snprintf(char *, size_t, const char *, ...);
333 #endif
334
335 #if !HAVE_STRLCAT
336 size_t strlcat(char *, const char *, size_t);
337 #endif
338
339 #if !HAVE_STRLCPY
340 size_t strlcpy(char *, const char *, size_t);
341 #endif
342
343 #if !HAVE_STRSEP || defined(__NetBSD__)
344 char *strsep(char **, const char *);
345 #endif
346
347 #if !HAVE_STRSUFTOLL
348 long long strsuftoll(const char *, const char *, long long, long long);
349 long long strsuftollx(const char *, const char *,
350 long long, long long, char *, size_t);
351 #endif
352
353 #if !HAVE_STRTOLL
354 long long strtoll(const char *, char **, int);
355 #endif
356
357 #if !HAVE_USER_FROM_UID
358 const char *user_from_uid(uid_t, int);
359 #endif
360
361 #if !HAVE_GROUP_FROM_GID
362 const char *group_from_gid(gid_t, int);
363 #endif
364
365 #if !HAVE_VASPRINTF
366 int vasprintf(char **, const char *, va_list);
367 #endif
368
369 #if !HAVE_VASNPRINTF
370 int vasnprintf(char **, size_t, const char *, va_list);
371 #endif
372
373 #if !HAVE_VSNPRINTF
374 int vsnprintf(char *, size_t, const char *, va_list);
375 #endif
376
377 /*
378 * getmode() and setmode() are always defined, as these function names
379 * exist but with very different meanings on other OS's. The compat
380 * versions here simply accept an octal mode number; the "u+x,g-w" type
381 * of syntax is not accepted.
382 */
383
384 #define getmode __nbcompat_getmode
385 #define setmode __nbcompat_setmode
386
387 mode_t getmode(const void *, mode_t);
388 void *setmode(const char *);
389
390 /* Eliminate assertions embedded in binaries. */
391
392 #undef _DIAGASSERT
393 #define _DIAGASSERT(x)
394
395 /* Various sources use this */
396 #undef __RCSID
397 #define __RCSID(x)
398 #undef __SCCSID
399 #define __SCCSID(x)
400 #undef __COPYRIGHT
401 #define __COPYRIGHT(x)
402 #undef __KERNEL_RCSID
403 #define __KERNEL_RCSID(x,y)
404
405 /* Heimdal expects this one. */
406
407 #undef RCSID
408 #define RCSID(x)
409
410 /* Some definitions not available on all systems. */
411
412 /* <errno.h> */
413
414 #ifndef EFTYPE
415 #define EFTYPE EIO
416 #endif
417
418 /* <fcntl.h> */
419
420 #ifndef O_EXLOCK
421 #define O_EXLOCK 0
422 #endif
423 #ifndef O_SHLOCK
424 #define O_SHLOCK 0
425 #endif
426
427 /* <limits.h> */
428
429 #ifndef UID_MAX
430 #define UID_MAX 32767
431 #endif
432 #ifndef GID_MAX
433 #define GID_MAX UID_MAX
434 #endif
435
436 #ifndef UQUAD_MAX
437 #define UQUAD_MAX ((u_quad_t)-1)
438 #endif
439 #ifndef QUAD_MAX
440 #define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1))
441 #endif
442 #ifndef QUAD_MIN
443 #define QUAD_MIN ((quad_t)(~QUAD_MAX))
444 #endif
445 #ifndef ULLONG_MAX
446 #define ULLONG_MAX ((unsigned long long)-1)
447 #endif
448 #ifndef LLONG_MAX
449 #define LLONG_MAX ((long long)(ULLONG_MAX >> 1))
450 #endif
451 #ifndef LLONG_MIN
452 #define LLONG_MIN ((long long)(~LLONG_MAX))
453 #endif
454
455 /* <paths.h> */
456
457 #ifndef _PATH_BSHELL
458 #define _PATH_BSHELL PATH_BSHELL
459 #endif
460 #ifndef _PATH_DEFPATH
461 #define _PATH_DEFPATH "/usr/bin:/bin:/usr/local/bin"
462 #endif
463 #ifndef _PATH_DEV
464 #define _PATH_DEV "/dev/"
465 #endif
466 #ifndef _PATH_DEVNULL
467 #define _PATH_DEVNULL _PATH_DEV "null"
468 #endif
469 #ifndef _PATH_TMP
470 #define _PATH_TMP "/tmp/"
471 #endif
472 #ifndef _PATH_DEFTAPE
473 #define _PATH_DEFTAPE "/dev/nrst0"
474 #endif
475
476 /* <stdarg.h> */
477
478 #ifndef _BSD_VA_LIST_
479 #define _BSD_VA_LIST_ va_list
480 #endif
481
482 /* <stdint.h> */
483
484 #if !defined(SIZE_MAX) && defined(SIZE_T_MAX)
485 #define SIZE_MAX SIZE_T_MAX
486 #endif
487
488 #ifndef UINT32_MAX
489 #define UINT32_MAX 0xffffffffU
490 #endif
491
492 /* <stdlib.h> */
493
494 #ifndef __GNUC__
495 # if HAVE_ALLOCA_H
496 # include <alloca.h>
497 # else
498 # ifndef alloca /* predefined by HP cc +Olibcalls */
499 char *alloca ();
500 # endif
501 # endif
502 #endif
503
504 /* avoid prototype conflicts with host */
505 #define cgetcap __nbcompat_cgetcap
506 #define cgetclose __nbcompat_cgetclose
507 #define cgetent __nbcompat_cgetent
508 #define cgetfirst __nbcompat_cgetfirst
509 #define cgetmatch __nbcompat_cgetmatch
510 #define cgetnext __nbcompat_cgetnext
511 #define cgetnum __nbcompat_cgetnum
512 #define cgetset __nbcompat_cgetset
513 #define cgetstr __nbcompat_cgetstr
514 #define cgetustr __nbcompat_cgetustr
515
516 char *cgetcap(char *, const char *, int);
517 int cgetclose(void);
518 int cgetent(char **, char **, const char *);
519 int cgetfirst(char **, char **);
520 int cgetmatch(const char *, const char *);
521 int cgetnext(char **, char **);
522 int cgetnum(char *, const char *, long *);
523 int cgetset(const char *);
524 int cgetstr(char *, const char *, char **);
525 int cgetustr(char *, const char *, char **);
526
527 /* <sys/endian.h> */
528
529 #if WORDS_BIGENDIAN
530 #if !HAVE_HTOBE16
531 #define htobe16(x) (x)
532 #endif
533 #if !HAVE_HTOBE32
534 #define htobe32(x) (x)
535 #endif
536 #if !HAVE_HTOBE64
537 #define htobe64(x) (x)
538 #endif
539 #if !HAVE_HTOLE16
540 #define htole16(x) bswap16((u_int16_t)(x))
541 #endif
542 #if !HAVE_HTOLE32
543 #define htole32(x) bswap32((u_int32_t)(x))
544 #endif
545 #if !HAVE_HTOLE64
546 #define htole64(x) bswap64((u_int64_t)(x))
547 #endif
548 #else
549 #if !HAVE_HTOBE16
550 #define htobe16(x) bswap16((u_int16_t)(x))
551 #endif
552 #if !HAVE_HTOBE32
553 #define htobe32(x) bswap32((u_int32_t)(x))
554 #endif
555 #if !HAVE_HTOBE64
556 #define htobe64(x) bswap64((u_int64_t)(x))
557 #endif
558 #if !HAVE_HTOLE16
559 #define htole16(x) (x)
560 #endif
561 #if !HAVE_HTOLE32
562 #define htole32(x) (x)
563 #endif
564 #if !HAVE_HTOLE64
565 #define htole64(x) (x)
566 #endif
567 #endif
568 #if !HAVE_BE16TOH
569 #define be16toh(x) htobe16(x)
570 #endif
571 #if !HAVE_BE32TOH
572 #define be32toh(x) htobe32(x)
573 #endif
574 #if !HAVE_BE64TOH
575 #define be64toh(x) htobe64(x)
576 #endif
577 #if !HAVE_LE16TOH
578 #define le16toh(x) htole16(x)
579 #endif
580 #if !HAVE_LE32TOH
581 #define le32toh(x) htole32(x)
582 #endif
583 #if !HAVE_LE64TOH
584 #define le64toh(x) htole64(x)
585 #endif
586
587 /* <sys/mman.h> */
588
589 #ifndef MAP_FILE
590 #define MAP_FILE 0
591 #endif
592
593 /* HP-UX has MAP_ANONYMOUS but not MAP_ANON */
594 #ifndef MAP_ANON
595 #ifdef MAP_ANONYMOUS
596 #define MAP_ANON MAP_ANONYMOUS
597 #endif
598 #endif
599
600 /* <sys/param.h> */
601
602 #undef BIG_ENDIAN
603 #undef LITTLE_ENDIAN
604 #define BIG_ENDIAN 4321
605 #define LITTLE_ENDIAN 1234
606
607 #undef BYTE_ORDER
608 #if WORDS_BIGENDIAN
609 #define BYTE_ORDER BIG_ENDIAN
610 #else
611 #define BYTE_ORDER LITTLE_ENDIAN
612 #endif
613
614 #ifndef DEV_BSIZE
615 #define DEV_BSIZE (1 << 9)
616 #endif
617
618 #undef MIN
619 #undef MAX
620 #define MIN(a,b) ((a) < (b) ? (a) : (b))
621 #define MAX(a,b) ((a) > (b) ? (a) : (b))
622
623 #ifndef MAXBSIZE
624 #define MAXBSIZE (64 * 1024)
625 #endif
626 #ifndef MAXFRAG
627 #define MAXFRAG 8
628 #endif
629 #ifndef MAXPHYS
630 #define MAXPHYS (64 * 1024)
631 #endif
632
633 /* XXX needed by makefs; this should be done in a better way */
634 #undef btodb
635 #define btodb(x) ((x) << 9)
636
637 #undef setbit
638 #undef clrbit
639 #undef isset
640 #undef isclr
641 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
642 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
643 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
644 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
645
646 #ifndef powerof2
647 #define powerof2(x) ((((x)-1)&(x))==0)
648 #endif
649
650 #undef roundup
651 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
652
653 /* <sys/stat.h> */
654
655 #ifndef ALLPERMS
656 #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
657 #endif
658 #ifndef DEFFILEMODE
659 #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
660 #endif
661 #ifndef S_ISTXT
662 #ifdef S_ISVTX
663 #define S_ISTXT S_ISVTX
664 #else
665 #define S_ISTXT 0
666 #endif
667 #endif
668
669 /* Protected by _NETBSD_SOURCE otherwise. */
670 #if HAVE_STRUCT_STAT_ST_FLAGS && defined(__NetBSD__)
671 #define UF_SETTABLE 0x0000ffff
672 #define UF_NODUMP 0x00000001
673 #define UF_IMMUTABLE 0x00000002
674 #define UF_APPEND 0x00000004
675 #define UF_OPAQUE 0x00000008
676 #define SF_SETTABLE 0xffff0000
677 #define SF_ARCHIVED 0x00010000
678 #define SF_IMMUTABLE 0x00020000
679 #define SF_APPEND 0x00040000
680 #endif
681
682 /* <sys/syslimits.h> */
683
684 #ifndef LINE_MAX
685 #define LINE_MAX 2048
686 #endif
687
688 /* <sys/time.h> */
689
690 #ifndef timercmp
691 #define timercmp(tvp, uvp, cmp) \
692 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
693 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
694 ((tvp)->tv_sec cmp (uvp)->tv_sec))
695 #endif
696 #ifndef timeradd
697 #define timeradd(tvp, uvp, vvp) \
698 do { \
699 (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
700 (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
701 if ((vvp)->tv_usec >= 1000000) { \
702 (vvp)->tv_sec++; \
703 (vvp)->tv_usec -= 1000000; \
704 } \
705 } while (/* CONSTCOND */ 0)
706 #endif
707 #ifndef timersub
708 #define timersub(tvp, uvp, vvp) \
709 do { \
710 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
711 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
712 if ((vvp)->tv_usec < 0) { \
713 (vvp)->tv_sec--; \
714 (vvp)->tv_usec += 1000000; \
715 } \
716 } while (/* CONSTCOND */ 0)
717 #endif
718
719 /* <sys/types.h> */
720
721 #ifdef major
722 #undef major
723 #endif
724 #define major(x) ((int32_t)((((x) & 0x000fff00) >> 8)))
725
726 #ifdef minor
727 #undef minor
728 #endif
729 #define minor(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \
730 (((x) & 0x000000ff) >> 0)))
731 #ifdef makedev
732 #undef makedev
733 #endif
734 #define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
735 (((y) << 12) & 0xfff00000) | \
736 (((y) << 0) & 0x000000ff)))
737 #ifndef NBBY
738 #define NBBY 8
739 #endif
740
741 #if !HAVE_U_QUAD_T
742 /* #define, not typedef, as quad_t exists as a struct on some systems */
743 #define quad_t long long
744 #define u_quad_t unsigned long long
745 #define strtoq strtoll
746 #define strtouq strtoull
747 #endif
748
749 /* Has quad_t but these prototypes don't get pulled into scope. w/o we lose */
750 #ifdef __NetBSD__
751 quad_t strtoq __P((const char *, char **, int));
752 u_quad_t strtouq __P((const char *, char **, int));
753 #endif
754
755 #endif /* !__NETBSD_COMPAT_DEFS_H__ */
756