Browse Source

Get rid CL_REQUIRE/CL_PROVIDE(cl_F_leastneg), it is not really necessary.

Move static variables least_negative_[SFDL]F into least_negative_LF() function
(which is the only user of those variables) in order to avoid possible static
order initialization problems. While at it, make least_negative_LF() function
static.
master
Alexei Sheplyakov 16 years ago
parent
commit
84167573d9
  1. 1
      include/cln/float.h
  2. 33
      src/float/misc/cl_F_leastneg.cc

1
include/cln/float.h

@ -567,7 +567,6 @@ extern const cl_F least_positive_float (float_format_t f);
// Returns the least negative floating point number (i.e. < 0 but closest to 0)
// in float format f.
extern const cl_F least_negative_float (float_format_t f);
//CL_REQUIRE(cl_F_leastneg)
// Returns the smallest floating point number e > 0 such that 1+e != 1.
extern const cl_F float_epsilon (float_format_t f);

33
src/float/misc/cl_F_leastneg.cc

@ -3,8 +3,6 @@
// General includes.
#include "cl_sysdep.h"
CL_PROVIDE(cl_F_leastneg)
// Specification.
#include "cln/float.h"
@ -19,6 +17,21 @@ CL_PROVIDE(cl_F_leastneg)
namespace cln {
static inline const cl_LF least_negative_LF (uintC len)
{
var Lfloat erg = allocate_lfloat(len,LF_exp_low,-1);
#if CL_DS_BIG_ENDIAN_P
TheLfloat(erg)->data[0] = bit(intDsize-1);
clear_loop_up(&TheLfloat(erg)->data[1],len-1);
#else
var uintD* ptr = clear_loop_up(&TheLfloat(erg)->data[0],len-1);
*ptr = bit(intDsize-1);
#endif
return erg;
}
const cl_F least_negative_float (float_format_t f)
{
// Exponent so klein wie möglich, Mantisse 10...0, Vorzeichen -.
static const cl_SF least_negative_SF =
@ -34,21 +47,6 @@ static const cl_DF least_negative_DF =
encode_DF(-1,DF_exp_low-DF_exp_mid,bit(DF_mant_len-32),0);
#endif
inline const cl_LF least_negative_LF (uintC len)
{
var Lfloat erg = allocate_lfloat(len,LF_exp_low,-1);
#if CL_DS_BIG_ENDIAN_P
TheLfloat(erg)->data[0] = bit(intDsize-1);
clear_loop_up(&TheLfloat(erg)->data[1],len-1);
#else
var uintD* ptr = clear_loop_up(&TheLfloat(erg)->data[0],len-1);
*ptr = bit(intDsize-1);
#endif
return erg;
}
const cl_F least_negative_float (float_format_t f)
{
floatformatcase((uintC)f
, return least_negative_SF;
, return least_negative_FF;
@ -59,4 +57,3 @@ const cl_F least_negative_float (float_format_t f)
} // namespace cln
CL_PROVIDE_END(cl_F_leastneg)
Loading…
Cancel
Save