/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2008 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"
/* Swap handler for SIGFPE codes. */
#include "lint.h"
#include <mtlib.h>
#include <errno.h>
#include <signal.h>
#include <floatingpoint.h>
#include <sys/ucontext.h>
#include <thread.h>
#include <synch.h>
#include <stdlib.h>
#ifndef FPE_INTDIV
#endif
#ifndef FPE_INTOVF
#endif
#ifndef FPE_FLTDIV
#endif
#ifndef FPE_FLTOVF
#endif
#ifndef FPE_FLTUND
#endif
#ifndef FPE_FLTRES
#endif
#ifndef FPE_FLTINV
#endif
#ifndef FPE_FLTSUB
#endif
#ifndef FPE_FLTDEN
#endif
#else
#endif /* __i386 */
/* Array of SIGFPE codes. */
#endif
0
};
/* Array of handlers. */
static int _sigfpe_master_enabled;
/* Originally zero, set to 1 by _enable_sigfpe_master. */
#ifndef BADSIG
#endif
static void
{
int i;
int code;
continue;
/* Find index of handler. */
if (i >= N_SIGFPE_CODE)
i = N_SIGFPE_CODE - 1;
switch ((intptr_t)sigfpe_handlers[i]) {
case ((intptr_t)(SIGFPE_DEFAULT)):
switch (code) {
case FPE_FLTINV:
goto ieee;
case FPE_FLTRES:
goto ieee;
case FPE_FLTDIV:
goto ieee;
case FPE_FLTUND:
goto ieee;
case FPE_FLTOVF:
goto ieee;
default: /* The common default treatment is to abort. */
break;
}
case ((intptr_t)(SIGFPE_ABORT)):
abort();
break;
case ((intptr_t)(SIGFPE_IGNORE)):
return;
default: /* User-defined not SIGFPE_DEFAULT or SIGFPE_ABORT. */
return;
}
ieee:
return;
case ((intptr_t)(SIGFPE_ABORT)):
abort();
default:
return;
}
}
static int
_enable_sigfpe_master(void)
{
/* Enable the sigfpe master handler always. */
}
static int
_test_sigfpe_master(void)
{
/*
* 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;
(void) _test_sigfpe_master();
continue;
/* Find index of handler. */
if (i >= N_SIGFPE_CODE) {
/* Not 0 or SIGFPE code */
return ((sigfpe_handler_type)BADSIG);
}
oldhdl = sigfpe_handlers[i];
sigfpe_handlers[i] = hdl;
return (oldhdl);
}