From a995e477ffb4dd1184da87e9e46a9e57f3178c63 Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 1 Oct 2003 02:50:57 +0000 Subject: Various tweaks to make things run on Mac OS. The main change is the use of pthread to implement ffork. --- src/cmd/sam/unix.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/cmd') diff --git a/src/cmd/sam/unix.c b/src/cmd/sam/unix.c index cc15db44..205af4cd 100644 --- a/src/cmd/sam/unix.c +++ b/src/cmd/sam/unix.c @@ -270,3 +270,39 @@ int create(char *name, int omode, int perm) return fd; } + +/* SHOULD BE ELSEWHERE */ +#ifdef __APPLE__ +#include + +Lock plk; + +ulong +pread(int fd, void *buf, ulong n, ulong off) +{ + ulong rv; + + lock(&plk); + if (lseek(fd, off, 0) != off) + return -1; + rv = read(fd, buf, n); + unlock(&plk); + + return rv; +} + +ulong +pwrite(int fd, void *buf, ulong n, ulong off) +{ + ulong rv; + + lock(&plk); + if (lseek(fd, off, 0) != off) + return -1; + rv = write(fd, buf, n); + unlock(&plk); + + return rv; +} +#endif + -- cgit v1.2.3