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