I'm going to split out @jfb's original patch into three separate ones to lubricate the review process:
- locale stuff
- cmath stuff
- classic_table & ctype mask stuff
This patch covers the first one.
Differential D5385
[libc++] Support newlib as libc++'s C library [locale part] jroelofs on Sep 17 2014, 10:45 AM. Authored by
Details
I'm going to split out @jfb's original patch into three separate ones to lubricate the review process:
This patch covers the first one.
Diff Detail Event TimelineComment Actions A general comment: How much of this file is the same as $LIBCXX/include/support/bionic/bionic_locale.h, and would it be beneficial/desirable to create a file that stubs out the locale routines and share it between those two implementations. Other than that, this looks pretty good.
Comment Actions Yeah, it would be better to share the implementation of these between android and newlib. Where's the right place to put that kind of shared thing?
Comment Actions s/isascii/__isascii/ along with appropriate shims in include/support because isascii isn't supposed to be part of C++. On second thought, this probably breaks OSX and any other platform that doesn't have support shims. I'm not sure of the best way to proceed on that.
Comment Actions I'm ready to sign off on this after the typos are fixed, but I'd like someone like @mclow.lists to chime in since the __libcpp_isascii thing is kind of ugly (but I don't see a better way).
Comment Actions It is kind of ugly; and I worry about isascii being a macro. Comment Actions Why don't we fix the real problem first and stop bothering with the symptoms. The isascii checks break the masks for any char with high bit set. We should IMO have a templated function map2index or so. Then we get: size_t map2index<char>(char_type a) { return (unsigned char)a; } size_t map2index<wchar_t>(char_type a) { return a; } Comment Actions It looks like SunOS's isascii is a macro: http://docs.oracle.com/cd/E19683-01/816-0213/6m6ne383q/index.html @joerg For the ctype<char> ones, I think that's fine, but I don't think that works for ctype<wchar_t> because classic_table has only at least 256 entries. That would get isascii out of include/__locale, and we can leave the ones in src/locale.cpp, which solves this messiness.
Comment Actions ctype<T>::classic_table() is only defined for ctype<char>. We do perform these same checks in ctype<wchar_t>::do_is() though... I'm not sure what the rules are for classifying wide characters... Shouldn't we just be passing these down to the C library's iswupper() and friends as we do in ctype_byname<wchar_t>::do_is()? Comment Actions Thanks for splitting. This is all non-contentious as far as I can tell, so I think it's ready to go. |
Upstream Newlib fixed this in https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html