Mercurial > hg > toybox
annotate lib/portability.h @ 1146:3570984a1015 draft
Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 19 Dec 2013 15:02:18 -0600 |
parents | 52e69f6710ca |
children | d01ab969cc5d |
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 |
372
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
7 // 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
|
8 // 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
|
9 // 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
|
10 // 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
|
11 |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
12 // This makes it stop. |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
13 |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
14 #undef _FORTIFY_SOURCE |
9051cb744d0a
Shut up even MORE gcc/glibc spurious warnings.
Rob Landley <rob@landley.net>
parents:
166
diff
changeset
|
15 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
16 // 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
|
17 |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
18 #ifdef __GNUC__ |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
19 #define noreturn __attribute__((noreturn)) |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
20 #else |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
21 #define noreturn |
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 |
1146
3570984a1015
Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.
Rob Landley <rob@landley.net>
parents:
813
diff
changeset
|
45 #ifndef MNT_DETACH |
3570984a1015
Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.
Rob Landley <rob@landley.net>
parents:
813
diff
changeset
|
46 #define MNT_DETACH 2 |
3570984a1015
Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.
Rob Landley <rob@landley.net>
parents:
813
diff
changeset
|
47 #endif |
3570984a1015
Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.
Rob Landley <rob@landley.net>
parents:
813
diff
changeset
|
48 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
49 // 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
|
50 // 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
|
51 // 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
|
52 // 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
|
53 // 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
|
54 |
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
55 // 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
|
56 // 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
|
57 // 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
|
58 |
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
|
59 #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
|
60 // "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
|
61 // 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
|
62 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
|
63 |
550
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
64 // 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
|
65 #include <time.h> |
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
66 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
|
67 |
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 // 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
|
69 #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
|
70 #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
|
71 #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
|
72 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
|
73 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
74 // 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
|
75 #elif __GLIBC__ == 2 && __GLIBC_MINOR__ < 10 |
727
fb17cd078e63
Fix ancient glibc workaround to force fstatat64
Rob Landley <rob@landley.net>
parents:
713
diff
changeset
|
76 #define fstatat fstatat64 |
fb17cd078e63
Fix ancient glibc workaround to force fstatat64
Rob Landley <rob@landley.net>
parents:
713
diff
changeset
|
77 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
|
78 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
|
79 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
|
80 #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
|
81 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
|
82 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
|
83 #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
|
84 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
|
85 #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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 #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
|
91 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
|
92 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
93 // 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
|
94 |
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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 #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
|
101 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
|
102 int utimensat(int fd, const char *path, const struct timespec times[2], int flag); |
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
|
103 #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
|
104 |
550
b2194045c40e
Remove "feature test macros", replace non-portable fdprintf() with standard fprintf().
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
105 #endif |
63
69efffcacd70
Add fdprintf(). Remove reread() and rewrite() which handle -EINTR, which
Rob Landley <rob@landley.net>
parents:
53
diff
changeset
|
106 |
806
bbec26ccb40c
Comment updates and a policy statement about avoiding #define GNU_dammit
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
107 // 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
|
108 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
109 #ifndef __APPLE__ |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
110 #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
|
111 #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
|
112 |
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
113 #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
|
114 #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
|
115 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
116 #define IS_BIG_ENDIAN 0 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
117 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
118 |
549
1f5bd8c93093
Implement Apple and Android versions of getline(), getdelim(), and clearenv().
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
533
diff
changeset
|
119 int clearenv(void); |
100
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
120 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
121 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
122 #ifdef __BIG_ENDIAN__ |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
123 #define IS_BIG_ENDIAN 1 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
124 #else |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
125 #define IS_BIG_ENDIAN 0 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
126 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
127 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
128 #endif |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
129 |
c3d1d74d5d8f
MacOS X has a defective sed with no -r.
Rob Landley <rob@landley.net>
parents:
94
diff
changeset
|
130 #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
|
131 #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
|
132 #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
|
133 #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
|
134 #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
|
135 #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
|
136 #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
|
137 #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
|
138 #else |
41d55b5d49fd
Add start of mke2fs/gene2fs, and some other stuff I've been working on.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
139 #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
|
140 #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
|
141 #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
|
142 #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
|
143 #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
|
144 #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
|
145 #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
|
146 #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
|
147 |
1146
3570984a1015
Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.
Rob Landley <rob@landley.net>
parents:
813
diff
changeset
|
148 #if defined(__APPLE__) || defined(__ANDROID__) || (__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
|
149 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
|
150 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
|
151 #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
|
152 |
1146
3570984a1015
Regression test against Ancient Build Environment (Ubuntu 8.04), fixup bit-rot.
Rob Landley <rob@landley.net>
parents:
813
diff
changeset
|
153 // compile time probes for stuff libc didn't provide |
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
|
154 #include "generated/portability.h" |