blob: 832dd12333d75380efd3ed620b7b0db69c455fcc [file] [log] [blame]
Rob Landley7051a962010-01-06 05:28:32 -06001// The tendency of gcc to produce stupid warnings continues with
Georgi Chorbadzhiyski522d9062012-03-16 06:42:08 -05002// warn_unused_result, which warns about things like ignoring the return code
Rob Landley7051a962010-01-06 05:28:32 -06003// 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 Landleyf05f6602012-03-07 19:04:50 -060010#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 Landley90163772007-01-18 21:54:08 -050017#include <stdio.h>
18#define fdprintf(...) dprintf(__VA_ARGS__)
19
Rob Landleyefa93b92007-11-15 21:12:24 -060020#ifdef __GNUC__
21#define noreturn __attribute__((noreturn))
22#else
23#define noreturn
24#endif
Rob Landley2aa494d2007-02-13 16:41:51 -050025
26#ifndef __APPLE__
27#include <byteswap.h>
Rob Landley055cfcb2007-01-14 20:20:06 -050028#include <endian.h>
29
30#if __BYTE_ORDER == __BIG_ENDIAN
31#define IS_BIG_ENDIAN 1
Rob Landley2aa494d2007-02-13 16:41:51 -050032#else
33#define IS_BIG_ENDIAN 0
34#endif
35
Georgi Chorbadzhiyski522d9062012-03-16 06:42:08 -050036int clearenv(void);
Rob Landley2aa494d2007-02-13 16:41:51 -050037#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 Landley055cfcb2007-01-14 20:20:06 -050048#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 Landley055cfcb2007-01-14 20:20:06 -050057#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 Landleyfd1c5ba2007-02-03 14:10:00 -050064
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 Chorbadzhiyski522d9062012-03-16 06:42:08 -050076
77#if defined(__APPLE__) || defined(__ANDROID__)
78ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
79ssize_t getline(char **lineptr, size_t *n, FILE *stream);
80#endif