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

include/cln/float.h
src/float/transcendental/cl_F_exp1.cc
src/float/transcendental/cl_F_exp1_def.cc
src/float/transcendental/cl_F_exp1_f.cc
src/float/transcendental/cl_F_exp1_var.cc
src/float/transcendental/cl_F_tran.h
src/float/transcendental/cl_LF_exp1.cc

index 48a83b8abe8ad1a43ce6b2ff4b79140c66c19438..4f25dc0e34c4a3259ee85363fd6135d88b76a5d2 100644 (file)
@@ -636,8 +636,6 @@ extern const cl_F exp1 (float_format_t f);
 // exp1() liefert die Zahl e = exp(1) im Default-Float-Format.
 extern const cl_F exp1 (void);
 
-//CL_REQUIRE(cl_F_exp1_var)
-
 
 // ln(x) liefert zu einem Float x>0 die Zahl ln(x).
 extern const cl_F ln (const cl_F& x);
index 96fe892d2fd868a75882b6c5aa978b66a9c8b8d4..08ef3d7f8ee2f8c15f8de11cd46d7d2cf3850df7 100644 (file)
@@ -18,9 +18,9 @@ namespace cln {
 const cl_F exp1 (const cl_F& y)
 {
        floattypecase(y
-       ,       return cl_SF_exp1;
-       ,       return cl_FF_exp1;
-       ,       return cl_DF_exp1;
+       ,       return cl_SF_exp1();
+       ,       return cl_FF_exp1();
+       ,       return cl_DF_exp1();
        ,       return exp1(TheLfloat(y)->len);
        );
 }
index ee74b0583b7b955ad909240419b5eb431ba85e57..cc50f69490267d9c34b6601cc394fb1fcfbf5dc1 100644 (file)
@@ -17,9 +17,9 @@ namespace cln {
 const cl_F exp1 (void)
 {
        floatformatcase(default_float_format
-       ,       return cl_SF_exp1;
-       ,       return cl_FF_exp1;
-       ,       return cl_DF_exp1;
+       ,       return cl_SF_exp1();
+       ,       return cl_FF_exp1();
+       ,       return cl_DF_exp1();
        ,       return exp1(len);
        );
 }
index 1e18b6d9ef0d8a2a7ee0d4d789c381d69f28ed52..aa8c451556930397e58a9910aad164bf3fb4a8fb 100644 (file)
@@ -17,9 +17,9 @@ namespace cln {
 const cl_F exp1 (float_format_t f)
 {
        floatformatcase((uintC)f
-       ,       return cl_SF_exp1;
-       ,       return cl_FF_exp1;
-       ,       return cl_DF_exp1;
+       ,       return cl_SF_exp1();
+       ,       return cl_FF_exp1();
+       ,       return cl_DF_exp1();
        ,       return exp1(len);
        );
 }
index a68310d2cb83be5b4a1154d00aa7aa093ee59e98..e9b91b33fabb2e3ccf38603a7ba34fce5d14f4c2 100644 (file)
@@ -3,8 +3,6 @@
 // General includes.
 #include "cl_sysdep.h"
 
-CL_PROVIDE(cl_F_exp1_var)
-
 // Specification.
 #include "cl_F_tran.h"
 
@@ -18,20 +16,36 @@ CL_PROVIDE(cl_F_exp1_var)
 
 namespace cln {
 
-// Mantisse von exp(1) :
-  static const uintD exp1_mantisse [64/intDsize] =
-    #include "cl_F_exp1_var.h"
-
-cl_LF cl_LF_exp1 = encode_LF_array(0,2,exp1_mantisse,64/intDsize);
+cl_LF& cl_LF_exp1()
+{
+       // Mantisse von exp(1) :
+       static const uintD exp1_mantisse [64/intDsize] =
+               #include "cl_F_exp1_var.h"
+       static cl_LF val = encode_LF_array(0,2,exp1_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_exp1 = cl_LF_to_SF(cl_LF_exp1);
-const cl_FF cl_FF_exp1 = cl_LF_to_FF(cl_LF_exp1);
-const cl_DF cl_DF_exp1 = cl_LF_to_DF(cl_LF_exp1);
+const cl_SF& cl_SF_exp1()
+{
+       static const cl_SF val = cl_LF_to_SF(cl_LF_exp1());
+       return val;
+}
+
+const cl_FF& cl_FF_exp1()
+{
+       static const cl_FF val = cl_LF_to_FF(cl_LF_exp1());
+       return val;
+}
+
+const cl_DF& cl_DF_exp1()
+{
+       static const cl_DF val = cl_LF_to_DF(cl_LF_exp1());
+       return val;
+}
 
 }  // namespace cln
 
-CL_PROVIDE_END(cl_F_exp1_var)
index b91d00c3dd9e9eb88ae7cc73b3b847f91028b8c1..06395bceef3efda3cd43ae7722efcda7ff865021 100644 (file)
@@ -114,10 +114,10 @@ extern const cl_F cl_ln10 (const cl_F& y);
 extern const cl_F cl_ln10 (float_format_t f);
 
 // e = exp(1).
-extern const cl_SF cl_SF_exp1;
-extern const cl_FF cl_FF_exp1;
-extern const cl_DF cl_DF_exp1;
-extern cl_LF cl_LF_exp1; // as long as it has ever been computed
+extern const cl_SF& cl_SF_exp1();
+extern const cl_FF& cl_FF_exp1();
+extern const cl_DF& cl_DF_exp1();
+extern cl_LF& cl_LF_exp1(); // as long as it has ever been computed
 extern const cl_LF exp1 (uintC len); // computes it even further
 
 // expx(x) liefert zu einem Float x (betragsmäßig <1) exp(x) als Float.
index 286fad13c2148ce379791f9bc7e5d67618dff7a1..70f79cc3a0bfec6768699861f9abdd2e2a22d9b4 100644 (file)
@@ -78,13 +78,13 @@ const cl_LF compute_exp1 (uintC len)
 
 const cl_LF exp1 (uintC len)
 {
-       var uintC oldlen = TheLfloat(cl_LF_exp1)->len; // vorhandene Länge
+       var uintC oldlen = TheLfloat(cl_LF_exp1())->len; // vorhandene Länge
        if (len < oldlen)
-               return shorten(cl_LF_exp1,len);
+               return shorten(cl_LF_exp1(),len);
        if (len == oldlen)
-               return cl_LF_exp1;
+               return cl_LF_exp1();
 
-       // TheLfloat(cl_LF_exp1)->len um mindestens einen konstanten Faktor
+       // TheLfloat(cl_LF_exp1())->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
@@ -92,8 +92,8 @@ const cl_LF exp1 (uintC len)
                newlen = oldlen;
 
        // gewünschte > vorhandene Länge -> muß nachberechnen:
-       cl_LF_exp1 = compute_exp1(newlen); // (exp 1)
-       return (len < newlen ? shorten(cl_LF_exp1,len) : cl_LF_exp1);
+       cl_LF_exp1() = compute_exp1(newlen); // (exp 1)
+       return (len < newlen ? shorten(cl_LF_exp1(),len) : cl_LF_exp1());
 }
 
 }  // namespace cln