summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-07-06 21:29:05 +0000
committerjhb <jhb@FreeBSD.org>2006-07-06 21:29:05 +0000
commit6fe08fdbd364751465599ae63ca8f140a122cce0 (patch)
tree44321a65f965efadd798b885626b9552a9b02297
parentc025122efb4887b6cf1e73d8e13340215ee870fa (diff)
downloadFreeBSD-src-6fe08fdbd364751465599ae63ca8f140a122cce0.zip
FreeBSD-src-6fe08fdbd364751465599ae63ca8f140a122cce0.tar.gz
Use the regular poll(2) function to implement poll(2) for the IBCS2 compat
ABI as FreeBSD's poll(2) is ABI compatible. The ibcs2_poll() function attempted to implement poll(2) using a wrapper around select(2). Besides being somewhat ugly, it also had at least one bug in that instead of allocating complete fdset's on the stack via the stackgap it just allocated pointers to fdsets.
-rw-r--r--sys/i386/ibcs2/ibcs2_msg.c77
-rw-r--r--sys/i386/ibcs2/ibcs2_poll.h51
-rw-r--r--sys/i386/ibcs2/syscalls.master4
3 files changed, 2 insertions, 130 deletions
diff --git a/sys/i386/ibcs2/ibcs2_msg.c b/sys/i386/ibcs2/ibcs2_msg.c
index bbca3b8..0492bef 100644
--- a/sys/i386/ibcs2/ibcs2_msg.c
+++ b/sys/i386/ibcs2/ibcs2_msg.c
@@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$");
#include <i386/ibcs2/ibcs2_types.h>
#include <i386/ibcs2/ibcs2_signal.h>
#include <i386/ibcs2/ibcs2_util.h>
-#include <i386/ibcs2/ibcs2_poll.h>
#include <i386/ibcs2/ibcs2_proto.h>
@@ -57,79 +56,3 @@ ibcs2_putmsg(td, uap)
{
return 0; /* fake */
}
-
-
-int
-ibcs2_poll(td, uap)
- struct thread *td;
- struct ibcs2_poll_args *uap;
-{
- int error, i, nfds;
- fd_set *readfds, *writefds, *exceptfds;
- struct timeval timeout, *tp;
- struct ibcs2_poll conv;
- caddr_t sg = stackgap_init();
-
- if (uap->nfds > FD_SETSIZE)
- return EINVAL;
- readfds = stackgap_alloc(&sg, sizeof(fd_set *));
- writefds = stackgap_alloc(&sg, sizeof(fd_set *));
- exceptfds = stackgap_alloc(&sg, sizeof(fd_set *));
-
- FD_ZERO(readfds);
- FD_ZERO(writefds);
- FD_ZERO(exceptfds);
- if (uap->timeout == -1)
- tp = NULL;
- else {
- timeout.tv_usec = (uap->timeout % 1000)*1000;
- timeout.tv_sec = uap->timeout / 1000;
- tp = &timeout;
- }
-
- nfds = 0;
- for (i = 0; i < uap->nfds; i++) {
- if ((error = copyin(uap->fds + i*sizeof(struct ibcs2_poll),
- &conv, sizeof(conv))) != 0)
- return error;
- conv.revents = 0;
- if (conv.fd < 0 || conv.fd >= FD_SETSIZE)
- continue;
- if (conv.fd >= nfds)
- nfds = conv.fd + 1;
- if (conv.events & IBCS2_READPOLL)
- FD_SET(conv.fd, readfds);
- if (conv.events & IBCS2_WRITEPOLL)
- FD_SET(conv.fd, writefds);
- FD_SET(conv.fd, exceptfds);
- }
- error = kern_select(td, nfds, readfds, writefds, exceptfds, tp);
- if (error != 0)
- return error;
- if (td->td_retval[0] == 0)
- return 0;
- td->td_retval[0] = 0;
- for (td->td_retval[0] = 0, i = 0; i < uap->nfds; i++) {
- copyin(uap->fds + i*sizeof(struct ibcs2_poll),
- &conv, sizeof(conv));
- conv.revents = 0;
- if (conv.fd < 0 || conv.fd > FD_SETSIZE)
- /* should check for open as well */
- conv.revents |= IBCS2_POLLNVAL;
- else {
- if (FD_ISSET(conv.fd, readfds))
- conv.revents |= IBCS2_POLLIN;
- if (FD_ISSET(conv.fd, writefds))
- conv.revents |= IBCS2_POLLOUT;
- if (FD_ISSET(conv.fd, exceptfds))
- conv.revents |= IBCS2_POLLERR;
- if (conv.revents)
- ++td->td_retval[0];
- }
- if ((error = copyout(&conv,
- uap->fds + i*sizeof(struct ibcs2_poll),
- sizeof(conv))) != 0)
- return error;
- }
- return 0;
-}
diff --git a/sys/i386/ibcs2/ibcs2_poll.h b/sys/i386/ibcs2/ibcs2_poll.h
deleted file mode 100644
index fecec70..0000000
--- a/sys/i386/ibcs2/ibcs2_poll.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 1995 Steven Wallace
- * 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. 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.
- *
- * $FreeBSD$
- */
-
-
-#ifndef _IBCS2_POLL_H
-#define _IBCS2_POLL_H 1
-
-/* iBCS2 poll commands */
-#define IBCS2_POLLIN 0x0001
-#define IBCS2_POLLPRI 0x0002
-#define IBCS2_POLLOUT 0x0004
-#define IBCS2_POLLERR 0x0008
-#define IBCS2_POLLHUP 0x0010
-#define IBCS2_POLLNVAL 0x0020
-#define IBCS2_POLLRDNORM 0x0040
-#define IBCS2_POLLWRNORM 0x0004
-#define IBCS2_POLLRDBAND 0x0080
-#define IBCS2_POLLWRBAND 0x0100
-#define IBCS2_READPOLL (IBCS2_POLLIN|IBCS2_POLLRDNORM|IBCS2_POLLRDBAND)
-#define IBCS2_WRITEPOLL (IBCS2_POLLOUT|IBCS2_POLLWRNORM|IBCS2_POLLWRBAND)
-
-struct ibcs2_poll {
- int fd;
- short events;
- short revents;
-};
-
-#endif /* _IBCS2_POLL_H */
diff --git a/sys/i386/ibcs2/syscalls.master b/sys/i386/ibcs2/syscalls.master
index ac1e444..1a9b590 100644
--- a/sys/i386/ibcs2/syscalls.master
+++ b/sys/i386/ibcs2/syscalls.master
@@ -158,8 +158,8 @@
86 AUE_PUTMSG MSTD { int ibcs2_putmsg(int fd, \
struct ibcs2_stropts *ctl, \
struct ibcs2_stropts *dat, int flags); }
-87 AUE_POLL STD { int ibcs2_poll(struct ibcs2_poll *fds, \
- long nfds, int timeout); }
+87 AUE_POLL MNOPROTO { int poll(struct pollfd *fds, u_int nfds, \
+ int timeout); }
88 AUE_NULL UNIMPL nosys
89 AUE_NULL MSTD { int ibcs2_secure(int cmd, int a1, int a2, \
int a3, int a4, int a5); }
OpenPOWER on IntegriCloud