This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Go patch committed: Provide matherr function


Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Ian Lance Taylor <iant@google.com> writes:
>
>> On SVID-based systems, when certain math functions encounter an
>> exceptional condition they call a magic function named matherr.  That
>> function is permitted to change the result which the math functions will
>> return.  a program is permitted to provide its own version of matherr.
>>
>> Solaris works this way and at least the Solaris version of matherr does
>> not act as Go, or an ordinary interpretation of the function, would
>> expect.  E.g., calling acos on an out-of-range value will return 0
>> rather than NaN.
>
> Unfortunately, this breaks the libgo build on Solaris 8 and 9:
>
> /vol/gcc/src/hg/trunk/local/libgo/runtime/go-matherr.c: In function 'matherr':
> /vol/gcc/src/hg/trunk/local/libgo/runtime/go-matherr.c:38:17: error: 'NAN' undeclared (first use in this function)
> /vol/gcc/src/hg/trunk/local/libgo/runtime/go-matherr.c:38:17: note: each undeclared identifier is reported only once for each function it appears in
> /vol/gcc/src/hg/trunk/local/libgo/runtime/go-matherr.c:68:28: error: 'INFINITY' undeclared (first use in this function)
> make[4]: *** [go-matherr.lo] Error 1
>
> I couldn't find an appproprite replacement in the system headers.

Hmmm, INFINITY and NAN are in C99.

Does it work to do something like

#ifndef INFINITY
#define INFINITY (1.0 / 0.0)
#endif

#ifndef NAN
#define NAN (0.0 / 0.0)
#endif

?

Another possibility for NAN would to call nan(), if that is available.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]