diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-08-02 20:20:34 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-08-02 20:20:34 +0000 |
commit | 051b97e82f11412622564140923b4465d6118a57 (patch) | |
tree | 625c67788333d6a9349ff61e6f1249f6af78776e /sys/compat/sunos | |
parent | 20b39632ff51269de73cc695aed5350d4fd1f0d9 (diff) |
Make emulations use our native poll(2)
Diffstat (limited to 'sys/compat/sunos')
-rw-r--r-- | sys/compat/sunos/sunos.h | 17 | ||||
-rw-r--r-- | sys/compat/sunos/sunos_misc.c | 133 | ||||
-rw-r--r-- | sys/compat/sunos/syscalls.master | 8 |
3 files changed, 8 insertions, 150 deletions
diff --git a/sys/compat/sunos/sunos.h b/sys/compat/sunos/sunos.h index 154bbda3297..c43aa2381b2 100644 --- a/sys/compat/sunos/sunos.h +++ b/sys/compat/sunos/sunos.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sunos.h,v 1.3 1996/05/10 12:50:22 deraadt Exp $ */ +/* $OpenBSD: sunos.h,v 1.4 1996/08/02 20:20:30 niklas Exp $ */ /* $NetBSD: sunos.h,v 1.8 1996/05/05 16:07:43 veego Exp $ */ #define SUNM_RDONLY 0x01 /* mount fs read-only */ @@ -110,21 +110,6 @@ struct sunos_termios { #define SUNOS_TCSNDBRK _IO('T', 12) #define SUNOS_TCDRAIN _IO('T', 13) -struct sunos_pollfd { - int fd; - short events; - short revents; -}; -#define SUNOS_POLLIN 0x0001 -#define SUNOS_POLLPRI 0x0002 -#define SUNOS_POLLOUT 0x0004 -#define SUNOS_POLLERR 0x0008 -#define SUNOS_POLLHUP 0x0010 -#define SUNOS_POLLNVAL 0x0020 -#define SUNOS_POLLRDNORM 0x0040 -#define SUNOS_POLLRDBAND 0x0080 -#define SUNOS_POLLWRBAND 0x0100 - /* Sun audio compatibility */ struct sunos_audio_prinfo { u_int sample_rate; diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c index adf49eb2542..f75c8b0caf8 100644 --- a/sys/compat/sunos/sunos_misc.c +++ b/sys/compat/sunos/sunos_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunos_misc.c,v 1.6 1996/05/02 13:07:19 deraadt Exp $ */ +/* $OpenBSD: sunos_misc.c,v 1.7 1996/08/02 20:20:31 niklas Exp $ */ /* $NetBSD: sunos_misc.c,v 1.65 1996/04/22 01:44:31 christos Exp $ */ /* @@ -101,8 +101,7 @@ #include <vm/vm.h> static int sunstatfs __P((struct statfs *, caddr_t)); -static void sunos_pollscan __P((struct proc *, struct sunos_pollfd *, - int, register_t *)); + int sunos_sys_wait4(p, v, retval) struct proc *p; @@ -1062,134 +1061,6 @@ sunos_sys_ptrace(p, v, retval) return sys_ptrace(p, &pa, retval); } -static void -sunos_pollscan(p, pl, nfd, retval) - struct proc *p; - struct sunos_pollfd *pl; - int nfd; - register_t *retval; -{ - register struct filedesc *fdp = p->p_fd; - register int msk, i; - struct file *fp; - int n = 0; - static int flag[3] = { FREAD, FWRITE, 0 }; - static int pflag[3] = { SUNOS_POLLIN|SUNOS_POLLRDNORM, - SUNOS_POLLOUT, SUNOS_POLLERR }; - - /* - * XXX: We need to implement the rest of the flags. - */ - for (i = 0; i < nfd; i++) { - fp = fdp->fd_ofiles[pl[i].fd]; - if (fp == NULL) { - if (pl[i].events & SUNOS_POLLNVAL) { - pl[i].revents |= SUNOS_POLLNVAL; - n++; - } - continue; - } - for (msk = 0; msk < 3; msk++) { - if (pl[i].events & pflag[msk]) { - if ((*fp->f_ops->fo_select)(fp, flag[msk], p)) { - pl[i].revents |= - pflag[msk] & pl[i].events; - n++; - } - } - } - } - *retval = n; -} - - -/* - * We are using the same mechanism as select only we encode/decode args - * differently. - */ -int -sunos_sys_poll(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct sunos_sys_poll_args *uap = v; - int i, s; - int error, error2; - size_t sz = sizeof(struct sunos_pollfd) * SCARG(uap, nfds); - struct sunos_pollfd *pl; - int msec = SCARG(uap, timeout); - struct timeval atv; - int timo; - int ncoll; - extern int nselcoll, selwait; - - pl = (struct sunos_pollfd *) malloc(sz, M_TEMP, M_WAITOK); - - if ((error = copyin(SCARG(uap, fds), pl, sz)) != 0) - goto bad; - - for (i = 0; i < SCARG(uap, nfds); i++) - pl[i].revents = 0; - - if (msec != -1) { - atv.tv_sec = msec / 1000; - atv.tv_usec = (msec - (atv.tv_sec * 1000)) * 1000; - - if (itimerfix(&atv)) { - error = EINVAL; - goto done; - } - s = splclock(); - timeradd(&atv, &time, &atv); - timo = hzto(&atv); - /* - * Avoid inadvertently sleeping forever. - */ - if (timo == 0) - timo = 1; - splx(s); - } else - timo = 0; - -retry: - ncoll = nselcoll; - p->p_flag |= P_SELECT; - sunos_pollscan(p, pl, SCARG(uap, nfds), retval); - if (*retval) - goto done; - s = splhigh(); - if (timo && timercmp(&time, &atv, >=)) { - splx(s); - goto done; - } - if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { - splx(s); - goto retry; - } - p->p_flag &= ~P_SELECT; - error = tsleep((caddr_t)&selwait, PSOCK | PCATCH, "sunos_poll", timo); - splx(s); - if (error == 0) - goto retry; - -done: - p->p_flag &= ~P_SELECT; - /* poll is not restarted after signals... */ - if (error == ERESTART) - error = EINTR; - if (error == EWOULDBLOCK) - error = 0; - - if ((error2 = copyout(pl, SCARG(uap, fds), sz)) != 0) - error = error2; - -bad: - free((char *) pl, M_TEMP); - - return (error); -} - /* * SunOS reboot system call (for compatibility). * Sun lets you pass in a boot string which the PROM diff --git a/sys/compat/sunos/syscalls.master b/sys/compat/sunos/syscalls.master index df55f67aea8..f402b5639c9 100644 --- a/sys/compat/sunos/syscalls.master +++ b/sys/compat/sunos/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.2 1996/04/18 21:21:48 niklas Exp $ + $OpenBSD: syscalls.master,v 1.3 1996/08/02 20:20:31 niklas Exp $ ; $NetBSD: syscalls.master,v 1.33 1996/02/28 16:05:43 pk Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -36,7 +36,9 @@ #include <sys/systm.h> #include <sys/signal.h> #include <sys/mount.h> +#include <sys/poll.h> #include <sys/syscallargs.h> + #include <compat/sunos/sunos.h> #include <compat/sunos/sunos_syscallargs.h> @@ -231,8 +233,8 @@ int *alen); } 151 UNIMPL getmsg 152 UNIMPL putmsg -153 STD { int sunos_sys_poll(struct sunos_pollfd *fds, \ - long nfds, int timeout); } +153 STD { int sys_poll(struct pollfd *fds, \ + unsigned long nfds, int timeout); } 154 UNIMPL #ifdef NFSSERVER 155 STD { int sunos_sys_nfssvc(int fd); } |