[821] | 1 | /* vi: set sw=4 ts=4: */
|
---|
| 2 | /*
|
---|
[2725] | 3 | * Copyright 2006, Bernhard Reutner-Fischer
|
---|
| 4 | *
|
---|
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
---|
| 6 | */
|
---|
| 7 | #ifndef BB_PLATFORM_H
|
---|
| 8 | #define BB_PLATFORM_H 1
|
---|
[821] | 9 |
|
---|
| 10 |
|
---|
| 11 | /* Convenience macros to test the version of gcc. */
|
---|
| 12 | #undef __GNUC_PREREQ
|
---|
| 13 | #if defined __GNUC__ && defined __GNUC_MINOR__
|
---|
| 14 | # define __GNUC_PREREQ(maj, min) \
|
---|
[1765] | 15 | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
---|
[821] | 16 | #else
|
---|
| 17 | # define __GNUC_PREREQ(maj, min) 0
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
| 20 | /* __restrict is known in EGCS 1.2 and above. */
|
---|
[2725] | 21 | #if !__GNUC_PREREQ(2,92)
|
---|
[821] | 22 | # ifndef __restrict
|
---|
[2725] | 23 | # define __restrict
|
---|
[821] | 24 | # endif
|
---|
| 25 | #endif
|
---|
| 26 |
|
---|
[2725] | 27 | #if !__GNUC_PREREQ(2,7)
|
---|
[821] | 28 | # ifndef __attribute__
|
---|
| 29 | # define __attribute__(x)
|
---|
| 30 | # endif
|
---|
| 31 | #endif
|
---|
| 32 |
|
---|
| 33 | #undef inline
|
---|
[1765] | 34 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
|
---|
[821] | 35 | /* it's a keyword */
|
---|
[2725] | 36 | #elif __GNUC_PREREQ(2,7)
|
---|
| 37 | # define inline __inline__
|
---|
[821] | 38 | #else
|
---|
[2725] | 39 | # define inline
|
---|
[821] | 40 | #endif
|
---|
| 41 |
|
---|
| 42 | #ifndef __const
|
---|
| 43 | # define __const const
|
---|
| 44 | #endif
|
---|
| 45 |
|
---|
[2725] | 46 | #define UNUSED_PARAM __attribute__ ((__unused__))
|
---|
| 47 | #define NORETURN __attribute__ ((__noreturn__))
|
---|
| 48 | /* "The malloc attribute is used to tell the compiler that a function
|
---|
| 49 | * may be treated as if any non-NULL pointer it returns cannot alias
|
---|
| 50 | * any other pointer valid when the function returns. This will often
|
---|
| 51 | * improve optimization. Standard functions with this property include
|
---|
| 52 | * malloc and calloc. realloc-like functions have this property as long
|
---|
| 53 | * as the old pointer is never referred to (including comparing it
|
---|
| 54 | * to the new pointer) after the function returns a non-NULL value."
|
---|
| 55 | */
|
---|
| 56 | #define RETURNS_MALLOC __attribute__ ((malloc))
|
---|
| 57 | #define PACKED __attribute__ ((__packed__))
|
---|
| 58 | #define ALIGNED(m) __attribute__ ((__aligned__(m)))
|
---|
| 59 |
|
---|
| 60 | /* __NO_INLINE__: some gcc's do not honor inlining! :( */
|
---|
| 61 | #if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__)
|
---|
| 62 | # define ALWAYS_INLINE __attribute__ ((always_inline)) inline
|
---|
| 63 | /* I've seen a toolchain where I needed __noinline__ instead of noinline */
|
---|
| 64 | # define NOINLINE __attribute__((__noinline__))
|
---|
| 65 | # if !ENABLE_WERROR
|
---|
| 66 | # define DEPRECATED __attribute__ ((__deprecated__))
|
---|
| 67 | # define UNUSED_PARAM_RESULT __attribute__ ((warn_unused_result))
|
---|
[821] | 68 | # else
|
---|
[2725] | 69 | # define DEPRECATED
|
---|
| 70 | # define UNUSED_PARAM_RESULT
|
---|
[821] | 71 | # endif
|
---|
[2725] | 72 | #else
|
---|
| 73 | # define ALWAYS_INLINE inline
|
---|
| 74 | # define NOINLINE
|
---|
| 75 | # define DEPRECATED
|
---|
| 76 | # define UNUSED_PARAM_RESULT
|
---|
| 77 | #endif
|
---|
[821] | 78 |
|
---|
| 79 | /* -fwhole-program makes all symbols local. The attribute externally_visible
|
---|
[3232] | 80 | * forces a symbol global. */
|
---|
[2725] | 81 | #if __GNUC_PREREQ(4,1)
|
---|
| 82 | # define EXTERNALLY_VISIBLE __attribute__(( visibility("default") ))
|
---|
| 83 | //__attribute__ ((__externally_visible__))
|
---|
| 84 | #else
|
---|
| 85 | # define EXTERNALLY_VISIBLE
|
---|
| 86 | #endif
|
---|
[821] | 87 |
|
---|
[2725] | 88 | /* At 4.4 gcc become much more anal about this, need to use "aliased" types */
|
---|
| 89 | #if __GNUC_PREREQ(4,4)
|
---|
| 90 | # define FIX_ALIASING __attribute__((__may_alias__))
|
---|
| 91 | #else
|
---|
| 92 | # define FIX_ALIASING
|
---|
| 93 | #endif
|
---|
| 94 |
|
---|
[821] | 95 | /* We use __extension__ in some places to suppress -pedantic warnings
|
---|
[3232] | 96 | * about GCC extensions. This feature didn't work properly before
|
---|
| 97 | * gcc 2.8. */
|
---|
[2725] | 98 | #if !__GNUC_PREREQ(2,8)
|
---|
[821] | 99 | # ifndef __extension__
|
---|
| 100 | # define __extension__
|
---|
| 101 | # endif
|
---|
| 102 | #endif
|
---|
| 103 |
|
---|
[2725] | 104 | /* FAST_FUNC is a qualifier which (possibly) makes function call faster
|
---|
| 105 | * and/or smaller by using modified ABI. It is usually only needed
|
---|
| 106 | * on non-static, busybox internal functions. Recent versions of gcc
|
---|
| 107 | * optimize statics automatically. FAST_FUNC on static is required
|
---|
| 108 | * only if you need to match a function pointer's type */
|
---|
| 109 | #if __GNUC_PREREQ(3,0) && defined(i386) /* || defined(__x86_64__)? */
|
---|
| 110 | /* stdcall makes callee to pop arguments from stack, not caller */
|
---|
| 111 | # define FAST_FUNC __attribute__((regparm(3),stdcall))
|
---|
| 112 | /* #elif ... - add your favorite arch today! */
|
---|
| 113 | #else
|
---|
| 114 | # define FAST_FUNC
|
---|
| 115 | #endif
|
---|
| 116 |
|
---|
| 117 | /* Make all declarations hidden (-fvisibility flag only affects definitions) */
|
---|
| 118 | /* (don't include system headers after this until corresponding pop!) */
|
---|
[3232] | 119 | #if __GNUC_PREREQ(4,1) && !defined(__CYGWIN__)
|
---|
[2725] | 120 | # define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN _Pragma("GCC visibility push(hidden)")
|
---|
| 121 | # define POP_SAVED_FUNCTION_VISIBILITY _Pragma("GCC visibility pop")
|
---|
| 122 | #else
|
---|
| 123 | # define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
|
---|
| 124 | # define POP_SAVED_FUNCTION_VISIBILITY
|
---|
| 125 | #endif
|
---|
| 126 |
|
---|
[3232] | 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 |
|
---|
| 135 |
|
---|
[821] | 136 | /* ---- Endian Detection ------------------------------------ */
|
---|
| 137 |
|
---|
[2725] | 138 | #include <limits.h>
|
---|
| 139 | #if defined(__digital__) && defined(__unix__)
|
---|
[821] | 140 | # include <sex.h>
|
---|
[2725] | 141 | #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
|
---|
| 142 | || defined(__APPLE__)
|
---|
| 143 | # include <sys/resource.h> /* rlimit */
|
---|
| 144 | # include <machine/endian.h>
|
---|
| 145 | # define bswap_64 __bswap64
|
---|
| 146 | # define bswap_32 __bswap32
|
---|
| 147 | # define bswap_16 __bswap16
|
---|
| 148 | #else
|
---|
[821] | 149 | # include <byteswap.h>
|
---|
| 150 | # include <endian.h>
|
---|
| 151 | #endif
|
---|
| 152 |
|
---|
[2725] | 153 | #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
|
---|
[821] | 154 | # define BB_BIG_ENDIAN 1
|
---|
| 155 | # define BB_LITTLE_ENDIAN 0
|
---|
[2725] | 156 | #elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN
|
---|
| 157 | # define BB_BIG_ENDIAN 0
|
---|
| 158 | # define BB_LITTLE_ENDIAN 1
|
---|
| 159 | #elif defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN
|
---|
[821] | 160 | # define BB_BIG_ENDIAN 1
|
---|
| 161 | # define BB_LITTLE_ENDIAN 0
|
---|
[2725] | 162 | #elif defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN
|
---|
[821] | 163 | # define BB_BIG_ENDIAN 0
|
---|
| 164 | # define BB_LITTLE_ENDIAN 1
|
---|
[2725] | 165 | #elif defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
|
---|
| 166 | # define BB_BIG_ENDIAN 1
|
---|
| 167 | # define BB_LITTLE_ENDIAN 0
|
---|
| 168 | #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
|
---|
| 169 | # define BB_BIG_ENDIAN 0
|
---|
| 170 | # define BB_LITTLE_ENDIAN 1
|
---|
| 171 | #elif defined(__386__)
|
---|
| 172 | # define BB_BIG_ENDIAN 0
|
---|
| 173 | # define BB_LITTLE_ENDIAN 1
|
---|
| 174 | #else
|
---|
| 175 | # error "Can't determine endianness"
|
---|
[821] | 176 | #endif
|
---|
| 177 |
|
---|
[2725] | 178 | #if ULONG_MAX > 0xffffffff
|
---|
| 179 | # define bb_bswap_64(x) bswap_64(x)
|
---|
| 180 | #endif
|
---|
| 181 |
|
---|
| 182 | /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */
|
---|
[821] | 183 | #if BB_BIG_ENDIAN
|
---|
[2725] | 184 | # define SWAP_BE16(x) (x)
|
---|
| 185 | # define SWAP_BE32(x) (x)
|
---|
| 186 | # define SWAP_BE64(x) (x)
|
---|
| 187 | # define SWAP_LE16(x) bswap_16(x)
|
---|
| 188 | # define SWAP_LE32(x) bswap_32(x)
|
---|
| 189 | # define SWAP_LE64(x) bb_bswap_64(x)
|
---|
| 190 | # define IF_BIG_ENDIAN(...) __VA_ARGS__
|
---|
| 191 | # define IF_LITTLE_ENDIAN(...)
|
---|
[821] | 192 | #else
|
---|
[2725] | 193 | # define SWAP_BE16(x) bswap_16(x)
|
---|
| 194 | # define SWAP_BE32(x) bswap_32(x)
|
---|
| 195 | # define SWAP_BE64(x) bb_bswap_64(x)
|
---|
| 196 | # define SWAP_LE16(x) (x)
|
---|
| 197 | # define SWAP_LE32(x) (x)
|
---|
| 198 | # define SWAP_LE64(x) (x)
|
---|
| 199 | # define IF_BIG_ENDIAN(...)
|
---|
| 200 | # define IF_LITTLE_ENDIAN(...) __VA_ARGS__
|
---|
[821] | 201 | #endif
|
---|
| 202 |
|
---|
[3232] | 203 |
|
---|
[2725] | 204 | /* ---- Unaligned access ------------------------------------ */
|
---|
| 205 |
|
---|
[3232] | 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;
|
---|
| 211 |
|
---|
[2725] | 212 | /* NB: unaligned parameter should be a pointer, aligned one -
|
---|
| 213 | * a lvalue. This makes it more likely to not swap them by mistake
|
---|
| 214 | */
|
---|
| 215 | #if defined(i386) || defined(__x86_64__) || defined(__powerpc__)
|
---|
[3232] | 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))
|
---|
[2725] | 218 | # define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p))
|
---|
| 219 | # define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p))
|
---|
| 220 | # define move_to_unaligned16(u16p, v) (*(bb__aliased_uint16_t*)(u16p) = (v))
|
---|
| 221 | # define move_to_unaligned32(u32p, v) (*(bb__aliased_uint32_t*)(u32p) = (v))
|
---|
| 222 | /* #elif ... - add your favorite arch today! */
|
---|
[821] | 223 | #else
|
---|
[2725] | 224 | /* performs reasonably well (gcc usually inlines memcpy here) */
|
---|
| 225 | # define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int)))
|
---|
[3232] | 226 | # define move_from_unaligned_long(v, longp) (memcpy(&(v), (longp), sizeof(long)))
|
---|
[2725] | 227 | # define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2))
|
---|
| 228 | # define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4))
|
---|
| 229 | # define move_to_unaligned16(u16p, v) do { \
|
---|
| 230 | uint16_t __t = (v); \
|
---|
[3232] | 231 | memcpy((u16p), &__t, 2); \
|
---|
[2725] | 232 | } while (0)
|
---|
| 233 | # define move_to_unaligned32(u32p, v) do { \
|
---|
| 234 | uint32_t __t = (v); \
|
---|
| 235 | memcpy((u32p), &__t, 4); \
|
---|
| 236 | } while (0)
|
---|
[821] | 237 | #endif
|
---|
| 238 |
|
---|
| 239 |
|
---|
[3232] | 240 | /* ---- Size-saving "small" ints (arch-dependent) ----------- */
|
---|
[1765] | 241 |
|
---|
| 242 | #if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__)
|
---|
| 243 | /* add other arches which benefit from this... */
|
---|
| 244 | typedef signed char smallint;
|
---|
| 245 | typedef unsigned char smalluint;
|
---|
| 246 | #else
|
---|
| 247 | /* for arches where byte accesses generate larger code: */
|
---|
| 248 | typedef int smallint;
|
---|
| 249 | typedef unsigned smalluint;
|
---|
| 250 | #endif
|
---|
| 251 |
|
---|
| 252 | /* ISO C Standard: 7.16 Boolean type and values <stdbool.h> */
|
---|
| 253 | #if (defined __digital__ && defined __unix__)
|
---|
| 254 | /* old system without (proper) C99 support */
|
---|
[2725] | 255 | # define bool smalluint
|
---|
[1765] | 256 | #else
|
---|
| 257 | /* modern system, so use it */
|
---|
[2725] | 258 | # include <stdbool.h>
|
---|
[1765] | 259 | #endif
|
---|
| 260 |
|
---|
[3232] | 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 */
|
---|
[2725] | 292 | # define ALIGN1 __attribute__((aligned(1)))
|
---|
| 293 | # define ALIGN2 __attribute__((aligned(2)))
|
---|
| 294 | # define ALIGN4 __attribute__((aligned(4)))
|
---|
[1765] | 295 | #else
|
---|
| 296 | /* Arches which MUST have 2 or 4 byte alignment for everything are here */
|
---|
[2725] | 297 | # define ALIGN1
|
---|
| 298 | # define ALIGN2
|
---|
| 299 | # define ALIGN4
|
---|
[1765] | 300 | #endif
|
---|
| 301 |
|
---|
[3232] | 302 | /*
|
---|
[821] | 303 | * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably.
|
---|
| 304 | * For earlier versions there is no reliable way to check if we are building
|
---|
[2725] | 305 | * for a mmu-less system.
|
---|
[821] | 306 | */
|
---|
[2725] | 307 | #if ENABLE_NOMMU || \
|
---|
| 308 | (defined __UCLIBC__ && __UCLIBC_MAJOR__ >= 0 && __UCLIBC_MINOR__ >= 9 && \
|
---|
| 309 | __UCLIBC_SUBLEVEL__ > 28 && !defined __ARCH_USE_MMU__)
|
---|
| 310 | # define BB_MMU 0
|
---|
| 311 | # define USE_FOR_NOMMU(...) __VA_ARGS__
|
---|
| 312 | # define USE_FOR_MMU(...)
|
---|
[1765] | 313 | #else
|
---|
[2725] | 314 | # define BB_MMU 1
|
---|
| 315 | # define USE_FOR_NOMMU(...)
|
---|
| 316 | # define USE_FOR_MMU(...) __VA_ARGS__
|
---|
[821] | 317 | #endif
|
---|
| 318 |
|
---|
[2725] | 319 | #if defined(__digital__) && defined(__unix__)
|
---|
| 320 | # include <standards.h>
|
---|
| 321 | # include <inttypes.h>
|
---|
| 322 | # define PRIu32 "u"
|
---|
| 323 | # if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET
|
---|
| 324 | # define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET)
|
---|
| 325 | # endif
|
---|
| 326 | # if !defined ADJ_FREQUENCY && defined MOD_FREQUENCY
|
---|
| 327 | # define ADJ_FREQUENCY MOD_FREQUENCY
|
---|
| 328 | # endif
|
---|
| 329 | # if !defined ADJ_TIMECONST && defined MOD_TIMECONST
|
---|
| 330 | # define ADJ_TIMECONST MOD_TIMECONST
|
---|
| 331 | # endif
|
---|
| 332 | # if !defined ADJ_TICK && defined MOD_CLKB
|
---|
| 333 | # define ADJ_TICK MOD_CLKB
|
---|
| 334 | # endif
|
---|
[3232] | 335 | #endif
|
---|
[1765] | 336 |
|
---|
[3232] | 337 | #if defined(__CYGWIN__)
|
---|
| 338 | # define MAXSYMLINKS SYMLOOP_MAX
|
---|
| 339 | #endif
|
---|
[821] | 340 |
|
---|
[3232] | 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
|
---|
[2725] | 345 | #endif
|
---|
[821] | 346 |
|
---|
[3232] | 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
|
---|
[821] | 383 | #endif
|
---|
[2725] | 384 |
|
---|
| 385 | #if defined(__dietlibc__)
|
---|
| 386 | # undef HAVE_STRCHRNUL
|
---|
[821] | 387 | #endif
|
---|
[2725] | 388 |
|
---|
| 389 | #if defined(__WATCOMC__)
|
---|
[3232] | 390 | # undef HAVE_DPRINTF
|
---|
| 391 | # undef HAVE_GETLINE
|
---|
[2725] | 392 | # undef HAVE_MEMRCHR
|
---|
| 393 | # undef HAVE_MKDTEMP
|
---|
| 394 | # undef HAVE_SETBIT
|
---|
[3232] | 395 | # undef HAVE_STPCPY
|
---|
[2725] | 396 | # undef HAVE_STRCASESTR
|
---|
| 397 | # undef HAVE_STRCHRNUL
|
---|
| 398 | # undef HAVE_STRSEP
|
---|
| 399 | # undef HAVE_STRSIGNAL
|
---|
[3232] | 400 | # undef HAVE_STRVERSCMP
|
---|
[2725] | 401 | # undef HAVE_VASPRINTF
|
---|
[3232] | 402 | # undef HAVE_UNLOCKED_STDIO
|
---|
| 403 | # undef HAVE_UNLOCKED_LINE_OPS
|
---|
| 404 | # undef HAVE_NET_ETHERNET_H
|
---|
[821] | 405 | #endif
|
---|
[2725] | 406 |
|
---|
[3232] | 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
|
---|
| 432 | #endif
|
---|
| 433 |
|
---|
[2725] | 434 | #if defined(__FreeBSD__)
|
---|
| 435 | # undef HAVE_STRCHRNUL
|
---|
[821] | 436 | #endif
|
---|
| 437 |
|
---|
[3232] | 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
|
---|
| 454 | #endif
|
---|
| 455 |
|
---|
[2725] | 456 | /*
|
---|
| 457 | * Now, define prototypes for all the functions defined in platform.c
|
---|
| 458 | * These must come after all the HAVE_* macros are defined (or not)
|
---|
| 459 | */
|
---|
| 460 |
|
---|
[3232] | 461 | #ifndef HAVE_DPRINTF
|
---|
| 462 | extern int dprintf(int fd, const char *format, ...);
|
---|
[821] | 463 | #endif
|
---|
| 464 |
|
---|
[2725] | 465 | #ifndef HAVE_MEMRCHR
|
---|
| 466 | extern void *memrchr(const void *s, int c, size_t n) FAST_FUNC;
|
---|
[1765] | 467 | #endif
|
---|
[2725] | 468 |
|
---|
| 469 | #ifndef HAVE_MKDTEMP
|
---|
| 470 | extern char *mkdtemp(char *template) FAST_FUNC;
|
---|
[1765] | 471 | #endif
|
---|
[2725] | 472 |
|
---|
| 473 | #ifndef HAVE_SETBIT
|
---|
| 474 | # define setbit(a, b) ((a)[(b) >> 3] |= 1 << ((b) & 7))
|
---|
| 475 | # define clrbit(a, b) ((a)[(b) >> 3] &= ~(1 << ((b) & 7)))
|
---|
[1765] | 476 | #endif
|
---|
[2725] | 477 |
|
---|
[3232] | 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 |
|
---|
[2725] | 486 | #ifndef HAVE_STRCASESTR
|
---|
| 487 | extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC;
|
---|
[1765] | 488 | #endif
|
---|
| 489 |
|
---|
[2725] | 490 | #ifndef HAVE_STRCHRNUL
|
---|
| 491 | extern char *strchrnul(const char *s, int c) FAST_FUNC;
|
---|
[1765] | 492 | #endif
|
---|
[2725] | 493 |
|
---|
| 494 | #ifndef HAVE_STRSEP
|
---|
| 495 | extern char *strsep(char **stringp, const char *delim) FAST_FUNC;
|
---|
[1765] | 496 | #endif
|
---|
[2725] | 497 |
|
---|
| 498 | #ifndef HAVE_STRSIGNAL
|
---|
| 499 | /* Not exactly the same: instead of "Stopped" it shows "STOP" etc */
|
---|
| 500 | # define strsignal(sig) get_signame(sig)
|
---|
[1765] | 501 | #endif
|
---|
[2725] | 502 |
|
---|
| 503 | #ifndef HAVE_VASPRINTF
|
---|
| 504 | extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC;
|
---|
[1765] | 505 | #endif
|
---|
| 506 |
|
---|
[3232] | 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;
|
---|
[821] | 511 | #endif
|
---|
[3232] | 512 |
|
---|
| 513 | #endif
|
---|