Browse Source

Get rid of CL_REQUIRE/CL_PROVIDE(cl_ieee).

While at it, remove work around for ancient (fixed in 8+ years) glibc/Linux
bug (the kernel and/or libc was initializing FPU into non-IEEE mode, so division
by 0 resulted in SIGFPE instead of NaN).
master
Alexei Sheplyakov 16 years ago
parent
commit
88f748dfb4
  1. 1
      autoconf/aclocal.m4
  2. 4
      configure.ac
  3. 1
      include/cln/dfloat.h
  4. 1
      include/cln/ffloat.h
  5. 1
      include/cln/float.h
  6. 24
      m4/fpu_control.m4
  7. 61
      src/float/base/cl_ieee.cc
  8. 21
      src/float/base/cl_ieee.h
  9. 20
      src/float/cl_float_config.h.in
  10. 2
      src/float/dfloat/elem/cl_DF_div.cc
  11. 2
      src/float/dfloat/elem/cl_DF_minus.cc
  12. 2
      src/float/dfloat/elem/cl_DF_mul.cc
  13. 2
      src/float/dfloat/elem/cl_DF_plus.cc
  14. 2
      src/float/ffloat/elem/cl_FF_div.cc
  15. 2
      src/float/ffloat/elem/cl_FF_minus.cc
  16. 2
      src/float/ffloat/elem/cl_FF_mul.cc
  17. 2
      src/float/ffloat/elem/cl_FF_plus.cc

1
autoconf/aclocal.m4

@ -7,7 +7,6 @@ dnl Borrowed from GNU clisp.
m4_include([alloca.m4])
m4_include([as-underscore.m4])
m4_include([c++-constructors.m4])
m4_include([fpu_control.m4])
m4_include([general.m4])
m4_include([gettimeofday.m4])
m4_include([param.m4]) dnl called intparam.m4 in clisp

4
configure.ac

@ -13,7 +13,7 @@ dnl
dnl
AC_INIT(src/integer/gcd/cl_I_gcd.cc)
AC_CONFIG_AUX_DIR(autoconf)
AC_CONFIG_HEADER(include/cln/config.h include/cln/version.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h)
AC_CONFIG_HEADER(include/cln/config.h include/cln/version.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/timing/cl_t_config.h)
AC_PROG_MAKE_SET
dnl This piece of sed script replaces every line containing '@subdir@'
dnl by several consecutive lines, each referencing one subdir.
@ -135,8 +135,6 @@ dnl checks for functions and declarations
dnl
CL_ALLOCA
dnl set variable ALLOCA, DEFS NO_ALLOCA
CL_FPU_CONTROL
dnl DEFS HAVE_FPU_CONTROL_T, HAVE_SETFPUCW
CL_GETTIMEOFDAY
dnl DEFS HAVE_GETTIMEOFDAY, GETTIMEOFDAY_DOTS, GETTIMEOFDAY_TZP_T
ac_cv_func_ftime=no

1
include/cln/dfloat.h

@ -309,7 +309,6 @@ inline cl_DF& operator/= (cl_DF& x, const double y) { return x = x / y; }
/* */
CL_REQUIRE(cl_ieee)
// Runtime typing support.

1
include/cln/ffloat.h

@ -308,7 +308,6 @@ inline cl_FF& operator/= (cl_FF& x, const cl_FF& y) { return x = x / y; }
inline cl_FF& operator/= (cl_FF& x, const float y) { return x = x / y; }
CL_REQUIRE(cl_ieee)
/* */

1
include/cln/float.h

@ -760,7 +760,6 @@ public:
};
CL_REQUIRE(cl_ieee)
// If this is true, floating point underflow returns zero instead of throwing an exception.

24
m4/fpu_control.m4

