From 03a227b7346dfd02b1e2623468f4a2cfc3e05f6e Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Thu, 21 Aug 2008 16:06:02 +0400 Subject: [PATCH] Get rid CL_REQUIRE/CL_PROVIDE(cl_F_mostpos), it is not really necessary. Move static variables most_positive_[SFDL]F into most_positive_LF() function (which is the only user of those variables) in order to avoid possible static order initialization problems. While at it, make most_positive_LF() function static. --- include/cln/float.h | 1 - src/float/misc/cl_F_mostpos.cc | 35 ++++++++++++++++------------------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/include/cln/float.h b/include/cln/float.h index 5032cbe..6a3f9bf 100644 --- a/include/cln/float.h +++ b/include/cln/float.h @@ -556,7 +556,6 @@ extern const cl_F signum (const cl_F& x); // Returns the largest (most positive) floating point number in float format f. extern const cl_F most_positive_float (float_format_t f); -//CL_REQUIRE(cl_F_mostpos) // Returns the smallest (most negative) floating point number in float format f. extern const cl_F most_negative_float (float_format_t f); diff --git a/src/float/misc/cl_F_mostpos.cc b/src/float/misc/cl_F_mostpos.cc index c8e413d..d273db5 100644 --- a/src/float/misc/cl_F_mostpos.cc +++ b/src/float/misc/cl_F_mostpos.cc @@ -3,8 +3,6 @@ // General includes. #include "cl_sysdep.h" -CL_PROVIDE(cl_F_mostpos) - // Specification. #include "cln/float.h" @@ -19,22 +17,7 @@ CL_PROVIDE(cl_F_mostpos) namespace cln { -// Exponent so groß wie möglich, Mantisse 1...1, Vorzeichen +. - -static const cl_SF most_positive_SF = - make_SF(0,SF_exp_high,bit(SF_mant_len+1)-1); - -static const cl_FF most_positive_FF = - encode_FF(0,FF_exp_high-FF_exp_mid,bit(FF_mant_len+1)-1); - -static const cl_DF most_positive_DF = -#if (cl_word_size==64) - encode_DF(0,DF_exp_high-DF_exp_mid,bit(DF_mant_len+1)-1); -#else - encode_DF(0,DF_exp_high-DF_exp_mid,bit(DF_mant_len-32+1)-1,bitm(32)-1); -#endif - -inline const cl_LF most_positive_LF (uintC len) +static inline const cl_LF most_positive_LF (uintC len) { var Lfloat erg = allocate_lfloat(len,LF_exp_high,0); fill_loop_up(&TheLfloat(erg)->data[0],len,~(uintD)0); @@ -43,6 +26,21 @@ inline const cl_LF most_positive_LF (uintC len) const cl_F most_positive_float (float_format_t f) { + // Exponent so groß wie möglich, Mantisse 1...1, Vorzeichen +. + + static const cl_SF most_positive_SF = + make_SF(0,SF_exp_high,bit(SF_mant_len+1)-1); + + static const cl_FF most_positive_FF = + encode_FF(0,FF_exp_high-FF_exp_mid,bit(FF_mant_len+1)-1); + + static const cl_DF most_positive_DF = +#if (cl_word_size==64) + encode_DF(0,DF_exp_high-DF_exp_mid,bit(DF_mant_len+1)-1); +#else + encode_DF(0,DF_exp_high-DF_exp_mid,bit(DF_mant_len-32+1)-1,bitm(32)-1); +#endif + floatformatcase((uintC)f , return most_positive_SF; , return most_positive_FF; @@ -53,4 +51,3 @@ const cl_F most_positive_float (float_format_t f) } // namespace cln -CL_PROVIDE_END(cl_F_mostpos)