This is the mail archive of the
mailing list for the GCC project.
Re: Go patch committed: Provide matherr function
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
> Ian Lance Taylor <firstname.lastname@example.org> 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: *** [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
#define INFINITY (1.0 / 0.0)
#define NAN (0.0 / 0.0)
Another possibility for NAN would to call nan(), if that is available.