blob: 5aa4a0bf8969673cf3c26be0d8e93c3906d78852 [file] [log] [blame]
Rob Landley90163772007-01-18 21:54:08 -05001
2// Humor glibc to get dprintf, then #define it to something more portable.
3#define _GNU_SOURCE
4#include <stdio.h>
5#define fdprintf(...) dprintf(__VA_ARGS__)
6
Rob Landley055cfcb2007-01-14 20:20:06 -05007#include <endian.h>
8
9#if __BYTE_ORDER == __BIG_ENDIAN
10#define IS_BIG_ENDIAN 1
11#define IS_LITTLE_ENDIAN 0
12#define SWAP_BE16(x) (x)
13#define SWAP_BE32(x) (x)
14#define SWAP_BE64(x) (x)
15#define SWAP_LE16(x) bswap_16(x)
16#define SWAP_LE32(x) bswap_32(x)
17#define SWAP_LE64(x) bswap_64(x)
18#else
19#define IS_LITTLE_ENDIAN 1
20#define IS_BIG_ENDIAN 0
21#define SWAP_BE16(x) bswap_16(x)
22#define SWAP_BE32(x) bswap_32(x)
23#define SWAP_BE64(x) bswap_64(x)
24#define SWAP_LE16(x) (x)
25#define SWAP_LE32(x) (x)
26#define SWAP_LE64(x) (x)
27#endif