Sat Jan 21 20:05:27 2012 UTC ()
Always redefine DEV_BSIZE=512.
All references of DEV_BSIZE in tools are to manipulate target
(i.e. NetBSD's) file images (in installboot(8) and makefs(8) etc.) and
no host's DEV_BSIZE is required for the moment.  Closes PR toolchain/42574.


(tsutsui)
diff -r1.82 -r1.83 src/tools/compat/compat_defs.h

cvs diff -r1.82 -r1.83 src/tools/compat/compat_defs.h (switch to unified diff)

--- src/tools/compat/compat_defs.h 2011/11/03 14:13:53 1.82
+++ src/tools/compat/compat_defs.h 2012/01/21 20:05:27 1.83
@@ -1,1196 +1,1196 @@ @@ -1,1196 +1,1196 @@
1/* $NetBSD: compat_defs.h,v 1.82 2011/11/03 14:13:53 joerg Exp $ */ 1/* $NetBSD: compat_defs.h,v 1.83 2012/01/21 20:05:27 tsutsui Exp $ */
2 2
3#ifndef __NETBSD_COMPAT_DEFS_H__ 3#ifndef __NETBSD_COMPAT_DEFS_H__
4#define __NETBSD_COMPAT_DEFS_H__ 4#define __NETBSD_COMPAT_DEFS_H__
5 5
6 6
7/* Work around some complete brain damage. */ 7/* Work around some complete brain damage. */
8/* 8/*
9 * Linux: <features.h> turns on _POSIX_SOURCE by default, even though the 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 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. 11 * of this crap from being pulled in, and undefine _POSIX_SOURCE.
12 */ 12 */
13 13
14#if defined(__linux__) && HAVE_FEATURES_H 14#if defined(__linux__) && HAVE_FEATURES_H
15#include <features.h> 15#include <features.h>
16#define __USE_ISOC99 1 16#define __USE_ISOC99 1
17#endif 17#endif
18 18
19/* So _NETBSD_SOURCE doesn't end up defined. Define enough to pull in standard 19/* So _NETBSD_SOURCE doesn't end up defined. Define enough to pull in standard
20 defs. Other platforms may need similiar defines. */ 20 defs. Other platforms may need similiar defines. */
21#ifdef __NetBSD__ 21#ifdef __NetBSD__
22#define _ISOC99_SOURCE 22#define _ISOC99_SOURCE
23#define _POSIX_SOURCE 1 23#define _POSIX_SOURCE 1
24#define _POSIX_C_SOURCE 200112L 24#define _POSIX_C_SOURCE 200112L
25#define _XOPEN_SOURCE 600 25#define _XOPEN_SOURCE 600
26#else 26#else
27#undef _POSIX_SOURCE 27#undef _POSIX_SOURCE
28#undef _POSIX_C_SOURCE 28#undef _POSIX_C_SOURCE
29#endif 29#endif
30 30
31/* System headers needed for (re)definitions below. */ 31/* System headers needed for (re)definitions below. */
32 32
33#include <sys/types.h> 33#include <sys/types.h>
34#include <sys/mman.h> 34#include <sys/mman.h>
35#include <sys/param.h> 35#include <sys/param.h>
36/* time.h needs to be pulled in first at least on netbsd w/o _NETBSD_SOURCE */ 36/* time.h needs to be pulled in first at least on netbsd w/o _NETBSD_SOURCE */
37#include <sys/time.h> 37#include <sys/time.h>
38#include <sys/stat.h> 38#include <sys/stat.h>
39#include <errno.h> 39#include <errno.h>
40#include <fcntl.h> 40#include <fcntl.h>
41#include <limits.h> 41#include <limits.h>
42#include <paths.h> 42#include <paths.h>
43#include <stdarg.h> 43#include <stdarg.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <string.h> 46#include <string.h>
47 47
48#if HAVE_SYS_CDEFS_H 48#if HAVE_SYS_CDEFS_H
49#include <sys/cdefs.h> 49#include <sys/cdefs.h>
50#endif 50#endif
51#if HAVE_SYS_SYSLIMITS_H 51#if HAVE_SYS_SYSLIMITS_H
52#include <sys/syslimits.h> 52#include <sys/syslimits.h>
53#endif 53#endif
54#if HAVE_SYS_SYSMACROS_H 54#if HAVE_SYS_SYSMACROS_H
55/* major(), minor() on SVR4 */ 55/* major(), minor() on SVR4 */
56#include <sys/sysmacros.h> 56#include <sys/sysmacros.h>
57#endif 57#endif
58#if HAVE_INTTYPES_H 58#if HAVE_INTTYPES_H
59#include <inttypes.h> 59#include <inttypes.h>
60#endif 60#endif
61#if HAVE_STDDEF_H 61#if HAVE_STDDEF_H
62#include <stddef.h> 62#include <stddef.h>
63#endif 63#endif
64 64
65#ifdef _NETBSD_SOURCE 65#ifdef _NETBSD_SOURCE
66#error _NETBSD_SOURCE is *not* to be defined. 66#error _NETBSD_SOURCE is *not* to be defined.
67#endif 67#endif
68 68
69/* Need this since we can't depend on NetBSD's version to be around */ 69/* Need this since we can't depend on NetBSD's version to be around */
70#ifdef __UNCONST 70#ifdef __UNCONST
71#undef __UNCONST 71#undef __UNCONST
72#endif 72#endif
73#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) 73#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
74 74
75/* We don't include <pwd.h> here, so that "compat_pwd.h" works. */ 75/* We don't include <pwd.h> here, so that "compat_pwd.h" works. */
76struct passwd; 76struct passwd;
77 77
78/* We don't include <grp.h> either */ 78/* We don't include <grp.h> either */
79struct group; 79struct group;
80 80
81/* Assume an ANSI compiler for the host. */ 81/* Assume an ANSI compiler for the host. */
82 82
83#undef __P 83#undef __P
84#define __P(x) x 84#define __P(x) x
85 85
86#ifndef __BEGIN_DECLS 86#ifndef __BEGIN_DECLS
87#define __BEGIN_DECLS 87#define __BEGIN_DECLS
88#endif 88#endif
89#ifndef __END_DECLS 89#ifndef __END_DECLS
90#define __END_DECLS 90#define __END_DECLS
91#endif 91#endif
92 92
93/* Some things usually in BSD <sys/cdefs.h>. */ 93/* Some things usually in BSD <sys/cdefs.h>. */
94 94
95#ifndef __CONCAT 95#ifndef __CONCAT
96#define __CONCAT(x,y) x ## y 96#define __CONCAT(x,y) x ## y
97#endif 97#endif
98#if !defined(__attribute__) && !defined(__GNUC__) 98#if !defined(__attribute__) && !defined(__GNUC__)
99#define __attribute__(x) 99#define __attribute__(x)
100#endif 100#endif
101#if !defined(__packed) 101#if !defined(__packed)
102#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 102#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
103#define __packed __attribute__((__packed__)) 103#define __packed __attribute__((__packed__))
104#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) 104#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
105#define __packed __attribute__((__packed__)) 105#define __packed __attribute__((__packed__))
106#else 106#else
107#define __packed error: no __packed for this compiler 107#define __packed error: no __packed for this compiler
108#endif 108#endif
109#endif /* !__packed */ 109#endif /* !__packed */
110#ifndef __RENAME 110#ifndef __RENAME
111#define __RENAME(x) 111#define __RENAME(x)
112#endif 112#endif
113#undef __aconst 113#undef __aconst
114#define __aconst 114#define __aconst
115#undef __dead 115#undef __dead
116#define __dead 116#define __dead
117#undef __printflike 117#undef __printflike
118#define __printflike(x,y) 118#define __printflike(x,y)
119#undef __restrict 119#undef __restrict
120#define __restrict 120#define __restrict
121#undef __unused 121#undef __unused
122#define __unused 122#define __unused
123#undef __arraycount 123#undef __arraycount
124#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) 124#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
125 125
126/* Dirent support. */ 126/* Dirent support. */
127 127
128#if HAVE_DIRENT_H 128#if HAVE_DIRENT_H
129# if defined(__linux__) && defined(__USE_BSD) 129# if defined(__linux__) && defined(__USE_BSD)
130# undef __USE_BSD 130# undef __USE_BSD
131# include <dirent.h> 131# include <dirent.h>
132# define __USE_BSD 1 132# define __USE_BSD 1
133# undef d_fileno 133# undef d_fileno
134# else 134# else
135# include <dirent.h> 135# include <dirent.h>
136# if defined(__DARWIN_UNIX03) 136# if defined(__DARWIN_UNIX03)
137# undef d_fileno 137# undef d_fileno
138# endif 138# endif
139# endif 139# endif
140# define NAMLEN(dirent) (strlen((dirent)->d_name)) 140# define NAMLEN(dirent) (strlen((dirent)->d_name))
141#else 141#else
142# define dirent direct 142# define dirent direct
143# define NAMLEN(dirent) ((dirent)->d_namlen) 143# define NAMLEN(dirent) ((dirent)->d_namlen)
144# if HAVE_SYS_NDIR_H 144# if HAVE_SYS_NDIR_H
145# include <sys/ndir.h> 145# include <sys/ndir.h>
146# endif 146# endif
147# if HAVE_SYS_DIR_H 147# if HAVE_SYS_DIR_H
148# include <sys/dir.h> 148# include <sys/dir.h>
149# endif 149# endif
150# if HAVE_NDIR_H 150# if HAVE_NDIR_H
151# include <ndir.h> 151# include <ndir.h>
152# endif 152# endif
153#endif 153#endif
154 154
155/* Type substitutes. */ 155/* Type substitutes. */
156 156
157#if !HAVE_ID_T 157#if !HAVE_ID_T
158typedef unsigned int id_t; 158typedef unsigned int id_t;
159#endif 159#endif
160 160
161#if !HAVE_SOCKLEN_T 161#if !HAVE_SOCKLEN_T
162typedef int socklen_t; 162typedef int socklen_t;
163#endif 163#endif
164 164
165#if !HAVE_U_LONG 165#if !HAVE_U_LONG
166typedef unsigned long u_long; 166typedef unsigned long u_long;
167#endif 167#endif
168 168
169#if !HAVE_U_CHAR 169#if !HAVE_U_CHAR
170typedef unsigned char u_char; 170typedef unsigned char u_char;
171#endif 171#endif
172 172
173#if !HAVE_U_INT 173#if !HAVE_U_INT
174typedef unsigned int u_int; 174typedef unsigned int u_int;
175#endif 175#endif
176 176
177#if !HAVE_U_SHORT 177#if !HAVE_U_SHORT
178typedef unsigned short u_short; 178typedef unsigned short u_short;
179#endif 179#endif
180 180
181/* Prototypes for replacement functions. */ 181/* Prototypes for replacement functions. */
182 182
183#if !HAVE_ATOLL 183#if !HAVE_ATOLL
184long long int atoll(const char *); 184long long int atoll(const char *);
185#endif 185#endif
186 186
187#if !HAVE_ASPRINTF 187#if !HAVE_ASPRINTF
188int asprintf(char **, const char *, ...); 188int asprintf(char **, const char *, ...);
189#endif 189#endif
190 190
191#if !HAVE_ASNPRINTF 191#if !HAVE_ASNPRINTF
192int asnprintf(char **, size_t, const char *, ...); 192int asnprintf(char **, size_t, const char *, ...);
193#endif 193#endif
194 194
195#if !HAVE_BASENAME 195#if !HAVE_BASENAME
196char *basename(char *); 196char *basename(char *);
197#endif 197#endif
198 198
199#if !HAVE_DECL_OPTIND 199#if !HAVE_DECL_OPTIND
200int getopt(int, char *const *, const char *); 200int getopt(int, char *const *, const char *);
201extern char *optarg; 201extern char *optarg;
202extern int optind, opterr, optopt; 202extern int optind, opterr, optopt;
203#endif 203#endif
204 204
205#if !HAVE_DIRNAME 205#if !HAVE_DIRNAME
206char *dirname(char *); 206char *dirname(char *);
207#endif 207#endif
208 208
209#if !HAVE_DIRFD 209#if !HAVE_DIRFD
210#if HAVE_DIR_DD_FD 210#if HAVE_DIR_DD_FD
211#define dirfd(dirp) ((dirp)->dd_fd) 211#define dirfd(dirp) ((dirp)->dd_fd)
212#elif HAVE_DIR___DD_FD 212#elif HAVE_DIR___DD_FD
213#define dirfd(dirp) ((dirp)->__dd_fd) 213#define dirfd(dirp) ((dirp)->__dd_fd)
214#else 214#else
215/*XXX: Very hacky but no other way to bring this into scope w/o defining 215/*XXX: Very hacky but no other way to bring this into scope w/o defining
216 _NETBSD_SOURCE which we're avoiding. */ 216 _NETBSD_SOURCE which we're avoiding. */
217#ifdef __NetBSD__ 217#ifdef __NetBSD__
218struct _dirdesc { 218struct _dirdesc {
219 int dd_fd; /* file descriptor associated with directory */ 219 int dd_fd; /* file descriptor associated with directory */
220 long dd_loc; /* offset in current buffer */ 220 long dd_loc; /* offset in current buffer */
221 long dd_size; /* amount of data returned by getdents */ 221 long dd_size; /* amount of data returned by getdents */
222 char *dd_buf; /* data buffer */ 222 char *dd_buf; /* data buffer */
223 int dd_len; /* size of data buffer */ 223 int dd_len; /* size of data buffer */
224 off_t dd_seek; /* magic cookie returned by getdents */ 224 off_t dd_seek; /* magic cookie returned by getdents */
225 long dd_rewind; /* magic cookie for rewinding */ 225 long dd_rewind; /* magic cookie for rewinding */
226 int dd_flags; /* flags for readdir */ 226 int dd_flags; /* flags for readdir */
227 void *dd_lock; /* lock for concurrent access */ 227 void *dd_lock; /* lock for concurrent access */
228}; 228};
229#define dirfd(dirp) (((struct _dirdesc *)dirp)->dd_fd) 229#define dirfd(dirp) (((struct _dirdesc *)dirp)->dd_fd)
230#else 230#else
231#error cannot figure out how to turn a DIR * into a fd 231#error cannot figure out how to turn a DIR * into a fd
232#endif 232#endif
233#endif 233#endif
234#endif 234#endif
235 235
236#if !HAVE_ERR_H 236#if !HAVE_ERR_H
237void err(int, const char *, ...); 237void err(int, const char *, ...);
238void errx(int, const char *, ...); 238void errx(int, const char *, ...);
239void warn(const char *, ...); 239void warn(const char *, ...);
240void warnx(const char *, ...); 240void warnx(const char *, ...);
241void vwarnx(const char *, va_list); 241void vwarnx(const char *, va_list);
242#endif 242#endif
243 243
244#if !HAVE_ESETFUNC 244#if !HAVE_ESETFUNC
245void (*esetfunc(void (*)(int, const char *, ...)))(int, const char *, ...); 245void (*esetfunc(void (*)(int, const char *, ...)))(int, const char *, ...);
246size_t estrlcpy(char *, const char *, size_t); 246size_t estrlcpy(char *, const char *, size_t);
247size_t estrlcat(char *, const char *, size_t); 247size_t estrlcat(char *, const char *, size_t);
248char *estrdup(const char *); 248char *estrdup(const char *);
249char *estrndup(const char *, size_t); 249char *estrndup(const char *, size_t);
250void *ecalloc(size_t, size_t); 250void *ecalloc(size_t, size_t);
251void *emalloc(size_t); 251void *emalloc(size_t);
252void *erealloc(void *, size_t); 252void *erealloc(void *, size_t);
253FILE *efopen(const char *, const char *); 253FILE *efopen(const char *, const char *);
254int easprintf(char **, const char *, ...); 254int easprintf(char **, const char *, ...);
255int evasprintf(char **, const char *, va_list); 255int evasprintf(char **, const char *, va_list);
256#endif 256#endif
257 257
258#if !HAVE_FGETLN || defined(__NetBSD__) 258#if !HAVE_FGETLN || defined(__NetBSD__)
259char *fgetln(FILE *, size_t *); 259char *fgetln(FILE *, size_t *);
260#endif 260#endif
261 261
262#if !HAVE_FLOCK 262#if !HAVE_FLOCK
263# define LOCK_SH 0x01 263# define LOCK_SH 0x01
264# define LOCK_EX 0x02 264# define LOCK_EX 0x02
265# define LOCK_NB 0x04 265# define LOCK_NB 0x04
266# define LOCK_UN 0x08 266# define LOCK_UN 0x08
267int flock(int, int); 267int flock(int, int);
268#endif 268#endif
269 269
270#if !HAVE_FPARSELN || BROKEN_FPARSELN || defined(__NetBSD__) 270#if !HAVE_FPARSELN || BROKEN_FPARSELN || defined(__NetBSD__)
271# define FPARSELN_UNESCESC 0x01 271# define FPARSELN_UNESCESC 0x01
272# define FPARSELN_UNESCCONT 0x02 272# define FPARSELN_UNESCCONT 0x02
273# define FPARSELN_UNESCCOMM 0x04 273# define FPARSELN_UNESCCOMM 0x04
274# define FPARSELN_UNESCREST 0x08 274# define FPARSELN_UNESCREST 0x08
275# define FPARSELN_UNESCALL 0x0f 275# define FPARSELN_UNESCALL 0x0f
276char *fparseln(FILE *, size_t *, size_t *, const char [3], int); 276char *fparseln(FILE *, size_t *, size_t *, const char [3], int);
277#endif 277#endif
278 278
279#if !HAVE_GETLINE 279#if !HAVE_GETLINE
280ssize_t getdelim(char **, size_t *, int, FILE *); 280ssize_t getdelim(char **, size_t *, int, FILE *);
281ssize_t getline(char **, size_t *, FILE *); 281ssize_t getline(char **, size_t *, FILE *);
282#endif 282#endif
283 283
284#if !HAVE_ISSETUGID 284#if !HAVE_ISSETUGID
285int issetugid(void); 285int issetugid(void);
286#endif 286#endif
287 287
288#if !HAVE_ISBLANK && !defined(isblank) 288#if !HAVE_ISBLANK && !defined(isblank)
289#define isblank(x) ((x) == ' ' || (x) == '\t') 289#define isblank(x) ((x) == ' ' || (x) == '\t')
290#endif 290#endif
291 291
292#define __nbcompat_bswap16(x) ((((x) << 8) & 0xff00) | (((x) >> 8) & 0x00ff)) 292#define __nbcompat_bswap16(x) ((((x) << 8) & 0xff00) | (((x) >> 8) & 0x00ff))
293 293
294#define __nbcompat_bswap32(x) ((((x) << 24) & 0xff000000) | \ 294#define __nbcompat_bswap32(x) ((((x) << 24) & 0xff000000) | \
295 (((x) << 8) & 0x00ff0000) | \ 295 (((x) << 8) & 0x00ff0000) | \
296 (((x) >> 8) & 0x0000ff00) | \ 296 (((x) >> 8) & 0x0000ff00) | \
297 (((x) >> 24) & 0x000000ff)) 297 (((x) >> 24) & 0x000000ff))
298 298
299#define __nbcompat_bswap64(x) (((u_int64_t)bswap32((x)) << 32) | \ 299#define __nbcompat_bswap64(x) (((u_int64_t)bswap32((x)) << 32) | \
300 ((u_int64_t)bswap32((x) >> 32))) 300 ((u_int64_t)bswap32((x) >> 32)))
301 301
302#if ! HAVE_DECL_BSWAP16 302#if ! HAVE_DECL_BSWAP16
303#ifdef bswap16 303#ifdef bswap16
304#undef bswap16 304#undef bswap16
305#endif 305#endif
306#define bswap16(x) __nbcompat_bswap16(x) 306#define bswap16(x) __nbcompat_bswap16(x)
307#endif 307#endif
308#if ! HAVE_DECL_BSWAP32 308#if ! HAVE_DECL_BSWAP32
309#ifdef bswap32 309#ifdef bswap32
310#undef bswap32 310#undef bswap32
311#endif 311#endif
312#define bswap32(x) __nbcompat_bswap32(x) 312#define bswap32(x) __nbcompat_bswap32(x)
313#endif 313#endif
314#if ! HAVE_DECL_BSWAP64 314#if ! HAVE_DECL_BSWAP64
315#ifdef bswap64 315#ifdef bswap64
316#undef bswap64 316#undef bswap64
317#endif 317#endif
318#define bswap64(x) __nbcompat_bswap64(x) 318#define bswap64(x) __nbcompat_bswap64(x)
319#endif 319#endif
320 320
321#if !HAVE_MKSTEMP 321#if !HAVE_MKSTEMP
322int mkstemp(char *); 322int mkstemp(char *);
323#endif 323#endif
324 324
325#if !HAVE_MKDTEMP 325#if !HAVE_MKDTEMP
326char *mkdtemp(char *); 326char *mkdtemp(char *);
327#endif 327#endif
328 328
329#if !HAVE_MKSTEMP || !HAVE_MKDTEMP 329#if !HAVE_MKSTEMP || !HAVE_MKDTEMP
330/* This is a prototype for the internal function defined in 330/* This is a prototype for the internal function defined in
331 * src/lib/lib/stdio/gettemp.c */ 331 * src/lib/lib/stdio/gettemp.c */
332int __nbcompat_gettemp(char *, int *, int); 332int __nbcompat_gettemp(char *, int *, int);
333#endif 333#endif
334 334
335#if !HAVE_PREAD 335#if !HAVE_PREAD
336ssize_t pread(int, void *, size_t, off_t); 336ssize_t pread(int, void *, size_t, off_t);
337#endif 337#endif
338 338
339#if !HAVE_HEAPSORT 339#if !HAVE_HEAPSORT
340int heapsort (void *, size_t, size_t, int (*)(const void *, const void *)); 340int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));
341#endif 341#endif
342/* Make them use our version */ 342/* Make them use our version */
343# define heapsort __nbcompat_heapsort 343# define heapsort __nbcompat_heapsort
344 344
345char *flags_to_string(unsigned long, const char *); 345char *flags_to_string(unsigned long, const char *);
346int string_to_flags(char **, unsigned long *, unsigned long *); 346int string_to_flags(char **, unsigned long *, unsigned long *);
347 347
348/* 348/*
349 * HAVE_X_FROM_Y and HAVE_PWCACHE_FOODB go together, because we cannot 349 * HAVE_X_FROM_Y and HAVE_PWCACHE_FOODB go together, because we cannot
350 * supply an implementation of one without the others -- some parts are 350 * supply an implementation of one without the others -- some parts are
351 * libc internal and this varies from system to system. 351 * libc internal and this varies from system to system.
352 * 352 *
353 * XXX this is dubious anyway: we assume (see HAVE_DECLs below) that if the 353 * XXX this is dubious anyway: we assume (see HAVE_DECLs below) that if the
354 * XXX host system has all of these functions, all of their interfaces 354 * XXX host system has all of these functions, all of their interfaces
355 * XXX and interactions are exactly the same as in our libc/libutil -- ugh. 355 * XXX and interactions are exactly the same as in our libc/libutil -- ugh.
356 */ 356 */
357#if !HAVE_USER_FROM_UID || !HAVE_UID_FROM_USER || !HAVE_GROUP_FROM_GID || \ 357#if !HAVE_USER_FROM_UID || !HAVE_UID_FROM_USER || !HAVE_GROUP_FROM_GID || \
358 !HAVE_GID_FROM_GROUP || !HAVE_PWCACHE_USERDB || !HAVE_PWCACHE_GROUDB 358 !HAVE_GID_FROM_GROUP || !HAVE_PWCACHE_USERDB || !HAVE_PWCACHE_GROUDB
359/* Make them use our version */ 359/* Make them use our version */
360# define user_from_uid __nbcompat_user_from_uid 360# define user_from_uid __nbcompat_user_from_uid
361# define uid_from_user __nbcompat_uid_from_user 361# define uid_from_user __nbcompat_uid_from_user
362# define pwcache_userdb __nbcompat_pwcache_userdb 362# define pwcache_userdb __nbcompat_pwcache_userdb
363# define group_from_gid __nbcompat_group_from_gid 363# define group_from_gid __nbcompat_group_from_gid
364# define gid_from_group __nbcompat_gid_from_group 364# define gid_from_group __nbcompat_gid_from_group
365# define pwcache_groupdb __nbcompat_pwcache_groupdb 365# define pwcache_groupdb __nbcompat_pwcache_groupdb
366#endif 366#endif
367 367
368#if !HAVE_DECL_UID_FROM_USER 368#if !HAVE_DECL_UID_FROM_USER
369int uid_from_user(const char *, uid_t *); 369int uid_from_user(const char *, uid_t *);
370#endif 370#endif
371 371
372#if !HAVE_DECL_USER_FROM_UID 372#if !HAVE_DECL_USER_FROM_UID
373const char *user_from_uid(uid_t, int); 373const char *user_from_uid(uid_t, int);
374#endif 374#endif
375 375
376#if !HAVE_DECL_PWCACHE_USERDB 376#if !HAVE_DECL_PWCACHE_USERDB
377int pwcache_userdb(int (*)(int), void (*)(void), 377int pwcache_userdb(int (*)(int), void (*)(void),
378 struct passwd * (*)(const char *), struct passwd * (*)(uid_t)); 378 struct passwd * (*)(const char *), struct passwd * (*)(uid_t));
379#endif 379#endif
380 380
381#if !HAVE_DECL_GID_FROM_GROUP 381#if !HAVE_DECL_GID_FROM_GROUP
382int gid_from_group(const char *, gid_t *); 382int gid_from_group(const char *, gid_t *);
383#endif 383#endif
384 384
385#if !HAVE_DECL_GROUP_FROM_GID 385#if !HAVE_DECL_GROUP_FROM_GID
386const char *group_from_gid(gid_t, int); 386const char *group_from_gid(gid_t, int);
387#endif 387#endif
388 388
389#if !HAVE_DECL_PWCACHE_GROUPDB 389#if !HAVE_DECL_PWCACHE_GROUPDB
390int pwcache_groupdb(int (*)(int), void (*)(void), 390int pwcache_groupdb(int (*)(int), void (*)(void),
391 struct group * (*)(const char *), struct group * (*)(gid_t)); 391 struct group * (*)(const char *), struct group * (*)(gid_t));
392#endif 392#endif
393 393
394#if !HAVE_DECL_STRNDUP 394#if !HAVE_DECL_STRNDUP
395char *strndup(const char *, size_t); 395char *strndup(const char *, size_t);
396#endif 396#endif
397#if !HAVE_DECL_LCHFLAGS 397#if !HAVE_DECL_LCHFLAGS
398int lchflags(const char *, unsigned long); 398int lchflags(const char *, unsigned long);
399#endif 399#endif
400#if !HAVE_DECL_LCHMOD 400#if !HAVE_DECL_LCHMOD
401int lchmod(const char *, mode_t); 401int lchmod(const char *, mode_t);
402#endif 402#endif
403#if !HAVE_DECL_LCHOWN 403#if !HAVE_DECL_LCHOWN
404int lchown(const char *, uid_t, gid_t); 404int lchown(const char *, uid_t, gid_t);
405#endif 405#endif
406 406
407#if !HAVE_PWRITE 407#if !HAVE_PWRITE
408ssize_t pwrite(int, const void *, size_t, off_t); 408ssize_t pwrite(int, const void *, size_t, off_t);
409#endif 409#endif
410 410
411#if !HAVE_RAISE_DEFAULT_SIGNAL 411#if !HAVE_RAISE_DEFAULT_SIGNAL
412int raise_default_signal(int); 412int raise_default_signal(int);
413#endif 413#endif
414 414
415#if !HAVE_SETENV 415#if !HAVE_SETENV
416int setenv(const char *, const char *, int); 416int setenv(const char *, const char *, int);
417#endif 417#endif
418 418
419#if !HAVE_DECL_SETGROUPENT 419#if !HAVE_DECL_SETGROUPENT
420int setgroupent(int); 420int setgroupent(int);
421#endif 421#endif
422 422
423#if !HAVE_DECL_SETPASSENT 423#if !HAVE_DECL_SETPASSENT
424int setpassent(int); 424int setpassent(int);
425#endif 425#endif
426 426
427#if !HAVE_SETPROGNAME || defined(__NetBSD__) 427#if !HAVE_SETPROGNAME || defined(__NetBSD__)
428const char *getprogname(void); 428const char *getprogname(void);
429void setprogname(const char *); 429void setprogname(const char *);
430#endif 430#endif
431 431
432#if !HAVE_SNPRINTF 432#if !HAVE_SNPRINTF
433int snprintf(char *, size_t, const char *, ...); 433int snprintf(char *, size_t, const char *, ...);
434#endif 434#endif
435 435
436#if !HAVE_STRLCAT 436#if !HAVE_STRLCAT
437size_t strlcat(char *, const char *, size_t); 437size_t strlcat(char *, const char *, size_t);
438#endif 438#endif
439 439
440#if !HAVE_STRLCPY 440#if !HAVE_STRLCPY
441size_t strlcpy(char *, const char *, size_t); 441size_t strlcpy(char *, const char *, size_t);
442#endif 442#endif
443 443
444#if !HAVE_STRMODE 444#if !HAVE_STRMODE
445void strmode(mode_t, char *); 445void strmode(mode_t, char *);
446#endif 446#endif
447 447
448#if !HAVE_STRNDUP 448#if !HAVE_STRNDUP
449char *strndup(const char *, size_t); 449char *strndup(const char *, size_t);
450#endif 450#endif
451 451
452#if !HAVE_STRSEP || defined(__NetBSD__) 452#if !HAVE_STRSEP || defined(__NetBSD__)
453char *strsep(char **, const char *); 453char *strsep(char **, const char *);
454#endif 454#endif
455 455
456#if !HAVE_DECL_STRSUFTOLL 456#if !HAVE_DECL_STRSUFTOLL
457long long strsuftoll(const char *, const char *, long long, long long); 457long long strsuftoll(const char *, const char *, long long, long long);
458long long strsuftollx(const char *, const char *, 458long long strsuftollx(const char *, const char *,
459 long long, long long, char *, size_t); 459 long long, long long, char *, size_t);
460#endif 460#endif
461 461
462#if !HAVE_STRTOLL 462#if !HAVE_STRTOLL
463long long strtoll(const char *, char **, int); 463long long strtoll(const char *, char **, int);
464#endif 464#endif
465 465
466#if !HAVE_USER_FROM_UID 466#if !HAVE_USER_FROM_UID
467const char *user_from_uid(uid_t, int); 467const char *user_from_uid(uid_t, int);
468#endif 468#endif
469 469
470#if !HAVE_GROUP_FROM_GID 470#if !HAVE_GROUP_FROM_GID
471const char *group_from_gid(gid_t, int); 471const char *group_from_gid(gid_t, int);
472#endif 472#endif
473 473
474#if !HAVE_VASPRINTF 474#if !HAVE_VASPRINTF
475int vasprintf(char **, const char *, va_list); 475int vasprintf(char **, const char *, va_list);
476#endif 476#endif
477 477
478#if !HAVE_VASNPRINTF 478#if !HAVE_VASNPRINTF
479int vasnprintf(char **, size_t, const char *, va_list); 479int vasnprintf(char **, size_t, const char *, va_list);
480#endif 480#endif
481 481
482#if !HAVE_VSNPRINTF 482#if !HAVE_VSNPRINTF
483int vsnprintf(char *, size_t, const char *, va_list); 483int vsnprintf(char *, size_t, const char *, va_list);
484#endif 484#endif
485 485
486/* 486/*
487 * getmode() and setmode() are always defined, as these function names 487 * getmode() and setmode() are always defined, as these function names
488 * exist but with very different meanings on other OS's. The compat 488 * exist but with very different meanings on other OS's. The compat
489 * versions here simply accept an octal mode number; the "u+x,g-w" type 489 * versions here simply accept an octal mode number; the "u+x,g-w" type
490 * of syntax is not accepted. 490 * of syntax is not accepted.
491 */ 491 */
492 492
493#define getmode __nbcompat_getmode 493#define getmode __nbcompat_getmode
494#define setmode __nbcompat_setmode 494#define setmode __nbcompat_setmode
495 495
496mode_t getmode(const void *, mode_t); 496mode_t getmode(const void *, mode_t);
497void *setmode(const char *); 497void *setmode(const char *);
498 498
499/* Eliminate assertions embedded in binaries. */ 499/* Eliminate assertions embedded in binaries. */
500 500
501#undef _DIAGASSERT 501#undef _DIAGASSERT
502#define _DIAGASSERT(x) 502#define _DIAGASSERT(x)
503 503
504/* Various sources use this */ 504/* Various sources use this */
505#undef __RCSID 505#undef __RCSID
506#define __RCSID(x) struct XXXNETBSD_RCSID 506#define __RCSID(x) struct XXXNETBSD_RCSID
507#undef __SCCSID 507#undef __SCCSID
508#define __SCCSID(x) 508#define __SCCSID(x)
509#undef __COPYRIGHT 509#undef __COPYRIGHT
510#define __COPYRIGHT(x) struct XXXNETBSD_COPYRIGHT 510#define __COPYRIGHT(x) struct XXXNETBSD_COPYRIGHT
511#undef __KERNEL_RCSID 511#undef __KERNEL_RCSID
512#define __KERNEL_RCSID(x,y) 512#define __KERNEL_RCSID(x,y)
513 513
514/* Heimdal expects this one. */ 514/* Heimdal expects this one. */
515 515
516#undef RCSID 516#undef RCSID
517#define RCSID(x) 517#define RCSID(x)
518 518
519/* Some definitions not available on all systems. */ 519/* Some definitions not available on all systems. */
520 520
521#ifndef __inline 521#ifndef __inline
522#define __inline inline 522#define __inline inline
523#endif 523#endif
524 524
525/* <errno.h> */ 525/* <errno.h> */
526 526
527#ifndef EFTYPE 527#ifndef EFTYPE
528#define EFTYPE EIO 528#define EFTYPE EIO
529#endif 529#endif
530 530
531/* <fcntl.h> */ 531/* <fcntl.h> */
532 532
533#ifndef O_EXLOCK 533#ifndef O_EXLOCK
534#define O_EXLOCK 0 534#define O_EXLOCK 0
535#endif 535#endif
536#ifndef O_SHLOCK 536#ifndef O_SHLOCK
537#define O_SHLOCK 0 537#define O_SHLOCK 0
538#endif 538#endif
539 539
540/* <inttypes.h> */ 540/* <inttypes.h> */
541 541
542#if UCHAR_MAX == 0xffU /* char is an 8-bit type */ 542#if UCHAR_MAX == 0xffU /* char is an 8-bit type */
543#ifndef PRId8 543#ifndef PRId8
544#define PRId8 "hhd" 544#define PRId8 "hhd"
545#endif 545#endif
546#ifndef PRIi8 546#ifndef PRIi8
547#define PRIi8 "hhi" 547#define PRIi8 "hhi"
548#endif 548#endif
549#ifndef PRIo8 549#ifndef PRIo8
550#define PRIo8 "hho" 550#define PRIo8 "hho"
551#endif 551#endif
552#ifndef PRIu8 552#ifndef PRIu8
553#define PRIu8 "hhu" 553#define PRIu8 "hhu"
554#endif 554#endif
555#ifndef PRIx8 555#ifndef PRIx8
556#define PRIx8 "hhx" 556#define PRIx8 "hhx"
557#endif 557#endif
558#ifndef PRIX8 558#ifndef PRIX8
559#define PRIX8 "hhX" 559#define PRIX8 "hhX"
560#endif 560#endif
561#ifndef SCNd8 561#ifndef SCNd8
562#define SCNd8 "hhd" 562#define SCNd8 "hhd"
563#endif 563#endif
564#ifndef SCNi8 564#ifndef SCNi8
565#define SCNi8 "hhi" 565#define SCNi8 "hhi"
566#endif 566#endif
567#ifndef SCNo8 567#ifndef SCNo8
568#define SCNo8 "hho" 568#define SCNo8 "hho"
569#endif 569#endif
570#ifndef SCNu8 570#ifndef SCNu8
571#define SCNu8 "hhu" 571#define SCNu8 "hhu"
572#endif 572#endif
573#ifndef SCNx8 573#ifndef SCNx8
574#define SCNx8 "hhx" 574#define SCNx8 "hhx"
575#endif 575#endif
576#ifndef SCNX8 576#ifndef SCNX8
577#define SCNX8 "hhX" 577#define SCNX8 "hhX"
578#endif 578#endif
579#endif /* char is an 8-bit type */ 579#endif /* char is an 8-bit type */
580#if ! (defined(PRId8) && defined(PRIi8) && defined(PRIo8) && \ 580#if ! (defined(PRId8) && defined(PRIi8) && defined(PRIo8) && \
581 defined(PRIu8) && defined(PRIx8) && defined(PRIX8)) 581 defined(PRIu8) && defined(PRIx8) && defined(PRIX8))
582#error "Don't know how to define PRI[diouxX]8" 582#error "Don't know how to define PRI[diouxX]8"
583#endif 583#endif
584#if ! (defined(SCNd8) && defined(SCNi8) && defined(SCNo8) && \ 584#if ! (defined(SCNd8) && defined(SCNi8) && defined(SCNo8) && \
585 defined(SCNu8) && defined(SCNx8) && defined(SCNX8)) 585 defined(SCNu8) && defined(SCNx8) && defined(SCNX8))
586#error "Don't know how to define SCN[diouxX]8" 586#error "Don't know how to define SCN[diouxX]8"
587#endif 587#endif
588 588
589#if USHRT_MAX == 0xffffU /* short is a 16-bit type */ 589#if USHRT_MAX == 0xffffU /* short is a 16-bit type */
590#ifndef PRId16 590#ifndef PRId16
591#define PRId16 "hd" 591#define PRId16 "hd"
592#endif 592#endif
593#ifndef PRIi16 593#ifndef PRIi16
594#define PRIi16 "hi" 594#define PRIi16 "hi"
595#endif 595#endif
596#ifndef PRIo16 596#ifndef PRIo16
597#define PRIo16 "ho" 597#define PRIo16 "ho"
598#endif 598#endif
599#ifndef PRIu16 599#ifndef PRIu16
600#define PRIu16 "hu" 600#define PRIu16 "hu"
601#endif 601#endif
602#ifndef PRIx16 602#ifndef PRIx16
603#define PRIx16 "hx" 603#define PRIx16 "hx"
604#endif 604#endif
605#ifndef PRIX16 605#ifndef PRIX16
606#define PRIX16 "hX" 606#define PRIX16 "hX"
607#endif 607#endif
608#ifndef SCNd16 608#ifndef SCNd16
609#define SCNd16 "hd" 609#define SCNd16 "hd"
610#endif 610#endif
611#ifndef SCNi16 611#ifndef SCNi16
612#define SCNi16 "hi" 612#define SCNi16 "hi"
613#endif 613#endif
614#ifndef SCNo16 614#ifndef SCNo16
615#define SCNo16 "ho" 615#define SCNo16 "ho"
616#endif 616#endif
617#ifndef SCNu16 617#ifndef SCNu16
618#define SCNu16 "hu" 618#define SCNu16 "hu"
619#endif 619#endif
620#ifndef SCNx16 620#ifndef SCNx16
621#define SCNx16 "hx" 621#define SCNx16 "hx"
622#endif 622#endif
623#ifndef SCNX16 623#ifndef SCNX16
624#define SCNX16 "hX" 624#define SCNX16 "hX"
625#endif 625#endif
626#endif /* short is a 16-bit type */ 626#endif /* short is a 16-bit type */
627#if ! (defined(PRId16) && defined(PRIi16) && defined(PRIo16) && \ 627#if ! (defined(PRId16) && defined(PRIi16) && defined(PRIo16) && \
628 defined(PRIu16) && defined(PRIx16) && defined(PRIX16)) 628 defined(PRIu16) && defined(PRIx16) && defined(PRIX16))
629#error "Don't know how to define PRI[diouxX]16" 629#error "Don't know how to define PRI[diouxX]16"
630#endif 630#endif
631#if ! (defined(SCNd16) && defined(SCNi16) && defined(SCNo16) && \ 631#if ! (defined(SCNd16) && defined(SCNi16) && defined(SCNo16) && \
632 defined(SCNu16) && defined(SCNx16) && defined(SCNX16)) 632 defined(SCNu16) && defined(SCNx16) && defined(SCNX16))
633#error "Don't know how to define SCN[diouxX]16" 633#error "Don't know how to define SCN[diouxX]16"
634#endif 634#endif
635 635
636#if UINT_MAX == 0xffffffffU /* int is a 32-bit type */ 636#if UINT_MAX == 0xffffffffU /* int is a 32-bit type */
637#ifndef PRId32 637#ifndef PRId32
638#define PRId32 "d" 638#define PRId32 "d"
639#endif 639#endif
640#ifndef PRIi32 640#ifndef PRIi32
641#define PRIi32 "i" 641#define PRIi32 "i"
642#endif 642#endif
643#ifndef PRIo32 643#ifndef PRIo32
644#define PRIo32 "o" 644#define PRIo32 "o"
645#endif 645#endif
646#ifndef PRIu32 646#ifndef PRIu32
647#define PRIu32 "u" 647#define PRIu32 "u"
648#endif 648#endif
649#ifndef PRIx32 649#ifndef PRIx32
650#define PRIx32 "x" 650#define PRIx32 "x"
651#endif 651#endif
652#ifndef PRIX32 652#ifndef PRIX32
653#define PRIX32 "X" 653#define PRIX32 "X"
654#endif 654#endif
655#ifndef SCNd32 655#ifndef SCNd32
656#define SCNd32 "d" 656#define SCNd32 "d"
657#endif 657#endif
658#ifndef SCNi32 658#ifndef SCNi32
659#define SCNi32 "i" 659#define SCNi32 "i"
660#endif 660#endif
661#ifndef SCNo32 661#ifndef SCNo32
662#define SCNo32 "o" 662#define SCNo32 "o"
663#endif 663#endif
664#ifndef SCNu32 664#ifndef SCNu32
665#define SCNu32 "u" 665#define SCNu32 "u"
666#endif 666#endif
667#ifndef SCNx32 667#ifndef SCNx32
668#define SCNx32 "x" 668#define SCNx32 "x"
669#endif 669#endif
670#ifndef SCNX32 670#ifndef SCNX32
671#define SCNX32 "X" 671#define SCNX32 "X"
672#endif 672#endif
673#endif /* int is a 32-bit type */ 673#endif /* int is a 32-bit type */
674#if ULONG_MAX == 0xffffffffU /* long is a 32-bit type */ 674#if ULONG_MAX == 0xffffffffU /* long is a 32-bit type */
675#ifndef PRId32 675#ifndef PRId32
676#define PRId32 "ld" 676#define PRId32 "ld"
677#endif 677#endif
678#ifndef PRIi32 678#ifndef PRIi32
679#define PRIi32 "li" 679#define PRIi32 "li"
680#endif 680#endif
681#ifndef PRIo32 681#ifndef PRIo32
682#define PRIo32 "lo" 682#define PRIo32 "lo"
683#endif 683#endif
684#ifndef PRIu32 684#ifndef PRIu32
685#define PRIu32 "lu" 685#define PRIu32 "lu"
686#endif 686#endif
687#ifndef PRIx32 687#ifndef PRIx32
688#define PRIx32 "lx" 688#define PRIx32 "lx"
689#endif 689#endif
690#ifndef PRIX32 690#ifndef PRIX32
691#define PRIX32 "lX" 691#define PRIX32 "lX"
692#endif 692#endif
693#ifndef SCNd32 693#ifndef SCNd32
694#define SCNd32 "ld" 694#define SCNd32 "ld"
695#endif 695#endif
696#ifndef SCNi32 696#ifndef SCNi32
697#define SCNi32 "li" 697#define SCNi32 "li"
698#endif 698#endif
699#ifndef SCNo32 699#ifndef SCNo32
700#define SCNo32 "lo" 700#define SCNo32 "lo"
701#endif 701#endif
702#ifndef SCNu32 702#ifndef SCNu32
703#define SCNu32 "lu" 703#define SCNu32 "lu"
704#endif 704#endif
705#ifndef SCNx32 705#ifndef SCNx32
706#define SCNx32 "lx" 706#define SCNx32 "lx"
707#endif 707#endif
708#ifndef SCNX32 708#ifndef SCNX32
709#define SCNX32 "lX" 709#define SCNX32 "lX"
710#endif 710#endif
711#endif /* long is a 32-bit type */ 711#endif /* long is a 32-bit type */
712#if ! (defined(PRId32) && defined(PRIi32) && defined(PRIo32) && \ 712#if ! (defined(PRId32) && defined(PRIi32) && defined(PRIo32) && \
713 defined(PRIu32) && defined(PRIx32) && defined(PRIX32)) 713 defined(PRIu32) && defined(PRIx32) && defined(PRIX32))
714#error "Don't know how to define PRI[diouxX]32" 714#error "Don't know how to define PRI[diouxX]32"
715#endif 715#endif
716#if ! (defined(SCNd32) && defined(SCNi32) && defined(SCNo32) && \ 716#if ! (defined(SCNd32) && defined(SCNi32) && defined(SCNo32) && \
717 defined(SCNu32) && defined(SCNx32) && defined(SCNX32)) 717 defined(SCNu32) && defined(SCNx32) && defined(SCNX32))
718#error "Don't know how to define SCN[diouxX]32" 718#error "Don't know how to define SCN[diouxX]32"
719#endif 719#endif
720 720
721#if ULONG_MAX == 0xffffffffffffffffU /* long is a 64-bit type */ 721#if ULONG_MAX == 0xffffffffffffffffU /* long is a 64-bit type */
722#ifndef PRId64 722#ifndef PRId64
723#define PRId64 "ld" 723#define PRId64 "ld"
724#endif 724#endif
725#ifndef PRIi64 725#ifndef PRIi64
726#define PRIi64 "li" 726#define PRIi64 "li"
727#endif 727#endif
728#ifndef PRIo64 728#ifndef PRIo64
729#define PRIo64 "lo" 729#define PRIo64 "lo"
730#endif 730#endif
731#ifndef PRIu64 731#ifndef PRIu64
732#define PRIu64 "lu" 732#define PRIu64 "lu"
733#endif 733#endif
734#ifndef PRIx64 734#ifndef PRIx64
735#define PRIx64 "lx" 735#define PRIx64 "lx"
736#endif 736#endif
737#ifndef PRIX64 737#ifndef PRIX64
738#define PRIX64 "lX" 738#define PRIX64 "lX"
739#endif 739#endif
740#ifndef SCNd64 740#ifndef SCNd64
741#define SCNd64 "ld" 741#define SCNd64 "ld"
742#endif 742#endif
743#ifndef SCNi64 743#ifndef SCNi64
744#define SCNi64 "li" 744#define SCNi64 "li"
745#endif 745#endif
746#ifndef SCNo64 746#ifndef SCNo64
747#define SCNo64 "lo" 747#define SCNo64 "lo"
748#endif 748#endif
749#ifndef SCNu64 749#ifndef SCNu64
750#define SCNu64 "lu" 750#define SCNu64 "lu"
751#endif 751#endif
752#ifndef SCNx64 752#ifndef SCNx64
753#define SCNx64 "lx" 753#define SCNx64 "lx"
754#endif 754#endif
755#ifndef SCNX64 755#ifndef SCNX64
756#define SCNX64 "lX" 756#define SCNX64 "lX"
757#endif 757#endif
758#endif /* long is a 64-bit type */ 758#endif /* long is a 64-bit type */
759#if ULLONG_MAX == 0xffffffffffffffffU /* long long is a 64-bit type */ 759#if ULLONG_MAX == 0xffffffffffffffffU /* long long is a 64-bit type */
760#ifndef PRId64 760#ifndef PRId64
761#define PRId64 "lld" 761#define PRId64 "lld"
762#endif 762#endif
763#ifndef PRIi64 763#ifndef PRIi64
764#define PRIi64 "lli" 764#define PRIi64 "lli"
765#endif 765#endif
766#ifndef PRIo64 766#ifndef PRIo64
767#define PRIo64 "llo" 767#define PRIo64 "llo"
768#endif 768#endif
769#ifndef PRIu64 769#ifndef PRIu64
770#define PRIu64 "llu" 770#define PRIu64 "llu"
771#endif 771#endif
772#ifndef PRIx64 772#ifndef PRIx64
773#define PRIx64 "llx" 773#define PRIx64 "llx"
774#endif 774#endif
775#ifndef PRIX64 775#ifndef PRIX64
776#define PRIX64 "llX" 776#define PRIX64 "llX"
777#endif 777#endif
778#ifndef SCNd64 778#ifndef SCNd64
779#define SCNd64 "lld" 779#define SCNd64 "lld"
780#endif 780#endif
781#ifndef SCNi64 781#ifndef SCNi64
782#define SCNi64 "lli" 782#define SCNi64 "lli"
783#endif 783#endif
784#ifndef SCNo64 784#ifndef SCNo64
785#define SCNo64 "llo" 785#define SCNo64 "llo"
786#endif 786#endif
787#ifndef SCNu64 787#ifndef SCNu64
788#define SCNu64 "llu" 788#define SCNu64 "llu"
789#endif 789#endif
790#ifndef SCNx64 790#ifndef SCNx64
791#define SCNx64 "llx" 791#define SCNx64 "llx"
792#endif 792#endif
793#ifndef SCNX64 793#ifndef SCNX64
794#define SCNX64 "llX" 794#define SCNX64 "llX"
795#endif 795#endif
796#endif /* long long is a 64-bit type */ 796#endif /* long long is a 64-bit type */
797#if ! (defined(PRId64) && defined(PRIi64) && defined(PRIo64) && \ 797#if ! (defined(PRId64) && defined(PRIi64) && defined(PRIo64) && \
798 defined(PRIu64) && defined(PRIx64) && defined(PRIX64)) 798 defined(PRIu64) && defined(PRIx64) && defined(PRIX64))
799#error "Don't know how to define PRI[diouxX]64" 799#error "Don't know how to define PRI[diouxX]64"
800#endif 800#endif
801#if ! (defined(SCNd64) && defined(SCNi64) && defined(SCNo64) && \ 801#if ! (defined(SCNd64) && defined(SCNi64) && defined(SCNo64) && \
802 defined(SCNu64) && defined(SCNx64) && defined(SCNX64)) 802 defined(SCNu64) && defined(SCNx64) && defined(SCNX64))
803#error "Don't know how to define SCN[diouxX]64" 803#error "Don't know how to define SCN[diouxX]64"
804#endif 804#endif
805 805
806/* <limits.h> */ 806/* <limits.h> */
807 807
808#ifndef UID_MAX 808#ifndef UID_MAX
809#define UID_MAX 32767 809#define UID_MAX 32767
810#endif 810#endif
811#ifndef GID_MAX 811#ifndef GID_MAX
812#define GID_MAX UID_MAX 812#define GID_MAX UID_MAX
813#endif 813#endif
814 814
815#ifndef UQUAD_MAX 815#ifndef UQUAD_MAX
816#define UQUAD_MAX ((u_quad_t)-1) 816#define UQUAD_MAX ((u_quad_t)-1)
817#endif 817#endif
818#ifndef QUAD_MAX 818#ifndef QUAD_MAX
819#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) 819#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1))
820#endif 820#endif
821#ifndef QUAD_MIN 821#ifndef QUAD_MIN
822#define QUAD_MIN ((quad_t)(~QUAD_MAX)) 822#define QUAD_MIN ((quad_t)(~QUAD_MAX))
823#endif 823#endif
824#ifndef ULLONG_MAX 824#ifndef ULLONG_MAX
825#define ULLONG_MAX ((unsigned long long)-1) 825#define ULLONG_MAX ((unsigned long long)-1)
826#endif 826#endif
827#ifndef LLONG_MAX 827#ifndef LLONG_MAX
828#define LLONG_MAX ((long long)(ULLONG_MAX >> 1)) 828#define LLONG_MAX ((long long)(ULLONG_MAX >> 1))
829#endif 829#endif
830#ifndef LLONG_MIN 830#ifndef LLONG_MIN
831#define LLONG_MIN ((long long)(~LLONG_MAX)) 831#define LLONG_MIN ((long long)(~LLONG_MAX))
832#endif 832#endif
833 833
834/* <paths.h> */ 834/* <paths.h> */
835 835
836/* The host's _PATH_BSHELL might be broken, so override it. */ 836/* The host's _PATH_BSHELL might be broken, so override it. */
837#undef _PATH_BSHELL 837#undef _PATH_BSHELL
838#define _PATH_BSHELL PATH_BSHELL 838#define _PATH_BSHELL PATH_BSHELL
839#ifndef _PATH_DEFPATH 839#ifndef _PATH_DEFPATH
840#define _PATH_DEFPATH "/usr/bin:/bin:/usr/local/bin" 840#define _PATH_DEFPATH "/usr/bin:/bin:/usr/local/bin"
841#endif 841#endif
842#ifndef _PATH_DEV 842#ifndef _PATH_DEV
843#define _PATH_DEV "/dev/" 843#define _PATH_DEV "/dev/"
844#endif 844#endif
845#ifndef _PATH_DEVNULL 845#ifndef _PATH_DEVNULL
846#define _PATH_DEVNULL _PATH_DEV "null" 846#define _PATH_DEVNULL _PATH_DEV "null"
847#endif 847#endif
848#ifndef _PATH_TMP 848#ifndef _PATH_TMP
849#define _PATH_TMP "/tmp/" 849#define _PATH_TMP "/tmp/"
850#endif 850#endif
851#ifndef _PATH_DEFTAPE 851#ifndef _PATH_DEFTAPE
852#define _PATH_DEFTAPE "/dev/nrst0" 852#define _PATH_DEFTAPE "/dev/nrst0"
853#endif 853#endif
854#ifndef _PATH_VI 854#ifndef _PATH_VI
855#define _PATH_VI "/usr/bin/vi" 855#define _PATH_VI "/usr/bin/vi"
856#endif 856#endif
857 857
858/* <stdint.h> */ 858/* <stdint.h> */
859 859
860#if !defined(SIZE_MAX) && defined(SIZE_T_MAX) 860#if !defined(SIZE_MAX) && defined(SIZE_T_MAX)
861#define SIZE_MAX SIZE_T_MAX 861#define SIZE_MAX SIZE_T_MAX
862#endif 862#endif
863 863
864#ifndef UINT8_MAX 864#ifndef UINT8_MAX
865#define UINT8_MAX 0xffU 865#define UINT8_MAX 0xffU
866#endif 866#endif
867 867
868#ifndef UINT16_MAX 868#ifndef UINT16_MAX
869#define UINT16_MAX 0xffffU 869#define UINT16_MAX 0xffffU
870#endif 870#endif
871 871
872#ifndef UINT32_MAX 872#ifndef UINT32_MAX
873#define UINT32_MAX 0xffffffffU 873#define UINT32_MAX 0xffffffffU
874#endif 874#endif
875 875
876/* <stdlib.h> */ 876/* <stdlib.h> */
877 877
878#ifndef __GNUC__ 878#ifndef __GNUC__
879# if HAVE_ALLOCA_H 879# if HAVE_ALLOCA_H
880# include <alloca.h> 880# include <alloca.h>
881# else 881# else
882# ifndef alloca /* predefined by HP cc +Olibcalls */ 882# ifndef alloca /* predefined by HP cc +Olibcalls */
883char *alloca (); 883char *alloca ();
884# endif 884# endif
885# endif 885# endif
886#endif 886#endif
887 887
888/* avoid prototype conflicts with host */ 888/* avoid prototype conflicts with host */
889#define cgetcap __nbcompat_cgetcap 889#define cgetcap __nbcompat_cgetcap
890#define cgetclose __nbcompat_cgetclose 890#define cgetclose __nbcompat_cgetclose
891#define cgetent __nbcompat_cgetent 891#define cgetent __nbcompat_cgetent
892#define cgetfirst __nbcompat_cgetfirst 892#define cgetfirst __nbcompat_cgetfirst
893#define cgetmatch __nbcompat_cgetmatch 893#define cgetmatch __nbcompat_cgetmatch
894#define cgetnext __nbcompat_cgetnext 894#define cgetnext __nbcompat_cgetnext
895#define cgetnum __nbcompat_cgetnum 895#define cgetnum __nbcompat_cgetnum
896#define cgetset __nbcompat_cgetset 896#define cgetset __nbcompat_cgetset
897#define cgetstr __nbcompat_cgetstr 897#define cgetstr __nbcompat_cgetstr
898#define cgetustr __nbcompat_cgetustr 898#define cgetustr __nbcompat_cgetustr
899 899
900char *cgetcap(char *, const char *, int); 900char *cgetcap(char *, const char *, int);
901int cgetclose(void); 901int cgetclose(void);
902int cgetent(char **, const char * const *, const char *); 902int cgetent(char **, const char * const *, const char *);
903int cgetfirst(char **, const char * const *); 903int cgetfirst(char **, const char * const *);
904int cgetmatch(const char *, const char *); 904int cgetmatch(const char *, const char *);
905int cgetnext(char **, const char * const *); 905int cgetnext(char **, const char * const *);
906int cgetnum(char *, const char *, long *); 906int cgetnum(char *, const char *, long *);
907int cgetset(const char *); 907int cgetset(const char *);
908int cgetstr(char *, const char *, char **); 908int cgetstr(char *, const char *, char **);
909int cgetustr(char *, const char *, char **); 909int cgetustr(char *, const char *, char **);
910 910
911/* <sys/endian.h> */ 911/* <sys/endian.h> */
912 912
913#if WORDS_BIGENDIAN 913#if WORDS_BIGENDIAN
914#if !HAVE_DECL_HTOBE16 914#if !HAVE_DECL_HTOBE16
915#define htobe16(x) (x) 915#define htobe16(x) (x)
916#endif 916#endif
917#if !HAVE_DECL_HTOBE32 917#if !HAVE_DECL_HTOBE32
918#define htobe32(x) (x) 918#define htobe32(x) (x)
919#endif 919#endif
920#if !HAVE_DECL_HTOBE64 920#if !HAVE_DECL_HTOBE64
921#define htobe64(x) (x) 921#define htobe64(x) (x)
922#endif 922#endif
923#if !HAVE_DECL_HTOLE16 923#if !HAVE_DECL_HTOLE16
924#define htole16(x) bswap16((u_int16_t)(x)) 924#define htole16(x) bswap16((u_int16_t)(x))
925#endif 925#endif
926#if !HAVE_DECL_HTOLE32 926#if !HAVE_DECL_HTOLE32
927#define htole32(x) bswap32((u_int32_t)(x)) 927#define htole32(x) bswap32((u_int32_t)(x))
928#endif 928#endif
929#if !HAVE_DECL_HTOLE64 929#if !HAVE_DECL_HTOLE64
930#define htole64(x) bswap64((u_int64_t)(x)) 930#define htole64(x) bswap64((u_int64_t)(x))
931#endif 931#endif
932#else 932#else
933#if !HAVE_DECL_HTOBE16 933#if !HAVE_DECL_HTOBE16
934#define htobe16(x) bswap16((u_int16_t)(x)) 934#define htobe16(x) bswap16((u_int16_t)(x))
935#endif 935#endif
936#if !HAVE_DECL_HTOBE32 936#if !HAVE_DECL_HTOBE32
937#define htobe32(x) bswap32((u_int32_t)(x)) 937#define htobe32(x) bswap32((u_int32_t)(x))
938#endif 938#endif
939#if !HAVE_DECL_HTOBE64 939#if !HAVE_DECL_HTOBE64
940#define htobe64(x) bswap64((u_int64_t)(x)) 940#define htobe64(x) bswap64((u_int64_t)(x))
941#endif 941#endif
942#if !HAVE_DECL_HTOLE16 942#if !HAVE_DECL_HTOLE16
943#define htole16(x) (x) 943#define htole16(x) (x)
944#endif 944#endif
945#if !HAVE_DECL_HTOLE32 945#if !HAVE_DECL_HTOLE32
946#define htole32(x) (x) 946#define htole32(x) (x)
947#endif 947#endif
948#if !HAVE_DECL_HTOLE64 948#if !HAVE_DECL_HTOLE64
949#define htole64(x) (x) 949#define htole64(x) (x)
950#endif 950#endif
951#endif 951#endif
952#if !HAVE_DECL_BE16TOH 952#if !HAVE_DECL_BE16TOH
953#define be16toh(x) htobe16(x) 953#define be16toh(x) htobe16(x)
954#endif 954#endif
955#if !HAVE_DECL_BE32TOH 955#if !HAVE_DECL_BE32TOH
956#define be32toh(x) htobe32(x) 956#define be32toh(x) htobe32(x)
957#endif 957#endif
958#if !HAVE_DECL_BE64TOH 958#if !HAVE_DECL_BE64TOH
959#define be64toh(x) htobe64(x) 959#define be64toh(x) htobe64(x)
960#endif 960#endif
961#if !HAVE_DECL_LE16TOH 961#if !HAVE_DECL_LE16TOH
962#define le16toh(x) htole16(x) 962#define le16toh(x) htole16(x)
963#endif 963#endif
964#if !HAVE_DECL_LE32TOH 964#if !HAVE_DECL_LE32TOH
965#define le32toh(x) htole32(x) 965#define le32toh(x) htole32(x)
966#endif 966#endif
967#if !HAVE_DECL_LE64TOH 967#if !HAVE_DECL_LE64TOH
968#define le64toh(x) htole64(x) 968#define le64toh(x) htole64(x)
969#endif 969#endif
970 970
971#define __GEN_ENDIAN_ENC(bits, endian) \ 971#define __GEN_ENDIAN_ENC(bits, endian) \
972static void \ 972static void \
973endian ## bits ## enc(void *dst, uint ## bits ## _t u) \ 973endian ## bits ## enc(void *dst, uint ## bits ## _t u) \
974{ \ 974{ \
975 u = hto ## endian ## bits (u); \ 975 u = hto ## endian ## bits (u); \
976 memcpy(dst, &u, sizeof(u)); \ 976 memcpy(dst, &u, sizeof(u)); \
977} 977}
978#if !HAVE_DECL_BE16ENC 978#if !HAVE_DECL_BE16ENC
979__GEN_ENDIAN_ENC(16, be) 979__GEN_ENDIAN_ENC(16, be)
980#endif 980#endif
981#if !HAVE_DECL_BE32ENC 981#if !HAVE_DECL_BE32ENC
982__GEN_ENDIAN_ENC(32, be) 982__GEN_ENDIAN_ENC(32, be)
983#endif 983#endif
984#if !HAVE_DECL_BE64ENC 984#if !HAVE_DECL_BE64ENC
985__GEN_ENDIAN_ENC(64, be) 985__GEN_ENDIAN_ENC(64, be)
986#endif 986#endif
987#if !HAVE_DECL_LE16ENC 987#if !HAVE_DECL_LE16ENC
988__GEN_ENDIAN_ENC(16, le) 988__GEN_ENDIAN_ENC(16, le)
989#endif 989#endif
990#if !HAVE_DECL_LE32ENC 990#if !HAVE_DECL_LE32ENC
991__GEN_ENDIAN_ENC(32, le) 991__GEN_ENDIAN_ENC(32, le)
992#endif 992#endif
993#if !HAVE_DECL_LE64ENC 993#if !HAVE_DECL_LE64ENC
994__GEN_ENDIAN_ENC(64, le) 994__GEN_ENDIAN_ENC(64, le)
995#endif 995#endif
996#undef __GEN_ENDIAN_ENC 996#undef __GEN_ENDIAN_ENC
997 997
998#define __GEN_ENDIAN_DEC(bits, endian) \ 998#define __GEN_ENDIAN_DEC(bits, endian) \
999static uint ## bits ## _t \ 999static uint ## bits ## _t \
1000endian ## bits ## dec(const void *buf) \ 1000endian ## bits ## dec(const void *buf) \
1001{ \ 1001{ \
1002 uint ## bits ## _t u; \ 1002 uint ## bits ## _t u; \
1003 memcpy(&u, buf, sizeof(u)); \ 1003 memcpy(&u, buf, sizeof(u)); \
1004 return endian ## bits ## toh (u); \ 1004 return endian ## bits ## toh (u); \
1005} 1005}
1006#if !HAVE_DECL_BE16DEC 1006#if !HAVE_DECL_BE16DEC
1007__GEN_ENDIAN_DEC(16, be) 1007__GEN_ENDIAN_DEC(16, be)
1008#endif 1008#endif
1009#if !HAVE_DECL_BE32DEC 1009#if !HAVE_DECL_BE32DEC
1010__GEN_ENDIAN_DEC(32, be) 1010__GEN_ENDIAN_DEC(32, be)
1011#endif 1011#endif
1012#if !HAVE_DECL_BE64DEC 1012#if !HAVE_DECL_BE64DEC
1013__GEN_ENDIAN_DEC(64, be) 1013__GEN_ENDIAN_DEC(64, be)
1014#endif 1014#endif
1015#if !HAVE_DECL_LE16DEC 1015#if !HAVE_DECL_LE16DEC
1016__GEN_ENDIAN_DEC(16, le) 1016__GEN_ENDIAN_DEC(16, le)
1017#endif 1017#endif
1018#if !HAVE_DECL_LE32DEC 1018#if !HAVE_DECL_LE32DEC
1019__GEN_ENDIAN_DEC(32, le) 1019__GEN_ENDIAN_DEC(32, le)
1020#endif 1020#endif
1021#if !HAVE_DECL_LE64DEC 1021#if !HAVE_DECL_LE64DEC
1022__GEN_ENDIAN_DEC(64, le) 1022__GEN_ENDIAN_DEC(64, le)
1023#endif 1023#endif
1024#undef __GEN_ENDIAN_DEC 1024#undef __GEN_ENDIAN_DEC
1025 1025
1026/* <sys/mman.h> */ 1026/* <sys/mman.h> */
1027 1027
1028#ifndef MAP_FILE 1028#ifndef MAP_FILE
1029#define MAP_FILE 0 1029#define MAP_FILE 0
1030#endif 1030#endif
1031 1031
1032/* HP-UX has MAP_ANONYMOUS but not MAP_ANON */ 1032/* HP-UX has MAP_ANONYMOUS but not MAP_ANON */
1033#ifndef MAP_ANON 1033#ifndef MAP_ANON
1034#ifdef MAP_ANONYMOUS 1034#ifdef MAP_ANONYMOUS
1035#define MAP_ANON MAP_ANONYMOUS 1035#define MAP_ANON MAP_ANONYMOUS
1036#endif 1036#endif
1037#endif 1037#endif
1038 1038
1039/* <sys/param.h> */ 1039/* <sys/param.h> */
1040 1040
1041#undef BIG_ENDIAN 1041#undef BIG_ENDIAN
1042#undef LITTLE_ENDIAN 1042#undef LITTLE_ENDIAN
1043#undef PDP_ENDIAN 1043#undef PDP_ENDIAN
1044#define BIG_ENDIAN 4321 1044#define BIG_ENDIAN 4321
1045#define LITTLE_ENDIAN 1234 1045#define LITTLE_ENDIAN 1234
1046#define PDP_ENDIAN 3412 1046#define PDP_ENDIAN 3412
1047 1047
1048#undef BYTE_ORDER 1048#undef BYTE_ORDER
1049#if WORDS_BIGENDIAN 1049#if WORDS_BIGENDIAN
1050#define BYTE_ORDER BIG_ENDIAN 1050#define BYTE_ORDER BIG_ENDIAN
1051#else 1051#else
1052#define BYTE_ORDER LITTLE_ENDIAN 1052#define BYTE_ORDER LITTLE_ENDIAN
1053#endif 1053#endif
1054 1054
1055#ifndef DEV_BSIZE 1055/* all references of DEV_BSIZE in tools are for NetBSD's file images */
 1056#undef DEV_BSIZE
