9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

commit a71862d4fff6274e7b59e5d6381a05d8a1db579b
parent 45d1314a1bd1886c42c1bdaac4a0128f23f50e32
Author: sin <sin@2f30.org>
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:
lib9/_p9dir.c | 2+-
lib9/dirread.c | 22+---------------------
lib9/readcons.c | 3---
3 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/lib9/_p9dir.c b/lib9/_p9dir.c @@ -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 <linux/hdreg.h> #include <linux/fs.h> #include <sys/ioctl.h> diff --git a/lib9/dirread.c b/lib9/dirread.c @@ -4,7 +4,7 @@ #include <sys/stat.h> #include <dirent.h> -#if defined (__UCLIBC__) +#if defined (__linux__) # include <sys/syscall.h> # 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) diff --git a/lib9/readcons.c b/lib9/readcons.c @@ -2,9 +2,6 @@ #define NOPLAN9DEFINES #include <libc.h> #include <termios.h> -#ifndef __MUSL__ -# include <sys/termios.h> -#endif static int rawx(int fd, int echoing)