[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
isnan-nolibm, isnanl-nolibm: fix compilation error
From: |
Bruno Haible |
Subject: |
isnan-nolibm, isnanl-nolibm: fix compilation error |
Date: |
Sun, 11 Mar 2007 23:41:39 +0100 |
User-agent: |
KMail/1.5.4 |
These modules fail to compile with SunPRO C 5.0 and Compaq C 6.4, because
these compilers refuse to compile statically initialized variables whose
initializers contains a NaN or Infinity. I'm applying this workaround.
2007-03-11 Bruno Haible <address@hidden>
* lib/isnan.c (rpl_isnan, rpl_isnanl): Work around bug regarding
initializers in SunPRO C and Compaq C compilers.
*** lib/isnan.c 25 Feb 2007 02:35:37 -0000 1.2
--- lib/isnan.c 11 Mar 2007 22:35:15 -0000
***************
*** 58,78 ****
#ifdef KNOWN_EXPBIT0_LOCATION
/* Be careful to not do any floating-point operation on x, such as x == x,
because x may be a signaling NaN. */
static memory_double nan = { L_(0.0) / L_(0.0) };
static DOUBLE plus_inf = L_(1.0) / L_(0.0);
static DOUBLE minus_inf = -L_(1.0) / L_(0.0);
! memory_double m;
! /* A NaN can be recognized through its exponent. But exclude +Infinity and
! -Infinity, which have the same exponent. */
! m.value = x;
! if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD])
! & (EXP_MASK << EXPBIT0_BIT))
! == 0)
! return (memcmp (&m.value, &plus_inf, sizeof (DOUBLE)) != 0
! && memcmp (&m.value, &minus_inf, sizeof (DOUBLE)) != 0);
! else
! return 0;
#else
/* The configuration did not find sufficient information. Give up about
the signaling NaNs, handle only the quiet NaNs. */
--- 58,89 ----
#ifdef KNOWN_EXPBIT0_LOCATION
/* Be careful to not do any floating-point operation on x, such as x == x,
because x may be a signaling NaN. */
+ # if defined __SUNPRO_C || defined __DECC
+ /* The Sun C 5.0 compilers and the Compaq (ex-DEC) 6.4 compilers don't
+ recognize the initializers as constant expressions. */
+ memory_double nan;
+ DOUBLE plus_inf = L_(1.0) / L_(0.0);
+ DOUBLE minus_inf = -L_(1.0) / L_(0.0);
+ nan.value = L_(0.0) / L_(0.0);
+ # else
static memory_double nan = { L_(0.0) / L_(0.0) };
static DOUBLE plus_inf = L_(1.0) / L_(0.0);
static DOUBLE minus_inf = -L_(1.0) / L_(0.0);
! # endif
! {
! memory_double m;
! /* A NaN can be recognized through its exponent. But exclude +Infinity
and
! -Infinity, which have the same exponent. */
! m.value = x;
! if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD])
! & (EXP_MASK << EXPBIT0_BIT))
! == 0)
! return (memcmp (&m.value, &plus_inf, sizeof (DOUBLE)) != 0
! && memcmp (&m.value, &minus_inf, sizeof (DOUBLE)) != 0);
! else
! return 0;
! }
#else
/* The configuration did not find sufficient information. Give up about
the signaling NaNs, handle only the quiet NaNs. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- isnan-nolibm, isnanl-nolibm: fix compilation error,
Bruno Haible <=