Rob Landley | 7051a96 | 2010-01-06 05:28:32 -0600 | [diff] [blame] | 1 | // The tendency of gcc to produce stupid warnings continues with |
Georgi Chorbadzhiyski | 522d906 | 2012-03-16 06:42:08 -0500 | [diff] [blame^] | 2 | // warn_unused_result, which warns about things like ignoring the return code |
Rob Landley | 7051a96 | 2010-01-06 05:28:32 -0600 | [diff] [blame] | 3 | // of nice(2) (which is completely useless since -1 is a legitimate return |
| 4 | // value on success and even the man page tells you to use errno instead). |
| 5 | |
| 6 | // This makes it stop. |
| 7 | |
| 8 | #undef _FORTIFY_SOURCE |
| 9 | |
Rob Landley | f05f660 | 2012-03-07 19:04:50 -0600 | [diff] [blame] | 10 | #define _FILE_OFFSET_BITS 64 |
| 11 | |
| 12 | #define _POSIX_C_SOURCE 200809L |
| 13 | #define _XOPEN_SOURCE 600 |
| 14 | #define _BSD_SOURCE |
| 15 | #define _SVID_SOURCE |
| 16 | |
Rob Landley | 9016377 | 2007-01-18 21:54:08 -0500 | [diff] [blame] | 17 | #include <stdio.h> |
| 18 | #define fdprintf(...) dprintf(__VA_ARGS__) |
| 19 | |
Rob Landley | efa93b9 | 2007-11-15 21:12:24 -0600 | [diff] [blame] | 20 | #ifdef __GNUC__ |
| 21 | #define noreturn __attribute__((noreturn)) |
| 22 | #else |
| 23 | #define noreturn |
| 24 | #endif |
Rob Landley | 2aa494d | 2007-02-13 16:41:51 -0500 | [diff] [blame] | 25 | |
| 26 | #ifndef __APPLE__ |
| 27 | #include <byteswap.h> |
Rob Landley | 055cfcb | 2007-01-14 20:20:06 -0500 | [diff] [blame] | 28 | #include <endian.h> |
| 29 | |
| 30 | #if __BYTE_ORDER == __BIG_ENDIAN |
| 31 | #define IS_BIG_ENDIAN 1 |
Rob Landley | 2aa494d | 2007-02-13 16:41:51 -0500 | [diff] [blame] | 32 | #else |
| 33 | #define IS_BIG_ENDIAN 0 |
| 34 | #endif |
| 35 | |
Georgi Chorbadzhiyski | 522d906 | 2012-03-16 06:42:08 -0500 | [diff] [blame^] | 36 | int clearenv(void); |
Rob Landley | 2aa494d | 2007-02-13 16:41:51 -0500 | [diff] [blame] | 37 | #else |
| 38 | |
| 39 | #ifdef __BIG_ENDIAN__ |
| 40 | #define IS_BIG_ENDIAN 1 |
| 41 | #else |
| 42 | #define IS_BIG_ENDIAN 0 |
| 43 | #endif |
| 44 | |
| 45 | #endif |
| 46 | |
| 47 | #if IS_BIG_ENDIAN |
Rob Landley | 055cfcb | 2007-01-14 20:20:06 -0500 | [diff] [blame] | 48 | #define IS_LITTLE_ENDIAN 0 |
| 49 | #define SWAP_BE16(x) (x) |
| 50 | #define SWAP_BE32(x) (x) |
| 51 | #define SWAP_BE64(x) (x) |
| 52 | #define SWAP_LE16(x) bswap_16(x) |
| 53 | #define SWAP_LE32(x) bswap_32(x) |
| 54 | #define SWAP_LE64(x) bswap_64(x) |
| 55 | #else |
| 56 | #define IS_LITTLE_ENDIAN 1 |
Rob Landley | 055cfcb | 2007-01-14 20:20:06 -0500 | [diff] [blame] | 57 | #define SWAP_BE16(x) bswap_16(x) |
| 58 | #define SWAP_BE32(x) bswap_32(x) |
| 59 | #define SWAP_BE64(x) bswap_64(x) |
| 60 | #define SWAP_LE16(x) (x) |
| 61 | #define SWAP_LE32(x) (x) |
| 62 | #define SWAP_LE64(x) (x) |
| 63 | #endif |
Rob Landley | fd1c5ba | 2007-02-03 14:10:00 -0500 | [diff] [blame] | 64 | |
| 65 | // Some versions of gcc produce spurious "may be uninitialized" warnings in |
| 66 | // cases where it provably can't happen. Unfortunately, although this warning |
| 67 | // is calculated and produced separately from the "is definitely used |
| 68 | // uninitialized" warnings, there's no way to turn off the broken spurious "may |
| 69 | // be" warnings without also turning off the non-broken "is" warnings. |
| 70 | |
| 71 | #if CFG_TOYBOX_DEBUG |
| 72 | #define GCC_BUG =0 |
| 73 | #else |
| 74 | #define GCC_BUG |
| 75 | #endif |
Georgi Chorbadzhiyski | 522d906 | 2012-03-16 06:42:08 -0500 | [diff] [blame^] | 76 | |
| 77 | #if defined(__APPLE__) || defined(__ANDROID__) |
| 78 | ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); |
| 79 | ssize_t getline(char **lineptr, size_t *n, FILE *stream); |
| 80 | #endif |