]> www.ginac.de Git - cln.git/blob - src/float/dfloat/elem/cl_DF_globals.cc
Replace CL_REQUIRE/CL_PROVIDE(cl_DF_globals) with portable code.
[cln.git] / src / float / dfloat / elem / cl_DF_globals.cc
1 // Global variables for cl_DF.
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_DF.h"
8
9
10 // Implementation.
11
12 namespace cln {
13
14 const cl_DF cl_DF_0 = cl_DF_0;
15 const cl_DF cl_DF_1 = cl_DF_1;
16 const cl_DF cl_DF_minus1 = cl_DF_minus1;
17
18 int cl_DF_globals_init_helper::count = 0;
19
20 cl_DF_globals_init_helper::cl_DF_globals_init_helper()
21 {
22         if (count++ == 0) {
23 #if (cl_word_size == 64)
24                 new ((void *)&cl_DF_0) cl_DF(allocate_dfloat(0)); // 0.0d0
25                 new ((void *)&cl_DF_1) cl_DF(encode_DF(0, 1, bit(DF_mant_len))); // 1.0d0
26                 new ((void *)&cl_DF_minus1) cl_DF(encode_DF(-1,1,bit(DF_mant_len))); // -1.0d0
27 #else
28                 new ((void *)&cl_DF_0) cl_DF(allocate_dfloat(0, 0)); // 0.0d0
29                 new ((void *)&cl_DF_1) cl_DF(encode_DF(0, 1, bit(DF_mant_len - 32), 0)); // 1.0d0
30                 new ((void *)&cl_DF_minus1) cl_DF(encode_DF(-1, 1, bit(DF_mant_len - 32), 0)); // -1.0d0
31 #endif
32         }
33 }
34 cl_DF_globals_init_helper::~cl_DF_globals_init_helper()
35 {
36         if (--count == 0) {
37                 // Nothing to clean up
38         }
39 }
40
41 }  // namespace cln
42