This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ctype macros broken on 64-bits builds?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]