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