signal.c revision be10f7d91e42e379302ee5ead703b5f0bf8b47c6
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
/*
* 4.3BSD signal compatibility functions
*
* the implementation interprets signal masks equal to -1 as "all of the
* signals in the signal set", thereby allowing signals with numbers
* above 32 to be blocked when referenced in code such as:
*
* for (i = 0; i < NSIG; i++)
* mask |= sigmask(i)
*/
#include <ucontext.h>
#include <signal.h>
#include <errno.h>
#include "libc.h"
/*
* DO NOT remove the _ from these 3 functions or the subsequent
* calls to them below. The non _ versions of these functions
* are the wrong functions to call. This is BCP. Extra
* care should be taken when modifying this code.
*/
extern int _sigfillset(sigset_t *);
extern int _sigemptyset(sigset_t *);
void (*_siguhandler[NSIG])() = { 0 };
/*
* forward declarations
*/
int ucbsiginterrupt(int, int);
int ucbsigpause(int);
int ucbsigblock(int);
int ucbsigsetmask(int);
/*
* sigvechandler is the real signal handler installed for all
* signals handled in the 4.3BSD compatibility interface - it translates
* SVR4 signal hander arguments into 4.3BSD signal handler arguments
* and then calls the real handler
*/
int
{
return (0); /* keep the same as the original prototype */
}
static void
{
struct sigcontext sc;
int code;
char *addr;
#ifdef NEVER
int gwinswitch = 0;
#endif
#if defined(__sparc)
/*
* Hack to emulate the 4.x kernel behavior of incrementing
* the PC on integer divide by zero and integer overflow
* on sparc machines. (5.x does not increment the PC.)
*/
}
/* XX64 There is no REG_PSR for sparcv9, we map in REG_CCR for now */
#if defined(__sparcv9)
#else
#endif
/*
* XXX - What a kludge!
* Store a pointer to the original ucontext_t in the sigcontext
* so that it's available to the sigcleanup call that needs to
* return from the signal handler. Otherwise, vital information
* (e.g., the "out" registers) that's only saved in the
* ucontext_t isn't available to sigcleanup.
*/
#ifdef NEVER
/*
* XXX - Sorry, we can never pass the saved register windows
* on in the sigcontext because we use that space to save the
* ucontext_t.
*/
int i, j;
gwinswitch = 1;
/* XXX - should use bcopy to move this in bulk */
for (j = 0; j < 8; j++)
for (j = 0; j < 8; j++)
}
}
#endif
#endif
/*
* Translate signal codes from new to old.
* /usr/ucbinclude/sys/signal.h contains old codes.
*/
code = 0;
addr = SIG_NOADDR;
switch (sig) {
case SIGILL:
case ILL_PRVOPC:
break;
case ILL_BADSTK:
break;
case ILL_ILLTRP:
break;
default:
break;
}
break;
case SIGEMT:
break;
case SIGFPE:
case FPE_INTDIV:
break;
case FPE_INTOVF:
break;
case FPE_FLTDIV:
break;
case FPE_FLTOVF:
break;
case FPE_FLTUND:
break;
case FPE_FLTRES:
break;
default:
break;
}
break;
case SIGBUS:
case BUS_ADRALN:
break;
case BUS_ADRERR:
break;
default: /* BUS_OBJERR */
break;
}
break;
case SIGSEGV:
case SEGV_MAPERR:
code = SEGV_NOMAP;
break;
case SEGV_ACCERR:
break;
default:
break;
}
break;
default:
addr = SIG_NOADDR;
break;
}
}
if (sc.sc_onstack)
else
#if defined(__sparc)
#if defined(__sparcv9)
#else
#endif
#ifdef NEVER
if (gwinswitch == 1) {
int i, j;
/* XXX - should use bcopy to move this in bulk */
for (j = 0; j < 8; j++)
for (j = 0; j < 8; j++)
}
}
#endif
}
}
#endif
(void) setcontext(ucp);
}
#if defined(__sparc)
/*
* Emulate the special sigcleanup trap.
* This is only used by statically linked 4.x applications
* and thus is only called by the static BCP support.
* It lives here because of its close relationship with
* the ucbsigvechandler code above.
*
* It's used by 4.x applications to:
* 1. return from a signal handler (in __sigtramp)
* 2. [sig]longjmp
* 3. context switch, in the old 4.x liblwp
*/
void
{
int sig;
/*
* If there's a pointer to a ucontext_t hiding in the sigcontext,
* we *must* use that to return, since it contains important data
* such as the original "out" registers when the signal occurred.
*/
} else {
/*
* Otherwise, use a local ucontext_t and
* initialize it with getcontext.
*/
sig = 0;
(void) getcontext(ucp);
}
if (scp->sc_onstack) {
} else
#if defined(__sparcv9)
#else
#endif
}
}
(void) setcontext(ucp);
/* NOTREACHED */
}
#endif
int
_sigsetmask(int mask)
{
return (ucbsigsetmask(mask));
}
int
ucbsigsetmask(int mask)
{
}
int
{
return (ucbsigblock(mask));
}
int
ucbsigblock(int mask)
{
}
int
{
return (ucbsigpause(mask));
}
int
ucbsigpause(int mask)
{
int ret;
return (ret);
}
int
{
}
int
{
void (*ohandler)(int, int, struct sigcontext *, char *);
void (*nhandler)(int, int, struct sigcontext *, char *);
return (-1);
}
return (-1);
}
if (nvec) {
/*
* To be compatible with the behavior of SunOS 4.x:
* If the new signal handler is SIG_IGN or SIG_DFL,
* do not change the signal's entry in the handler array.
* This allows a child of vfork(2) to set signal handlers
* to SIG_IGN or SIG_DFL without affecting the parent.
*/
} else {
}
} else
return (-1);
}
if (ovec) {
ovec->sv_handler =
(void (*) (int, int, struct sigcontext *, char *))
else
}
return (0);
}
int
{
struct sigaltstack nalt;
struct sigaltstack oalt;
struct sigaltstack *naltp;
if (nss) {
/*
* XXX: assumes stack growth is down (like sparc)
*/
} else
naltp = (struct sigaltstack *)0;
return (-1);
if (oss) {
/*
* XXX: assumes stack growth is down (like sparc)
*/
}
return (0);
}
void (*
ucbsignal(int s, void (*a)(int)))(int)
{
return (SIG_ERR);
return (SIG_ERR);
}
return ((void (*) (int)) osv.sv_handler);
}
void (*
usignal(int s, void (*a) (int)))(int)
{
return (ucbsignal(s, a));
}
/*
* Set signal state to prevent restart of system calls
* after an instance of the indicated signal.
*/
int
{
}
int
{
int ret;
return (ret);
if (flag)
else
}