Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/include/platform.h
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/include/platform.h
r3085 r3232 8 8 #define BB_PLATFORM_H 1 9 9 10 /* Assume all these functions exist by default. Platforms where it is not11 * true will #undef them below.12 */13 #define HAVE_FDPRINTF 114 #define HAVE_MEMRCHR 115 #define HAVE_MKDTEMP 116 #define HAVE_SETBIT 117 #define HAVE_STRCASESTR 118 #define HAVE_STRCHRNUL 119 #define HAVE_STRSEP 120 #define HAVE_STRSIGNAL 121 #define HAVE_VASPRINTF 122 10 23 11 /* Convenience macros to test the version of gcc. */ … … 36 24 # endif 37 25 #endif 38 39 /* Define macros for some gcc attributes. This permits us to use the40 macros freely, and know that they will come into play for the41 version of gcc in which they are supported. */42 26 43 27 #if !__GNUC_PREREQ(2,7) … … 94 78 95 79 /* -fwhole-program makes all symbols local. The attribute externally_visible 96 80 * forces a symbol global. */ 97 81 #if __GNUC_PREREQ(4,1) 98 82 # define EXTERNALLY_VISIBLE __attribute__(( visibility("default") )) … … 110 94 111 95 /* We use __extension__ in some places to suppress -pedantic warnings 112 113 96 * about GCC extensions. This feature didn't work properly before 97 * gcc 2.8. */ 114 98 #if !__GNUC_PREREQ(2,8) 115 99 # ifndef __extension__ 116 100 # define __extension__ 117 # endif118 #endif119 120 /* gcc-2.95 had no va_copy but only __va_copy. */121 #if !__GNUC_PREREQ(3,0)122 # include <stdarg.h>123 # if !defined va_copy && defined __va_copy124 # define va_copy(d,s) __va_copy((d),(s))125 101 # endif 126 102 #endif … … 141 117 /* Make all declarations hidden (-fvisibility flag only affects definitions) */ 142 118 /* (don't include system headers after this until corresponding pop!) */ 143 #if __GNUC_PREREQ(4,1) 119 #if __GNUC_PREREQ(4,1) && !defined(__CYGWIN__) 144 120 # define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN _Pragma("GCC visibility push(hidden)") 145 121 # define POP_SAVED_FUNCTION_VISIBILITY _Pragma("GCC visibility pop") … … 148 124 # define POP_SAVED_FUNCTION_VISIBILITY 149 125 #endif 126 127 /* gcc-2.95 had no va_copy but only __va_copy. */ 128 #if !__GNUC_PREREQ(3,0) 129 # include <stdarg.h> 130 # if !defined va_copy && defined __va_copy 131 # define va_copy(d,s) __va_copy((d),(s)) 132 # endif 133 #endif 134 150 135 151 136 /* ---- Endian Detection ------------------------------------ */ … … 216 201 #endif 217 202 203 218 204 /* ---- Unaligned access ------------------------------------ */ 205 206 #include <stdint.h> 207 typedef int bb__aliased_int FIX_ALIASING; 208 typedef long bb__aliased_long FIX_ALIASING; 209 typedef uint16_t bb__aliased_uint16_t FIX_ALIASING; 210 typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; 219 211 220 212 /* NB: unaligned parameter should be a pointer, aligned one - … … 222 214 */ 223 215 #if defined(i386) || defined(__x86_64__) || defined(__powerpc__) 224 # include <stdint.h> 225 typedef int bb__aliased_int FIX_ALIASING; 226 typedef uint16_t bb__aliased_uint16_t FIX_ALIASING; 227 typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; 228 # define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp)) 216 # define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp)) 217 # define move_from_unaligned_long(v, longp) ((v) = *(bb__aliased_long*)(longp)) 229 218 # define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p)) 230 219 # define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p)) … … 235 224 /* performs reasonably well (gcc usually inlines memcpy here) */ 236 225 # define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int))) 226 # define move_from_unaligned_long(v, longp) (memcpy(&(v), (longp), sizeof(long))) 237 227 # define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2)) 238 228 # define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4)) 239 229 # define move_to_unaligned16(u16p, v) do { \ 240 230 uint16_t __t = (v); \ 241 memcpy((u16p), &__t, 4); \231 memcpy((u16p), &__t, 2); \ 242 232 } while (0) 243 233 # define move_to_unaligned32(u32p, v) do { \ … … 247 237 #endif 248 238 249 /* ---- Compiler dependent settings ------------------------- */ 250 251 #if (defined __digital__ && defined __unix__) \ 252 || defined __APPLE__ \ 253 || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ 254 # undef HAVE_MNTENT_H 255 # undef HAVE_SYS_STATFS_H 256 #else 257 # define HAVE_MNTENT_H 1 258 /* Patch bco to compile this busybox on rhel3 */ 259 #include <linux/version.h> 260 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 261 # define HAVE_SYS_STATFS_H 1 262 #endif 263 #endif 264 265 /*----- Kernel versioning ------------------------------------*/ 266 267 #ifndef KERNEL_VERSION 268 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 269 #endif 270 271 /* ---- Miscellaneous --------------------------------------- */ 272 273 #if defined __GLIBC__ || defined __UCLIBC__ \ 274 || defined __dietlibc__ || defined _NEWLIB_VERSION 275 # include <features.h> 276 #endif 277 278 /* Size-saving "small" ints (arch-dependent) */ 239 240 /* ---- Size-saving "small" ints (arch-dependent) ----------- */ 241 279 242 #if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__) 280 243 /* add other arches which benefit from this... */ … … 296 259 #endif 297 260 298 /* Try to defeat gcc's alignment of "char message[]"-like data */ 299 #if 1 /* if needed: !defined(arch1) && !defined(arch2) */ 261 262 /*----- Kernel versioning ------------------------------------*/ 263 264 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 265 266 267 /* ---- Miscellaneous --------------------------------------- */ 268 269 #if defined __GLIBC__ \ 270 || defined __UCLIBC__ \ 271 || defined __dietlibc__ \ 272 || defined __BIONIC__ \ 273 || defined _NEWLIB_VERSION 274 # include <features.h> 275 #endif 276 277 /* Define bb_setpgrp */ 278 #if defined(__digital__) && defined(__unix__) 279 /* use legacy setpgrp(pid_t, pid_t) for now. move to platform.c */ 280 # define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me, __me); } while (0) 281 #else 282 # define bb_setpgrp() setpgrp() 283 #endif 284 285 /* fdprintf is more readable, we used it before dprintf was standardized */ 286 #include <unistd.h> 287 #define fdprintf dprintf 288 289 /* Useful for defeating gcc's alignment of "char message[]"-like data */ 290 #if !defined(__s390__) 291 /* on s390[x], non-word-aligned data accesses require larger code */ 300 292 # define ALIGN1 __attribute__((aligned(1))) 301 293 # define ALIGN2 __attribute__((aligned(2))) … … 308 300 #endif 309 301 310 311 /* uclibc does not implement daemon() for no-mmu systems. 302 /* 312 303 * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably. 313 304 * For earlier versions there is no reliable way to check if we are building … … 326 317 #endif 327 318 328 /* Don't use lchown with glibc older than 2.1.x */329 #if defined(__GLIBC__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1330 # define lchown chown331 #endif332 333 319 #if defined(__digital__) && defined(__unix__) 334 335 320 # include <standards.h> 336 321 # include <inttypes.h> 337 322 # define PRIu32 "u" 338 /* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */339 # define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me, __me); } while (0)340 323 # if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET 341 324 # define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET) … … 350 333 # define ADJ_TICK MOD_CLKB 351 334 # endif 352 353 #else 354 355 # define bb_setpgrp() setpgrp() 356 357 #endif 358 359 #if defined(__GLIBC__) 360 # define fdprintf dprintf 335 #endif 336 337 #if defined(__CYGWIN__) 338 # define MAXSYMLINKS SYMLOOP_MAX 339 #endif 340 341 #if defined(ANDROID) || defined(__ANDROID__) 342 # define BB_ADDITIONAL_PATH ":/system/sbin:/system/bin:/system/xbin" 343 # define SYS_ioprio_set __NR_ioprio_set 344 # define SYS_ioprio_get __NR_ioprio_get 345 #endif 346 347 348 /* ---- Who misses what? ------------------------------------ */ 349 350 /* Assume all these functions and header files exist by default. 351 * Platforms where it is not true will #undef them below. 352 */ 353 #define HAVE_CLEARENV 1 354 #define HAVE_FDATASYNC 1 355 #define HAVE_DPRINTF 1 356 #define HAVE_MEMRCHR 1 357 #define HAVE_MKDTEMP 1 358 #define HAVE_PTSNAME_R 1 359 #define HAVE_SETBIT 1 360 #define HAVE_SIGHANDLER_T 1 361 #define HAVE_STPCPY 1 362 #define HAVE_STRCASESTR 1 363 #define HAVE_STRCHRNUL 1 364 #define HAVE_STRSEP 1 365 #define HAVE_STRSIGNAL 1 366 #define HAVE_STRVERSCMP 1 367 #define HAVE_VASPRINTF 1 368 #define HAVE_UNLOCKED_STDIO 1 369 #define HAVE_UNLOCKED_LINE_OPS 1 370 #define HAVE_GETLINE 1 371 #define HAVE_XTABS 1 372 #define HAVE_MNTENT_H 1 373 #define HAVE_NET_ETHERNET_H 1 374 #define HAVE_SYS_STATFS_H 1 375 376 #if defined(__UCLIBC_MAJOR__) 377 # if __UCLIBC_MAJOR__ == 0 \ 378 && ( __UCLIBC_MINOR__ < 9 \ 379 || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 32) \ 380 ) 381 # undef HAVE_STRVERSCMP 382 # endif 361 383 #endif 362 384 … … 366 388 367 389 #if defined(__WATCOMC__) 368 # undef HAVE_FDPRINTF 390 # undef HAVE_DPRINTF 391 # undef HAVE_GETLINE 369 392 # undef HAVE_MEMRCHR 370 393 # undef HAVE_MKDTEMP 371 394 # undef HAVE_SETBIT 395 # undef HAVE_STPCPY 372 396 # undef HAVE_STRCASESTR 373 397 # undef HAVE_STRCHRNUL 374 398 # undef HAVE_STRSEP 375 399 # undef HAVE_STRSIGNAL 400 # undef HAVE_STRVERSCMP 376 401 # undef HAVE_VASPRINTF 402 # undef HAVE_UNLOCKED_STDIO 403 # undef HAVE_UNLOCKED_LINE_OPS 404 # undef HAVE_NET_ETHERNET_H 405 #endif 406 407 #if defined(__CYGWIN__) 408 # undef HAVE_CLEARENV 409 # undef HAVE_FDPRINTF 410 # undef HAVE_MEMRCHR 411 # undef HAVE_PTSNAME_R 412 # undef HAVE_STRVERSCMP 413 # undef HAVE_UNLOCKED_LINE_OPS 414 #endif 415 416 /* These BSD-derived OSes share many similarities */ 417 #if (defined __digital__ && defined __unix__) \ 418 || defined __APPLE__ \ 419 || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ 420 # undef HAVE_CLEARENV 421 # undef HAVE_FDATASYNC 422 # undef HAVE_GETLINE 423 # undef HAVE_MNTENT_H 424 # undef HAVE_PTSNAME_R 425 # undef HAVE_SYS_STATFS_H 426 # undef HAVE_SIGHANDLER_T 427 # undef HAVE_STRVERSCMP 428 # undef HAVE_XTABS 429 # undef HAVE_DPRINTF 430 # undef HAVE_UNLOCKED_STDIO 431 # undef HAVE_UNLOCKED_LINE_OPS 377 432 #endif 378 433 379 434 #if defined(__FreeBSD__) 380 435 # undef HAVE_STRCHRNUL 436 #endif 437 438 #if defined(__NetBSD__) 439 # define HAVE_GETLINE 1 /* Recent NetBSD versions have getline() */ 440 #endif 441 442 #if defined(__digital__) && defined(__unix__) 443 # undef HAVE_STPCPY 444 #endif 445 446 #if defined(ANDROID) || defined(__ANDROID__) 447 # undef HAVE_DPRINTF 448 # undef HAVE_GETLINE 449 # undef HAVE_STPCPY 450 # undef HAVE_STRCHRNUL 451 # undef HAVE_STRVERSCMP 452 # undef HAVE_UNLOCKED_LINE_OPS 453 # undef HAVE_NET_ETHERNET_H 381 454 #endif 382 455 … … 386 459 */ 387 460 388 #ifndef HAVE_ FDPRINTF389 extern int fdprintf(int fd, const char *format, ...);461 #ifndef HAVE_DPRINTF 462 extern int dprintf(int fd, const char *format, ...); 390 463 #endif 391 464 … … 403 476 #endif 404 477 478 #ifndef HAVE_SIGHANDLER_T 479 typedef void (*sighandler_t)(int); 480 #endif 481 482 #ifndef HAVE_STPCPY 483 extern char *stpcpy(char *p, const char *to_add) FAST_FUNC; 484 #endif 485 405 486 #ifndef HAVE_STRCASESTR 406 487 extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; … … 424 505 #endif 425 506 426 #endif 507 #ifndef HAVE_GETLINE 508 # include <stdio.h> /* for FILE */ 509 # include <sys/types.h> /* size_t */ 510 extern ssize_t getline(char **lineptr, size_t *n, FILE *stream) FAST_FUNC; 511 #endif 512 513 #endif
Note:
See TracChangeset
for help on using the changeset viewer.