annotate lib/portability.h @ 100:c3d1d74d5d8f

MacOS X has a defective sed with no -r.
author Rob Landley <rob@landley.net>
date Tue, 13 Feb 2007 16:41:51 -0500
parents 884c03c29f21
children 5f1d3ad8a888
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
1 // Humor glibc to get dprintf, then #define it to something more portable.
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
2 #define _GNU_SOURCE
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
3 #include <stdio.h>
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
4 #define fdprintf(...) dprintf(__VA_ARGS__)
69efffcacd70 Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents: 53
diff changeset
5
100
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
6
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
7 #ifndef __APPLE__
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
8 #include <byteswap.h>
53
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 #include <endian.h>
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
10
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 #if __BYTE_ORDER == __BIG_ENDIAN
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 #define IS_BIG_ENDIAN 1
100
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
13 #else
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
14 #define IS_BIG_ENDIAN 0
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
15 #endif
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
16
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
17 #else
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
18
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
19 #ifdef __BIG_ENDIAN__
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
20 #define IS_BIG_ENDIAN 1
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
21 #else
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
22 #define IS_BIG_ENDIAN 0
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
23 #endif
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
24
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
25 #endif
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
26
c3d1d74d5d8f MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents: 94
diff changeset
27 #if IS_BIG_ENDIAN
53
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 #define IS_LITTLE_ENDIAN 0
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 #define SWAP_BE16(x) (x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 #define SWAP_BE32(x) (x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 #define SWAP_BE64(x) (x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 #define SWAP_LE16(x) bswap_16(x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 #define SWAP_LE32(x) bswap_32(x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 #define SWAP_LE64(x) bswap_64(x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 #else
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 #define IS_LITTLE_ENDIAN 1
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 #define SWAP_BE16(x) bswap_16(x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 #define SWAP_BE32(x) bswap_32(x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 #define SWAP_BE64(x) bswap_64(x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 #define SWAP_LE16(x) (x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 #define SWAP_LE32(x) (x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 #define SWAP_LE64(x) (x)
41d55b5d49fd Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 #endif
94
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
44
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
45 // Some versions of gcc produce spurious "may be uninitialized" warnings in
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
46 // cases where it provably can't happen. Unfortunately, although this warning
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
47 // is calculated and produced separately from the "is definitely used
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
48 // uninitialized" warnings, there's no way to turn off the broken spurious "may
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
49 // be" warnings without also turning off the non-broken "is" warnings.
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
50
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
51 #if CFG_TOYBOX_DEBUG
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
52 #define GCC_BUG =0
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
53 #else
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
54 #define GCC_BUG
884c03c29f21 Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents: 63
diff changeset
55 #endif