Various tweaks to make things run on Mac OS.
The main change is the use of pthread to implement ffork.
diff --git a/src/lib9/Makefile b/src/lib9/Makefile
index 5f8e5ae..ab69485 100644
--- a/src/lib9/Makefile
+++ b/src/lib9/Makefile
@@ -19,7 +19,7 @@
nrand.$O\
qlock.$O\
readn.$O\
- rendez.$O\
+ rendez-$(SYSNAME).$O\
strecpy.$O\
sysfatal.$O\
tas-$(OBJTYPE).$O\
@@ -31,7 +31,7 @@
werrstr.$O\
HFILES=\
- lib9.h\
+ $(9SRC)/include/lib9.h\
include $(9SRC)/Makesyslib
diff --git a/src/lib9/argv0.c b/src/lib9/argv0.c
index 2c846f4..4c61f44 100644
--- a/src/lib9/argv0.c
+++ b/src/lib9/argv0.c
@@ -2,3 +2,8 @@
char *argv0;
+/*
+ * Mac OS can't deal with files that only declare data.
+ * ARGBEGIN mentions this function so that this file gets pulled in.
+ */
+void __fixargv0(void) { }
diff --git a/src/lib9/await.c b/src/lib9/await.c
index 9df7faa..49160e7 100644
--- a/src/lib9/await.c
+++ b/src/lib9/await.c
@@ -1,5 +1,6 @@
#include <signal.h>
#include <sys/types.h>
+#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/time.h>
diff --git a/src/lib9/ffork-FreeBSD.c b/src/lib9/ffork-FreeBSD.c
index a7c82e6..3829bb2 100644
--- a/src/lib9/ffork-FreeBSD.c
+++ b/src/lib9/ffork-FreeBSD.c
@@ -31,3 +31,9 @@
lock((Lock*)&lk->access_lock);
}
+int
+getfforkid(void)
+{
+ return getpid();
+}
+
diff --git a/src/lib9/ffork-Linux.c b/src/lib9/ffork-Linux.c
index aad8004..3b5c8ee 100644
--- a/src/lib9/ffork-Linux.c
+++ b/src/lib9/ffork-Linux.c
@@ -37,3 +37,9 @@
return pid;
}
+int
+getfforkid(void)
+{
+ return getpid();
+}
+
diff --git a/src/lib9/lock.c b/src/lib9/lock.c
index 2da7362..5d6f2f3 100644
--- a/src/lib9/lock.c
+++ b/src/lib9/lock.c
@@ -8,12 +8,9 @@
{
int x;
-_ntas++;
+ _ntas++;
x = _tas(v);
- if(x == 0 || x == 0xCAFEBABE)
- return x;
- fprint(2, "%d: tas %p got %ux\n", getpid(), v, x);
- abort();
+ return x;
}
int
diff --git a/src/lib9/sysfatal.c b/src/lib9/sysfatal.c
index f9ab698..33a533b 100644
--- a/src/lib9/sysfatal.c
+++ b/src/lib9/sysfatal.c
@@ -14,6 +14,7 @@
vseprint(buf, buf+sizeof buf, fmt, arg);
va_end(arg);
+ __fixargv0();
fprint(2, "%s; %s\n", argv0 ? argv0 : "<prog>", buf);
exits("fatal");
}