@ -1,24 +0,0 @@
dnl -*- Autoconf -*-
dnl Copyright (C) 1993-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
AC_PREREQ(2.57)
AC_DEFUN([CL_FPU_CONTROL],
[dnl Check for Linux with <fpu_control.h> and fpu_control_t or __setfpucw().
dnl glibc versions since October 1998 define fpu_control_t. Earlier versions
dnl define and declare __setfpucw(). Very early Linux libc versions have none,
dnl and __fpu_control is of type `unsigned short'.
CL_COMPILE_CHECK([fpu_control_t], cl_cv_type_fpu_control_t,
[#include <fpu_control.h>], [fpu_control_t x;],
AC_DEFINE(HAVE_FPU_CONTROL_T,,[have <fpu_control.h> and it defines the fpu_control_t type]))
CL_COMPILE_CHECK([__setfpucw], cl_cv_func_setfpucw,
[#include <fpu_control.h>], [__setfpucw(_FPU_IEEE);],
AC_DEFINE(HAVE_SETFPUCW,,[have <fpu_control.h> and it declares the __setfpucw() function]))
])

61
src/float/base/cl_ieee.cc

@ -1,61 +0,0 @@
// System dependent IEEE floating-point coprocessor initialization.
// General includes.
#include "cl_sysdep.h"
CL_PROVIDE(cl_ieee)
// Specification.
#include "cl_ieee.h"
// Implementation.
#include "cl_FF.h"
#include "cl_DF.h"
#include "cl_float_config.h"
#if (defined(linux) || defined(__linux)) && (defined(FAST_FLOAT) || defined(FAST_DOUBLE))
// Division by 0.0 should return NaN and not raise an SIGFPE.
// For this, we either have to link with -lieee or copy some
// part from libc-linux/sysdeps/linux/{i386,m68k}/ieee.c:
#include <fpu_control.h>
#if 0 // Unfortunately this gives an error if also linked with -lieee
#if defined(HAVE_FPU_CONTROL_T)
fpu_control_t __fpu_control = _FPU_IEEE;
#else
unsigned short __fpu_control = _FPU_IEEE;
#endif
#else
AT_INITIALIZATION(ieee)
{
#if defined(_FPU_IEEE)
#if defined(HAVE_FPU_CONTROL_T)
extern fpu_control_t __fpu_control;
__fpu_control = _FPU_IEEE;
#elif defined(HAVE_SETFPUCW)
__setfpucw(_FPU_IEEE);
#else
extern unsigned short __fpu_control;
__fpu_control = _FPU_IEEE;
#endif
#else
// Nothing to do (as on some architectures):
// probably this means that _FPU_DEFAULT is just as good as _FPU_IEEE.
#endif
}
#endif
#endif
namespace cln {
// This dummy links in this module whenever some module needs IEEE floats.
int cl_ieee_module;
} // namespace cln
CL_PROVIDE_END(cl_ieee)

21
src/float/base/cl_ieee.h

@ -1,21 +0,0 @@
// IEEE floating-point
#ifndef _CL_IEEE_H
#define _CL_IEEE_H
namespace cln {
// To make sure that cl_ieee.cc is linked in.
// NEED_IEEE_FLOATS()
#if (defined(linux) || defined(__linux)) // only needed on Linux
#define NEED_IEEE_FLOATS() \
CL_REQUIRE(cl_ieee) \
CL_FORCE_LINK(CONCAT(cl_ieee_dummy_,__LINE__), cl_ieee_module)
#else
#define NEED_IEEE_FLOATS()
#endif
extern int cl_ieee_module;
} // namespace cln
#endif /* _CL_IEEE_H */

20
src/float/cl_float_config.h.in

@ -1,20 +0,0 @@
// Defines OS dependent macros
#ifndef _CL_FLOAT_CONFIG_H
#define _CL_FLOAT_CONFIG_H
/* These definitions are adjusted by `configure' automatically. */
/* functions and declarations */
/* CL_FPU_CONTROL */
/* Define if you have <fpu_control.h> and it defines the fpu_control_t type. */
#undef HAVE_FPU_CONTROL_T
/* Define if you have <fpu_control.h> and it declares the __setfpucw()
function. */
#undef HAVE_SETFPUCW
#endif /* _CL_FLOAT_CONFIG_H */

2
src/float/dfloat/elem/cl_DF_div.cc

@ -14,14 +14,12 @@
#include "cl_F.h"
#include "cl_low.h"
#include "cl_DS.h"
#include "cl_ieee.h"
#include "cl_inline.h"
#include "cl_DF_zerop.cc"
namespace cln {
NEED_IEEE_FLOATS()
const cl_DF operator/ (const cl_DF& x1, const cl_DF& x2)
{

2
src/float/dfloat/elem/cl_DF_minus.cc

@ -10,11 +10,9 @@
// Implementation.
#include "cl_DF.h"
#include "cl_ieee.h"
namespace cln {
NEED_IEEE_FLOATS()
const cl_DF operator- (const cl_DF& x1, const cl_DF& x2)
{

2
src/float/dfloat/elem/cl_DF_mul.cc

@ -13,14 +13,12 @@
#include "cl_F.h"
#include "cl_low.h"
#include "cl_DS.h"
#include "cl_ieee.h"
#include "cl_inline.h"
#include "cl_DF_zerop.cc"
namespace cln {
NEED_IEEE_FLOATS()
const cl_DF operator* (const cl_DF& x1, const cl_DF& x2)
{

2
src/float/dfloat/elem/cl_DF_plus.cc

@ -11,12 +11,10 @@
#include "cl_DF.h"
#include "cl_F.h"
#include "cl_ieee.h"
#include "cl_xmacros.h"
namespace cln {
NEED_IEEE_FLOATS()
const cl_DF operator+ (const cl_DF& x1, const cl_DF& x2)
{

2
src/float/ffloat/elem/cl_FF_div.cc

@ -13,14 +13,12 @@
#include "cl_N.h"
#include "cl_F.h"
#include "cl_low.h"
#include "cl_ieee.h"
#include "cl_inline.h"
#include "cl_FF_zerop.cc"
namespace cln {
NEED_IEEE_FLOATS()
const cl_FF operator/ (const cl_FF& x1, const cl_FF& x2)
{

2
src/float/ffloat/elem/cl_FF_minus.cc

@ -10,11 +10,9 @@
// Implementation.
#include "cl_FF.h"
#include "cl_ieee.h"
namespace cln {
NEED_IEEE_FLOATS()
const cl_FF operator- (const cl_FF& x1, const cl_FF& x2)
{

2
src/float/ffloat/elem/cl_FF_mul.cc

@ -12,14 +12,12 @@
#include "cl_FF.h"
#include "cl_F.h"
#include "cl_low.h"
#include "cl_ieee.h"
#include "cl_inline.h"
#include "cl_FF_zerop.cc"
namespace cln {
NEED_IEEE_FLOATS()
const cl_FF operator* (const cl_FF& x1, const cl_FF& x2)
{

2
src/float/ffloat/elem/cl_FF_plus.cc

@ -11,12 +11,10 @@
#include "cl_FF.h"
#include "cl_F.h"
#include "cl_ieee.h"
#include "cl_xmacros.h"
namespace cln {
NEED_IEEE_FLOATS()
const cl_FF operator+ (const cl_FF& x1, const cl_FF& x2)
{

Loading…
Cancel
Save