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