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 | |
parent | 20b39632ff51269de73cc695aed5350d4fd1f0d9 (diff) |
Make emulations use our native poll(2)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/compat/ibcs2/ibcs2_misc.c | 18 | ||||
-rw-r--r-- | sys/compat/ibcs2/syscalls.master | 9 | ||||
-rw-r--r-- | sys/compat/osf1/osf1_misc.c | 21 | ||||
-rw-r--r-- | sys/compat/osf1/syscalls.master | 8 | ||||
-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 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_fcntl.c | 137 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_poll.h | 50 | ||||
-rw-r--r-- | sys/compat/svr4/syscalls.master | 6 |
10 files changed, 47 insertions, 360 deletions
diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c index 0b7255b368c..f1b4185ba4a 100644 --- a/sys/compat/ibcs2/ibcs2_misc.c +++ b/sys/compat/ibcs2/ibcs2_misc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ibcs2_misc.c,v 1.6 1996/08/02 20:20:27 niklas Exp $ */ /* $NetBSD: ibcs2_misc.c,v 1.15 1996/05/03 17:05:25 christos Exp $ */ /* @@ -1196,23 +1197,6 @@ ibcs2_sys_sysfs(p, v, retval) } int -ibcs2_sys_poll(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ -#ifdef notyet - struct ibcs2_sys_poll_args /* { - syscallarg(struct ibcs2_pollfd *) fds; - syscallarg(long) nfds; - syscallarg(int) timeout; - } */ *uap = v; -#endif - - return EINVAL; /* XXX - TODO */ -} - -int xenix_sys_rdchk(p, v, retval) struct proc *p; void *v; diff --git a/sys/compat/ibcs2/syscalls.master b/sys/compat/ibcs2/syscalls.master index 455ef4affb2..80c384f9257 100644 --- a/sys/compat/ibcs2/syscalls.master +++ b/sys/compat/ibcs2/syscalls.master @@ -1,4 +1,5 @@ - $NetBSD: syscalls.master,v 1.8 1996/01/07 06:09:43 mycroft Exp $ + $OpenBSD: syscalls.master,v 1.4 1996/08/02 20:20:28 niklas Exp $ +; $NetBSD: syscalls.master,v 1.8 1996/01/07 06:09:43 mycroft Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -35,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/ibcs2/ibcs2_types.h> #include <compat/ibcs2/ibcs2_signal.h> #include <compat/ibcs2/ibcs2_syscallargs.h> @@ -157,8 +160,8 @@ 86 STD { int ibcs2_sys_putmsg(int fd, \ struct ibcs2_stropts *ctl, \ struct ibcs2_stropts *dat, int flags); } -87 STD { int ibcs2_sys_poll(struct ibcs2_pollfd *fds, \ - long nfds, int timeout); } +87 STD { int sys_poll(struct pollfd *fds, \ + unsigned long nfds, int timeout); } 88 UNIMPL 89 UNIMPL 90 STD { int ibcs2_sys_symlink(char *path, char *link); } diff --git a/sys/compat/osf1/osf1_misc.c b/sys/compat/osf1/osf1_misc.c index 19df0d2d95c..4a56c1165f6 100644 --- a/sys/compat/osf1/osf1_misc.c +++ b/sys/compat/osf1/osf1_misc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: osf1_misc.c,v 1.2 1996/08/02 20:20:29 niklas Exp $ */ /* $NetBSD: osf1_misc.c,v 1.7 1995/10/07 06:53:04 mycroft Exp $ */ /* @@ -545,6 +546,26 @@ osf1_sys_fcntl(p, v, retval) } int +osf1_sys_poll(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + register struct osf1_sys_poll_args /* { + syscallarg(struct pollfd *) fds; + syscallarg(unsigned int) nfds; + syscallarg(int) timeout; + } */ *uap = v; + struct sys_poll_args a; + + SCARG(&a, fds) = fds; + SCARG(&a, nfds) = nfds; + SCARG(&a, timeout) = timeout; + + return sys_poll(p, a, retval); +} + +int osf1_sys_socket(p, v, retval) struct proc *p; void *v; diff --git a/sys/compat/osf1/syscalls.master b/sys/compat/osf1/syscalls.master index b2598938356..32af409fa70 100644 --- a/sys/compat/osf1/syscalls.master +++ b/sys/compat/osf1/syscalls.master @@ -1,4 +1,5 @@ - $NetBSD: syscalls.master,v 1.2 1995/10/07 06:27:28 mycroft Exp $ + $OpenBSD: syscalls.master,v 1.2 1996/08/02 20:20:30 niklas Exp $ +; $NetBSD: syscalls.master,v 1.2 1995/10/07 06:27:28 mycroft Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -35,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/osf1/osf1_syscallargs.h> 0 NOARGS { int sys_nosys(void); } syscall @@ -145,7 +148,8 @@ 92 STD { int osf1_sys_fcntl(int fd, int cmd, void *arg); } 93 NOARGS { int sys_select(u_int nd, fd_set *in, fd_set *ou, \ fd_set *ex, struct timeval *tv); } -94 UNIMPL poll +94 STD { int osf1_sys_poll(struct pollfd *fds, \ + unsigned int nfds, int timeout); } 95 NOARGS { int sys_fsync(int fd); } 96 NOARGS { int sys_setpriority(int which, int who, int prio); } 97 STD { int osf1_sys_socket(int domain, int type, \ 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); } diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c index 11f7d5f46f5..7c97627786e 100644 --- a/sys/compat/svr4/svr4_fcntl.c +++ b/sys/compat/svr4/svr4_fcntl.c @@ -1,3 +1,4 @@ +/* $OpenBSD: svr4_fcntl.c,v 1.3 1996/08/02 20:20:32 niklas Exp $ */ /* $NetBSD: svr4_fcntl.c,v 1.14 1995/10/14 20:24:24 christos Exp $ */ /* @@ -38,7 +39,7 @@ #include <sys/kernel.h> #include <sys/mount.h> #include <sys/malloc.h> - +#include <sys/poll.h> #include <sys/syscallargs.h> #include <compat/svr4/svr4_types.h> @@ -46,15 +47,12 @@ #include <compat/svr4/svr4_syscallargs.h> #include <compat/svr4/svr4_util.h> #include <compat/svr4/svr4_fcntl.h> -#include <compat/svr4/svr4_poll.h> static u_long svr4_to_bsd_cmd __P((u_long)); static int svr4_to_bsd_flags __P((int)); static int bsd_to_svr4_flags __P((int)); static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *)); static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *)); -static void svr4_pollscan __P((struct proc *, struct svr4_pollfd *, int, - register_t *)); static u_long svr4_to_bsd_cmd(cmd) @@ -324,134 +322,3 @@ svr4_sys_fcntl(p, v, retval) return ENOSYS; } } - - -static void -svr4_pollscan(p, pl, nfd, retval) - struct proc *p; - struct svr4_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] = { SVR4_POLLIN|SVR4_POLLRDNORM, - SVR4_POLLOUT, SVR4_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 & SVR4_POLLNVAL) { - pl[i].revents |= SVR4_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 -svr4_sys_poll(p, v, retval) - register struct proc *p; - void *v; - register_t *retval; -{ - struct svr4_sys_poll_args *uap = v; - int i, s; - int error, error2; - size_t sz = sizeof(struct svr4_pollfd) * SCARG(uap, nfds); - struct svr4_pollfd *pl; - int msec = SCARG(uap, timeout); - struct timeval atv; - int timo; - int ncoll; - extern int nselcoll, selwait; - - pl = (struct svr4_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++) { - DPRINTF(("pollfd %d, %x\n", pl[i].fd, pl[i].events)); - 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; - svr4_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, "svr4_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); -} diff --git a/sys/compat/svr4/svr4_poll.h b/sys/compat/svr4/svr4_poll.h deleted file mode 100644 index c63e5f2e91f..00000000000 --- a/sys/compat/svr4/svr4_poll.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: svr4_poll.h,v 1.2 1994/11/18 02:53:55 christos Exp $ */ - -/* - * Copyright (c) 1994 Christos Zoulas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SVR4_POLL_H_ -#define _SVR4_POLL_H_ - -struct svr4_pollfd { - int fd; - short events; - short revents; -}; - -#define SVR4_POLLIN 0x0001 -#define SVR4_POLLPRI 0x0002 -#define SVR4_POLLOUT 0x0004 -#define SVR4_POLLERR 0x0008 -#define SVR4_POLLHUP 0x0010 -#define SVR4_POLLNVAL 0x0020 -#define SVR4_POLLRDNORM 0x0040 -#define SVR4_POLLRDBAND 0x0080 -#define SVR4_POLLWRBAND 0x0100 - - -#endif /* !_SVR4_POLL_H_ */ diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master index 30faf667e07..c43e9c8254b 100644 --- a/sys/compat/svr4/syscalls.master +++ b/sys/compat/svr4/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.6 1996/04/25 10:20:18 niklas Exp $ + $OpenBSD: syscalls.master,v 1.7 1996/08/02 20:20:33 niklas Exp $ ; $NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -157,8 +157,8 @@ struct svr4_strbuf *dat, int *flags); } 86 STD { int svr4_sys_putmsg(int fd, struct svr4_strbuf *ctl, \ struct svr4_strbuf *dat, int flags); } -87 STD { int svr4_sys_poll(struct svr4_pollfd *fds, \ - long nfds, int timeout); } +87 STD { int sys_poll(struct pollfd *fds, \ + unsigned long nfds, int timeout); } 88 STD { int svr4_sys_lstat(char *path, \ struct svr4_stat *ub); } 89 NOARGS { int sys_symlink(char *path, char *link); } |