tps@chem.ucsd.edu (Tom Stockfisch) (12/12/89)
With 3.2 floating point exceptions are ignored, with NaN's and Infinity's
propagated through floating point exceptions, presumably according to
IEEE rules. I happen to prefer that all exceptions result in SIGFPE
being raised, so that a process stops right away and either aborts
or calls a signal()-specified error handler.
How can I achieve this?
--
|| Tom Stockfisch, UCSD Chemistry tps@chem.ucsd.edu
deb@kea.wpd.sgi.com (Deb Ryan) (12/13/89)
In article <624@chem.ucsd.EDU>, tps@chem.ucsd.edu (Tom Stockfisch) writes: > With 3.2 floating point exceptions are ignored, with NaN's and Infinity's > propagated through floating point exceptions, presumably according to > IEEE rules. I happen to prefer that all exceptions result in SIGFPE > being raised, so that a process stops right away and either aborts > or calls a signal()-specified error handler. > > How can I achieve this? > -- > > || Tom Stockfisch, UCSD Chemistry tps@chem.ucsd.edu You two choices: 1. Wait for the trap handler, comming out in the aspen release. This will make it easy to core dump, or do anything your heart can code in a subroutine . 2. If all you really want to do is coredump, this Fortran callable C routine will show you what to do. signal (2) will also allow you to specify your own handler, but you will be pretty limited without information about the exception. ----------------------------------cut here ------------------------------------- #include <stdio.h> #include <signal.h> #include <sys/fpu.h> /* this code uses information from the manpages fpc(3c) and signal(2) set_traps is a fortran callable subroutine which will enable foating point exceptions, and coredump upon recieving one */ set_traps_() { union fpc_csr fpstat; /* enable the floating point traps */ fpstat.fc_word = get_fpc_csr(); fpstat.fc_word |= (FPCSR_ENABLES | FPCSR_EXCEPTIONS); set_fpc_csr (fpstat.fc_word); /* abort upon recieving floating point trap */ signal (SIGFPE, SIG_DFL); } /* test routine for set_traps */ main() { float zero=0.0; float one=1.0; float result; set_traps_(); /* divide by zero */ printf( "\n\ndividing by zero:\n"); result = one/zero; printf("one/zero yields %e\n",result); } -- -Deb deb@sgi.com Deborah Ryan Caruso @ Silicon Graphics
stephen@mincom.OZ (Stephen Kirby) (12/14/89)
In article <624@chem.ucsd.EDU>, tps@chem.ucsd.edu (Tom Stockfisch) writes: > With 3.2 floating point exceptions are ignored, with NaN's and Infinity's > propagated through floating point exceptions, presumably according to > IEEE rules. I happen to prefer that all exceptions result in SIGFPE > being raised, so that a process stops right away and either aborts > or calls a signal()-specified error handler. > > How can I achieve this? > || Tom Stockfisch, UCSD Chemistry tps@chem.ucsd.edu I wish to support this request. We are attempting to develop commercial software, and are very worried that our programs don't crash during debugging when divide by zero's occur. || Stephen Kirby, MINCOM