| Date: Mon, 3 Mar 2014 10:59:34 +0000
Simplify preprocessor conditions to enable building on musl-libc
musl-libc does not export __MUSL__ so we cannot use that. I've
chosen to go with the common solution here that works on uClibc,
glibc and musl-libc by just using syscall(2) and getdents(2).
To build 9base, you will need the appropriate kernel headers in
place.
Diffstat:
M lib9/_p9dir.c | 2 +-
M lib9/dirread.c | 22 +---------------------
M lib9/readcons.c | 3 ---
3 files changed, 2 insertions(+), 25 deletions(-)
--- |
| @@ -61,7 +61,7 @@ disksize(int fd, struct stat *st)
return (vlong)lab.d_partitions[n].p_size * lab.d_secsize;
}
-#elif defined(__linux__) && !defined(__MUSL__)
+#elif defined(__linux__)
#include
#include
#include |
| @@ -4,7 +4,7 @@
#include
#include
-#if defined (__UCLIBC__)
+#if defined (__linux__)
# include
# if defined (__USE_LARGEFILE64)
# define getdents SYS_getdents64
@@ -16,30 +16,10 @@
extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*);
#if defined(__linux__)
-# if defined (__UCLIBC__)
static int
mygetdents(int fd, struct dirent *buf, int n) {
return syscall (getdents, fd, (void*) buf, n);
}
-# elif defined(__MUSL__)
-static int
-mygetdents(int fd, struct dirent *buf, int n)
-{
- return getdents(fd, (void*)buf, n);
-}
-# else
-static int
-mygetdents(int fd, struct dirent *buf, int n)
-{
- off_t off;
- int nn;
-
- /* This doesn't match the man page, but it works in Debian with a 2.2 kernel */
- off = p9seek(fd, 0, 1);
- nn = getdirentries(fd, (void*)buf, n, &off);
- return nn;
-}
-# endif
#elif defined(__APPLE__) || defined(__FreeBSD__)
static int
mygetdents(int fd, struct dirent *buf, int n) |