[PATCH] PR 15930: Fixinc for isnan on IRIX 6.5.18 and later
Fri Aug 13 19:48:00 GMT 2004
On Fri, 13 Aug 2004, Bruce Korb wrote:
> 1. Are we talking about specifically two __generic macros, or is
> this really a generally "__generic" transform that fixes up
> more than just the two examples?
The __generic transform is a MIPSPro intrinsic that performs a generic
transform, that I've been unable to implement as a "real" macro. For
example, unlike a real macro, "/usr/bin/cc -E" on IRIX doesn't perform
the substitution, and there's no macro definition given for __generic
in IRIX's system headers,
The two classes from IRIX 6.5.19's <internal/math_core.h> are the unary
#define fpclassify(x) __generic(x,,, _fpclassify, _fpclassifyf, _fpclassifyl,,,)(x)
#define isfinite(x) __generic(x,,, _isfinite, _isfinitef, _isfinitel,,,)(x)
#define isinf(x) __generic(x,,, _isinf, _isinff, _isinfl,,,)(x)
#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)
#define isnormal(x) __generic(x,,, _isnormal, _isnormalf, _isnormall,,,)(x)
#define signbit(x) __generic(x,,, _signbit, _signbitf, _signbitl,,,)(x)
And then much later in that file, the binary functions:
#define isgreater(x,y) __generic(x,y,, _isgreater, _isgreaterf, _isgreaterl,,,)(x,y)
#define isgreaterequal(x,y) __generic(x,y,, _isgreaterequal, _isgreaterequalf, _isgreaterequall,,,)(x,y)
#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)
#define islessequal(x,y) __generic(x,y,, _islessequal, _islessequalf, _islessequall,,,)(x,y)
#define islessgreater(x,y) __generic(x,y,, _islessgreater, _islessgreaterf, _islessgreaterl,,,)(x,y)
#define isunordered(x,y) __generic(x,y,, _isunordered, _isunorderedf, _isunorderedl,,,)(x,y)
Notice the blank/omitted second and/or third arguments that make it
difficult to handle this as a pure macro or as a GCC builtin function.
In C99 mode, when these __generic definitions are used, all of the _foo
functions (both unary and binary) are prototyped. Additionally for the
unary functions, IRIX's libm.a and libc.a also contain function entry
points for versions without the leading underscore, i.e. isnan, isnanf
and isnanl, that are used outside of C99 mode. Unfortunately, these
don't get prototype in C99 mode, hence the additional prototypes. This
allows "isnanf" to be used by GCC with default arguments, the same way
that it can be used by the native IRIX cc with default arguments.
Given that there are no equivalents for the binary operators, i.e.
"islessequalf" or "islessequall", and the macro substitutions are
significantly different, it's easier to treat the unary __generic
and the binary __generic as independent beasts.
The ugliness with these macros, if it isn't previously clear, is that
C99 states that these functions should "behave" like macros. For example,
you should be able to pass two "long double"s to isgreater without loss
of precision. In theory, on IRIX, you could always call the _isgreaterl
form, extending arguments to the largest floating point type, but more
conventionally (e.g. in glibc's and newlib's <math.h> headers) these
macros select the appropriate function to call based upon the size (or
sizes) of their arguments.
> 2. If there are just these two examples, would it make sense to just
> "select" all the text involved and just replace it? Whatever.
> I'll leave it to your judgement.
As explained above, there are six unary instances/substitutions and six
binary instances/substitutions. For the inclhack.def test_text I just
gave one example of each.
> > Ok for mainline?
> fixinclude fixes ought to go in all active "lines" (assuming they have
> shown to fix the problem *AND* not caused regressions with other fixes.
Sorry, force of habit. I realised after I sent it that I meant to write
"OK for mainline, 3.4 and 3.3?"
Ok for mainline, 3.4 and 3.3? :>
More information about the Gcc-patches