diff options
Diffstat (limited to 'include/platform.h')
-rw-r--r-- | include/platform.h | 158 |
1 files changed, 82 insertions, 76 deletions
diff --git a/include/platform.h b/include/platform.h index eb9f8032b..48e256aa0 100644 --- a/include/platform.h +++ b/include/platform.h | |||
@@ -17,24 +17,6 @@ | |||
17 | # endif | 17 | # endif |
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | /* Assume all these functions exist by default. Platforms where it is not | ||
21 | * true will #undef them below. | ||
22 | */ | ||
23 | #define HAVE_CLEARENV 1 | ||
24 | #define HAVE_FDATASYNC 1 | ||
25 | #define HAVE_DPRINTF 1 | ||
26 | #define HAVE_MEMRCHR 1 | ||
27 | #define HAVE_MKDTEMP 1 | ||
28 | #define HAVE_PTSNAME_R 1 | ||
29 | #define HAVE_SETBIT 1 | ||
30 | #define HAVE_SIGHANDLER_T 1 | ||
31 | #define HAVE_STPCPY 1 | ||
32 | #define HAVE_STRCASESTR 1 | ||
33 | #define HAVE_STRCHRNUL 1 | ||
34 | #define HAVE_STRSEP 1 | ||
35 | #define HAVE_STRSIGNAL 1 | ||
36 | #define HAVE_VASPRINTF 1 | ||
37 | |||
38 | /* Convenience macros to test the version of gcc. */ | 20 | /* Convenience macros to test the version of gcc. */ |
39 | #undef __GNUC_PREREQ | 21 | #undef __GNUC_PREREQ |
40 | #if defined __GNUC__ && defined __GNUC_MINOR__ | 22 | #if defined __GNUC__ && defined __GNUC_MINOR__ |
@@ -51,10 +33,6 @@ | |||
51 | # endif | 33 | # endif |
52 | #endif | 34 | #endif |
53 | 35 | ||
54 | /* Define macros for some gcc attributes. This permits us to use the | ||
55 | macros freely, and know that they will come into play for the | ||
56 | version of gcc in which they are supported. */ | ||
57 | |||
58 | #if !__GNUC_PREREQ(2,7) | 36 | #if !__GNUC_PREREQ(2,7) |
59 | # ifndef __attribute__ | 37 | # ifndef __attribute__ |
60 | # define __attribute__(x) | 38 | # define __attribute__(x) |
@@ -108,7 +86,7 @@ | |||
108 | #endif | 86 | #endif |
109 | 87 | ||
110 | /* -fwhole-program makes all symbols local. The attribute externally_visible | 88 | /* -fwhole-program makes all symbols local. The attribute externally_visible |
111 | forces a symbol global. */ | 89 | * forces a symbol global. */ |
112 | #if __GNUC_PREREQ(4,1) | 90 | #if __GNUC_PREREQ(4,1) |
113 | # define EXTERNALLY_VISIBLE __attribute__(( visibility("default") )) | 91 | # define EXTERNALLY_VISIBLE __attribute__(( visibility("default") )) |
114 | //__attribute__ ((__externally_visible__)) | 92 | //__attribute__ ((__externally_visible__)) |
@@ -124,22 +102,14 @@ | |||
124 | #endif | 102 | #endif |
125 | 103 | ||
126 | /* We use __extension__ in some places to suppress -pedantic warnings | 104 | /* We use __extension__ in some places to suppress -pedantic warnings |
127 | about GCC extensions. This feature didn't work properly before | 105 | * about GCC extensions. This feature didn't work properly before |
128 | gcc 2.8. */ | 106 | * gcc 2.8. */ |
129 | #if !__GNUC_PREREQ(2,8) | 107 | #if !__GNUC_PREREQ(2,8) |
130 | # ifndef __extension__ | 108 | # ifndef __extension__ |
131 | # define __extension__ | 109 | # define __extension__ |
132 | # endif | 110 | # endif |
133 | #endif | 111 | #endif |
134 | 112 | ||
135 | /* gcc-2.95 had no va_copy but only __va_copy. */ | ||
136 | #if !__GNUC_PREREQ(3,0) | ||
137 | # include <stdarg.h> | ||
138 | # if !defined va_copy && defined __va_copy | ||
139 | # define va_copy(d,s) __va_copy((d),(s)) | ||
140 | # endif | ||
141 | #endif | ||
142 | |||
143 | /* FAST_FUNC is a qualifier which (possibly) makes function call faster | 113 | /* FAST_FUNC is a qualifier which (possibly) makes function call faster |
144 | * and/or smaller by using modified ABI. It is usually only needed | 114 | * and/or smaller by using modified ABI. It is usually only needed |
145 | * on non-static, busybox internal functions. Recent versions of gcc | 115 | * on non-static, busybox internal functions. Recent versions of gcc |
@@ -163,6 +133,15 @@ | |||
163 | # define POP_SAVED_FUNCTION_VISIBILITY | 133 | # define POP_SAVED_FUNCTION_VISIBILITY |
164 | #endif | 134 | #endif |
165 | 135 | ||
136 | /* gcc-2.95 had no va_copy but only __va_copy. */ | ||
137 | #if !__GNUC_PREREQ(3,0) | ||
138 | # include <stdarg.h> | ||
139 | # if !defined va_copy && defined __va_copy | ||
140 | # define va_copy(d,s) __va_copy((d),(s)) | ||
141 | # endif | ||
142 | #endif | ||
143 | |||
144 | |||
166 | /* ---- Endian Detection ------------------------------------ */ | 145 | /* ---- Endian Detection ------------------------------------ */ |
167 | 146 | ||
168 | #include <limits.h> | 147 | #include <limits.h> |
@@ -238,6 +217,7 @@ | |||
238 | # define IF_LITTLE_ENDIAN(...) __VA_ARGS__ | 217 | # define IF_LITTLE_ENDIAN(...) __VA_ARGS__ |
239 | #endif | 218 | #endif |
240 | 219 | ||
220 | |||
241 | /* ---- Unaligned access ------------------------------------ */ | 221 | /* ---- Unaligned access ------------------------------------ */ |
242 | 222 | ||
243 | #include <stdint.h> | 223 | #include <stdint.h> |
@@ -270,37 +250,9 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; | |||
270 | } while (0) | 250 | } while (0) |
271 | #endif | 251 | #endif |
272 | 252 | ||
273 | /* ---- Compiler dependent settings ------------------------- */ | ||
274 | 253 | ||
275 | #if (defined __digital__ && defined __unix__) \ | 254 | /* ---- Size-saving "small" ints (arch-dependent) ----------- */ |
276 | || defined __APPLE__ \ | ||
277 | || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ | ||
278 | # undef HAVE_CLEARENV | ||
279 | # undef HAVE_FDATASYNC | ||
280 | # undef HAVE_MNTENT_H | ||
281 | # undef HAVE_PTSNAME_R | ||
282 | # undef HAVE_SYS_STATFS_H | ||
283 | # undef HAVE_SIGHANDLER_T | ||
284 | # undef HAVE_XTABS | ||
285 | # undef HAVE_DPRINTF | ||
286 | #else | ||
287 | # define HAVE_MNTENT_H 1 | ||
288 | # define HAVE_SYS_STATFS_H 1 | ||
289 | # define HAVE_XTABS 1 | ||
290 | #endif | ||
291 | |||
292 | /*----- Kernel versioning ------------------------------------*/ | ||
293 | |||
294 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) | ||
295 | |||
296 | /* ---- Miscellaneous --------------------------------------- */ | ||
297 | 255 | ||
298 | #if defined __GLIBC__ || defined __UCLIBC__ \ | ||
299 | || defined __dietlibc__ || defined _NEWLIB_VERSION | ||
300 | # include <features.h> | ||
301 | #endif | ||
302 | |||
303 | /* Size-saving "small" ints (arch-dependent) */ | ||
304 | #if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__) | 256 | #if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__) |
305 | /* add other arches which benefit from this... */ | 257 | /* add other arches which benefit from this... */ |
306 | typedef signed char smallint; | 258 | typedef signed char smallint; |
@@ -320,7 +272,34 @@ typedef unsigned smalluint; | |||
320 | # include <stdbool.h> | 272 | # include <stdbool.h> |
321 | #endif | 273 | #endif |
322 | 274 | ||
323 | /* Try to defeat gcc's alignment of "char message[]"-like data */ | 275 | |
276 | /*----- Kernel versioning ------------------------------------*/ | ||
277 | |||
278 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) | ||
279 | |||
280 | |||
281 | /* ---- Miscellaneous --------------------------------------- */ | ||
282 | |||
283 | #if defined __GLIBC__ \ | ||
284 | || defined __UCLIBC__ \ | ||
285 | || defined __dietlibc__ \ | ||
286 | || defined _NEWLIB_VERSION | ||
287 | # include <features.h> | ||
288 | #endif | ||
289 | |||
290 | /* Define bb_setpgrp */ | ||
291 | #if defined(__digital__) && defined(__unix__) | ||
292 | /* use legacy setpgrp(pid_t, pid_t) for now. move to platform.c */ | ||
293 | # define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me, __me); } while (0) | ||
294 | #else | ||
295 | # define bb_setpgrp() setpgrp() | ||
296 | #endif | ||
297 | |||
298 | /* fdprintf is more readable, we used it before dprintf was standardized */ | ||
299 | #include <unistd.h> | ||
300 | #define fdprintf dprintf | ||
301 | |||
302 | /* Useful for defeating gcc's alignment of "char message[]"-like data */ | ||
324 | #if 1 /* if needed: !defined(arch1) && !defined(arch2) */ | 303 | #if 1 /* if needed: !defined(arch1) && !defined(arch2) */ |
325 | # define ALIGN1 __attribute__((aligned(1))) | 304 | # define ALIGN1 __attribute__((aligned(1))) |
326 | # define ALIGN2 __attribute__((aligned(2))) | 305 | # define ALIGN2 __attribute__((aligned(2))) |
@@ -332,8 +311,7 @@ typedef unsigned smalluint; | |||
332 | # define ALIGN4 | 311 | # define ALIGN4 |
333 | #endif | 312 | #endif |
334 | 313 | ||
335 | 314 | /* | |
336 | /* uclibc does not implement daemon() for no-mmu systems. | ||
337 | * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably. | 315 | * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably. |
338 | * For earlier versions there is no reliable way to check if we are building | 316 | * For earlier versions there is no reliable way to check if we are building |
339 | * for a mmu-less system. | 317 | * for a mmu-less system. |
@@ -351,12 +329,9 @@ typedef unsigned smalluint; | |||
351 | #endif | 329 | #endif |
352 | 330 | ||
353 | #if defined(__digital__) && defined(__unix__) | 331 | #if defined(__digital__) && defined(__unix__) |
354 | |||
355 | # include <standards.h> | 332 | # include <standards.h> |
356 | # include <inttypes.h> | 333 | # include <inttypes.h> |
357 | # define PRIu32 "u" | 334 | # define PRIu32 "u" |
358 | /* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */ | ||
359 | # define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me, __me); } while (0) | ||
360 | # if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET | 335 | # if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET |
361 | # define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET) | 336 | # define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET) |
362 | # endif | 337 | # endif |
@@ -369,17 +344,31 @@ typedef unsigned smalluint; | |||
369 | # if !defined ADJ_TICK && defined MOD_CLKB | 344 | # if !defined ADJ_TICK && defined MOD_CLKB |
370 | # define ADJ_TICK MOD_CLKB | 345 | # define ADJ_TICK MOD_CLKB |
371 | # endif | 346 | # endif |
347 | #endif | ||
372 | 348 | ||
373 | # undef HAVE_STPCPY | ||
374 | |||
375 | #else | ||
376 | |||
377 | # define bb_setpgrp() setpgrp() | ||
378 | 349 | ||
379 | #endif | 350 | /* ---- Who misses what? ------------------------------------ */ |
380 | 351 | ||
381 | #include <unistd.h> | 352 | /* Assume all these functions exist by default. Platforms where it is not |
382 | #define fdprintf dprintf | 353 | * true will #undef them below. |
354 | */ | ||
355 | #define HAVE_CLEARENV 1 | ||
356 | #define HAVE_FDATASYNC 1 | ||
357 | #define HAVE_DPRINTF 1 | ||
358 | #define HAVE_MEMRCHR 1 | ||
359 | #define HAVE_MKDTEMP 1 | ||
360 | #define HAVE_PTSNAME_R 1 | ||
361 | #define HAVE_SETBIT 1 | ||
362 | #define HAVE_SIGHANDLER_T 1 | ||
363 | #define HAVE_STPCPY 1 | ||
364 | #define HAVE_STRCASESTR 1 | ||
365 | #define HAVE_STRCHRNUL 1 | ||
366 | #define HAVE_STRSEP 1 | ||
367 | #define HAVE_STRSIGNAL 1 | ||
368 | #define HAVE_VASPRINTF 1 | ||
369 | #define HAVE_MNTENT_H 1 | ||
370 | #define HAVE_SYS_STATFS_H 1 | ||
371 | #define HAVE_XTABS 1 | ||
383 | 372 | ||
384 | #if defined(__dietlibc__) | 373 | #if defined(__dietlibc__) |
385 | # undef HAVE_STRCHRNUL | 374 | # undef HAVE_STRCHRNUL |
@@ -416,6 +405,23 @@ typedef unsigned smalluint; | |||
416 | # undef HAVE_STRCHRNUL | 405 | # undef HAVE_STRCHRNUL |
417 | #endif | 406 | #endif |
418 | 407 | ||
408 | #if (defined __digital__ && defined __unix__) \ | ||
409 | || defined __APPLE__ \ | ||
410 | || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ | ||
411 | # undef HAVE_CLEARENV | ||
412 | # undef HAVE_FDATASYNC | ||
413 | # undef HAVE_MNTENT_H | ||
414 | # undef HAVE_PTSNAME_R | ||
415 | # undef HAVE_SYS_STATFS_H | ||
416 | # undef HAVE_SIGHANDLER_T | ||
417 | # undef HAVE_XTABS | ||
418 | # undef HAVE_DPRINTF | ||
419 | #endif | ||
420 | |||
421 | #if defined(__digital__) && defined(__unix__) | ||
422 | # undef HAVE_STPCPY | ||
423 | #endif | ||
424 | |||
419 | /* | 425 | /* |
420 | * Now, define prototypes for all the functions defined in platform.c | 426 | * Now, define prototypes for all the functions defined in platform.c |
421 | * These must come after all the HAVE_* macros are defined (or not) | 427 | * These must come after all the HAVE_* macros are defined (or not) |