ctype macros broken on 64-bits builds?
Jonathan S. Shapiro
shap@eros-os.com
Thu Jul 24 15:59:00 GMT 2008
On Mon, 2008-07-21 at 11:06 +0000, Martijn van Buul wrote:
> The alternative option would be to do what the rest of the world has been
> doing for a while (Including the BSDs, from which this ctype.* seems to
> have borrowed quite a bit), and rewriting isalpha and friends to
>
> #define isalpha(c) ((__ctype_ptr)[(unsigned)(c + 1)]&(_U|_L))
>
> with __ctype_ptr pointing at element 0 of the array in ctype/ctype_.c,
> instead of at element 1.
This should definitely shift to the "c+1" variant. It has no marginal
cost at compile time (the +1 will constant-fold into the base address in
the optimizer) but it is amenable to static analysis where the wrapping
version presents fairly nasty problems. If we're going to change it,
better to change it to something that is friendly to analysis.
shap
More information about the Newlib
mailing list