diff options
author | rsc <devnull@localhost> | 2005-05-01 18:40:01 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-05-01 18:40:01 +0000 |
commit | 52e6164443782187e17e22f7ccddd0d9a25006e4 (patch) | |
tree | 20706d2a7ded04fd76ec0207736d1051a1dd393e | |
parent | cea10000c59882b43525e4fd4fb17a55b7dba1c1 (diff) | |
download | plan9port-52e6164443782187e17e22f7ccddd0d9a25006e4.tar.gz plan9port-52e6164443782187e17e22f7ccddd0d9a25006e4.tar.bz2 plan9port-52e6164443782187e17e22f7ccddd0d9a25006e4.zip |
OpenBSD support.
-rwxr-xr-x | bin/9l | 2 | ||||
-rw-r--r-- | include/libc.h | 6 | ||||
-rw-r--r-- | include/u.h | 5 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/lib9/sendfd.c | 48 | ||||
-rw-r--r-- | src/mkcommon | 4 | ||||
-rw-r--r-- | src/mkhdr | 1 |
7 files changed, 35 insertions, 33 deletions
@@ -169,7 +169,7 @@ case "$tag" in *OpenBSD*) ld=gcc userpath=true - extralibs="$extralibs -lutil -lpthread" + extralibs="$extralibs -lutil" ;; *FreeBSD*) ld=gcc diff --git a/include/libc.h b/include/libc.h index ac8ffa9d..88382c15 100644 --- a/include/libc.h +++ b/include/libc.h @@ -638,7 +638,7 @@ extern void freenetconninfo(NetConnInfo*); #define DMWRITE 0x2 /* mode bit for write permission */ #define DMEXEC 0x1 /* mode bit for execute permission */ -#if defined(__FreeBSD__) +#ifdef RFMEM /* FreeBSD, OpenBSD */ #undef RFFDG #undef RFNOTEG #undef RFPROC @@ -832,6 +832,10 @@ extern int post9pservice(int, char*); # endif #endif +#ifdef __OpenBSD__ +#define sched_yield() syscall(302) /* what is this? */ +#endif + /* command line */ extern char *argv0; extern void __fixargv0(void); diff --git a/include/u.h b/include/u.h index 84cd78d0..ccadff00 100644 --- a/include/u.h +++ b/include/u.h @@ -81,7 +81,10 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; # undef _NEEDUSHORT # undef _NEEDUINT # undef _NEEDULONG -# undef PLAN9PORT_USING_PTHREADS +#elif defined(__OpenBSD__) +# undef _NEEDUSHORT +# undef _NEEDUINT +# undef _NEEDULONG #else /* No idea what system this is -- try some defaults */ # include <pthread.h> diff --git a/src/Makefile b/src/Makefile index 92cc6fa3..6a410501 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ ../bin/mk: mkmk.sh SYSNAME=`uname` export SYSNAME; \ - OBJTYPE=`uname -m | sed 's;i.86;386;; s;amd64;x86_64;; s;/.*;;; s; ;;g; s/PowerMacintosh/power/; s/ppc64/power/g; s/ppc/power/g'` export OBJTYPE; \ + OBJTYPE=`uname -m | sed 's;i.86;386;; s;amd64;x86_64;; s;/.*;;; s; ;;g; s/PowerMacintosh/power/; s/macppc/power/g; s/ppc64/power/g; s/ppc/power/g'` export OBJTYPE; \ PATH=`pwd`/../bin:$$PATH export PATH; \ PLAN9=`pwd`/.. export PLAN9; \ sh -x mkmk.sh diff --git a/src/lib9/sendfd.c b/src/lib9/sendfd.c index 4c4aa7f0..6f1154a5 100644 --- a/src/lib9/sendfd.c +++ b/src/lib9/sendfd.c @@ -6,21 +6,16 @@ #include <unistd.h> #include <errno.h> -typedef struct Sendfd Sendfd; -struct Sendfd { - struct cmsghdr cmsg; - int fd; -}; - int sendfd(int s, int fd) { char buf[1]; struct iovec iov; struct msghdr msg; + struct cmsghdr *cmsg; int n; - Sendfd sfd; - + char cms[CMSG_SPACE(sizeof(int))]; + buf[0] = 0; iov.iov_base = buf; iov.iov_len = 1; @@ -28,14 +23,14 @@ sendfd(int s, int fd) memset(&msg, 0, sizeof msg); msg.msg_iov = &iov; msg.msg_iovlen = 1; + msg.msg_control = (caddr_t)cms; + msg.msg_controllen = CMSG_LEN(sizeof(int)); - sfd.cmsg.cmsg_len = sizeof sfd; - sfd.cmsg.cmsg_level = SOL_SOCKET; - sfd.cmsg.cmsg_type = SCM_RIGHTS; - sfd.fd = fd; - - msg.msg_control = (caddr_t)&sfd; - msg.msg_controllen = sizeof sfd; + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(sizeof(int)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + *(int*)CMSG_DATA(cmsg) = fd; if((n=sendmsg(s, &msg, 0)) != iov.iov_len) return -1; @@ -46,10 +41,12 @@ int recvfd(int s) { int n; + int fd; char buf[1]; struct iovec iov; struct msghdr msg; - Sendfd sfd; + struct cmsghdr *cmsg; + char cms[CMSG_SPACE(sizeof(int))]; iov.iov_base = buf; iov.iov_len = 1; @@ -60,20 +57,13 @@ recvfd(int s) msg.msg_iov = &iov; msg.msg_iovlen = 1; - memset(&sfd, 0, sizeof sfd); - sfd.fd = -1; - sfd.cmsg.cmsg_len = sizeof sfd; - sfd.cmsg.cmsg_level = SOL_SOCKET; - sfd.cmsg.cmsg_type = SCM_RIGHTS; - - msg.msg_control = (caddr_t)&sfd; - msg.msg_controllen = sizeof sfd; + msg.msg_control = (caddr_t)cms; + msg.msg_controllen = sizeof cms; if((n=recvmsg(s, &msg, 0)) < 0) return -1; - if(n==0 && sfd.fd==-1){ - werrstr("eof in recvfd"); - return -1; - } - return sfd.fd; + + cmsg = CMSG_FIRSTHDR(&msg); + fd = *(int*)CMSG_DATA(cmsg); + return fd; } diff --git a/src/mkcommon b/src/mkcommon index e99a261f..1b1e1925 100644 --- a/src/mkcommon +++ b/src/mkcommon @@ -9,6 +9,10 @@ %.$O: %.s $AS $AFLAGS $stem.s +# OpenBSD needs this; sigh +%.$O: %.S + $CC $CFLAGS $stem.S + y.tab.h y.tab.c: $YFILES $YACC $YFLAGS $prereq @@ -5,6 +5,7 @@ OBJTYPE=`uname -m | sed ' s;/.*;;; s; ;;g; s;PowerMacintosh;power;g; + s;macppc;power;g; s;ppc64;power;g; s;ppc;power;g'` |