Implement the ksem_* family of syscalls.
This commit is contained in:
parent
f6f0eee324
commit
6d0cb97ff8
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.netbsd32,v 1.20 2005/12/11 12:20:22 christos Exp $
|
||||
# $NetBSD: files.netbsd32,v 1.21 2006/03/05 01:28:20 cube Exp $
|
||||
#
|
||||
# config file description for machine-independent netbsd32 compat code.
|
||||
# included by ports that need it.
|
||||
@ -16,6 +16,7 @@ file compat/netbsd32/netbsd32_fs.c compat_netbsd32
|
||||
file compat/netbsd32/netbsd32_ioctl.c compat_netbsd32
|
||||
file compat/netbsd32/netbsd32_ipc.c compat_netbsd32
|
||||
file compat/netbsd32/netbsd32_select.c compat_netbsd32
|
||||
file compat/netbsd32/netbsd32_sem.c compat_netbsd32 & p1003_1b_semaphore
|
||||
file compat/netbsd32/netbsd32_signal.c compat_netbsd32
|
||||
file compat/netbsd32/netbsd32_socket.c compat_netbsd32
|
||||
file compat/netbsd32/netbsd32_sysctl.c compat_netbsd32
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: netbsd32.h,v 1.48 2005/12/11 12:20:22 christos Exp $ */
|
||||
/* $NetBSD: netbsd32.h,v 1.49 2006/03/05 01:28:20 cube Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2001 Matthew R. Green
|
||||
@ -115,6 +115,8 @@ typedef netbsd32_pointer_t netbsd32_ucontextp;
|
||||
|
||||
/* from <sys/types.h> */
|
||||
typedef netbsd32_pointer_t netbsd32_fd_setp_t;
|
||||
typedef netbsd32_intptr_t netbsd32_semid_t;
|
||||
typedef netbsd32_pointer_t netbsd32_semidp_t;
|
||||
|
||||
/* from <sys/uio.h> */
|
||||
typedef netbsd32_pointer_t netbsd32_iovecp_t;
|
||||
|
185
sys/compat/netbsd32/netbsd32_sem.c
Normal file
185
sys/compat/netbsd32/netbsd32_sem.c
Normal file
@ -0,0 +1,185 @@
|
||||
/* $NetBSD: netbsd32_sem.c,v 1.1 2006/03/05 01:28:20 cube Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 The NetBSD Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to the NetBSD Foundation
|
||||
* by Quentin Garnier.
|
||||
*
|
||||
* 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. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: netbsd32_sem.c,v 1.1 2006/03/05 01:28:20 cube Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_posix.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/ksem.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sa.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/netbsd32/netbsd32.h>
|
||||
#include <compat/netbsd32/netbsd32_syscallargs.h>
|
||||
#include <compat/netbsd32/netbsd32_conv.h>
|
||||
|
||||
static int
|
||||
netbsd32_ksem_copyout(const void *src, void *dst, size_t size)
|
||||
{
|
||||
const semid_t *idp = src;
|
||||
netbsd32_semid_t id32, *outidp = dst;
|
||||
|
||||
KASSERT(size == sizeof(semid_t));
|
||||
|
||||
id32 = (netbsd32_semidp_t)(*idp & 0xffffffff);
|
||||
return copyout(&id32, outidp, sizeof(id32));
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_init(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_init_args /* {
|
||||
syscallarg(unsigned int) value;
|
||||
syscallarg(netbsd32_semidp_t) idp;
|
||||
} */ *uap = v;
|
||||
|
||||
return do_ksem_init(l, SCARG(uap, value),
|
||||
NETBSD32PTR64(SCARG(uap, idp)), netbsd32_ksem_copyout);
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_open(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_open_args /* {
|
||||
syscallarg(const netbsd32_charp) name;
|
||||
syscallarg(int) oflag;
|
||||
syscallarg(mode_t) mode;
|
||||
syscallarg(unsigned int) value;
|
||||
syscallarg(netbsd32_semidp_t) idp;
|
||||
} */ *uap = v;
|
||||
|
||||
return do_ksem_open(l, NETBSD32PTR64(SCARG(uap, name)),
|
||||
SCARG(uap, oflag), SCARG(uap, mode), SCARG(uap, value),
|
||||
NETBSD32PTR64(SCARG(uap, idp)), netbsd32_ksem_copyout);
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_unlink(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_unlink_args /* {
|
||||
syscallarg(const netbsd32_charp) name;
|
||||
} */ *uap = v;
|
||||
struct sys__ksem_unlink_args ua;
|
||||
|
||||
NETBSD32TOP_UAP(name, const char);
|
||||
return sys__ksem_unlink(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_close(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_close_args /* {
|
||||
syscallarg(netbsd32_semid_t) id;
|
||||
} */ *uap = v;
|
||||
struct sys__ksem_close_args ua;
|
||||
|
||||
NETBSD32TOX_UAP(id, semid_t);
|
||||
return sys__ksem_close(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_post(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_post_args /* {
|
||||
syscallarg(netbsd32_semid_t) id;
|
||||
} */ *uap = v;
|
||||
struct sys__ksem_post_args ua;
|
||||
|
||||
NETBSD32TOX_UAP(id, semid_t);
|
||||
return sys__ksem_post(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_wait(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_wait_args /* {
|
||||
syscallarg(netbsd32_semid_t) id;
|
||||
} */ *uap = v;
|
||||
struct sys__ksem_wait_args ua;
|
||||
|
||||
NETBSD32TOX_UAP(id, semid_t);
|
||||
return sys__ksem_wait(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_trywait(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_trywait_args /* {
|
||||
syscallarg(netbsd32_semid_t) id;
|
||||
} */ *uap = v;
|
||||
struct sys__ksem_trywait_args ua;
|
||||
|
||||
NETBSD32TOX_UAP(id, semid_t);
|
||||
return sys__ksem_trywait(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_destroy(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_destroy_args /* {
|
||||
syscallarg(netbsd32_semid_t) id;
|
||||
} */ *uap = v;
|
||||
struct sys__ksem_destroy_args ua;
|
||||
|
||||
NETBSD32TOX_UAP(id, semid_t);
|
||||
return sys__ksem_destroy(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
netbsd32__ksem_getvalue(struct lwp *l, void *v, register_t *retval)
|
||||
{
|
||||
struct netbsd32__ksem_getvalue_args /* {
|
||||
syscallarg(netbsd32_semid_t) id;
|
||||
syscallarg(netbsd32_intp) value;
|
||||
} */ *uap = v;
|
||||
struct sys__ksem_getvalue_args ua;
|
||||
|
||||
NETBSD32TOX_UAP(id, semid_t);
|
||||
NETBSD32TOP_UAP(value, unsigned int);
|
||||
return sys__ksem_getvalue(l, &ua, retval);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
$NetBSD: syscalls.master,v 1.41 2005/12/11 12:20:22 christos Exp $
|
||||
$NetBSD: syscalls.master,v 1.42 2006/03/05 01:28:20 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
|
||||
@ -42,6 +42,7 @@
|
||||
#include "opt_ntp.h"
|
||||
#include "opt_sysv.h"
|
||||
#include "opt_compat_43.h"
|
||||
#include "opt_posix.h"
|
||||
|
||||
#include "fs_lfs.h"
|
||||
#include "fs_nfs.h"
|
||||
@ -412,16 +413,31 @@
|
||||
netbsd32_timespecp_t timeout); }
|
||||
245 UNIMPL
|
||||
246 UNIMPL
|
||||
247 UNIMPL
|
||||
248 UNIMPL
|
||||
249 UNIMPL
|
||||
250 UNIMPL
|
||||
251 UNIMPL
|
||||
252 UNIMPL
|
||||
253 UNIMPL
|
||||
254 UNIMPL
|
||||
255 UNIMPL
|
||||
256 UNIMPL
|
||||
#if defined(P1003_1B_SEMAPHORE) || (!defined(_KERNEL) && defined(_LIBC))
|
||||
247 STD { int netbsd32__ksem_init(unsigned int value, netbsd32_semidp_t idp); }
|
||||
248 STD { int netbsd32__ksem_open(const netbsd32_charp name, int oflag, \
|
||||
mode_t mode, unsigned int value, netbsd32_semidp_t idp); }
|
||||
249 STD { int netbsd32__ksem_unlink(const netbsd32_charp name); }
|
||||
250 STD { int netbsd32__ksem_close(netbsd32_semid_t id); }
|
||||
251 STD { int netbsd32__ksem_post(netbsd32_semid_t id); }
|
||||
252 STD { int netbsd32__ksem_wait(netbsd32_semid_t id); }
|
||||
253 STD { int netbsd32__ksem_trywait(netbsd32_semid_t id); }
|
||||
254 STD { int netbsd32__ksem_getvalue(netbsd32_semid_t id, \
|
||||
netbsd32_intp value); }
|
||||
255 STD { int netbsd32__ksem_destroy(netbsd32_semid_t id); }
|
||||
256 UNIMPL sys__ksem_timedwait
|
||||
#else
|
||||
247 EXCL sys__ksem_init
|
||||
248 EXCL sys__ksem_open
|
||||
249 EXCL sys__ksem_unlink
|
||||
250 EXCL sys__ksem_close
|
||||
251 EXCL sys__ksem_post
|
||||
252 EXCL sys__ksem_wait
|
||||
253 EXCL sys__ksem_trywait
|
||||
254 EXCL sys__ksem_getvalue
|
||||
255 EXCL sys__ksem_destroy
|
||||
256 UNIMPL sys__ksem_timedwait
|
||||
#endif
|
||||
257 UNIMPL
|
||||
258 UNIMPL
|
||||
259 UNIMPL
|
||||
|
Loading…
Reference in New Issue
Block a user