changeset 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.
author Rob Landley <rob@landley.net>
date Mon, 04 Feb 2013 08:07:32 -0600
parents 6b8cc11d517c
children 9155a0813ffc
files lib/portability.h
diffstat 1 files changed, 32 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/lib/portability.h	Sun Feb 03 17:04:36 2013 -0600
+++ b/lib/portability.h	Mon Feb 04 08:07:32 2013 -0600
@@ -19,10 +19,28 @@
 
 #include <features.h>
 
+// Various constants old build environments might not have even if kernel does
+
 #ifndef O_DIRECTORY
 #define O_DIRECTORY 0200000
 #endif
 
+#ifndef O_NOFOLLOW
+#define O_NOFOLLOW  0400000
+#endif
+
+#ifndef AT_FDCWD
+#define AT_FDCWD -100
+#endif
+
+#ifndef AT_SYMLINK_NOFOLLOW
+#define AT_SYMLINK_NOFOLLOW 0x100
+#endif
+
+#ifndef AT_REMOVEDIR
+#define AT_REMOVEDIR 0x200
+#endif
+
 #if defined(__GLIBC__)
 // "Function prototypes shall be provided." but aren't.
 // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
@@ -38,15 +56,9 @@
 #include <unistd.h>
 #include <stdio.h>
 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
-#ifndef O_NOFOLLOW
-#define O_NOFOLLOW      00400000        /* don't follow links */
-#endif
 
 // When building under obsolete glibc, hold its hand a bit.
-#elif __GLIBC_MINOR__ < 10
-#define AT_FDCWD -100
-#define AT_SYMLINK_NOFOLLOW 0x100
-#define AT_REMOVEDIR 0x200
+#elif __GLIBC__ == 2 && __GLIBC_MINOR__ < 10
 #define fstatat fstatat64
 int fstatat64(int dirfd, const char *pathname, void *buf, int flags);
 int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);
@@ -63,10 +75,23 @@
 int unlinkat(int dirfd, const char *pathname, int flags);
 #include <stdio.h>
 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
+
+// Straight from posix-2008, things old glibc didn't define
+
+int faccessat(int fd, const char *path, int amode, int flag);
+int linkat(int fd1, const char *path1, int fd2, const char *path2, int flag);
+int mkdirat(int fd, const char *path, mode_t mode);
+int symlinkat(const char *path1, int fd, const char *path2);
+int mknodat(int fd, const char *path, mode_t mode, dev_t dev);
+#include <sys/time.h>
+int futimens(int fd, const struct timespec times[2]);
+int utimensat(int fd, const char *path, const struct timespec times[2], int flag);
 #endif
 
 #endif
 
+// Test for gcc
+
 #ifdef __GNUC__
 #define noreturn	__attribute__((noreturn))
 #else
@@ -112,18 +137,6 @@
 #define SWAP_LE64(x) (x)
 #endif
 
-// Some versions of gcc produce spurious "may be uninitialized" warnings in
-// cases where it provably can't happen.  Unfortunately, although this warning
-// is calculated and produced separately from the "is definitely used
-// uninitialized" warnings, there's no way to turn off the broken spurious "may
-// be" warnings without also turning off the non-broken "is" warnings.
-
-#if CFG_TOYBOX_DEBUG
-#define GCC_BUG =0
-#else
-#define GCC_BUG
-#endif
-
 #if defined(__APPLE__) || defined(__ANDROID__)
 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
 ssize_t getline(char **lineptr, size_t *n, FILE *stream);