Mercurial > hg > toybox
annotate lib/portability.h @ 1776:7bf68329eb3b draft default tip
Repository switched to git at https://github.com/landley/toybox
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 09 Apr 2015 02:28:32 -0500 |
parents | 2f2c7ae058d7 |
children |
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. |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
2 |
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
|
3 // 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
|
4 // 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
|
5 // 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
|
6 |
1235
63db77909fc8
Group headers by standard (POSIX or LSB) or function (internationalization, networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
Rob Landley <rob@landley.net>
parents:
1186
diff
changeset
|
7 // For musl |
63db77909fc8
Group headers by standard (POSIX or LSB) or function (internationalization, networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
Rob Landley <rob@landley.net>
parents:
1186
diff
changeset
|
8 #define _ALL_SOURCE |
63db77909fc8
Group headers by standard (POSIX or LSB) or function (internationalization, networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
Rob Landley <rob@landley.net>
parents:
1186
diff
changeset
|
9 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
10 // Test for gcc (using compiler builtin #define) |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
11 |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
12 #ifdef __GNUC__ |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
13 #define noreturn __attribute__((noreturn)) |
1717
2f2c7ae058d7
Only switch on printf format warnings for error_exit() and friends when TOYBOX_DEBUG enabled.
Rob Landley <rob@landley.net>
parents:
1716
diff
changeset
|
14 #if CFG_TOYBOX_DEBUG |
1716
ef5d02d0d37f
let the compiler check format strings
Elliott Hughes <enh@google.com>
parents:
1673
diff
changeset
|
15 #define printf_format __attribute__((format(printf, 1, 2))) |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
16 #else |
1717
2f2c7ae058d7
Only switch on printf format warnings for error_exit() and friends when TOYBOX_DEBUG enabled.
Rob Landley <rob@landley.net>
parents:
1716
diff
changeset
|
17 #define printf_format |
2f2c7ae058d7
Only switch on printf format warnings for error_exit() and friends when TOYBOX_DEBUG enabled.
Rob Landley <rob@landley.net>
parents:
1716
diff
changeset
|
18 #endif |
2f2c7ae058d7
Only switch on printf format warnings for error_exit() and friends when TOYBOX_DEBUG enabled.
Rob Landley <rob@landley.net>
parents:
1716
diff
changeset
|
19 #else |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
20 #define noreturn |
1716
ef5d02d0d37f
let the compiler check format strings
Elliott Hughes <enh@google.com>
parents:
1673
diff
changeset
|
21 #define printf_format |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
22 #endif |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
23 |
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
|
24 // Always use long file support. |
533 | 25 #define _FILE_OFFSET_BITS 64 |
26 | |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
27 // This isn't in the spec, but it's how we determine what libc 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
|
28 |
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
|
29 #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
|
30 |
800
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
31 // Various constants old build environments might not have even if kernel does |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
32 |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
33 #ifndef AT_FDCWD |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
34 #define AT_FDCWD -100 |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
35 #endif |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
36 |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
37 #ifndef AT_SYMLINK_NOFOLLOW |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
38 #define AT_SYMLINK_NOFOLLOW 0x100 |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
39 #endif |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
40 |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
41 #ifndef AT_REMOVEDIR |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
42 #define AT_REMOVEDIR 0x200 |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
43 #endif |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
44 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
45 // We don't define GNU_dammit because we're not part of the gnu project, and |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
46 // don't want to get any FSF on us. Unfortunately glibc (gnu libc) |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
47 // won't give us Linux syscall wrappers without claiming to be part of the |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
48 // gnu project (because Stallman's "GNU owns Linux" revisionist history |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
49 // crusade includes the kernel, even though Linux was inspired by Minix). |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
50 |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
51 // We use most non-posix Linux syscalls directly through the syscall() wrapper, |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
52 // but even many posix-2008 functions aren't provided by glibc unless you |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
53 // claim it's in the name of Gnu. |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
54 |
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
|
55 #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
|
56 // "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
|
57 // 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
|
58 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
|
59 |
1395 | 60 // According to posix, #include header, get a function definition. But glibc... |
61 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/wcwidth.html | |
62 #include <wchar.h> | |
63 int wcwidth(wchar_t wc); | |
64 | |
550
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
65 // 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
|
66 #include <time.h> |
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
67 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
|
68 |
1632
aafd2f28245a
When you include the posix header libgen.h, glibc #defines basename to some random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
Rob Landley <rob@landley.net>
parents:
1600
diff
changeset
|
69 // They didn't like posix basename so they defined another function with the |
aafd2f28245a
When you include the posix header libgen.h, glibc #defines basename to some random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
Rob Landley <rob@landley.net>
parents:
1600
diff
changeset
|
70 // same name and if you include libgen.h it #defines basename to something |
aafd2f28245a
When you include the posix header libgen.h, glibc #defines basename to some random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
Rob Landley <rob@landley.net>
parents:
1600
diff
changeset
|
71 // else (where they implemented the real basename), and that define breaks |
aafd2f28245a
When you include the posix header libgen.h, glibc #defines basename to some random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
Rob Landley <rob@landley.net>
parents:
1600
diff
changeset
|
72 // the table entry for the basename command. They didn't make a new function |
aafd2f28245a
When you include the posix header libgen.h, glibc #defines basename to some random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
Rob Landley <rob@landley.net>
parents:
1600
diff
changeset
|
73 // with a different name for their new behavior because gnu. |
aafd2f28245a
When you include the posix header libgen.h, glibc #defines basename to some random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
Rob Landley <rob@landley.net>
parents:
1600
diff
changeset
|
74 // |
1665
5d003cc2fa16
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
Rob Landley <rob@landley.net>
parents:
1664
diff
changeset
|
75 // Solution: don't use their broken header, provide an inline to redirect the |
5d003cc2fa16
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
Rob Landley <rob@landley.net>
parents:
1664
diff
changeset
|
76 // correct name to the broken name. |
5d003cc2fa16
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
Rob Landley <rob@landley.net>
parents:
1664
diff
changeset
|
77 |
5d003cc2fa16
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
Rob Landley <rob@landley.net>
parents:
1664
diff
changeset
|
78 char *dirname(char *path); |
5d003cc2fa16
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
Rob Landley <rob@landley.net>
parents:
1664
diff
changeset
|
79 char *__xpg_basename (char *path); |
5d003cc2fa16
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
Rob Landley <rob@landley.net>
parents:
1664
diff
changeset
|
80 static inline char *basename(char *path) { return __xpg_basename(path); } |
1632
aafd2f28245a
When you include the posix header libgen.h, glibc #defines basename to some random other symbol name (because gnu) and this screws up nontrivial macro expansions of NEWTOY(basename), so work around it in portability.h.
Rob Landley <rob@landley.net>
parents:
1600
diff
changeset
|
81 |
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
|
82 // 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
|
83 #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
|
84 #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
|
85 #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
|
86 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); |
1494
ca340df928bc
Tweak portability.h for uClibc version in buildroot defconfig.
Rob Landley <rob@landley.net>
parents:
1459
diff
changeset
|
87 char *stpcpy(char *dest, const char *src); |
ca340df928bc
Tweak portability.h for uClibc version in buildroot defconfig.
Rob Landley <rob@landley.net>
parents:
1459
diff
changeset
|
88 pid_t getsid(pid_t pid); |
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
|
89 |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
90 // uClibc's last-ever release was in 2012, so of course it doesn't define |
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
91 // any flag newer than MS_MOVE, which was added in 2001 (linux 2.5.0.5), |
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
92 // eleven years earlier. |
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
93 |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
94 #include <sys/mount.h> |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
95 #ifndef MS_MOVE |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
96 #define MS_MOVE (1<<13) |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
97 #endif |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
98 #ifndef MS_REC |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
99 #define MS_REC (1<<14) |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
100 #endif |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
101 #ifndef MS_SILENT |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
102 #define MS_SILENT (1<<15) |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
103 #endif |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
104 #ifndef MS_UNBINDABLE |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
105 #define MS_UNBINDABLE (1<<17) |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
106 #endif |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
107 #ifndef MS_PRIVATE |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
108 #define MS_PRIVATE (1<<18) |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
109 #endif |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
110 #ifndef MS_SLAVE |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
111 #define MS_SLAVE (1<<19) |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
112 #endif |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
113 #ifndef MS_SHARED |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
114 #define MS_SHARED (1<<20) |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
115 #endif |
1459
240bd13db413
Work around uClibc brain-damage.
Rob Landley <rob@landley.net>
parents:
1433
diff
changeset
|
116 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
117 // When building under obsolete glibc (Ubuntu 8.04-ish), hold its hand a bit. |
800
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
118 #elif __GLIBC__ == 2 && __GLIBC_MINOR__ < 10 |
727
fb17cd078e63
Fix ancient glibc workaround to force fstatat64
Rob Landley <rob@landley.net>
parents:
713
diff
changeset
|
119 #define fstatat fstatat64 |
fb17cd078e63
Fix ancient glibc workaround to force fstatat64
Rob Landley <rob@landley.net>
parents:
713
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 #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
|
124 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
|
125 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
|
126 #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
|
127 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
|
128 #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
|
129 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
|
130 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
|
131 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
|
132 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
|
133 #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
|
134 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); |
800
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
135 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
136 // Straight from posix-2008, things old glibc had but didn't prototype |
800
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
137 |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
138 int faccessat(int fd, const char *path, int amode, int flag); |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
139 int linkat(int fd1, const char *path1, int fd2, const char *path2, int flag); |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
140 int mkdirat(int fd, const char *path, mode_t mode); |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
141 int symlinkat(const char *path1, int fd, const char *path2); |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
142 int mknodat(int fd, const char *path, mode_t mode, dev_t dev); |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
143 #include <sys/time.h> |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
144 int futimens(int fd, const struct timespec times[2]); |
4ffb735aea59
More support for old (~2008) build environments, move the #ifdef checks for symbols out of specific library version checks (shouldn't hurt anything), remove obsolete debug macro.
Rob Landley <rob@landley.net>
parents:
789
diff
changeset
|
145 int utimensat(int fd, const char *path, const struct timespec times[2], int flag); |
1148
d01ab969cc5d
Only define MNT_DETACH for old glibc, portability.h included _before_ sys/mount.h...
Rob Landley <rob@landley.net>
parents:
1146
diff
changeset
|
146 |
d01ab969cc5d
Only define MNT_DETACH for old glibc, portability.h included _before_ sys/mount.h...
Rob Landley <rob@landley.net>
parents:
1146
diff
changeset
|
147 #ifndef MNT_DETACH |
d01ab969cc5d
Only define MNT_DETACH for old glibc, portability.h included _before_ sys/mount.h...
Rob Landley <rob@landley.net>
parents:
1146
diff
changeset
|
148 #define MNT_DETACH 2 |
d01ab969cc5d
Only define MNT_DETACH for old glibc, portability.h included _before_ sys/mount.h...
Rob Landley <rob@landley.net>
parents:
1146
diff
changeset
|
149 #endif |
1665
5d003cc2fa16
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
Rob Landley <rob@landley.net>
parents:
1664
diff
changeset
|
150 #endif // Old glibc |
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
|
151 |
1665
5d003cc2fa16
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
Rob Landley <rob@landley.net>
parents:
1664
diff
changeset
|
152 #endif // glibc in general |
63
69efffcacd70
Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents:
53
diff
changeset
|
153 |
1664
692be264d4f0
fix non-glibc basename(3) usage
Elliott Hughes <enh@google.com>
parents:
1663
diff
changeset
|
154 #ifndef __GLIBC__ |
692be264d4f0
fix non-glibc basename(3) usage
Elliott Hughes <enh@google.com>
parents:
1663
diff
changeset
|
155 // POSIX basename. |
692be264d4f0
fix non-glibc basename(3) usage
Elliott Hughes <enh@google.com>
parents:
1663
diff
changeset
|
156 #include <libgen.h> |
692be264d4f0
fix non-glibc basename(3) usage
Elliott Hughes <enh@google.com>
parents:
1663
diff
changeset
|
157 #endif |
692be264d4f0
fix non-glibc basename(3) usage
Elliott Hughes <enh@google.com>
parents:
1663
diff
changeset
|
158 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
159 // Work out how to do endianness |
100
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
160 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
161 #ifndef __APPLE__ |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
162 #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
|
163 #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
|
164 |
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
165 #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
|
166 #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
|
167 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
168 #define IS_BIG_ENDIAN 0 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
169 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
170 |
549
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
171 int clearenv(void); |
100
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
172 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
173 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
174 #ifdef __BIG_ENDIAN__ |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
175 #define IS_BIG_ENDIAN 1 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
176 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
177 #define IS_BIG_ENDIAN 0 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
178 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
179 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
180 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
181 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
182 #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
|
183 #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
|
184 #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
|
185 #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
|
186 #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
|
187 #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
|
188 #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
|
189 #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
|
190 #else |
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
191 #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
|
192 #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
|
193 #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
|
194 #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
|
195 #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
|
196 #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
|
197 #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
|
198 #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
|
199 |
1567
73eb55d21cde
Patch from Elliott Hughes for Android/bionic build.
Rob Landley <rob@landley.net>
parents:
1565
diff
changeset
|
200 #if defined(__APPLE__) \ |
1275
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
201 || (defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 10) |
549
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
202 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
|
203 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
|
204 #endif |
813
52e69f6710ca
Compile time probe to fish O_NOFOLLOW out of linux headers when fcntl doesn't conform to posix-2008.
Rob Landley <rob@landley.net>
parents:
812
diff
changeset
|
205 |
1235
63db77909fc8
Group headers by standard (POSIX or LSB) or function (internationalization, networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
Rob Landley <rob@landley.net>
parents:
1186
diff
changeset
|
206 // Linux headers not listed by POSIX or LSB |
63db77909fc8
Group headers by standard (POSIX or LSB) or function (internationalization, networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
Rob Landley <rob@landley.net>
parents:
1186
diff
changeset
|
207 #include <sys/mount.h> |
63db77909fc8
Group headers by standard (POSIX or LSB) or function (internationalization, networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
Rob Landley <rob@landley.net>
parents:
1186
diff
changeset
|
208 #include <sys/swap.h> |
63db77909fc8
Group headers by standard (POSIX or LSB) or function (internationalization, networking). Move headers standards ignore (but which have been there >15 years) to lib/portability.h. Fold xregcomp into lib since it's posix.
Rob Landley <rob@landley.net>
parents:
1186
diff
changeset
|
209 |
1564
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1512
diff
changeset
|
210 // Android is missing some headers and functions |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1512
diff
changeset
|
211 // "generated/config.h" is included first |
1565
a3500bd8b322
Fixups for the android/bionic build probes patch.
Rob Landley <rob@landley.net>
parents:
1564
diff
changeset
|
212 #if CFG_TOYBOX_SHADOW |
1564
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1512
diff
changeset
|
213 #include <shadow.h> |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1512
diff
changeset
|
214 #endif |
1565
a3500bd8b322
Fixups for the android/bionic build probes patch.
Rob Landley <rob@landley.net>
parents:
1564
diff
changeset
|
215 #if CFG_TOYBOX_UTMPX |
1564
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1512
diff
changeset
|
216 #include <utmpx.h> |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1512
diff
changeset
|
217 #endif |
1662
c1715c752e89
AOSP master has <pty.h> and builds netcat/nc.
Elliott Hughes <enh@google.com>
parents:
1661
diff
changeset
|
218 |
1259
565980862743
Probes for O_NOFOLLOW that compile and run something aren't compatible with cross compiling, so just #define it to 0 if it's not in fcntl.h where posix-2008 says.
Rob Landley <rob@landley.net>
parents:
1235
diff
changeset
|
219 // Some systems don't define O_NOFOLLOW, and it varies by architecture, so... |
565980862743
Probes for O_NOFOLLOW that compile and run something aren't compatible with cross compiling, so just #define it to 0 if it's not in fcntl.h where posix-2008 says.
Rob Landley <rob@landley.net>
parents:
1235
diff
changeset
|
220 #include <fcntl.h> |
565980862743
Probes for O_NOFOLLOW that compile and run something aren't compatible with cross compiling, so just #define it to 0 if it's not in fcntl.h where posix-2008 says.
Rob Landley <rob@landley.net>
parents:
1235
diff
changeset
|
221 #ifndef O_NOFOLLOW |
565980862743
Probes for O_NOFOLLOW that compile and run something aren't compatible with cross compiling, so just #define it to 0 if it's not in fcntl.h where posix-2008 says.
Rob Landley <rob@landley.net>
parents:
1235
diff
changeset
|
222 #define O_NOFOLLOW 0 |
565980862743
Probes for O_NOFOLLOW that compile and run something aren't compatible with cross compiling, so just #define it to 0 if it's not in fcntl.h where posix-2008 says.
Rob Landley <rob@landley.net>
parents:
1235
diff
changeset
|
223 #endif |
1275
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
224 |
1433
00c20f410c46
Patches to commands for issues reported from static analysis tool.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
1395
diff
changeset
|
225 #ifndef O_CLOEXEC |
00c20f410c46
Patches to commands for issues reported from static analysis tool.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
1395
diff
changeset
|
226 #define O_CLOEXEC 02000000 |
00c20f410c46
Patches to commands for issues reported from static analysis tool.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
1395
diff
changeset
|
227 #endif |
00c20f410c46
Patches to commands for issues reported from static analysis tool.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
1395
diff
changeset
|
228 |
1275
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
229 #if defined(__SIZEOF_DOUBLE__) && defined(__SIZEOF_LONG__) \ |
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
230 && __SIZEOF_DOUBLE__ <= __SIZEOF_LONG__ |
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
231 typedef double FLOAT; |
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
232 #else |
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
233 typedef float FLOAT; |
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
234 #endif |
6f18a0845db3
Use compiler built-in macros to determine if argument parsing can use double or float for FLOAT arguments. (I.E. whether double fits in a long's memory.) Check in a way that the macros not being defined just gives us the shorter one.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
235 |
1600
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
236 #ifndef __uClinux__ |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
237 pid_t xfork(void); |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
238 #endif |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
239 |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
240 //#define strncpy(...) @@strncpyisbadmmkay@@ |
ce22ad7a26c1
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Rob Landley <rob@landley.net>
parents:
1571
diff
changeset
|
241 //#define strncat(...) @@strcatisbadmmkay@@ |
1660
b84024067049
This patch adds a TOYBOX_SELINUX configuration option to control both
Elliott Hughes <enh@google.com>
parents:
1632
diff
changeset
|
242 |
b84024067049
This patch adds a TOYBOX_SELINUX configuration option to control both
Elliott Hughes <enh@google.com>
parents:
1632
diff
changeset
|
243 #if CFG_TOYBOX_SELINUX |
b84024067049
This patch adds a TOYBOX_SELINUX configuration option to control both
Elliott Hughes <enh@google.com>
parents:
1632
diff
changeset
|
244 #include <selinux/selinux.h> |
1661
d4bc084916fd
id.c #ifdefectomy. (ifdefs belong in headers, not in C code.)
Rob Landley <rob@landley.net>
parents:
1660
diff
changeset
|
245 #else |
d4bc084916fd
id.c #ifdefectomy. (ifdefs belong in headers, not in C code.)
Rob Landley <rob@landley.net>
parents:
1660
diff
changeset
|
246 #define is_selinux_enabled() 0 |
d4bc084916fd
id.c #ifdefectomy. (ifdefs belong in headers, not in C code.)
Rob Landley <rob@landley.net>
parents:
1660
diff
changeset
|
247 int getcon(void* con); |
1660
b84024067049
This patch adds a TOYBOX_SELINUX configuration option to control both
Elliott Hughes <enh@google.com>
parents:
1632
diff
changeset
|
248 #endif |