~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <signal.h>
#include <sigcontext.h>
#include <stdio.h>
int
default_stack_flt_handler(int signr, struct sigcontext_struct sig)
{
int regnr = (sig.fpstate->sw & 0x3800) >> 11;
printf("got FPU stack fault %p\n", (void *)sig.fpstate->ipoff);
sig.fpstate->sw &= ~0x3f;
sig.fpstate->_st[regnr].significand[0] = 0;
sig.fpstate->_st[regnr].significand[1] = 0;
sig.fpstate->_st[regnr].significand[2] = 0;
sig.fpstate->_st[regnr].significand[3] = 0x8000;
sig.fpstate->_st[regnr].exponent = 0x3fff;
sigreturn (&sig);
return 1;
}
int
main (int argc, char argv[])
{
struct sigaction sa;
__setfpucw (0x1340);
sa.sa_handler = default_stack_flt_handler;
sa.sa_flags = 0;
sa.sa_restorer = NULL;
sigemptyset(&sa.sa_mask);
sigaddset(&sa.sa_mask, SIGFPE);
sigaction (SIGFPE, &sa, NULL);
return (int) (((double) argc) / ((double) ((argc < 100) - 1)));
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Uli
---------------. drepper@cygnus.com ,-. Rubensstrasse 5
Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany
Cygnus Solutions `--' drepper@gnu.ai.mit.edu `------------------------