applied Paul's final uClibc patches, thanks - 9base - revived minimalist port o… | |
git clone git://git.suckless.org/9base | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 0ebf0433351f6e6fd61c5bfc25d5d4bd685f7b3a | |
parent 4644257fec39484e3dedb9dc9688105bc2605b98 | |
Author: [email protected] <unknown> | |
Date: Wed, 7 Mar 2012 21:29:55 +0100 | |
applied Paul's final uClibc patches, thanks | |
Diffstat: | |
M join/join.c | 2 +- | |
M lib9/dirread.c | 19 +++++++++++++++++++ | |
M lib9/libc.h | 7 +++++++ | |
3 files changed, 27 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/join/join.c b/join/join.c | |
@@ -1,7 +1,7 @@ | |
/* join F1 F2 on stuff */ | |
#include <u.h> | |
-#include <libc.h> | |
#include <stdio.h> | |
+#include <libc.h> | |
#include <ctype.h> | |
#define F1 0 | |
#define F2 1 | |
diff --git a/lib9/dirread.c b/lib9/dirread.c | |
@@ -3,10 +3,28 @@ | |
#include <libc.h> | |
#include <sys/stat.h> | |
#include <dirent.h> | |
+#if defined(__linux__) && (__UCLIBC__) | |
+# include <sys/syscall.h> | |
+#endif | |
extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*); | |
#if defined(__linux__) | |
+# if defined(__UCLIBC__) | |
+/* uClibc doesn't provide getdirentries(2), getdents(2) isn't wrapped | |
+ * by uClibc either. So we are using getdents(2) syscall directly. | |
+ */ | |
+# warning "uClibc based system are using getdents(2) syscall directly." | |
+static int | |
+mygetdents(int fd, struct dirent *buf, int n) | |
+{ | |
+# if defined(__USE_LARGEFILE64) | |
+ return syscall(SYS_getdents64, fd, (void*)buf, n); | |
+# else | |
+ return syscall(SYS_getdents, fd, (void*)buf, n); | |
+# endif | |
+} | |
+# else | |
static int | |
mygetdents(int fd, struct dirent *buf, int n) | |
{ | |
@@ -18,6 +36,7 @@ mygetdents(int fd, struct dirent *buf, int n) | |
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/libc.h b/lib9/libc.h | |
@@ -334,6 +334,13 @@ extern long p9tm2sec(Tm*); | |
extern vlong p9nsec(void); | |
#ifndef NOPLAN9DEFINES | |
+/* Clear some declarations to avoid conflicts in edge situation. | |
+ * uClibc based systems have this issue. | |
+ */ | |
+#undef gmtime | |
+#undef localtime | |
+#undef asctime | |
+#undef ctime | |
#define gmtime p9gmtime | |
#define localtime p9localtime | |
#define asctime p9asctime |