netbsd32_select.c revision 1.6 1 /* $NetBSD: netbsd32_select.c,v 1.6 2005/07/09 21:58:09 cube Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2001 Matthew R. Green
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: netbsd32_select.c,v 1.6 2005/07/09 21:58:09 cube Exp $");
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/malloc.h>
37 #include <sys/mount.h>
38 #include <sys/time.h>
39 #include <sys/vnode.h>
40 #include <sys/file.h>
41 #include <sys/filedesc.h>
42 #include <sys/select.h>
43
44 #include <sys/proc.h>
45
46 #include <net/if.h>
47
48 #include <compat/netbsd32/netbsd32.h>
49 #include <compat/netbsd32/netbsd32_syscall.h>
50 #include <compat/netbsd32/netbsd32_syscallargs.h>
51 #include <compat/netbsd32/netbsd32_conv.h>
52
53 int
54 netbsd32_select(struct lwp *l, void *v, register_t *retval)
55 {
56 struct netbsd32_select_args /* {
57 syscallarg(int) nd;
58 syscallarg(netbsd32_fd_setp_t) in;
59 syscallarg(netbsd32_fd_setp_t) ou;
60 syscallarg(netbsd32_fd_setp_t) ex;
61 syscallarg(netbsd32_timevalp_t) tv;
62 } */ *uap = v;
63 int error;
64 struct netbsd32_timeval tv32;
65 struct timeval atv, *tv = NULL;
66
67 if (SCARG(uap, tv)) {
68 if ((error = copyin(NETBSD32PTR64(SCARG(uap, tv)),
69 (caddr_t)&tv32, sizeof(tv32))) != 0)
70 return error;
71 netbsd32_to_timeval(&tv32, &atv);
72 tv = &atv;
73 }
74
75 return selcommon(l, retval, SCARG(uap, nd), NETBSD32PTR64(SCARG(uap, in)),
76 NETBSD32PTR64(SCARG(uap, ou)), NETBSD32PTR64(SCARG(uap, ex)), tv,
77 NULL);
78 }
79