Re: sigaction inconsistancy (here I go again)
Also, I haven't gone into the code yet, but the floating point registers are not saved into the sigcontext so that they can be inspected and modified as appropriate. Thanks, John If I recall correctly - I think there's a discussion of why this is the case in the -hackers mail archive. - Dave Rivers - To Unsubscribe: send mail to majord...@freebsd.org with unsubscribe freebsd-hackers in the body of the message
sigaction inconsistancy (here I go again)
Hi, Running -current... I'm trying to verify SIGFPE handling and am finding some interesting issues. In the following test program, a divide by zero is done and the SIGFPE delivered. $ ./fp sig == 8 code== 0 z has the value 1.00 It seems that from machine/trap.h the value of code should have been: /* codes for SIGFPE/ARITHTRAP */ #define FPE_FLTDIV_TRAP 0x3 /* floating/decimal divide by zero */ ie: 3 and not 0. Also, I haven't gone into the code yet, but the floating point registers are not saved into the sigcontext so that they can be inspected and modified as appropriate. Thanks, John ps: I also noted that SA_RESTART is not documented in the man page with the other mask bits, but instead is mentioned in a follow-on statement. Just slightly misleading. -- #include stdio.h #include floatingpoint.h #include signal.h void fphand(int sig, int code, struct sigcontext *scp) { fprintf(stderr,"sig == %d\n",sig); fprintf(stderr,"code== %d\n",code); return; } void setup() { int rc; struct sigaction act, oact; act.sa_handler = fphand; act.sa_mask= 0; act.sa_flags = SA_RESTART; /* not doc'd in man page */ rc = sigaction(SIGFPE, act, oact); if (rc) { perror("sigaction"); exit(1); } return; } double doit(double x, double y) { return(x / y); } int main() { double x,y,z; fp_except_t mask = FP_X_DZ; setup(); fpsetmask(mask); x = 1.0; y = 0.0; z = doit(x,y); printf("z has the value %f\n",z); return((int) z); } To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
sigaction inconsistancy (here I go again)
Hi, Running -current... I'm trying to verify SIGFPE handling and am finding some interesting issues. In the following test program, a divide by zero is done and the SIGFPE delivered. $ ./fp sig == 8 code== 0 z has the value 1.00 It seems that from machine/trap.h the value of code should have been: /* codes for SIGFPE/ARITHTRAP */ #define FPE_FLTDIV_TRAP 0x3 /* floating/decimal divide by zero */ ie: 3 and not 0. Also, I haven't gone into the code yet, but the floating point registers are not saved into the sigcontext so that they can be inspected and modified as appropriate. Thanks, John ps: I also noted that SA_RESTART is not documented in the man page with the other mask bits, but instead is mentioned in a follow-on statement. Just slightly misleading. -- #include stdio.h #include floatingpoint.h #include signal.h void fphand(int sig, int code, struct sigcontext *scp) { fprintf(stderr,sig == %d\n,sig); fprintf(stderr,code== %d\n,code); return; } void setup() { int rc; struct sigaction act, oact; act.sa_handler = fphand; act.sa_mask= 0; act.sa_flags = SA_RESTART; /* not doc'd in man page */ rc = sigaction(SIGFPE, act, oact); if (rc) { perror(sigaction); exit(1); } return; } double doit(double x, double y) { return(x / y); } int main() { double x,y,z; fp_except_t mask = FP_X_DZ; setup(); fpsetmask(mask); x = 1.0; y = 0.0; z = doit(x,y); printf(z has the value %f\n,z); return((int) z); } To Unsubscribe: send mail to majord...@freebsd.org with unsubscribe freebsd-hackers in the body of the message