]> www.ginac.de Git - cln.git/blobdiff - src/float/dfloat/elem/cl_DF_globals.cc
Finalize CLN 1.3.7 release.
[cln.git] / src / float / dfloat / elem / cl_DF_globals.cc
index f64c98ec677e6588fbee5fbe78c930f9022da5d6..4009d494670593485ff9b61277209f8d447444b6 100644 (file)
@@ -1,32 +1,42 @@
 // Global variables for cl_DF.
 
 // General includes.
-#include "cl_sysdep.h"
-
-CL_PROVIDE(cl_DF_globals)
+#include "base/cl_sysdep.h"
 
 // Specification.
-#include "cl_DF.h"
+#include "float/dfloat/cl_DF.h"
 
 
 // Implementation.
 
-#if (cl_word_size==64)
-
-const cl_DF cl_DF_0 = allocate_dfloat(0); // 0.0d0
+namespace cln {
 
-const cl_DF cl_DF_1 = encode_DF(0,1,bit(DF_mant_len)); // 1.0d0
+const cl_DF cl_DF_0 = cl_DF_0;
+const cl_DF cl_DF_1 = cl_DF_1;
+const cl_DF cl_DF_minus1 = cl_DF_minus1;
 
-const cl_DF cl_DF_minus1 = encode_DF(-1,1,bit(DF_mant_len)); // -1.0d0
+int cl_DF_globals_init_helper::count = 0;
 
+cl_DF_globals_init_helper::cl_DF_globals_init_helper()
+{
+       if (count++ == 0) {
+#if (cl_word_size == 64)
+               new ((void *)&cl_DF_0) cl_DF(allocate_dfloat(0)); // 0.0d0
+               new ((void *)&cl_DF_1) cl_DF(encode_DF(0, 1, bit(DF_mant_len))); // 1.0d0
+               new ((void *)&cl_DF_minus1) cl_DF(encode_DF(-1,1,bit(DF_mant_len))); // -1.0d0
 #else
-
-const cl_DF cl_DF_0 = allocate_dfloat(0,0); // 0.0d0
-
-const cl_DF cl_DF_1 = encode_DF(0,1,bit(DF_mant_len-32),0); // 1.0d0
-
-const cl_DF cl_DF_minus1 = encode_DF(-1,1,bit(DF_mant_len-32),0); // -1.0d0
-
+               new ((void *)&cl_DF_0) cl_DF(allocate_dfloat(0, 0)); // 0.0d0
+               new ((void *)&cl_DF_1) cl_DF(encode_DF(0, 1, bit(DF_mant_len - 32), 0)); // 1.0d0
+               new ((void *)&cl_DF_minus1) cl_DF(encode_DF(-1, 1, bit(DF_mant_len - 32), 0)); // -1.0d0
 #endif
+       }
+}
+cl_DF_globals_init_helper::~cl_DF_globals_init_helper()
+{
+       if (--count == 0) {
+               // Nothing to clean up
+       }
+}
+
+}  // namespace cln
 
-CL_PROVIDE_END(cl_DF_globals)