The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/netbsd32/netbsd32_sem.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: netbsd32_sem.c,v 1.7 2008/04/29 06:53:02 martin Exp $  */
    2 
    3 /*
    4  *  Copyright (c) 2006 The NetBSD Foundation.
    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  *
   16  *  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   17  *  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   18  *  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   19  *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   20  *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   26  *  POSSIBILITY OF SUCH DAMAGE.
   27  */
   28 
   29 #include <sys/cdefs.h>
   30 __KERNEL_RCSID(0, "$NetBSD: netbsd32_sem.c,v 1.7 2008/04/29 06:53:02 martin Exp $");
   31 
   32 #ifdef _KERNEL_OPT
   33 #include "opt_posix.h"
   34 #endif
   35 
   36 #include <sys/types.h>
   37 #include <sys/param.h>
   38 #include <sys/systm.h>
   39 #include <sys/kernel.h>
   40 #include <sys/dirent.h>
   41 #include <sys/ksem.h>
   42 #include <sys/mount.h>
   43 #include <sys/proc.h>
   44 #include <sys/syscallargs.h>
   45 
   46 #include <compat/netbsd32/netbsd32.h>
   47 #include <compat/netbsd32/netbsd32_syscallargs.h>
   48 #include <compat/netbsd32/netbsd32_conv.h>
   49 
   50 static int
   51 netbsd32_ksem_copyout(const void *src, void *dst, size_t size)
   52 {
   53         const semid_t *idp = src;
   54         netbsd32_semid_t id32, *outidp = dst;
   55 
   56         KASSERT(size == sizeof(semid_t));
   57 
   58         /* Returning a kernel pointer to userspace sucks badly :-( */
   59         id32 = (netbsd32_semid_t)*idp;
   60         return copyout(&id32, outidp, sizeof(id32));
   61 }
   62 
   63 int
   64 netbsd32__ksem_init(struct lwp *l, const struct netbsd32__ksem_init_args *uap, register_t *retval)
   65 {
   66         /* {
   67                 syscallarg(unsigned int) value;
   68                 syscallarg(netbsd32_semidp_t) idp;
   69         } */
   70 
   71         return do_ksem_init(l, SCARG(uap, value),
   72             SCARG_P32(uap, idp), netbsd32_ksem_copyout);
   73 }
   74 
   75 int
   76 netbsd32__ksem_open(struct lwp *l, const struct netbsd32__ksem_open_args *uap, register_t *retval)
   77 {
   78         /* {
   79                 syscallarg(const netbsd32_charp) name;
   80                 syscallarg(int) oflag;
   81                 syscallarg(mode_t) mode;
   82                 syscallarg(unsigned int) value;
   83                 syscallarg(netbsd32_semidp_t) idp;
   84         } */
   85 
   86         return do_ksem_open(l, SCARG_P32(uap, name),
   87             SCARG(uap, oflag), SCARG(uap, mode), SCARG(uap, value),
   88             SCARG_P32(uap, idp), netbsd32_ksem_copyout);
   89 }
   90 
   91 int
   92 netbsd32__ksem_unlink(struct lwp *l, const struct netbsd32__ksem_unlink_args *uap, register_t *retval)
   93 {
   94         /* {
   95                 syscallarg(const netbsd32_charp) name;
   96         } */
   97         struct sys__ksem_unlink_args ua;
   98 
   99         NETBSD32TOP_UAP(name, const char);
  100         return sys__ksem_unlink(l, &ua, retval);
  101 }
  102 
  103 int
  104 netbsd32__ksem_close(struct lwp *l, const struct netbsd32__ksem_close_args *uap, register_t *retval)
  105 {
  106         /* {
  107                 syscallarg(netbsd32_semid_t) id;
  108         } */
  109         struct sys__ksem_close_args ua;
  110 
  111         NETBSD32TOX_UAP(id, semid_t);
  112         return sys__ksem_close(l, &ua, retval);
  113 }
  114 
  115 int
  116 netbsd32__ksem_post(struct lwp *l, const struct netbsd32__ksem_post_args *uap, register_t *retval)
  117 {
  118         /* {
  119                 syscallarg(netbsd32_semid_t) id;
  120         } */
  121         struct sys__ksem_post_args ua;
  122 
  123         NETBSD32TOX_UAP(id, semid_t);
  124         return sys__ksem_post(l, &ua, retval);
  125 }
  126 
  127 int
  128 netbsd32__ksem_wait(struct lwp *l, const struct netbsd32__ksem_wait_args *uap, register_t *retval)
  129 {
  130         /* {
  131                 syscallarg(netbsd32_semid_t) id;
  132         } */
  133         struct sys__ksem_wait_args ua;
  134 
  135         NETBSD32TOX_UAP(id, semid_t);
  136         return sys__ksem_wait(l, &ua, retval);
  137 }
  138 
  139 int
  140 netbsd32__ksem_trywait(struct lwp *l, const struct netbsd32__ksem_trywait_args *uap, register_t *retval)
  141 {
  142         /* {
  143                 syscallarg(netbsd32_semid_t) id;
  144         } */
  145         struct sys__ksem_trywait_args ua;
  146 
  147         NETBSD32TOX_UAP(id, semid_t);
  148         return sys__ksem_trywait(l, &ua, retval);
  149 }
  150 
  151 int
  152 netbsd32__ksem_destroy(struct lwp *l, const struct netbsd32__ksem_destroy_args *uap, register_t *retval)
  153 {
  154         /* {
  155                 syscallarg(netbsd32_semid_t) id;
  156         } */
  157         struct sys__ksem_destroy_args ua;
  158 
  159         NETBSD32TOX_UAP(id, semid_t);
  160         return sys__ksem_destroy(l, &ua, retval);
  161 }
  162 
  163 int
  164 netbsd32__ksem_getvalue(struct lwp *l, const struct netbsd32__ksem_getvalue_args *uap, register_t *retval)
  165 {
  166         /* {
  167                 syscallarg(netbsd32_semid_t) id;
  168                 syscallarg(netbsd32_intp) value;
  169         } */
  170         struct sys__ksem_getvalue_args ua;
  171 
  172         NETBSD32TOX_UAP(id, semid_t);
  173         NETBSD32TOP_UAP(value, unsigned int);
  174         return sys__ksem_getvalue(l, &ua, retval);
  175 }

Cache object: fd41efb941e3bb9e863a95058758614e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.