/*
* 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
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 1987 by Sun Microsystems, Inc.
*/
/* Swap handler for SIGFPE codes. */
#include <errno.h>
#include <signal.h>
#include <floatingpoint.h>
#ifndef FPE_INTDIV_TRAP
#endif
#ifndef FPE_CHKINST_TRAP
#endif
#ifndef FPE_TRAPV_TRAP
#endif
#ifndef FPE_FLTBSUN_TRAP
#endif
#ifndef FPE_FLTINEX_TRAP
#endif
#ifndef FPE_FLTDIV_TRAP
#endif
#ifndef FPE_FLTUND_TRAP
#endif
#ifndef FPE_FLTOPERR_TRAP
#endif
#ifndef FPE_FLTOVF_TRAP
#endif
#ifndef FPE_FLTNAN_TRAP
#endif
#ifndef FPE_FPA_ENABLE
#endif
#ifndef FPE_FPA_ERROR
#endif
/* Array of SIGFPE codes. */
0};
/* Array of handlers. */
static int _sigfpe_master_enabled;
/* Originally zero, set to 1 by _enable_sigfpe_master. */
void
int sig;
struct sigcontext *scp;
char *addr;
{
int i;
/* Find index of handler. */
if (i >= N_SIGFPE_CODE)
i = N_SIGFPE_CODE - 1;
switch ((unsigned int)sigfpe_handlers[i]) {
case (unsigned int)SIGFPE_DEFAULT:
switch (code) {
case FPE_FLTBSUN_TRAP:
case FPE_FLTOPERR_TRAP:
case FPE_FLTNAN_TRAP:
goto ieee;
case FPE_FLTINEX_TRAP:
goto ieee;
case FPE_FLTDIV_TRAP:
goto ieee;
case FPE_FLTUND_TRAP:
goto ieee;
case FPE_FLTOVF_TRAP:
goto ieee;
default: /* The common default treatment is to abort. */
break;
}
case (unsigned int)SIGFPE_ABORT:
abort();
case (unsigned int)SIGFPE_IGNORE:
return;
default: /* User-defined not SIGFPE_DEFAULT or
* SIGFPE_ABORT. */
return;
}
ieee:
switch ((unsigned int)ieee_handlers[(int) exception]) {
case (unsigned int)SIGFPE_DEFAULT:
/* Error condition but ignore it. */
case (unsigned int)SIGFPE_IGNORE:
/* Error condition but ignore it. */
return;
case (unsigned int)SIGFPE_ABORT:
abort();
default:
return;
}
}
int
{
/* Enable the sigfpe master handler always. */
newsigvec.sv_onstack = 0;
}
int
{
/*
* Enable the sigfpe master handler if it's never been enabled
* before.
*/
if (_sigfpe_master_enabled == 0)
return _enable_sigfpe_master();
else
return _sigfpe_master_enabled;
}
{
int i;
/* Find index of handler. */
if (i >= N_SIGFPE_CODE) {
}
oldhdl = sigfpe_handlers[i];
sigfpe_handlers[i] = hdl;
return oldhdl;
}