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