From d1f1de0458207ee4419088c9b90806570a59a2b0 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_leastpos), it is not really necessary. Move static variables least_positive_[SFDL]F into least_positive_LF() function (which is the only user of those variables) in order to avoid possible static order initialization problems. While at it, make least_positive_LF() function static. --- include/cln/float.h | 1 - src/float/misc/cl_F_leastpos.cc | 35 +++++++++++++++------------------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/include/cln/float.h b/include/cln/float.h index ada8a29..6a0fff5 100644 --- a/include/cln/float.h +++ b/include/cln/float.h @@ -563,7 +563,6 @@ extern const cl_F most_negative_float (float_format_t f); // Returns the least positive floating point number (i.e. > 0 but closest to 0) // in float format f. extern const cl_F least_positive_float (float_format_t f); -//CL_REQUIRE(cl_F_leastpos) // Returns the least negative floating point number (i.e. < 0 but closest to 0) // in float format f. diff --git a/src/float/misc/cl_F_leastpos.cc b/src/float/misc/cl_F_leastpos.cc index f913721..8bd1f95 100644 --- a/src/float/misc/cl_F_leastpos.cc +++ b/src/float/misc/cl_F_leastpos.cc @@ -3,8 +3,6 @@ // General includes. #include "cl_sysdep.h" -CL_PROVIDE(cl_F_leastpos) - // Specification. #include "cln/float.h" @@ -19,22 +17,7 @@ CL_PROVIDE(cl_F_leastpos) namespace cln { -// Exponent so klein wie möglich, Mantisse 10...0, Vorzeichen +. - -static const cl_SF least_positive_SF = - make_SF(0,SF_exp_low,bit(SF_mant_len)); - -static const cl_FF least_positive_FF = - encode_FF(0,FF_exp_low-FF_exp_mid,bit(FF_mant_len)); - -static const cl_DF least_positive_DF = - #if (cl_word_size==64) - encode_DF(0,DF_exp_low-DF_exp_mid,bit(DF_mant_len)); - #else - encode_DF(0,DF_exp_low-DF_exp_mid,bit(DF_mant_len-32),0); - #endif - -inline const cl_LF least_positive_LF (uintC len) +static inline const cl_LF least_positive_LF (uintC len) { var Lfloat erg = allocate_lfloat(len,LF_exp_low,0); #if CL_DS_BIG_ENDIAN_P @@ -49,6 +32,21 @@ inline const cl_LF least_positive_LF (uintC len) const cl_F least_positive_float (float_format_t f) { + // Exponent so klein wie möglich, Mantisse 10...0, Vorzeichen +. + + static const cl_SF least_positive_SF = + make_SF(0,SF_exp_low,bit(SF_mant_len)); + + static const cl_FF least_positive_FF = + encode_FF(0,FF_exp_low-FF_exp_mid,bit(FF_mant_len)); + + static const cl_DF least_positive_DF = + #if (cl_word_size==64) + encode_DF(0,DF_exp_low-DF_exp_mid,bit(DF_mant_len)); + #else + encode_DF(0,DF_exp_low-DF_exp_mid,bit(DF_mant_len-32),0); + #endif + floatformatcase((uintC)f , return least_positive_SF; , return least_positive_FF; @@ -59,4 +57,3 @@ const cl_F least_positive_float (float_format_t f) } // namespace cln -CL_PROVIDE_END(cl_F_leastpos)