Home | History | Annotate | Line # | Download | only in compat
compat_defs.h revision 1.10
      1  1.10    bjh21 /*	$NetBSD: compat_defs.h,v 1.10 2002/04/18 15:31:51 bjh21 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.1  thorpej #if !defined(__attribute__) && !defined(__GNUC__)
     73   1.1  thorpej #define __attribute__(x)
     74   1.1  thorpej #endif
     75   1.3       tv #ifndef __RENAME
     76   1.3       tv #define __RENAME(x)
     77   1.3       tv #endif
     78   1.3       tv #undef __aconst
     79   1.3       tv #define __aconst
     80   1.3       tv #undef __dead
     81   1.3       tv #define __dead
     82   1.3       tv 
     83   1.3       tv /* Dirent support. */
     84   1.3       tv 
     85   1.3       tv #if HAVE_DIRENT_H
     86   1.3       tv # include <dirent.h>
     87   1.3       tv # define NAMLEN(dirent) (strlen((dirent)->d_name))
     88   1.3       tv #else
     89   1.3       tv # define dirent direct
     90   1.3       tv # define NAMLEN(dirent) ((dirent)->d_namlen)
     91   1.3       tv # if HAVE_SYS_NDIR_H
     92   1.3       tv #  include <sys/ndir.h>
     93   1.3       tv # endif
     94   1.3       tv # if HAVE_SYS_DIR_H
     95   1.3       tv #  include <sys/dir.h>
     96   1.3       tv # endif
     97   1.3       tv # if HAVE_NDIR_H
     98   1.3       tv #  include <ndir.h>
     99   1.3       tv # endif
    100   1.3       tv #endif
    101   1.3       tv 
    102   1.1  thorpej /* Type substitutes. */
    103   1.1  thorpej 
    104   1.1  thorpej #if !HAVE_ID_T
    105   1.1  thorpej typedef unsigned long id_t;
    106   1.1  thorpej #endif
    107   1.1  thorpej 
    108   1.1  thorpej /* Prototypes for replacement functions. */
    109   1.1  thorpej 
    110   1.3       tv #if !HAVE_ASPRINTF
    111   1.3       tv int asprintf(char **, const char *, ...);
    112   1.3       tv #endif
    113   1.3       tv 
    114   1.3       tv #if !HAVE_ASNPRINTF
    115   1.3       tv int asnprintf(char **, size_t, const char *, ...);
    116   1.3       tv #endif
    117   1.3       tv 
    118   1.1  thorpej #if !HAVE_BASENAME
    119   1.1  thorpej char *basename(char *);
    120   1.1  thorpej #endif
    121   1.1  thorpej 
    122   1.4       tv #if !HAVE_DECL_OPTIND
    123   1.4       tv int getopt(int, char *const *, const char *);
    124   1.4       tv extern char *optarg;
    125   1.4       tv extern int optind, opterr, optopt;
    126   1.4       tv #endif
    127   1.4       tv 
    128   1.1  thorpej #if !HAVE_DIRNAME
    129   1.1  thorpej char *dirname(char *);
    130   1.1  thorpej #endif
    131   1.1  thorpej 
    132   1.3       tv #if !HAVE_DIRFD
    133   1.3       tv #if HAVE_DIR_DD_FD
    134   1.3       tv #define dirfd(dirp) ((dirp)->dd_fd)
    135   1.3       tv #else
    136   1.3       tv #error cannot figure out how to turn a DIR * into a fd
    137   1.3       tv #endif
    138   1.3       tv #endif
    139   1.3       tv 
    140   1.1  thorpej #if !HAVE_ERR_H
    141   1.3       tv void err(int, const char *, ...);
    142   1.3       tv void errx(int, const char *, ...);
    143   1.1  thorpej void warn(const char *, ...);
    144   1.1  thorpej void warnx(const char *, ...);
    145   1.1  thorpej #endif
    146   1.1  thorpej 
    147   1.1  thorpej #if !HAVE_FGETLN
    148   1.1  thorpej char *fgetln(FILE *, size_t *);
    149   1.1  thorpej #endif
    150   1.1  thorpej 
    151   1.1  thorpej #if !HAVE_FLOCK
    152   1.1  thorpej # define LOCK_SH		0x01
    153   1.1  thorpej # define LOCK_EX		0x02
    154   1.1  thorpej # define LOCK_NB		0x04
    155   1.1  thorpej # define LOCK_UN		0x08
    156   1.1  thorpej int flock(int, int);
    157   1.1  thorpej #endif
    158   1.1  thorpej 
    159   1.1  thorpej #if !HAVE_FPARSELN
    160   1.1  thorpej # define FPARSELN_UNESCESC	0x01
    161   1.1  thorpej # define FPARSELN_UNESCCONT	0x02
    162   1.1  thorpej # define FPARSELN_UNESCCOMM	0x04
    163   1.1  thorpej # define FPARSELN_UNESCREST	0x08
    164   1.1  thorpej # define FPARSELN_UNESCALL	0x0f
    165   1.1  thorpej char *fparseln(FILE *, size_t *, size_t *, const char [3], int);
    166  1.10    bjh21 #endif
    167  1.10    bjh21 
    168  1.10    bjh21 #if !HAVE_ISSETUGID
    169  1.10    bjh21 int issetugid(void);
    170   1.1  thorpej #endif
    171   1.1  thorpej 
    172   1.3       tv #if !HAVE_ISBLANK && !defined(isblank)
    173   1.3       tv #define isblank(x) ((x) == ' ' || (x) == '\t')
    174   1.1  thorpej #endif
    175   1.1  thorpej 
    176   1.4       tv #if !HAVE_MACHINE_BSWAP_H
    177   1.4       tv #define bswap16(x)	((((x) << 8) & 0xff00) | (((x) >> 8) & 0x00ff))
    178   1.4       tv 
    179   1.4       tv #define bswap32(x)	((((x) << 24) & 0xff000000) | \
    180   1.4       tv 			 (((x) <<  8) & 0x00ff0000) | \
    181   1.4       tv 			 (((x) >>  8) & 0x0000ff00) | \
    182   1.4       tv 			 (((x) >> 24) & 0x000000ff))
    183   1.4       tv 
    184   1.4       tv #define bswap64(x)	(((u_int64_t)bswap32((x)) << 32) | \
    185   1.4       tv 			 ((u_int64_t)bswap32((x) >> 32)))
    186   1.4       tv #endif
    187   1.4       tv 
    188   1.1  thorpej #if !HAVE_PREAD
    189   1.1  thorpej ssize_t pread(int, void *, size_t, off_t);
    190   1.2    lukem #endif
    191   1.2    lukem 
    192   1.2    lukem #if !HAVE_PWCACHE_USERDB
    193   1.2    lukem const char *user_from_uid(uid_t, int);
    194   1.2    lukem int uid_from_user(const char *, uid_t *);
    195   1.2    lukem int pwcache_userdb(int (*)(int), void (*)(void),
    196   1.2    lukem 		struct passwd * (*)(const char *), struct passwd * (*)(uid_t));
    197   1.2    lukem const char *group_from_gid(gid_t, int);
    198   1.2    lukem int gid_from_group(const char *, gid_t *);
    199   1.2    lukem int pwcache_groupdb(int (*)(int), void (*)(void),
    200   1.2    lukem 		struct group * (*)(const char *), struct group * (*)(gid_t));
    201   1.1  thorpej #endif
    202   1.1  thorpej 
    203   1.1  thorpej #if !HAVE_PWRITE
    204   1.1  thorpej ssize_t pwrite(int, const void *, size_t, off_t);
    205   1.1  thorpej #endif
    206   1.1  thorpej 
    207   1.3       tv #if !HAVE_SETENV
    208   1.3       tv int setenv(const char *, const char *, int);
    209   1.3       tv #endif
    210   1.3       tv 
    211   1.6       tv #if !HAVE_DECL_SETGROUPENT
    212   1.3       tv int setgroupent(int);
    213   1.3       tv #endif
    214   1.3       tv 
    215   1.6       tv #if !HAVE_DECL_SETPASSENT
    216   1.3       tv int setpassent(int);
    217   1.3       tv #endif
    218   1.3       tv 
    219   1.3       tv #if !HAVE_SETPROGNAME
    220   1.3       tv const char *getprogname(void);
    221   1.3       tv void setprogname(const char *);
    222   1.3       tv #endif
    223   1.3       tv 
    224   1.3       tv #if !HAVE_SNPRINTF
    225   1.3       tv int snprintf(char *, size_t, const char *, ...);
    226   1.3       tv #endif
    227   1.3       tv 
    228   1.3       tv #if !HAVE_STRLCAT
    229   1.3       tv size_t strlcat(char *, const char *, size_t);
    230   1.3       tv #endif
    231   1.3       tv 
    232   1.3       tv #if !HAVE_STRLCPY
    233   1.3       tv size_t strlcpy(char *, const char *, size_t);
    234   1.3       tv #endif
    235   1.3       tv 
    236   1.3       tv #if !HAVE_STRSEP
    237   1.3       tv char *strsep(char **, const char *);
    238   1.3       tv #endif
    239   1.3       tv 
    240   1.3       tv #if !HAVE_VASPRINTF
    241   1.3       tv int vasprintf(char **, const char *, va_list);
    242   1.3       tv #endif
    243   1.3       tv 
    244   1.3       tv #if !HAVE_VASNPRINTF
    245   1.3       tv int vasnprintf(char **, size_t, const char *, va_list);
    246   1.3       tv #endif
    247   1.3       tv 
    248   1.3       tv #if !HAVE_VSNPRINTF
    249   1.3       tv int vsnprintf(char *, size_t, const char *, va_list);
    250   1.3       tv #endif
    251   1.3       tv 
    252   1.1  thorpej /*
    253   1.1  thorpej  * getmode() and setmode() are always defined, as these function names
    254   1.1  thorpej  * exist but with very different meanings on other OS's.  The compat
    255   1.1  thorpej  * versions here simply accept an octal mode number; the "u+x,g-w" type
    256   1.1  thorpej  * of syntax is not accepted.
    257   1.1  thorpej  */
    258   1.1  thorpej 
    259   1.1  thorpej #define getmode __nbcompat_getmode
    260   1.1  thorpej #define setmode __nbcompat_setmode
    261   1.1  thorpej 
    262   1.1  thorpej mode_t getmode(const void *, mode_t);
    263   1.1  thorpej void *setmode(const char *);
    264   1.1  thorpej 
    265   1.3       tv /* Eliminate assertions embedded in binaries. */
    266   1.1  thorpej 
    267   1.1  thorpej #undef _DIAGASSERT
    268   1.3       tv #define _DIAGASSERT(x)
    269   1.4       tv 
    270   1.4       tv /* Heimdal expects this one. */
    271   1.4       tv 
    272   1.3       tv #undef RCSID
    273   1.3       tv #define RCSID(x)
    274   1.1  thorpej 
    275   1.3       tv /* Some definitions not available on all systems. */
    276   1.1  thorpej 
    277   1.4       tv /* <errno.h> */
    278   1.4       tv 
    279   1.4       tv #ifndef EFTYPE
    280   1.4       tv #define EFTYPE EIO
    281   1.4       tv #endif
    282   1.4       tv 
    283   1.4       tv /* <fcntl.h> */
    284   1.4       tv 
    285   1.4       tv #ifndef O_EXLOCK
    286   1.4       tv #define O_EXLOCK 0
    287   1.4       tv #endif
    288   1.4       tv #ifndef O_SHLOCK
    289   1.4       tv #define O_SHLOCK 0
    290   1.4       tv #endif
    291   1.4       tv 
    292   1.8    bjh21 /* <limits.h> */
    293   1.4       tv 
    294   1.4       tv #ifndef UID_MAX
    295   1.4       tv #define UID_MAX 32767
    296   1.4       tv #endif
    297   1.4       tv #ifndef GID_MAX
    298   1.4       tv #define GID_MAX UID_MAX
    299   1.4       tv #endif
    300   1.4       tv 
    301   1.4       tv #ifndef UQUAD_MAX
    302   1.4       tv #define UQUAD_MAX ((u_quad_t)-1)
    303   1.4       tv #endif
    304   1.4       tv #ifndef QUAD_MAX
    305   1.4       tv #define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1))
    306   1.4       tv #endif
    307   1.4       tv #ifndef QUAD_MIN
    308   1.4       tv #define QUAD_MIN ((quad_t)(~QUAD_MAX))
    309   1.4       tv #endif
    310   1.4       tv #ifndef ULLONG_MAX
    311   1.4       tv #define ULLONG_MAX ((unsigned long long)-1)
    312   1.4       tv #endif
    313   1.4       tv #ifndef LLONG_MAX
    314   1.4       tv #define LLONG_MAX ((long long)(ULLONG_MAX >> 1))
    315   1.4       tv #endif
    316   1.4       tv #ifndef LLONG_MIN
    317   1.4       tv #define LLONG_MIN ((long long)(~LLONG_MAX))
    318   1.3       tv #endif
    319   1.1  thorpej 
    320   1.4       tv /* <paths.h> */
    321   1.4       tv 
    322   1.3       tv #ifndef _PATH_BSHELL
    323   1.3       tv #if defined(__sun)
    324   1.3       tv /* Sun's /bin/sh is obnoxiously broken. */
    325   1.3       tv #define _PATH_BSHELL "/usr/xpg4/bin/sh"
    326   1.1  thorpej #else
    327   1.3       tv #define _PATH_BSHELL "/bin/sh"
    328   1.3       tv #endif
    329   1.1  thorpej #endif
    330   1.1  thorpej #ifndef _PATH_DEFPATH
    331   1.1  thorpej #define _PATH_DEFPATH "/usr/bin:/bin:/usr/local/bin"
    332   1.1  thorpej #endif
    333   1.1  thorpej #ifndef _PATH_DEV
    334   1.1  thorpej #define _PATH_DEV "/dev/"
    335   1.1  thorpej #endif
    336   1.1  thorpej #ifndef _PATH_DEVNULL
    337   1.1  thorpej #define _PATH_DEVNULL _PATH_DEV "null"
    338   1.1  thorpej #endif
    339   1.1  thorpej #ifndef _PATH_TMP
    340   1.1  thorpej #define _PATH_TMP "/tmp/"
    341   1.1  thorpej #endif
    342   1.1  thorpej 
    343   1.4       tv /* <stdarg.h> */
    344   1.3       tv 
    345   1.4       tv #ifndef _BSD_VA_LIST_
    346   1.4       tv #define _BSD_VA_LIST_ va_list
    347   1.9    bjh21 #endif
    348   1.9    bjh21 
    349   1.9    bjh21 /* <sys/endian.h> */
    350   1.9    bjh21 
    351   1.9    bjh21 #ifndef HAVE_SYS_ENDIAN_H
    352   1.9    bjh21 #if WORDS_BIGENDIAN
    353   1.9    bjh21 #define htobe16(x)	(x)
    354   1.9    bjh21 #define htobe32(x)	(x)
    355   1.9    bjh21 #define htobe64(x)	(x)
    356   1.9    bjh21 #define htole16(x)	bswap16((u_int16_t)(x))
    357   1.9    bjh21 #define htole32(x)	bswap32((u_int32_t)(x))
    358   1.9    bjh21 #define htole64(x)	bswap64((u_int64_t)(x))
    359   1.9    bjh21 #else
    360   1.9    bjh21 #define htobe16(x)	bswap16((u_int16_t)(x))
    361   1.9    bjh21 #define htobe32(x)	bswap32((u_int32_t)(x))
    362   1.9    bjh21 #define htobe64(x)	bswap64((u_int64_t)(x))
    363   1.9    bjh21 #define htole16(x)	(x)
    364   1.9    bjh21 #define htole32(x)	(x)
    365   1.9    bjh21 #define htole64(x)	(x)
    366   1.9    bjh21 #endif
    367   1.9    bjh21 #define be16toh(x)	htobe16(x)
    368   1.9    bjh21 #define be32toh(x)	htobe32(x)
    369   1.9    bjh21 #define be64toh(x)	htobe64(x)
    370   1.9    bjh21 #define le16toh(x)	htole16(x)
    371   1.9    bjh21 #define le32toh(x)	htole32(x)
    372   1.9    bjh21 #define le64toh(x)	htole64(x)
    373   1.1  thorpej #endif
    374   1.1  thorpej 
    375   1.4       tv /* <sys/mman.h> */
    376   1.3       tv 
    377   1.3       tv #ifndef MAP_FILE
    378   1.3       tv #define MAP_FILE 0
    379   1.3       tv #endif
    380   1.3       tv 
    381   1.4       tv /* <sys/param.h> */
    382   1.4       tv 
    383   1.4       tv #undef BIG_ENDIAN
    384   1.4       tv #undef LITTLE_ENDIAN
    385   1.4       tv #define BIG_ENDIAN 4321
    386   1.4       tv #define LITTLE_ENDIAN 1234
    387   1.4       tv 
    388   1.4       tv #undef BYTE_ORDER
    389   1.4       tv #if WORDS_BIGENDIAN
    390   1.4       tv #define BYTE_ORDER BIG_ENDIAN
    391   1.4       tv #else
    392   1.4       tv #define BYTE_ORDER LITTLE_ENDIAN
    393   1.4       tv #endif
    394   1.4       tv 
    395   1.7       tv #ifndef DEV_BSIZE
    396   1.7       tv #define DEV_BSIZE (1 << 9)
    397   1.7       tv #endif
    398   1.7       tv 
    399   1.4       tv #undef MIN
    400   1.4       tv #undef MAX
    401   1.4       tv #define MIN(a,b) ((a) < (b) ? (a) : (b))
    402   1.4       tv #define MAX(a,b) ((a) > (b) ? (a) : (b))
    403   1.4       tv 
    404   1.1  thorpej #ifndef MAXBSIZE
    405   1.1  thorpej #define MAXBSIZE (64 * 1024)
    406   1.1  thorpej #endif
    407   1.4       tv #ifndef MAXFRAG
    408   1.4       tv #define MAXFRAG 8
    409   1.1  thorpej #endif
    410   1.4       tv #ifndef MAXPHYS
    411   1.4       tv #define MAXPHYS (64 * 1024)
    412   1.3       tv #endif
    413   1.4       tv 
    414   1.6       tv /* XXX needed by makefs; this should be done in a better way */
    415   1.6       tv #undef btodb
    416   1.6       tv #define btodb(x) ((x) << 9)
    417   1.6       tv 
    418   1.6       tv #undef setbit
    419   1.6       tv #undef clrbit
    420   1.6       tv #undef isset
    421   1.6       tv #undef isclr
    422   1.6       tv #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
    423   1.6       tv #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
    424   1.6       tv #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
    425   1.6       tv #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
    426   1.6       tv 
    427   1.4       tv #ifndef powerof2
    428   1.4       tv #define powerof2(x) ((((x)-1)&(x))==0)
    429   1.3       tv #endif
    430   1.7       tv 
    431   1.7       tv #undef roundup
    432   1.7       tv #define roundup(x, y)	((((x)+((y)-1))/(y))*(y))
    433   1.3       tv 
    434   1.4       tv /* <sys/stat.h> */
    435   1.4       tv 
    436   1.4       tv #ifndef ALLPERMS
    437   1.4       tv #define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
    438   1.4       tv #endif
    439   1.4       tv #ifndef DEFFILEMODE
    440   1.4       tv #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
    441   1.4       tv #endif
    442   1.3       tv #ifndef S_ISTXT
    443   1.3       tv #ifdef S_ISVTX
    444   1.3       tv #define S_ISTXT S_ISVTX
    445   1.3       tv #else
    446   1.3       tv #define S_ISTXT 0
    447   1.3       tv #endif
    448   1.6       tv #endif
    449   1.6       tv 
    450   1.6       tv /* <sys/syslimits.h> */
    451   1.6       tv 
    452   1.6       tv #ifndef LINE_MAX
    453   1.6       tv #define LINE_MAX 2048
    454   1.4       tv #endif
    455   1.4       tv 
    456   1.4       tv /* <sys/time.h> */
    457   1.4       tv 
    458   1.4       tv #ifndef timercmp
    459   1.4       tv #define	timercmp(tvp, uvp, cmp)						\
    460   1.4       tv 	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
    461   1.4       tv 	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
    462   1.4       tv 	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
    463   1.4       tv #endif
    464   1.4       tv #ifndef timeradd
    465   1.4       tv #define	timeradd(tvp, uvp, vvp)						\
    466   1.4       tv 	do {								\
    467   1.4       tv 		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
    468   1.4       tv 		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
    469   1.4       tv 		if ((vvp)->tv_usec >= 1000000) {			\
    470   1.4       tv 			(vvp)->tv_sec++;				\
    471   1.4       tv 			(vvp)->tv_usec -= 1000000;			\
    472   1.4       tv 		}							\
    473   1.4       tv 	} while (/* CONSTCOND */ 0)
    474   1.4       tv #endif
    475   1.4       tv #ifndef timersub
    476   1.4       tv #define	timersub(tvp, uvp, vvp)						\
    477   1.4       tv 	do {								\
    478   1.4       tv 		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
    479   1.4       tv 		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
    480   1.4       tv 		if ((vvp)->tv_usec < 0) {				\
    481   1.4       tv 			(vvp)->tv_sec--;				\
    482   1.4       tv 			(vvp)->tv_usec += 1000000;			\
    483   1.4       tv 		}							\
    484   1.4       tv 	} while (/* CONSTCOND */ 0)
    485   1.4       tv #endif
    486   1.4       tv 
    487   1.4       tv /* <sys/types.h> */
    488   1.4       tv 
    489   1.4       tv #if !HAVE_U_QUAD_T
    490   1.4       tv /* #define, not typedef, as quad_t exists as a struct on some systems */
    491   1.4       tv #define quad_t long long
    492   1.4       tv #define u_quad_t unsigned long long
    493   1.4       tv #define strtouq strtoull
    494   1.1  thorpej #endif
    495   1.1  thorpej 
    496   1.1  thorpej #endif	/* !__NETBSD_COMPAT_DEFS_H__ */
    497