]> www.ginac.de Git - cln.git/commitdiff
Get rid of CL_REQUIRE/CL_PROVIDE(cl_F_eulerconst_var).
authorAlexei Sheplyakov <varg@theor.jinr.ru>
Thu, 21 Aug 2008 16:27:17 +0000 (20:27 +0400)
committerAlexei Sheplyakov <varg@theor.jinr.ru>
Wed, 27 Aug 2008 04:41:07 +0000 (08:41 +0400)
Turn cl_[SDFL]F_eulerconst 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_eulerconst.cc
src/float/transcendental/cl_F_eulerconst_def.cc
src/float/transcendental/cl_F_eulerconst_f.cc
src/float/transcendental/cl_F_eulerconst_var.cc
src/float/transcendental/cl_F_tran.h
src/float/transcendental/cl_LF_eulerconst.cc

index 4f25dc0e34c4a3259ee85363fd6135d88b76a5d2..701811a49ba1fffb574afcf0362f2c4d90635e72 100644 (file)
@@ -679,9 +679,6 @@ extern const cl_F eulerconst (float_format_t f);
 // eulerconst() liefert die Eulersche Konstante im Default-Float-Format.
 extern const cl_F eulerconst (void);
 
-//CL_REQUIRE(cl_F_eulerconst_var)
-
-
 // catalanconst(y) liefert die Catalansche Konstante
 // im selben Float-Format wie y.
 // > y: ein Float
