[Info-vax] math.h (Re: PC/VT Keyboarrd Mapping)
Craig A. Berry
craigberry at nospam.mac.com
Sun Jun 26 15:44:49 EDT 2016
On 6/26/16 12:20 PM, John Reagan wrote:
>
> We are doing some CRTL work right now ... untangling the mess inside math.h, etc.).
While you're in there, you may want to look at the IEEE floating point
classification macros. The standard says they should work for
"real-floating" data of any size, but the ones you've got now only work
for doubles, not for singles or long doubles. For example, here's the
signbit implementation you have now:
#define __VALH(x) ((unsigned int *)&x)[1]
#define signbit(x) (__VALH(x) & 0x80000000)
Because that's explicitly operating on the second longword of a longword
pair, it only works for T_FLOAT because that's the only size consisting
of two longwords.
If you replace that with this:
#define __HIGHBYTE(x) (((unsigned char *)&x)[sizeof(x)-1])
#define signbit(x) (__HIGHBYTE(x) & 0x80)
it will work for S_FLOAT, T_FLOAT, and X_FLOAT equally well because the
byte containing the classification info follows the same pattern, but
just has a different location for the different sizes. Similar things
should be possible for isnan, isinf, etc.
Of course if long double on x86_64 will be the 80-bit kind common on
that platform rather than X_FLOAT, then you're not quite done yet. But
I'd be surprised if you did that since IIRC Alpha didn't have hardware
support for X_FLOAT yet that was/is the long double format there, so why
would x86_64 be different.
More information about the Info-vax
mailing list