si_code broken for SIGFPE on Mac OS X/x86?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hello, sigaction: Unknown error: 0 si->si_code: 0 sigaction: Success si->si_code: 3 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... The following program (when compiled with" -mno-sse -mno-sse2 -mno- sse3" prints this on Mac OS X 10.4.5/x86: On Linux/x86, I get (after replacing the _cw with cw in the assembler code): (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?) This email sent to site_archiver@lists.apple.com
participants (1)
-
Jonas Maebe