si_code broken for SIGFPE on Mac OS X/x86?
si_code broken for SIGFPE on Mac OS X/x86?
- Subject: si_code broken for SIGFPE on Mac OS X/x86?
- From: Jonas Maebe <email@hidden>
- Date: Wed, 15 Mar 2006 22:28:02 +0100
Hello,
The following program (when compiled with" -mno-sse -mno-sse2 -mno-
sse3" prints this on Mac OS X 10.4.5/x86:
sigaction: Unknown error: 0
si->si_code: 0
On Linux/x86, I get (after replacing the _cw with cw in the assembler
code):
sigaction: Success
si->si_code: 3
(the perror() output is obviously of no importance, since no error
occurred installing the signal handler).
Is si_code for fpu-division by zero exceptions known to be broken on
Mac OS X/x86? (or is this not known since gcc generates sse code by
default on Mac OS X/x86?)
Thanks,
Jonas
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void sighandler(int signum, siginfo_t *si, void *pp) {
if (signum == SIGFPE) {
printf("si->si_code: %d\n",si->si_code);
} else {
printf("Wrong signal: %d\n",signum);
}
_exit(1);
}
// turn on fpu exceptions, masked by default
short cw = 0x1332;
int main() {
struct sigaction sa;
double a,b,c;
asm("fnclex");
asm("fldcw _cw");
memset(&sa,0,sizeof(sa));
sa.sa_sigaction = sighandler;
sa.sa_flags = SA_SIGINFO;
sigaction(SIGFPE,&sa,NULL);
perror("sigaction");
a = 1.0;
b = 0.0;
c = a / b;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden