R-alpha: Linux floating point fix

Thomas Lumley (thomas@biostat.washington.edu)
Sun, 17 Nov 1996 11:12:43 -0800 (PST)


Date: Sun, 17 Nov 1996 11:12:43 -0800 (PST)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: r-testers@stat.math.ethz.ch
Subject: R-alpha: Linux floating point fix
In-Reply-To: <Pine.SUN.3.91.961117100911.1500A-100000@chekov>


Appended is a program for Linux that switches the floating point error
handling between the Linux default (exceptions on NaN, division by zero,
overflow) and the IEEE default (no exceptions).  Compile and dyn.load it as
described in the dyn.load demo and use: 

.C("nosigfpe") to turn off floating point exceptions and
.C("sigfpe") to turn them back on (I don't know why you would want to...)

It appears that R can mysteriously lose its ability to ignore floating 
point errors (eg log(-1)) when code is dynamically loaded. The 
survival4 library does this. Possibly the _init code in the loaded 
library is responsible.  This may explain the conflicting messages about 
log(-1) under Linux-ELF.

thomas lumley
UW biostat
-----------------------------snip------------------------

#include <fpu_control.h>
void nosigfpe()
{
__setfpucw(_FPU_IEEE);
};

void sigfpe()
{
__setfpucw(_FPU_DEFAULT);
}


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-