index 8650ed85879e097645692df57c04590803eb9a8e..1d393f862e1ee32172809bf9d9213547e0b11002 100644 (file)
@@ -18,9 +18,9 @@ namespace cln {
 const cl_F eulerconst (const cl_F& y)
 {
        floattypecase(y
-       ,       return cl_SF_eulerconst;
-       ,       return cl_FF_eulerconst;
-       ,       return cl_DF_eulerconst;
+       ,       return cl_SF_eulerconst();
+       ,       return cl_FF_eulerconst();
+       ,       return cl_DF_eulerconst();
        ,       return eulerconst(TheLfloat(y)->len);
        );
 }
index 9a149a8ba850da2498c202d2092590dab5b1de93..777924fcd622ebba2be5058d007b411126d7f440 100644 (file)
@@ -17,9 +17,9 @@ namespace cln {
 const cl_F eulerconst (void)
 {
        floatformatcase(default_float_format
-       ,       return cl_SF_eulerconst;
-       ,       return cl_FF_eulerconst;
-       ,       return cl_DF_eulerconst;
+       ,       return cl_SF_eulerconst();
+       ,       return cl_FF_eulerconst();
+       ,       return cl_DF_eulerconst();
        ,       return eulerconst(len);
        );
 }
index e97e2cbe6019109fc5c4bf305f1a81c104bc233a..e4e445cc802847ae2e6082afa13e5bc97d4c15b2 100644 (file)
@@ -17,9 +17,9 @@ namespace cln {
 const cl_F eulerconst (float_format_t f)
 {
        floatformatcase((uintC)f
-       ,       return cl_SF_eulerconst;
-       ,       return cl_FF_eulerconst;
-       ,       return cl_DF_eulerconst;
+       ,       return cl_SF_eulerconst();
+       ,       return cl_FF_eulerconst();
+       ,       return cl_DF_eulerconst();
        ,       return eulerconst(len);
        );
 }
index 153a4a1925aaf3b68fc28af8bc8509490ddd5f77..b6339556eee881f4cf03328775bfe6de823b2588 100644 (file)
@@ -3,8 +3,6 @@
 // General includes.
 #include "cl_sysdep.h"
 
-CL_PROVIDE(cl_F_eulerconst_var)
-
 // Specification.
 #include "cl_F_tran.h"
 
@@ -18,20 +16,35 @@ CL_PROVIDE(cl_F_eulerconst_var)
 
 namespace cln {
 
-// Mantisse der Eulerschen Konstante :
-  static const uintD eulerconst_mantisse [64/intDsize] =
-    #include "cl_F_eulerconst_var.h"
-
-cl_LF cl_LF_eulerconst = encode_LF_array(0,0,eulerconst_mantisse,64/intDsize);
+cl_LF& cl_LF_eulerconst()
+{
+       // Mantisse der Eulerschen Konstante :
+       static const uintD eulerconst_mantisse [64/intDsize] =
+               #include "cl_F_eulerconst_var.h"
+       static cl_LF val = encode_LF_array(0,0,eulerconst_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_eulerconst = cl_LF_to_SF(cl_LF_eulerconst);
-const cl_FF cl_FF_eulerconst = cl_LF_to_FF(cl_LF_eulerconst);
-const cl_DF cl_DF_eulerconst = cl_LF_to_DF(cl_LF_eulerconst);
+const cl_SF& cl_SF_eulerconst()
+{
+       static const cl_SF val = cl_LF_to_SF(cl_LF_eulerconst());
+       return val;
+}
+const cl_FF& cl_FF_eulerconst()
+{
+       static const cl_FF val = cl_LF_to_FF(cl_LF_eulerconst());
+       return val;
+}
+
+const cl_DF& cl_DF_eulerconst()
+{
+       static const cl_DF val = cl_LF_to_DF(cl_LF_eulerconst());
+       return val;
+}
 
 }  // namespace cln
 
-CL_PROVIDE_END(cl_F_eulerconst_var)
index 06395bceef3efda3cd43ae7722efcda7ff865021..10d7af33524fe61d97812c331546f7a0f9412c3b 100644 (file)
@@ -126,10 +126,10 @@ extern const cl_LF expx_naive (const cl_LF& x); // requires cl_F_extendsqrtx
 extern const cl_LF expx_ratseries (const cl_LF& x); // requires extend by 1
 
 // Eulersche Konstante.
-extern const cl_SF cl_SF_eulerconst;
-extern const cl_FF cl_FF_eulerconst;
-extern const cl_DF cl_DF_eulerconst;
-extern cl_LF cl_LF_eulerconst; // as long as it has ever been computed
+extern const cl_SF& cl_SF_eulerconst();
+extern const cl_FF& cl_FF_eulerconst();
+extern const cl_DF& cl_DF_eulerconst();
+extern cl_LF& cl_LF_eulerconst(); // as long as it has ever been computed
 extern const cl_LF eulerconst (uintC len); // computes it even further
 
 // Catalansche Konstante.
index 0cc8bbfc00670ece9e8058c723751bf7ae00499a..998b4b57ea07721755fa21d06e1d89fa8b726b3d 100644 (file)
@@ -507,13 +507,13 @@ const cl_LF compute_eulerconst (uintC len)
 
 const cl_LF eulerconst (uintC len)
 {
-       var uintC oldlen = TheLfloat(cl_LF_eulerconst)->len; // vorhandene Länge
+       var uintC oldlen = TheLfloat(cl_LF_eulerconst())->len; // vorhandene Länge
        if (len < oldlen)
-               return shorten(cl_LF_eulerconst,len);
+               return shorten(cl_LF_eulerconst(),len);
        if (len == oldlen)
-               return cl_LF_eulerconst;
+               return cl_LF_eulerconst();
 
-       // TheLfloat(cl_LF_eulerconst)->len um mindestens einen konstanten Faktor
+       // TheLfloat(cl_LF_eulerconst())->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
@@ -521,8 +521,8 @@ const cl_LF eulerconst (uintC len)
                newlen = oldlen;
 
        // gewünschte > vorhandene Länge -> muß nachberechnen:
-       cl_LF_eulerconst = compute_eulerconst(newlen);
-       return (len < newlen ? shorten(cl_LF_eulerconst,len) : cl_LF_eulerconst);
+       cl_LF_eulerconst() = compute_eulerconst(newlen);
+       return (len < newlen ? shorten(cl_LF_eulerconst(),len) : cl_LF_eulerconst());
 }
 
 }  // namespace cln