math.h macro simplification
Howland Craig D (Craig)
howland@LGSInnovations.com
Sun Jun 14 13:04:00 GMT 2009
The attached patch does some minor cleanup to some of the C99 number
classification macros in math.h.
fpclassify, isinf, isnan, and signbit all get rid of un-necessary use of
GCC extensions so that they should work with all compilers. (The sizeof
operator does not evaluate its "argument", so the extension is not
needed to prevent multiple evaluation of the macro's argument.
Unfortunately, the same simplifications cannot be applied to the
2-argument is... comparison macros, as a means is needed to ensure that
each argument is evaluated exactly once.)
isfinite is still stuck with the extension, but is sped up a little by
saving the fpclassify return value and comparing it once or twice,
rather than calling fpclassify, itself, once or twice. (Changing the
values of the FP_ defines to allow a single compare--and thereby also
allowing the extension requirement to be eliminated--was considered but
not done to maintain full backwards compatibility.)
Changes were fully tested, compared both against absolute expected
results and the GLIBC versions as provided under RHEL5.
Craig
-------------- next part --------------
A non-text attachment was scrubbed...
Name: math.h.patch
Type: application/octet-stream
Size: 3032 bytes
Desc: math.h.patch
URL: <http://sourceware.org/pipermail/newlib/attachments/20090614/e5eaa611/attachment.obj>
More information about the Newlib
mailing list