[Openmcl-devel] Floating point exceptions on Windows
R. Matthew Emerson
rme at clozure.com
Tue May 5 13:29:28 EDT 2009
On May 3, 2009, at 11:18 AM, Martin wrote:
> I am using CCL 1.3-r11949 on Windows XP SP2 and have a problem with
> floating point exception propagation.
> Now, I have a file app1.c with a function with the following code
> __declspec(dllexport) double fn1 ()
> double zero = 0;
> return 1.0/zero;
> I compiled it into a DLL (Using MS Visual C++ 2005 Express Edition)
> the following command:
> cl /LD app1.c
> to yield app1.dll.
> Using it in CCL:
> Welcome to Clozure Common Lisp Version 1.3-r11949M (WindowsX8632)!
> ? (open-shared-library "D:/studies/floats/app1/app1.dll")
> #<SHLIB app1.dll #x89DED5E>
> ? (ff-call (%reference-external-entry-point (external
> "fn1")) :double-float)
> ? (log 10)
>> Error: DIVISION-BY-ZERO detected
>> performing LOG on (10.0)
>> While executing: CCL::%FP-ERROR-FROM-STATUS, in process listener(1).
>> Type :POP to abort, :R for a list of available restarts.
>> Type :? for other options.
> 1 >
This is kind of a long shot, but...if you disassemble fn1(), does it
use x87 or SSE2 instructions?
On non-Darwin x8632 systems (including Windows), we assume that
foreign code will use the x87 for floating-point operations. After
the ff-call, we therefore will look at the x87 state to see if the
foreign code signaled any fp exceptions. If the foreign code uses
SS2E, we won't notice any exceptiopns (because we're looking for them
in the wrong place: the x87 state, and not the mxcsr).
> 2. How can I disable floating point exceptions from within CCL?
The manual documents SET-FPU-MODE and GET-FPU-MODE, which will let you
More information about the Openmcl-devel