]> www.ginac.de Git - cln.git/commitdiff
Get rid of CL_REQUIRE/CL_PROVIDE(cl_F_ln10_var).
authorAlexei Sheplyakov <varg@theor.jinr.ru>
Thu, 21 Aug 2008 14:14:24 +0000 (18:14 +0400)
committerAlexei Sheplyakov <varg@theor.jinr.ru>
Wed, 27 Aug 2008 04:41:06 +0000 (08:41 +0400)
Turn cl_[SDFL]F_ln10 global variables into functions (which return a constant
reference to the static value) in order to avoid static initialization order
problems.

src/float/output/cl_F_dprint.cc
src/float/transcendental/cl_F_ln10.cc
src/float/transcendental/cl_F_ln10_f.cc
src/float/transcendental/cl_F_ln10_var.cc
src/float/transcendental/cl_F_tran.h
src/float/transcendental/cl_LF_ln10.cc

index 83f3db214f958dfd5c3f62e49fa4b37f9a2491a4..e3deccc79689296c942618077a4aabb98cfe6fcd 100644 (file)
@@ -28,7 +28,6 @@
 //   einen String mit seiner Dezimaldarstellung.
 // (substring string start [end]) wie subseq, jedoch für Strings schneller.
 
-CL_REQUIRE(cl_F_ln10_var)
 #include <cstring>
 #include "cln/output.h"
 #include "cl_sstring.h"
index f6367bfbb4535b065f9e1f646dc82fc204d63c7e..b3d581e6cc22f5ffe3618af6b97746811dd4c46d 100644 (file)
@@ -17,9 +17,9 @@ namespace cln {
 const cl_F cl_ln10 (const cl_F& y)
 {
        floattypecase(y
-       ,       return cl_SF_ln10;
-       ,       return cl_FF_ln10;
-       ,       return cl_DF_ln10;
+       ,       return cl_SF_ln10();
+       ,       return cl_FF_ln10();
+       ,       return cl_DF_ln10();
        ,       return cl_ln10(TheLfloat(y)->len);
        );
 }
index 2c0332b2b89b55fe1f0264b03ce33aa387417ce5..74aa5ce9ba0c276ebb82efea7563ab050b96f661 100644 (file)
@@ -16,9 +16,9 @@ namespace cln {
 const cl_F cl_ln10 (float_format_t f)
 {
        floatformatcase((uintC)f
-       ,       return cl_SF_ln10;
-       ,       return cl_FF_ln10;
-       ,       return cl_DF_ln10;
+       ,       return cl_SF_ln10();
+       ,       return cl_FF_ln10();
+       ,       return cl_DF_ln10();
        ,       return cl_ln10(len);
        );
 }
index 46a1e8de689b8fdc628b498e2e068fa3f9d421a6..4cc443db5096c3aa764d04fbde50a20ba580b78e 100644 (file)
@@ -3,8 +3,6 @@
 // General includes.
 #include "cl_sysdep.h"
 
-CL_PROVIDE(cl_F_ln10_var)
-
 // Specification.
 #include "cl_F_tran.h"
 
@@ -18,20 +16,36 @@ CL_PROVIDE(cl_F_ln10_var)
 
 namespace cln {
 
-// Mantisse von ln(10) :
-  static const uintD ln10_mantisse [64/intDsize] =
-    #include "cl_F_ln10_var.h"
-
-cl_LF cl_LF_ln10 = encode_LF_array(0,2,ln10_mantisse,64/intDsize);
+cl_LF& cl_LF_ln10()
+{
+       // Mantisse von ln(10) :
+       static const uintD ln10_mantisse [64/intDsize] =
+               #include "cl_F_ln10_var.h"
+       static cl_LF val = encode_LF_array(0,2,ln10_mantisse,64/intDsize);
+       return val;
+}
 
 // Problem: If someone changes free_hook, the destructor of this
 // will call the new hook, passing it some pointer obtained by the old
 // malloc_hook. ??
 
-const cl_SF cl_SF_ln10 = cl_LF_to_SF(cl_LF_ln10);
-const cl_FF cl_FF_ln10 = cl_LF_to_FF(cl_LF_ln10);
-const cl_DF cl_DF_ln10 = cl_LF_to_DF(cl_LF_ln10);
+const cl_SF& cl_SF_ln10()
+{
+       static const cl_SF val = cl_LF_to_SF(cl_LF_ln10());
+       return val;
+}
+
+const cl_FF& cl_FF_ln10()
+{
+       static const cl_FF val = cl_LF_to_FF(cl_LF_ln10());
+       return val;
+}
+
+const cl_DF& cl_DF_ln10()
+{
+       static const cl_DF val = cl_LF_to_DF(cl_LF_ln10());
+       return val;
+}
 
 }  // namespace cln
 
-CL_PROVIDE_END(cl_F_ln10_var)
index 5ad4da0cdcb3161ec42f714b30cc865871ac2638..b91d00c3dd9e9eb88ae7cc73b3b847f91028b8c1 100644 (file)
@@ -99,12 +99,11 @@ extern const cl_F cl_ln2 (const cl_F& y);
 extern const cl_F cl_ln2 (float_format_t f);
 
 // ln(10).
-extern const cl_SF cl_SF_ln10;
-extern const cl_FF cl_FF_ln10;
-extern const cl_DF cl_DF_ln10;
-extern cl_LF cl_LF_ln10; // as long as it has ever been computed
+extern const cl_SF& cl_SF_ln10();
+extern const cl_FF& cl_FF_ln10();
+extern const cl_DF& cl_DF_ln10();
+extern cl_LF& cl_LF_ln10(); // as long as it has ever been computed
 extern const cl_LF cl_ln10 (uintC len); // computes it even further
-//CL_REQUIRE(cl_F_ln10_var)
 
 // cl_ln10(y) liefert die Zahl ln(10) im selben Float-Format wie y.
 // > y: ein Float
index ae57e3321189bb61c5f3008c77bb70b6378bc88f..ddf25c2a6b6484b56c95f2cd7d267ee455620b12 100644 (file)
@@ -48,13 +48,13 @@ static inline const cl_LF compute_ln10_p2357 (uintC len)
 
 const cl_LF cl_ln10 (uintC len)
 {
-       var uintC oldlen = TheLfloat(cl_LF_ln10)->len; // vorhandene Länge
+       var uintC oldlen = TheLfloat(cl_LF_ln10())->len; // vorhandene Länge
        if (len < oldlen)
-               return shorten(cl_LF_ln10,len);
+               return shorten(cl_LF_ln10(),len);
        if (len == oldlen)
-               return cl_LF_ln10;
+               return cl_LF_ln10();
 
-       // TheLfloat(cl_LF_ln10)->len um mindestens einen konstanten Faktor
+       // TheLfloat(cl_LF_ln10())->len um mindestens einen konstanten Faktor
        // > 1 wachsen lassen, damit es nicht zu häufig nachberechnet wird:
        var uintC newlen = len;
        oldlen += floor(oldlen,2); // oldlen * 3/2
@@ -62,8 +62,8 @@ const cl_LF cl_ln10 (uintC len)
                newlen = oldlen;
 
        // gewünschte > vorhandene Länge -> muß nachberechnen:
-       cl_LF_ln10 = compute_ln10(newlen);
-       return (len < newlen ? shorten(cl_LF_ln10,len) : cl_LF_ln10);
+       cl_LF_ln10() = compute_ln10(newlen);
+       return (len < newlen ? shorten(cl_LF_ln10(),len) : cl_LF_ln10());
 }
 
 }  // namespace cln