diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 6 | ||||
-rw-r--r-- | include/platform.h | 61 |
2 files changed, 34 insertions, 33 deletions
diff --git a/include/libbb.h b/include/libbb.h index 77674f8a2..835beb20c 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -29,6 +29,10 @@ | |||
29 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
30 | #include <sys/mman.h> | 30 | #include <sys/mman.h> |
31 | #include <sys/socket.h> | 31 | #include <sys/socket.h> |
32 | #if defined __FreeBSD__ | ||
33 | #include <netinet/in.h> | ||
34 | #include <arpa/inet.h> | ||
35 | #endif | ||
32 | #include <sys/stat.h> | 36 | #include <sys/stat.h> |
33 | #include <sys/time.h> | 37 | #include <sys/time.h> |
34 | #include <sys/types.h> | 38 | #include <sys/types.h> |
@@ -86,7 +90,9 @@ int klogctl(int type, char *b, int len); | |||
86 | /* This is declared here rather than #including <libgen.h> in order to avoid | 90 | /* This is declared here rather than #including <libgen.h> in order to avoid |
87 | * confusing the two versions of basename. See the dirname/basename man page | 91 | * confusing the two versions of basename. See the dirname/basename man page |
88 | * for details. */ | 92 | * for details. */ |
93 | #if !defined __FreeBSD__ | ||
89 | char *dirname(char *path); | 94 | char *dirname(char *path); |
95 | #endif | ||
90 | /* Include our own copy of struct sysinfo to avoid binary compatibility | 96 | /* Include our own copy of struct sysinfo to avoid binary compatibility |
91 | * problems with Linux 2.4, which changed things. Grumble, grumble. */ | 97 | * problems with Linux 2.4, which changed things. Grumble, grumble. */ |
92 | struct sysinfo { | 98 | struct sysinfo { |
diff --git a/include/platform.h b/include/platform.h index e2136a2ea..99e747f0d 100644 --- a/include/platform.h +++ b/include/platform.h | |||
@@ -36,12 +36,10 @@ | |||
36 | #undef inline | 36 | #undef inline |
37 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L | 37 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L |
38 | /* it's a keyword */ | 38 | /* it's a keyword */ |
39 | #elif __GNUC_PREREQ(2,7) | ||
40 | # define inline __inline__ | ||
39 | #else | 41 | #else |
40 | # if __GNUC_PREREQ(2,7) | 42 | # define inline |
41 | # define inline __inline__ | ||
42 | # else | ||
43 | # define inline | ||
44 | # endif | ||
45 | #endif | 43 | #endif |
46 | 44 | ||
47 | #ifndef __const | 45 | #ifndef __const |
@@ -52,6 +50,7 @@ | |||
52 | #define NORETURN __attribute__ ((__noreturn__)) | 50 | #define NORETURN __attribute__ ((__noreturn__)) |
53 | #define PACKED __attribute__ ((__packed__)) | 51 | #define PACKED __attribute__ ((__packed__)) |
54 | #define ALIGNED(m) __attribute__ ((__aligned__(m))) | 52 | #define ALIGNED(m) __attribute__ ((__aligned__(m))) |
53 | |||
55 | /* __NO_INLINE__: some gcc's do not honor inlining! :( */ | 54 | /* __NO_INLINE__: some gcc's do not honor inlining! :( */ |
56 | #if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__) | 55 | #if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__) |
57 | # define ALWAYS_INLINE __attribute__ ((always_inline)) inline | 56 | # define ALWAYS_INLINE __attribute__ ((always_inline)) inline |
@@ -122,24 +121,34 @@ | |||
122 | 121 | ||
123 | /* ---- Endian Detection ------------------------------------ */ | 122 | /* ---- Endian Detection ------------------------------------ */ |
124 | 123 | ||
125 | #if (defined __digital__ && defined __unix__) | 124 | #if defined(__digital__) && defined(__unix__) |
126 | # include <sex.h> | 125 | # include <sex.h> |
127 | # define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN) | 126 | # define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN) |
128 | # define __BYTE_ORDER BYTE_ORDER | 127 | # define __BYTE_ORDER BYTE_ORDER |
128 | #elif defined __FreeBSD__ | ||
129 | char *strchrnul(const char *s, int c); | ||
130 | # include <sys/resource.h> /* rlimit */ | ||
131 | # include <machine/endian.h> | ||
132 | # define bswap_64 __bswap64 | ||
133 | # define bswap_32 __bswap32 | ||
134 | # define bswap_16 __bswap16 | ||
135 | # define __BIG_ENDIAN__ (_BYTE_ORDER == _BIG_ENDIAN) | ||
129 | #elif !defined __APPLE__ | 136 | #elif !defined __APPLE__ |
130 | # include <byteswap.h> | 137 | # include <byteswap.h> |
131 | # include <endian.h> | 138 | # include <endian.h> |
132 | #endif | 139 | #endif |
133 | 140 | ||
134 | #ifdef __BIG_ENDIAN__ | 141 | #if defined(__BIG_ENDIAN__) && __BIG_ENDIAN__ |
135 | # define BB_BIG_ENDIAN 1 | 142 | # define BB_BIG_ENDIAN 1 |
136 | # define BB_LITTLE_ENDIAN 0 | 143 | # define BB_LITTLE_ENDIAN 0 |
137 | #elif __BYTE_ORDER == __BIG_ENDIAN | 144 | #elif __BYTE_ORDER == __BIG_ENDIAN |
138 | # define BB_BIG_ENDIAN 1 | 145 | # define BB_BIG_ENDIAN 1 |
139 | # define BB_LITTLE_ENDIAN 0 | 146 | # define BB_LITTLE_ENDIAN 0 |
140 | #else | 147 | #elif __BYTE_ORDER == __LITTLE_ENDIAN |
141 | # define BB_BIG_ENDIAN 0 | 148 | # define BB_BIG_ENDIAN 0 |
142 | # define BB_LITTLE_ENDIAN 1 | 149 | # define BB_LITTLE_ENDIAN 1 |
150 | #else | ||
151 | # error "Can't determine endiannes" | ||
143 | #endif | 152 | #endif |
144 | 153 | ||
145 | /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ | 154 | /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ |
@@ -183,7 +192,7 @@ | |||
183 | 192 | ||
184 | #ifndef __APPLE__ | 193 | #ifndef __APPLE__ |
185 | # include <arpa/inet.h> | 194 | # include <arpa/inet.h> |
186 | # ifndef __socklen_t_defined | 195 | # if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED) |
187 | typedef int socklen_t; | 196 | typedef int socklen_t; |
188 | # endif | 197 | # endif |
189 | #else | 198 | #else |
@@ -192,20 +201,13 @@ typedef int socklen_t; | |||
192 | 201 | ||
193 | /* ---- Compiler dependent settings ------------------------- */ | 202 | /* ---- Compiler dependent settings ------------------------- */ |
194 | 203 | ||
195 | #if (defined __digital__ && defined __unix__) || defined __APPLE__ | 204 | #if (defined __digital__ && defined __unix__) \ |
205 | || defined __APPLE__ || defined __FreeBSD__ | ||
196 | # undef HAVE_MNTENT_H | 206 | # undef HAVE_MNTENT_H |
197 | # undef HAVE_SYS_STATFS_H | 207 | # undef HAVE_SYS_STATFS_H |
198 | #else | 208 | #else |
199 | # define HAVE_MNTENT_H 1 | 209 | # define HAVE_MNTENT_H 1 |
200 | # define HAVE_SYS_STATFS_H 1 | 210 | # define HAVE_SYS_STATFS_H 1 |
201 | #endif /* ___digital__ && __unix__ */ | ||
202 | |||
203 | /* linux/loop.h relies on __u64. Make sure we have that as a proper type | ||
204 | * until userspace is widely fixed. */ | ||
205 | #if (defined __INTEL_COMPILER && !defined __GNUC__) || \ | ||
206 | (defined __GNUC__ && defined __STRICT_ANSI__) | ||
207 | __extension__ typedef long long __s64; | ||
208 | __extension__ typedef unsigned long long __u64; | ||
209 | #endif | 211 | #endif |
210 | 212 | ||
211 | /*----- Kernel versioning ------------------------------------*/ | 213 | /*----- Kernel versioning ------------------------------------*/ |
@@ -224,14 +226,15 @@ __extension__ typedef unsigned long long __u64; | |||
224 | /* Don't perpetuate e2fsck crap into the headers. Clean up e2fsck instead. */ | 226 | /* Don't perpetuate e2fsck crap into the headers. Clean up e2fsck instead. */ |
225 | 227 | ||
226 | #if defined __GLIBC__ || defined __UCLIBC__ \ | 228 | #if defined __GLIBC__ || defined __UCLIBC__ \ |
227 | || defined __dietlibc__ || defined _NEWLIB_VERSION | 229 | || defined __dietlibc__ || defined _NEWLIB_VERSION |
228 | # include <features.h> | 230 | # include <features.h> |
229 | # define HAVE_FEATURES_H | 231 | # define HAVE_FEATURES_H |
230 | # include <stdint.h> | 232 | # include <stdint.h> |
231 | # define HAVE_STDINT_H | 233 | # define HAVE_STDINT_H |
232 | #elif !defined __APPLE__ | 234 | #elif !defined __APPLE__ |
233 | /* Largest integral types. */ | 235 | /* Largest integral types. */ |
234 | # if __BIG_ENDIAN__ | 236 | # if BB_BIG_ENDIAN |
237 | /* Looks BROKEN! */ | ||
235 | typedef long intmax_t; | 238 | typedef long intmax_t; |
236 | typedef unsigned long uintmax_t; | 239 | typedef unsigned long uintmax_t; |
237 | # else | 240 | # else |
@@ -308,18 +311,15 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c) | |||
308 | } | 311 | } |
309 | #endif | 312 | #endif |
310 | 313 | ||
311 | /* Don't use lchown with glibc older than 2.1.x ... uClibc lacks it */ | 314 | /* Don't use lchown with glibc older than 2.1.x */ |
312 | #if (defined __GLIBC__ && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1) || \ | 315 | #if defined(__GLIBC__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1 |
313 | defined __UC_LIBC__ | ||
314 | # define lchown chown | 316 | # define lchown chown |
315 | #endif | 317 | #endif |
316 | 318 | ||
317 | #if (defined __digital__ && defined __unix__) | 319 | #if defined(__digital__) && defined(__unix__) |
318 | 320 | ||
319 | # include <standards.h> | 321 | # include <standards.h> |
320 | # define HAVE_STANDARDS_H | ||
321 | # include <inttypes.h> | 322 | # include <inttypes.h> |
322 | # define HAVE_INTTYPES_H | ||
323 | # define PRIu32 "u" | 323 | # define PRIu32 "u" |
324 | /* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */ | 324 | /* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */ |
325 | # define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me,__me); } while (0) | 325 | # define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me,__me); } while (0) |
@@ -336,7 +336,7 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c) | |||
336 | # define ADJ_TICK MOD_CLKB | 336 | # define ADJ_TICK MOD_CLKB |
337 | # endif | 337 | # endif |
338 | 338 | ||
339 | #else /* !__digital__ */ | 339 | #else |
340 | 340 | ||
341 | # define bb_setpgrp() setpgrp() | 341 | # define bb_setpgrp() setpgrp() |
342 | 342 | ||
@@ -387,9 +387,4 @@ static ALWAYS_INLINE char* strchrnul(const char *s, char c) | |||
387 | # define HAVE_NO_UTSNAME_DOMAINNAME | 387 | # define HAVE_NO_UTSNAME_DOMAINNAME |
388 | #endif | 388 | #endif |
389 | 389 | ||
390 | /* If this system doesn't have IUCLC bit in struct termios::c_iflag... */ | ||
391 | #ifndef IUCLC | ||
392 | # define IUCLC 0 | ||
393 | #endif | ||
394 | |||
395 | #endif | 390 | #endif |