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.
// exp1() liefert die Zahl e = exp(1) im Default-Float-Format.
extern const cl_F exp1 (void);
// 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);
// ln(x) liefert zu einem Float x>0 die Zahl ln(x).
extern const cl_F ln (const cl_F& x);
const cl_F exp1 (const cl_F& y)
{
floattypecase(y
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);
);
}
, return exp1(TheLfloat(y)->len);
);
}
const cl_F exp1 (void)
{
floatformatcase(default_float_format
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();
const cl_F exp1 (float_format_t f)
{
floatformatcase((uintC)f
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();
// General includes.
#include "cl_sysdep.h"
// General includes.
#include "cl_sysdep.h"
-CL_PROVIDE(cl_F_exp1_var)
-
// Specification.
#include "cl_F_tran.h"
// Specification.
#include "cl_F_tran.h"
-// 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. ??
// 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;
+}
-CL_PROVIDE_END(cl_F_exp1_var)
extern const cl_F cl_ln10 (float_format_t f);
// e = exp(1).
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.
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.
const cl_LF 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
- return shorten(cl_LF_exp1,len);
+ return shorten(cl_LF_exp1(),len);
- // 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
// > 1 wachsen lassen, damit es nicht zu häufig nachberechnet wird:
var uintC newlen = len;
oldlen += floor(oldlen,2); // oldlen * 3/2
newlen = oldlen;
// gewünschte > vorhandene Länge -> muß nachberechnen:
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());