Mercurial > hg > toybox
annotate lib/portability.h @ 727:fb17cd078e63
Fix ancient glibc workaround to force fstatat64
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 01 Dec 2012 17:59:38 -0600 |
parents | ff8a27d3ab8f |
children | 9a6b08e7fe94 |
rev | line source |
---|---|
691
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
1 // Workarounds for horrible build environment idiosyncrasies. |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
2 // Instead of polluting the code with strange #ifdefs to work around bugs |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
3 // in specific compiler, library, or OS versions, localize all that here |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
4 // and in portability.c |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
5 |
372
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
6 // The tendency of gcc to produce stupid warnings continues with |
549
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
7 // warn_unused_result, which warns about things like ignoring the return code |
372
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
8 // of nice(2) (which is completely useless since -1 is a legitimate return |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
9 // value on success and even the man page tells you to use errno instead). |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
10 |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
11 // This makes it stop. |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
12 |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
13 #undef _FORTIFY_SOURCE |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
14 |
691
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
15 // Always use long file support. |
533 | 16 #define _FILE_OFFSET_BITS 64 |
17 | |
600
58d2fd7484bd
More header fiddling: crypt.h is silly, SUSv4 requires crypt() to be prototyped in unistd.h. The fact glibc refuses to do so without a wacky #define is a glibc bug, treat it as such.
Rob Landley <rob@landley.net>
parents:
550
diff
changeset
|
18 // This isn't in the spec, but it's how we determine what we're using. |
550
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
19 |
600
58d2fd7484bd
More header fiddling: crypt.h is silly, SUSv4 requires crypt() to be prototyped in unistd.h. The fact glibc refuses to do so without a wacky #define is a glibc bug, treat it as such.
Rob Landley <rob@landley.net>
parents:
550
diff
changeset
|
20 #include <features.h> |
550
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
21 |
713
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
22 #ifndef O_DIRECTORY |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
23 #define O_DIRECTORY 0200000 |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
24 #endif |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
25 |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
26 #if defined(__GLIBC__) |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
27 // "Function prototypes shall be provided." but aren't. |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
28 // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
29 char *crypt(const char *key, const char *salt); |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
30 |
550
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
31 // An SUSv4 function that glibc refuses to #define without crazy #defines, |
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
32 // see http://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html |
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
33 #include <time.h> |
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
34 char *strptime(const char *buf, const char *format, struct tm *tm); |
713
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
35 |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
36 // uClibc pretends to be glibc and copied a lot of its bugs, but has a few more |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
37 #if defined(__UCLIBC__) |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
38 #include <unistd.h> |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
39 #include <stdio.h> |
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
40 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); |
691
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
41 |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
42 // When building under obsolete glibc, hold its hand a bit. |
713
ff8a27d3ab8f
The headers of uClibc and older glibc got unhappy with O_DIRECTORY and some other stuff. Fix it up in portability.h.
Rob Landley <rob@landley.net>
parents:
702
diff
changeset
|
43 #elif __GLIBC_MINOR__ < 10 |
691
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
44 #define AT_FDCWD -100 |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
45 #define AT_SYMLINK_NOFOLLOW 0x100 |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
46 #define AT_REMOVEDIR 0x200 |
727
fb17cd078e63
Fix ancient glibc workaround to force fstatat64
Rob Landley <rob@landley.net>
parents:
713
diff
changeset
|
47 #define fstatat fstatat64 |
fb17cd078e63
Fix ancient glibc workaround to force fstatat64
Rob Landley <rob@landley.net>
parents:
713
diff
changeset
|
48 int fstatat64(int dirfd, const char *pathname, void *buf, int flags); |
691
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
49 int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
50 char *stpcpy(char *dest, const char *src); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
51 #include <sys/stat.h> |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
52 int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
53 int openat(int dirfd, const char *pathname, int flags, ...); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
54 #include <dirent.h> |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
55 DIR *fdopendir(int fd); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
56 #include <unistd.h> |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
57 int fchownat(int dirfd, const char *pathname, |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
58 uid_t owner, gid_t group, int flags); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
59 int isblank(int c); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
60 int unlinkat(int dirfd, const char *pathname, int flags); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
61 #include <stdio.h> |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
62 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
63 #endif |
8871e8002812
Older versions of glibc predated posix-2008. They still provide most of what we need, but require a boot to the headers to get them to admit it. Note that uClibc lies and claims to be glibc so we have to specifically exclude it here.
Rob Landley <rob@landley.net>
parents:
600
diff
changeset
|
64 |
550
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
65 #endif |
63
69efffcacd70
Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents:
53
diff
changeset
|
66 |
166
5f1d3ad8a888
Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.
Rob Landley <rob@landley.net>
parents:
100
diff
changeset
|
67 #ifdef __GNUC__ |
5f1d3ad8a888
Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.
Rob Landley <rob@landley.net>
parents:
100
diff
changeset
|
68 #define noreturn __attribute__((noreturn)) |
5f1d3ad8a888
Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.
Rob Landley <rob@landley.net>
parents:
100
diff
changeset
|
69 #else |
5f1d3ad8a888
Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.
Rob Landley <rob@landley.net>
parents:
100
diff
changeset
|
70 #define noreturn |
5f1d3ad8a888
Add noreturn mark to [p]error_exit(), suggested by Charlie Shepherd.
Rob Landley <rob@landley.net>
parents:
100
diff
changeset
|
71 #endif |
100
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
72 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
73 #ifndef __APPLE__ |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
74 #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
|
75 #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
|
76 |
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
77 #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
|
78 #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
|
79 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
80 #define IS_BIG_ENDIAN 0 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
81 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
82 |
549
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
83 int clearenv(void); |
100
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
84 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
85 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
86 #ifdef __BIG_ENDIAN__ |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
87 #define IS_BIG_ENDIAN 1 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
88 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
89 #define IS_BIG_ENDIAN 0 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
90 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
91 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
92 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
93 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
94 #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
|
95 #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
|
96 #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
|
97 #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
|
98 #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
|
99 #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
|
100 #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
|
101 #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
|
102 #else |
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
103 #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
|
104 #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
|
105 #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
|
106 #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
|
107 #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
|
108 #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
|
109 #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
|
110 #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
|
111 |
884c03c29f21
Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents:
63
diff
changeset
|
112 // 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
|
113 // 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
|
114 // 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
|
115 // 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
|
116 // 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
|
117 |
884c03c29f21
Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents:
63
diff
changeset
|
118 #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
|
119 #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
|
120 #else |
884c03c29f21
Teach build to build only the toys/*.c selected in .config, and teach
Rob Landley <rob@landley.net>
parents:
63
diff
changeset
|
121 #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
|
122 #endif |
549
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
123 |
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
124 #if defined(__APPLE__) || defined(__ANDROID__) |
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
125 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); |
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
126 ssize_t getline(char **lineptr, size_t *n, FILE *stream); |
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
127 #endif |