[hackers] [9base] Simplify preprocessor conditions to enable building on musl-libc || sin

From: <git_AT_suckless.org>
Date: Fri, 07 Mar 2014 16:04:06 +0100

commit a71862d4fff6274e7b59e5d6381a05d8a1db579b
Author: sin <sin_AT_2f30.org>
Date: Mon Mar 3 10:59:34 2014 +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.

diff --git a/lib9/_p9dir.c b/lib9/_p9dir.c
index 706130c..b49cd4d 100644
--- a/lib9/_p9dir.c
+++ b/lib9/_p9dir.c
_AT_@ -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
index aad4c36..99d5597 100644
--- a/lib9/dirread.c
+++ b/lib9/dirread.c
_AT_@ -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
_AT_@ -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
index fb7b0f3..0c54a4b 100644
--- a/lib9/readcons.c
+++ b/lib9/readcons.c
_AT_@ -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)
Received on Fri Mar 07 2014 - 16:04:06 CET

This archive was generated by hypermail 2.3.0 : Fri Mar 07 2014 - 16:12:13 CET