Return to BSD News archive
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!news.Hawaii.Edu!ames!hookup!swrinde!emory!europa.eng.gtefsd.com!newsxfer.itd.umich.edu!nntp.cs.ubc.ca!cs.ubc.ca!usenet
From: coatta@cs.ubc.ca (Terry Coatta)
Newsgroups: comp.os.386bsd.bugs
Subject: Floating Point Exceptions
Followup-To: comp.os.386bsd.bugs
Date: 4 Aug 1994 05:02:01 GMT
Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
Lines: 41
Distribution: world
Message-ID: <31pso9$4bb@cs.ubc.ca>
NNTP-Posting-Host: coatta.home.cs.ubc.ca
In porting an application to FreeBSD (1.1.5), I discovered that it was
dumping core due to SIGFPE's. The application was expecting certain
mat operations to simply set ``errno'' when an error condition occrred,
whereas it seemed that FreeBSD was raising SIGFPE.
I got around the problem by inserting code to manipulate the floating
point execption mask at the necessary points in the code. My first
bash looked something like:
oldMask = fpsetmask(0);
...math operation...
sticky = fpgetsticky();
fpresetsticky(sticky);
fpsetmask(oldMask);
These supressed the SIGFPE's as desired, but after the application ran for a
bit the floating point exception mask would end up changing values causing the
applciation to dump core elsewhere. After pulling out a considerable amount of
hair I changed the code to:
oldMask = fpgetmask();
fpsetmask(0);
...math operation...
sticky = fpgetsticky();
fpresetsticky(sticky);
fpsetmask(oldMask);
This new improved code seems to work without flaw. Now... my reading of the
man pages suggests that:
oldMask = fpsetmask(0);
and
oldMask = fpgetmask();
fpsetmask(0);
should be equivalent. However, that is contradicted by my actual experience.
So, is this a bug? Or did I just not read the man pages right?