ibcs2_msg.c (139799) | ibcs2_msg.c (141488) |
---|---|
1/*- 2 * Copyright (c) 1995 Steven Wallace 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1995 Steven Wallace 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25#include <sys/cdefs.h> |
26__FBSDID("$FreeBSD: head/sys/i386/ibcs2/ibcs2_msg.c 139799 2005-01-06 23:22:04Z imp $"); | 26__FBSDID("$FreeBSD: head/sys/i386/ibcs2/ibcs2_msg.c 141488 2005-02-07 22:02:18Z jhb $"); |
27 28/* 29 * IBCS2 message compatibility module. 30 * 31 */ 32 33#include <sys/param.h> 34#include <sys/systm.h> | 27 28/* 29 * IBCS2 message compatibility module. 30 * 31 */ 32 33#include <sys/param.h> 34#include <sys/systm.h> |
35#include <sys/syscallsubr.h> |
|
35#include <sys/sysproto.h> 36 37#include <i386/ibcs2/ibcs2_types.h> 38#include <i386/ibcs2/ibcs2_signal.h> 39#include <i386/ibcs2/ibcs2_util.h> 40#include <i386/ibcs2/ibcs2_poll.h> 41#include <i386/ibcs2/ibcs2_proto.h> 42 --- 15 unchanged lines hidden (view full) --- 58} 59 60 61int 62ibcs2_poll(td, uap) 63 struct thread *td; 64 struct ibcs2_poll_args *uap; 65{ | 36#include <sys/sysproto.h> 37 38#include <i386/ibcs2/ibcs2_types.h> 39#include <i386/ibcs2/ibcs2_signal.h> 40#include <i386/ibcs2/ibcs2_util.h> 41#include <i386/ibcs2/ibcs2_poll.h> 42#include <i386/ibcs2/ibcs2_proto.h> 43 --- 15 unchanged lines hidden (view full) --- 59} 60 61 62int 63ibcs2_poll(td, uap) 64 struct thread *td; 65 struct ibcs2_poll_args *uap; 66{ |
66 int error, i; | 67 int error, i, nfds; |
67 fd_set *readfds, *writefds, *exceptfds; | 68 fd_set *readfds, *writefds, *exceptfds; |
68 struct timeval *timeout; | 69 struct timeval timeout, *tp; |
69 struct ibcs2_poll conv; | 70 struct ibcs2_poll conv; |
70 struct select_args tmp_select; | |
71 caddr_t sg = stackgap_init(); 72 73 if (uap->nfds > FD_SETSIZE) 74 return EINVAL; 75 readfds = stackgap_alloc(&sg, sizeof(fd_set *)); 76 writefds = stackgap_alloc(&sg, sizeof(fd_set *)); 77 exceptfds = stackgap_alloc(&sg, sizeof(fd_set *)); | 71 caddr_t sg = stackgap_init(); 72 73 if (uap->nfds > FD_SETSIZE) 74 return EINVAL; 75 readfds = stackgap_alloc(&sg, sizeof(fd_set *)); 76 writefds = stackgap_alloc(&sg, sizeof(fd_set *)); 77 exceptfds = stackgap_alloc(&sg, sizeof(fd_set *)); |
78 timeout = stackgap_alloc(&sg, sizeof(struct timeval *)); | |
79 80 FD_ZERO(readfds); 81 FD_ZERO(writefds); 82 FD_ZERO(exceptfds); 83 if (uap->timeout == -1) | 78 79 FD_ZERO(readfds); 80 FD_ZERO(writefds); 81 FD_ZERO(exceptfds); 82 if (uap->timeout == -1) |
84 timeout = NULL; | 83 tp = NULL; |
85 else { | 84 else { |
86 timeout->tv_usec = (uap->timeout % 1000)*1000; 87 timeout->tv_sec = uap->timeout / 1000; | 85 timeout.tv_usec = (uap->timeout % 1000)*1000; 86 timeout.tv_sec = uap->timeout / 1000; 87 tp = &timeout; |
88 } 89 | 88 } 89 |
90 tmp_select.nd = 0; 91 tmp_select.in = readfds; 92 tmp_select.ou = writefds; 93 tmp_select.ex = exceptfds; 94 tmp_select.tv = timeout; 95 | 90 nfds = 0; |
96 for (i = 0; i < uap->nfds; i++) { 97 if ((error = copyin(uap->fds + i*sizeof(struct ibcs2_poll), 98 &conv, sizeof(conv))) != 0) 99 return error; 100 conv.revents = 0; 101 if (conv.fd < 0 || conv.fd > FD_SETSIZE) 102 continue; | 91 for (i = 0; i < uap->nfds; i++) { 92 if ((error = copyin(uap->fds + i*sizeof(struct ibcs2_poll), 93 &conv, sizeof(conv))) != 0) 94 return error; 95 conv.revents = 0; 96 if (conv.fd < 0 || conv.fd > FD_SETSIZE) 97 continue; |
103 if (conv.fd >= tmp_select.nd) 104 tmp_select.nd = conv.fd + 1; | 98 if (conv.fd >= nfds) 99 nfds = conv.fd + 1; |
105 if (conv.events & IBCS2_READPOLL) 106 FD_SET(conv.fd, readfds); 107 if (conv.events & IBCS2_WRITEPOLL) 108 FD_SET(conv.fd, writefds); 109 FD_SET(conv.fd, exceptfds); 110 } | 100 if (conv.events & IBCS2_READPOLL) 101 FD_SET(conv.fd, readfds); 102 if (conv.events & IBCS2_WRITEPOLL) 103 FD_SET(conv.fd, writefds); 104 FD_SET(conv.fd, exceptfds); 105 } |
111 if ((error = select(td, &tmp_select)) != 0) | 106 error = kern_select(td, nfds, readfds, writefds, exceptfds, tp); 107 if (error != 0) |
112 return error; 113 if (td->td_retval[0] == 0) 114 return 0; 115 td->td_retval[0] = 0; 116 for (td->td_retval[0] = 0, i = 0; i < uap->nfds; i++) { 117 copyin(uap->fds + i*sizeof(struct ibcs2_poll), 118 &conv, sizeof(conv)); 119 conv.revents = 0; --- 20 unchanged lines hidden --- | 108 return error; 109 if (td->td_retval[0] == 0) 110 return 0; 111 td->td_retval[0] = 0; 112 for (td->td_retval[0] = 0, i = 0; i < uap->nfds; i++) { 113 copyin(uap->fds + i*sizeof(struct ibcs2_poll), 114 &conv, sizeof(conv)); 115 conv.revents = 0; --- 20 unchanged lines hidden --- |