[PATCH] Simplify preprocessor conditions to enable building on musl-libc

From: sin <sin_AT_2f30.org>
Date: Mon, 3 Mar 2014 10:59:34 +0000

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.
---
 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
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)
-- 
1.7.10.4
--NzB8fVQJ5HfG6fxh--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Mon Mar 03 2014 - 13:24:06 CET