From: Bruno Haible Date: Sun, 11 Mar 2007 22:40:52 +0000 (+0000) Subject: Work around bug regarding initializers in SunPRO C and Compaq C compilers. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fd762677178fb5c3c75d811618431345206d541;p=pspp Work around bug regarding initializers in SunPRO C and Compaq C compilers. --- diff --git a/ChangeLog b/ChangeLog index 85d4d68570..f3ea3014d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-03-11 Bruno Haible + + * lib/isnan.c (rpl_isnan, rpl_isnanl): Work around bug regarding + initializers in SunPRO C and Compaq C compilers. + 2007-03-11 Bruno Haible * lib/gl_array_oset.c (gl_array_iterator_next): Make pointer diff --git a/lib/isnan.c b/lib/isnan.c index ce9e8ea78d..beeb98a506 100644 --- a/lib/isnan.c +++ b/lib/isnan.c @@ -58,21 +58,32 @@ FUNC (DOUBLE x) #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); - memory_double m; +# 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; + /* 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. */