From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: X-Archive-Original-Message-ID: Date: Wed, 16 Apr 1997 23:05:56 -0400 From: Jim Paradis Subject: SIGFPE -- the answer [ cc'ed to axp-list for everyone's edification ] Randy, I can be soooo dense sometimes. Remember the divide-by-zero exception handling problem you were having? I figured out what was *really* going on. Seeing as I wrote the floating-point emulation code for Linux/Alpha (or, more accurately, I wrote the code for another project which I then gave to David M-T to hammer into the Linux sources), I shoulda known this. Anyhow: there is a way to turn off those nasty SIGFPE's and get the results you want. It's a "secret" system call (osf_setsysinfo) which can be used to set the floating-point exception enable bits in the process struct. Here's da goods: To read and write the floating-point exception enable bits, you can use the following routines: #include #define __NR_getsysinfo 256 #define __NR_setsysinfo 257 unsigned long read_fpe_bits() { unsigned long fpcw; syscall(__NR_getsysinfo, 45, &fpcw, sizeof(fpcw), 0, 0); return(fpcw & IEEE_TRAP_ENABLE_MASK); } void write_fpe_bits(unsigned long fpcw) { syscall(__NR_setsysinfo, 14, &fpcw, sizeof(fpcw), 0, 0); } The bits themselves are defined in /usr/include/asm/fpu.h. Look for "IEEE_TRAP_ENABLE_xxx". Apparently INV (invalid operand), DZE (divide-by-zero) and OVF (overflow) are turned ON by default for all processes, and you have to turn them off manually. Hope this helps! -- Jim Paradis jrp@jrp.tiac.net http://www.tiac.net/users/jrp/index.html "It's not procrastination, it's my new Just-In-Time Workload Management System!" -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com