]> www.ginac.de Git - cln.git/blob - src/float/base/cl_ieee.cc
Replace CL_REQUIRE/CL_PROVIDE(cl_DF_globals) with portable code.
[cln.git] / src / float / base / cl_ieee.cc
1 // System dependent IEEE floating-point coprocessor initialization.
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 CL_PROVIDE(cl_ieee)
7
8 // Specification.
9 #include "cl_ieee.h"
10
11
12 // Implementation.
13
14 #include "cl_FF.h"
15 #include "cl_DF.h"
16 #include "cl_float_config.h"
17
18 #if (defined(linux) || defined(__linux)) && (defined(FAST_FLOAT) || defined(FAST_DOUBLE))
19
20 // Division by 0.0 should return NaN and not raise an SIGFPE.
21 // For this, we either have to link with -lieee or copy some
22 // part from libc-linux/sysdeps/linux/{i386,m68k}/ieee.c:
23
24 #include <fpu_control.h>
25
26 #if 0 // Unfortunately this gives an error if also linked with -lieee
27         #if defined(HAVE_FPU_CONTROL_T)
28                 fpu_control_t __fpu_control = _FPU_IEEE;
29         #else
30                 unsigned short __fpu_control = _FPU_IEEE;
31         #endif
32 #else
33 AT_INITIALIZATION(ieee)
34 {
35         #if defined(_FPU_IEEE)
36                 #if defined(HAVE_FPU_CONTROL_T)
37                         extern fpu_control_t __fpu_control;
38                         __fpu_control = _FPU_IEEE;
39                 #elif defined(HAVE_SETFPUCW)
40                         __setfpucw(_FPU_IEEE);
41                 #else
42                         extern unsigned short __fpu_control;
43                         __fpu_control = _FPU_IEEE;
44                 #endif
45         #else
46                 // Nothing to do (as on some architectures):
47                 // probably this means that _FPU_DEFAULT is just as good as _FPU_IEEE.
48         #endif
49 }
50 #endif
51
52 #endif
53
54 namespace cln {
55
56 // This dummy links in this module whenever some module needs IEEE floats.
57 int cl_ieee_module;
58
59 }  // namespace cln
60
61 CL_PROVIDE_END(cl_ieee)