1 /* $NetBSD: netbsd32_select.c,v 1.17 2009/03/29 19:21:19 christos Exp $ */
4 * Copyright (c) 1998, 2001 Matthew R. Green
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: netbsd32_select.c,v 1.17 2009/03/29 19:21:19 christos Exp $");
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/malloc.h>
35 #include <sys/mount.h>
37 #include <sys/vnode.h>
39 #include <sys/filedesc.h>
41 #include <sys/select.h>
42 #include <sys/dirent.h>
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>
54 netbsd32___select50(struct lwp
*l
,
55 const struct netbsd32___select50_args
*uap
, register_t
*retval
)
59 syscallarg(netbsd32_fd_setp_t) in;
60 syscallarg(netbsd32_fd_setp_t) ou;
61 syscallarg(netbsd32_fd_setp_t) ex;
62 syscallarg(netbsd32_timevalp_t) tv;
65 struct netbsd32_timeval tv32
;
66 struct timespec ats
, *ts
= NULL
;
68 if (SCARG_P32(uap
, tv
)) {
69 error
= copyin(SCARG_P32(uap
, tv
), &tv32
, sizeof(tv32
));
72 ats
.tv_sec
= tv32
.tv_sec
;
73 ats
.tv_nsec
= tv32
.tv_usec
* 1000;
77 return selcommon(retval
, SCARG(uap
, nd
), SCARG_P32(uap
, in
),
78 SCARG_P32(uap
, ou
), SCARG_P32(uap
, ex
), ts
, NULL
);
82 netbsd32___pselect50(struct lwp
*l
,
83 const struct netbsd32___pselect50_args
*uap
, register_t
*retval
)
87 syscallarg(netbsd32_fd_setp_t) in;
88 syscallarg(netbsd32_fd_setp_t) ou;
89 syscallarg(netbsd32_fd_setp_t) ex;
90 syscallarg(const netbsd32_timespecp_t) ts;
91 syscallarg(const netbsd32_sigsetp_t) mask;
94 struct netbsd32_timespec ts32
;
95 struct timespec ats
, *ts
= NULL
;
96 sigset_t amask
, *mask
= NULL
;
98 if (SCARG_P32(uap
, ts
)) {
99 error
= copyin(SCARG_P32(uap
, ts
), &ts32
, sizeof(ts32
));
102 netbsd32_to_timespec(&ts32
, &ats
);
105 if (SCARG_P32(uap
, mask
)) {
106 error
= copyin(SCARG_P32(uap
, mask
), &amask
, sizeof(amask
));
112 return selcommon(retval
, SCARG(uap
, nd
), SCARG_P32(uap
, in
),
113 SCARG_P32(uap
, ou
), SCARG_P32(uap
, ex
), ts
, mask
);
117 netbsd32___pollts50(struct lwp
*l
, const struct netbsd32___pollts50_args
*uap
,
121 syscallarg(struct netbsd32_pollfdp_t) fds;
122 syscallarg(u_int) nfds;
123 syscallarg(const netbsd32_timespecp_t) ts;
124 syscallarg(const netbsd32_sigsetp_t) mask;
127 struct netbsd32_timespec ts32
;
128 struct timespec ats
, *ts
= NULL
;
129 sigset_t amask
, *mask
= NULL
;
131 if (SCARG_P32(uap
, ts
)) {
132 error
= copyin(SCARG_P32(uap
, ts
), &ts32
, sizeof(ts32
));
135 netbsd32_to_timespec(&ts32
, &ats
);
138 if (NETBSD32PTR64( SCARG(uap
, mask
))) {
139 error
= copyin(SCARG_P32(uap
, mask
), &amask
, sizeof(amask
));
145 return pollcommon(retval
, SCARG_P32(uap
, fds
),
146 SCARG(uap
, nfds
), ts
, mask
);