1056#define DEV_BSIZE (1 << 9) 1057#define DEV_BSIZE (1 << 9)
1057#endif 
1058 1058
1059#undef MIN 1059#undef MIN
1060#undef MAX 1060#undef MAX
1061#define MIN(a,b) ((a) < (b) ? (a) : (b)) 1061#define MIN(a,b) ((a) < (b) ? (a) : (b))
1062#define MAX(a,b) ((a) > (b) ? (a) : (b)) 1062#define MAX(a,b) ((a) > (b) ? (a) : (b))
1063 1063
1064#ifndef MAXBSIZE 1064#ifndef MAXBSIZE
1065#define MAXBSIZE (64 * 1024) 1065#define MAXBSIZE (64 * 1024)
1066#endif 1066#endif
1067#ifndef MAXFRAG 1067#ifndef MAXFRAG
1068#define MAXFRAG 8 1068#define MAXFRAG 8
1069#endif 1069#endif
1070#ifndef MAXPHYS 1070#ifndef MAXPHYS
1071#define MAXPHYS (64 * 1024) 1071#define MAXPHYS (64 * 1024)
1072#endif 1072#endif
1073 1073
1074/* XXX needed by makefs; this should be done in a better way */ 1074/* XXX needed by makefs; this should be done in a better way */
1075#undef btodb 1075#undef btodb
1076#define btodb(x) ((x) << 9) 1076#define btodb(x) ((x) << 9)
1077 1077
1078#undef setbit 1078#undef setbit
1079#undef clrbit 1079#undef clrbit
1080#undef isset 1080#undef isset
1081#undef isclr 1081#undef isclr
1082#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 1082#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1083#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 1083#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1084#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 1084#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1085#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 1085#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1086 1086
1087#ifndef powerof2 1087#ifndef powerof2
1088#define powerof2(x) ((((x)-1)&(x))==0) 1088#define powerof2(x) ((((x)-1)&(x))==0)
1089#endif 1089#endif
1090 1090
1091#undef roundup 1091#undef roundup
1092#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 1092#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
1093 1093
1094/* <sys/stat.h> */ 1094/* <sys/stat.h> */
1095 1095
1096#ifndef ALLPERMS 1096#ifndef ALLPERMS
1097#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) 1097#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
1098#endif 1098#endif
1099#ifndef DEFFILEMODE 1099#ifndef DEFFILEMODE
1100#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) 1100#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
1101#endif 1101#endif
1102#ifndef S_ISTXT 1102#ifndef S_ISTXT
1103#ifdef S_ISVTX 1103#ifdef S_ISVTX
1104#define S_ISTXT S_ISVTX 1104#define S_ISTXT S_ISVTX
1105#else 1105#else
1106#define S_ISTXT 0 1106#define S_ISTXT 0
1107#endif 1107#endif
1108#endif 1108#endif
1109 1109
1110/* Protected by _NETBSD_SOURCE otherwise. */ 1110/* Protected by _NETBSD_SOURCE otherwise. */
1111#if HAVE_STRUCT_STAT_ST_FLAGS && defined(__NetBSD__) 1111#if HAVE_STRUCT_STAT_ST_FLAGS && defined(__NetBSD__)
1112#define UF_SETTABLE 0x0000ffff 1112#define UF_SETTABLE 0x0000ffff
1113#define UF_NODUMP 0x00000001 1113#define UF_NODUMP 0x00000001
1114#define UF_IMMUTABLE 0x00000002 1114#define UF_IMMUTABLE 0x00000002
1115#define UF_APPEND 0x00000004 1115#define UF_APPEND 0x00000004
1116#define UF_OPAQUE 0x00000008 1116#define UF_OPAQUE 0x00000008
1117#define SF_SETTABLE 0xffff0000 1117#define SF_SETTABLE 0xffff0000
1118#define SF_ARCHIVED 0x00010000 1118#define SF_ARCHIVED 0x00010000
1119#define SF_IMMUTABLE 0x00020000 1119#define SF_IMMUTABLE 0x00020000
1120#define SF_APPEND 0x00040000 1120#define SF_APPEND 0x00040000
1121#endif 1121#endif
1122 1122
1123/* <sys/syslimits.h> */ 1123/* <sys/syslimits.h> */
1124 1124
1125#ifndef LINE_MAX 1125#ifndef LINE_MAX
1126#define LINE_MAX 2048 1126#define LINE_MAX 2048
1127#endif 1127#endif
1128 1128
1129/* <sys/time.h> */ 1129/* <sys/time.h> */
1130 1130
1131#ifndef timercmp 1131#ifndef timercmp
1132#define timercmp(tvp, uvp, cmp) \ 1132#define timercmp(tvp, uvp, cmp) \
1133 (((tvp)->tv_sec == (uvp)->tv_sec) ? \ 1133 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
1134 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ 1134 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
1135 ((tvp)->tv_sec cmp (uvp)->tv_sec)) 1135 ((tvp)->tv_sec cmp (uvp)->tv_sec))
1136#endif 1136#endif
1137#ifndef timeradd 1137#ifndef timeradd
1138#define timeradd(tvp, uvp, vvp) \ 1138#define timeradd(tvp, uvp, vvp) \
1139 do { \ 1139 do { \
1140 (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ 1140 (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
1141 (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ 1141 (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
1142 if ((vvp)->tv_usec >= 1000000) { \ 1142 if ((vvp)->tv_usec >= 1000000) { \
1143 (vvp)->tv_sec++; \ 1143 (vvp)->tv_sec++; \
1144 (vvp)->tv_usec -= 1000000; \ 1144 (vvp)->tv_usec -= 1000000; \
1145 } \ 1145 } \
1146 } while (/* CONSTCOND */ 0) 1146 } while (/* CONSTCOND */ 0)
1147#endif 1147#endif
1148#ifndef timersub 1148#ifndef timersub
1149#define timersub(tvp, uvp, vvp) \ 1149#define timersub(tvp, uvp, vvp) \
1150 do { \ 1150 do { \
1151 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ 1151 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
1152 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ 1152 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
1153 if ((vvp)->tv_usec < 0) { \ 1153 if ((vvp)->tv_usec < 0) { \
1154 (vvp)->tv_sec--; \ 1154 (vvp)->tv_sec--; \
1155 (vvp)->tv_usec += 1000000; \ 1155 (vvp)->tv_usec += 1000000; \
1156 } \ 1156 } \
1157 } while (/* CONSTCOND */ 0) 1157 } while (/* CONSTCOND */ 0)
1158#endif 1158#endif
1159 1159
1160/* <sys/types.h> */ 1160/* <sys/types.h> */
1161 1161
1162#ifdef major 1162#ifdef major
1163#undef major 1163#undef major
1164#endif 1164#endif
1165#define major(x) ((int32_t)((((x) & 0x000fff00) >> 8))) 1165#define major(x) ((int32_t)((((x) & 0x000fff00) >> 8)))
1166 1166
1167#ifdef minor 1167#ifdef minor
1168#undef minor 1168#undef minor
1169#endif 1169#endif
1170#define minor(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \ 1170#define minor(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \
1171 (((x) & 0x000000ff) >> 0))) 1171 (((x) & 0x000000ff) >> 0)))
1172#ifdef makedev 1172#ifdef makedev
1173#undef makedev 1173#undef makedev
1174#endif 1174#endif
1175#define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \ 1175#define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
1176 (((y) << 12) & 0xfff00000) | \ 1176 (((y) << 12) & 0xfff00000) | \
1177 (((y) << 0) & 0x000000ff))) 1177 (((y) << 0) & 0x000000ff)))
1178#ifndef NBBY 1178#ifndef NBBY
1179#define NBBY 8 1179#define NBBY 8
1180#endif 1180#endif
1181 1181
1182#if !HAVE_U_QUAD_T 1182#if !HAVE_U_QUAD_T
1183/* #define, not typedef, as quad_t exists as a struct on some systems */ 1183/* #define, not typedef, as quad_t exists as a struct on some systems */
1184#define quad_t long long 1184#define quad_t long long
1185#define u_quad_t unsigned long long 1185#define u_quad_t unsigned long long
1186#define strtoq strtoll 1186#define strtoq strtoll
1187#define strtouq strtoull 1187#define strtouq strtoull
1188#endif 1188#endif
1189 1189
1190/* Has quad_t but these prototypes don't get pulled into scope. w/o we lose */ 1190/* Has quad_t but these prototypes don't get pulled into scope. w/o we lose */
1191#ifdef __NetBSD__ 1191#ifdef __NetBSD__
1192quad_t strtoq __P((const char *, char **, int));  1192quad_t strtoq __P((const char *, char **, int));
1193u_quad_t strtouq __P((const char *, char **, int));  1193u_quad_t strtouq __P((const char *, char **, int));
1194#endif 1194#endif
1195 1195
1196#endif /* !__NETBSD_COMPAT_DEFS_H__ */ 1196#endif /* !__NETBSD_COMPAT_DEFS_H__ */