This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: ctype macros broken on 64-bits builds?
- From: "Jonathan S. Shapiro" <shap at eros-os dot com>
- To: Martijn van Buul <pino+gmane_comp_lib_newlib at dohd dot org>
- Cc: newlib at sources dot redhat dot com
- Date: Mon, 21 Jul 2008 08:55:15 -0400
- Subject: Re: ctype macros broken on 64-bits builds?
- References: <slrng88rdm.1f2h.pino@mud.stack.nl>
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