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