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/linux/common/linux_sig_notalpha.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: linux_sig_notalpha.c,v 1.38 2008/04/28 20:23:44 martin Exp $   */
    2 
    3 /*-
    4  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Frank van der Linden and Eric Haszlakiewicz.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 /*
   33  * heavily from: svr4_signal.c,v 1.7 1995/01/09 01:04:21 christos Exp
   34  */
   35 
   36 #include <sys/cdefs.h>
   37 __KERNEL_RCSID(0, "$NetBSD: linux_sig_notalpha.c,v 1.38 2008/04/28 20:23:44 martin Exp $");
   38 
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <sys/proc.h>
   42 #include <sys/filedesc.h>
   43 #include <sys/mount.h>
   44 #include <sys/kernel.h>
   45 #include <sys/signal.h>
   46 #include <sys/signalvar.h>
   47 
   48 #include <sys/syscallargs.h>
   49 
   50 #include <compat/linux/common/linux_types.h>
   51 #include <compat/linux/common/linux_signal.h>
   52 #include <compat/linux/common/linux_util.h>
   53 #include <compat/linux/common/linux_ipc.h>
   54 #include <compat/linux/common/linux_sem.h>
   55 
   56 #include <compat/linux/linux_syscallargs.h>
   57 
   58 /* Used on: arm, i386, m68k, mips, sparc, sparc64 */
   59 /* Not used on: alpha */
   60 
   61 #if !defined(__amd64__)
   62 /*
   63  * The Linux signal() system call. I think that the signal() in the C
   64  * library actually calls sigaction, so I doubt this one is ever used.
   65  * But hey, it can't hurt having it here. The same restrictions as for
   66  * sigaction() apply.
   67  */
   68 int
   69 linux_sys_signal(struct lwp *l, const struct linux_sys_signal_args *uap, register_t *retval)
   70 {
   71         /* {
   72                 syscallarg(int) signum;
   73                 syscallarg(linux_handler_t) handler;
   74         } */
   75         struct sigaction nbsa, obsa;
   76         int error, sig;
   77 
   78         *retval = -1;
   79         sig = SCARG(uap, signum);
   80         if (sig < 0 || sig >= LINUX__NSIG)
   81                 return (EINVAL);
   82 
   83         nbsa.sa_handler = SCARG(uap, handler);
   84         sigemptyset(&nbsa.sa_mask);
   85         nbsa.sa_flags = SA_RESETHAND | SA_NODEFER;
   86         error = sigaction1(l, linux_to_native_signo[sig],
   87             &nbsa, &obsa, NULL, 0);
   88         if (error == 0)
   89                 *retval = (int)(long)obsa.sa_handler; /* XXXmanu cast */
   90         return (error);
   91 }
   92 
   93 
   94 /* ARGSUSED */
   95 int
   96 linux_sys_siggetmask(struct lwp *l, const void *v, register_t *retval)
   97 {
   98         struct proc *p = l->l_proc;
   99         sigset_t bss;
  100         linux_old_sigset_t lss;
  101         int error;
  102 
  103         mutex_enter(p->p_lock);
  104         error = sigprocmask1(l, SIG_SETMASK, 0, &bss);
  105         mutex_exit(p->p_lock);
  106         if (error)
  107                 return (error);
  108         native_to_linux_old_sigset(&lss, &bss);
  109         return (0);
  110 }
  111 
  112 /*
  113  * The following three functions fiddle with a process' signal mask.
  114  * Convert the signal masks because of the different signal
  115  * values for Linux. The need for this is the reason why
  116  * they are here, and have not been mapped directly.
  117  */
  118 int
  119 linux_sys_sigsetmask(struct lwp *l, const struct linux_sys_sigsetmask_args *uap, register_t *retval)
  120 {
  121         /* {
  122                 syscallarg(linux_old_sigset_t) mask;
  123         } */
  124         sigset_t nbss, obss;
  125         linux_old_sigset_t nlss, olss;
  126         struct proc *p = l->l_proc;
  127         int error;
  128 
  129         nlss = SCARG(uap, mask);
  130         linux_old_to_native_sigset(&nbss, &nlss);
  131         mutex_enter(p->p_lock);
  132         error = sigprocmask1(l, SIG_SETMASK, &nbss, &obss);
  133         mutex_exit(p->p_lock);
  134         if (error)
  135                 return (error);
  136         native_to_linux_old_sigset(&olss, &obss);
  137         *retval = olss;
  138         return (0);
  139 }
  140 
  141 int
  142 linux_sys_sigprocmask(struct lwp *l, const struct linux_sys_sigprocmask_args *uap, register_t *retval)
  143 {
  144         /* {
  145                 syscallarg(int) how;
  146                 syscallarg(const linux_old_sigset_t *) set;
  147                 syscallarg(linux_old_sigset_t *) oset;
  148         } */
  149 
  150         return(linux_sigprocmask1(l, SCARG(uap, how),
  151                                 SCARG(uap, set), SCARG(uap, oset)));
  152 }
  153 #endif /* !__amd64__ */
  154 
  155 /*
  156  * The deprecated pause(2), which is really just an instance
  157  * of sigsuspend(2).
  158  */
  159 int
  160 linux_sys_pause(struct lwp *l, const void *v, register_t *retval)
  161 {
  162 
  163         return (sigsuspend1(l, 0));
  164 }
  165 

Cache object: 30d38a6a8cccb8545777fde182df8373


[ 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.