[Rd] i386 floating point tweaking
Mon, 18 Nov 2002 17:57:47 +0000
Just been trying to get the polygon triangulation code from this
package: http://www-2.cs.cmu.edu/~quake/triangle.html to dyn.load into
R. Uh oh. Floating point exceptions.
Track it down to some FPU diddling that the author deems is necessary.
Here's my minimal code that breaks:
Compile with "R SHLIB flipme.c", then dyn.load and run:
Process R floating point exception at Mon Nov 18 17:41:50 2002
The debugger tells me its the printf line that kills it.
Anyone have an idea what's going on here? I've tried a few things:
* using _FPU_GETCW I've determined that R hasn't changed the control
word from the system default.
* I wrote a short main program that used dlopen() to call flipme - and
it worked fine, so the problem isn't intrinsic to dynamically loaded code.
* the author of the triangle package has put this in the code that
manipulates the FPU control word:
/* Don't change this routine unless you fully understand it.
- I dont understand it, I changed it, the code broke.
Anyone with deeper understanding of floating point, iee754, and
assorted other Recipes For Chaos (RFCs) care to comment before we go
back to using a file or a pipe to communicate between R and the code?