Mail Archives: cygwin/2009/09/17/15:46:54
I would like to get control when floating-point exceptions occur, but the simple
approach doesn't seem to work; see the STC below. It shows SIGSEGV can be
trapped but not SIGFPE. In another experiment I tried extending libsigsegv to
handle FP exceptions but got the same results.
Is there something I need to do to "condition" the Cygwin environment to
generate FP exceptions? I saw the code in winsup/something/or/other to map x86
FP exceptions to SIGFPE but it seems somehow the exceptions aren't being
generated in the first place.
Thanks much,
..mark
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
jmp_buf trapoline;
void segv_handler(int x)
{
puts("SIGSEGV handled, continuing");
longjmp(trapoline, 1);
}
void fpe_handler(int x)
{
puts("SIGFPE handled, continuing");
longjmp(trapoline, 2);
}
int main()
{
signal(SIGSEGV, segv_handler);
signal(SIGFPE, fpe_handler);
switch(setjmp(trapoline)) {
case 0:
// first, force a SIGSEGV
printf("%X\n", *(int *) 42);
break;
case 1:
// second, force a SIGFPE
printf("%f\n", 1E200 * 1E200);
break;
case 2:
// all done
break;
}
return 0;
}
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -