Implement pselect(2) and pollts(2).

This commit is contained in:
cube 2005-07-09 22:40:13 +00:00
parent 0056ee71b1
commit 57017881b4
2 changed files with 88 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_select.c,v 1.6 2005/07/09 21:58:09 cube Exp $ */
/* $NetBSD: netbsd32_select.c,v 1.7 2005/07/09 22:40:13 cube Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_select.c,v 1.6 2005/07/09 21:58:09 cube Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_select.c,v 1.7 2005/07/09 22:40:13 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_select.c,v 1.6 2005/07/09 21:58:09 cube Exp
#include <sys/vnode.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/poll.h>
#include <sys/select.h>
#include <sys/proc.h>
@ -76,3 +77,82 @@ netbsd32_select(struct lwp *l, void *v, register_t *retval)
NETBSD32PTR64(SCARG(uap, ou)), NETBSD32PTR64(SCARG(uap, ex)), tv,
NULL);
}
int
netbsd32_pselect(l, v, retval)
struct lwp *l;
void *v;
register_t *retval;
{
struct netbsd32_pselect_args /* {
syscallarg(int) nd;
syscallarg(netbsd32_fd_setp_t) in;
syscallarg(netbsd32_fd_setp_t) ou;
syscallarg(netbsd32_fd_setp_t) ex;
syscallarg(const netbsd32_timespecp_t) ts;
syscallarg(const netbsd32_sigsetp_t) mask;
} */ *uap = v;
int error;
struct netbsd32_timespec ts32;
struct timespec ts;
struct timeval atv, *tv = NULL;
sigset_t amask, *mask = NULL;
if (SCARG(uap, ts)) {
if ((error = copyin(NETBSD32PTR64(SCARG(uap, ts)),
(caddr_t)&ts32, sizeof(ts32))) != 0)
return error;
netbsd32_to_timespec(&ts32, &ts);
atv.tv_sec = ts.tv_sec;
atv.tv_usec = ts.tv_nsec / 1000;
tv = &atv;
}
if (SCARG(uap, mask)) {
if ((error = copyin(NETBSD32PTR64(SCARG(uap, mask)),
(caddr_t)&amask, sizeof(amask))) != 0)
return error;
mask = &amask;
}
return selcommon(l, retval, SCARG(uap, nd), NETBSD32PTR64(SCARG(uap, in)),
NETBSD32PTR64(SCARG(uap, ou)), NETBSD32PTR64(SCARG(uap, ex)), tv,
mask);
}
int
netbsd32_pollts(l, v, retval)
struct lwp *l;
void *v;
register_t *retval;
{
struct netbsd32_pollts_args /* {
syscallarg(struct netbsd32_pollfdp_t) fds;
syscallarg(u_int) nfds;
syscallarg(const netbsd32_timespecp_t) ts;
syscallarg(const netbsd32_sigsetp_t) mask;
} */ *uap = v;
int error;
struct netbsd32_timespec ts32;
struct timespec ts;
struct timeval atv, *tv = NULL;
sigset_t amask, *mask = NULL;
if (SCARG(uap, ts)) {
if ((error = copyin(NETBSD32PTR64(SCARG(uap, ts)),
(caddr_t)&ts32, sizeof(ts32))) != 0)
return error;
netbsd32_to_timespec(&ts32, &ts);
atv.tv_sec = ts.tv_sec;
atv.tv_usec = ts.tv_nsec / 1000;
tv = &atv;
}
if (SCARG(uap, mask)) {
if ((error = copyin(NETBSD32PTR64(SCARG(uap, mask)),
(caddr_t)&amask, sizeof(amask))) != 0)
return error;
mask = &amask;
}
return pollcommon(l, retval, NETBSD32PTR64(SCARG(uap, fds)),
SCARG(uap, nfds), tv, mask);
}

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.30 2005/07/08 22:21:43 cube Exp $
$NetBSD: syscalls.master,v 1.31 2005/07/09 22:40:13 cube Exp $
; from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -597,3 +597,8 @@
372 STD { int netbsd32_extattr_list_link(const netbsd32_charp path, \
int attrnamespace, netbsd32_voidp data, \
netbsd32_size_t nbytes); }
373 STD { int netbsd32_pselect(int nd, netbsd32_fd_setp_t in, \
netbsd32_fd_setp_t ou, netbsd32_fd_setp_t ex, \
const netbsd32_timespecp_t ts, const netbsd32_sigsetp_t mask); }
374 STD { int netbsd32_pollts(netbsd32_pollfdp_t fds, u_int nfds, \
const netbsd32_timespecp_t ts, const netbsd32_sigsetp_t mask); }