You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4932 Reporter: erwan Status: resolved (set by @xavierleroy on 2012-08-02T07:20:23Z) Resolution: suspended Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general) Monitored by: erwan @Chris00
Bug description
I've copied the example from the doc that illustrate how to call ocaml code
from a main in C.
But I would say that it would be better to do it once for all inside
caml_startup (or to fix the line that triggers the excp, but most likely it is no something dangerous).
Additional information
I've tried with 3.09.0 and 3.10.2 ; to reproduce it, just:
/* The [caml_init_ieee_float] function should initialize floating-point
hardware
so that it behaves as much as possible like the IEEE standard.
In particular, return special numbers like Infinity and NaN instead
of signalling exceptions. Currently, everyone is in IEEE mode
at program startup, except FreeBSD prior to 4.0R. */
For some reasons, I need to embed a camlruntime into a dll/so that is therefore not loaded at program startup. Hence fp signals I get when launching camlstartup (under linux and mingw).
So to sum-up, the only reasonnable solution is to fix the manual and to hint users to wrap camlstartup with fedisableexcept/
feenableexcept as I've suggested in the description section above (and to forget my note above, sorry for the noise).
ISO C99 standardizes <fenv.h> functions such as feholdexcept() to select "non-stop" float handling (no signalling exceptions). However, Microsoft doesn't implement C99, so there is still no truly portable solution.
ISO C99 also specifies that all programs start in "non-stop" mode, so the issue affects only OCaml code embedded in DLLs.
My feeling is that there is no better solution than what the reporter proposes: on the C/C++ application side, wrap calls to caml_startup() with operations appropriate to select non-stop mode and restore the original mode. In C99. that would be feholdexcept() and fesetenv(). For Win32, I have no idea.
I'm "suspending" this PR until Win32 supports C99...
Original bug ID: 4932
Reporter: erwan
Status: resolved (set by @xavierleroy on 2012-08-02T07:20:23Z)
Resolution: suspended
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Monitored by: erwan @Chris00
Bug description
I've copied the example from the doc that illustrate how to call ocaml code
from a main in C.
http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc135
and then I've add a call to
"feenableexcept(FE_INVALID);"
before the call to caml_startup(), and I get a
« Floating point exception ». The same occurs with FE_INEXACT.
The fix, from the user point of view, is quite easy : save/restore the fe flag before/after the call to caml_startup().
But I would say that it would be better to do it once for all inside
caml_startup (or to fix the line that triggers the excp, but most likely it is no something dangerous).
Additional information
I've tried with 3.09.0 and 3.10.2 ; to reproduce it, just:
File attachments
The text was updated successfully, but these errors were encountered: