[cfe-dev] [PATCH] Libc++ Windows fixes

Ruben Van Boxem vanboxem.ruben at gmail.com
Thu Sep 22 10:02:55 PDT 2011


2011/9/22 Howard Hinnant <hhinnant at apple.com>

> On Sep 22, 2011, at 11:33 AM, Ruben Van Boxem wrote:
>
> > Thanks! I'd like to do more, but I think I've reached my knowledge and
> > capability limits. Some Windows guru (or even better, a Windows C++
> > guru) will have to step up and implement more of libc++ to be usable.
> > Remember that the _strto*_l functions are very new, and most probably
> > don't work on XP, and may not work on Vista. I look to the Linux patch
> > on this and *hope* it is general/compatible enough to work without
> > much modification on Windows as well.
> >
> > I have finally gotten to more libc++ Windows work, and attached is a
> patch that addresses some of the issues that pop up. I know it's a lot to
> take in, but most changes are pretty logical (or I wouldn't have been able
> to find/code them). I'm currently facing implementing  wcsnrtombs and after
> that there's the more troubling issue of catgets and associates, which I'm
> quite worried about, as Win32 is almost orthogonal to this whole API. Ideas
> for that are very welcome.
> >
> > The patch explained:
> > - include/__config/type_traits: add a define
> _LIBCXX_HAS_FEATURE_IS_BASE_OF for MSVC and GCC, which both have this, but
> not __has_feature, which is Clang-only. Modify <type_traits> accordingly.
> >  - include/locale: Win32 does not have nl_types, which really sucks...
> big time.
> >  - include/cerrno: the missing error constants, very much acceptable as
> said by Howard in this thread some time ago.
> >  - include/__locale: include the new support/win32/locale.h header, and
> leave out the missing xlocale.h. Maybe a stupid name, but I haven't found a
> better name for it. Maybe once the whole win32 stuff is complete, some
> refactoring is in order. The mask type is defined and all values are defined
> to the correct values (extracted from mingw-w64 headers).
> >  - include/support/win32/support.h: a place for missing functions'
> declarations to live.
> >  - include/support/win32/locale.h: locale-related stuff (duh!) missing or
> otherwise defined in Win32 headers.
> >  - CMakeLists.txt: add the new files, only on Win32.
> >  - src/support/win32/support.cpp: implementation of functions in
> include/support/win32/support.h.
> >
> > All this should work for both MinGW(-w64)/GCC and Microsoft/MSVC
> headers/libraries. Note the *_l functions are only available on recent
> Windows versions, which should be good enough for now. Especially the locale
> stuff (up till now!) should work for more than only plain "C" locale.
> >
> > One point of attention: the FIXME in the new locale.h header needs
> attention: Win32 needs to call a function to enable thread-local locales,
> and then setlocale operates on the thread's locale, which is great. But this
> function needs to be called somewhere before everything else (in some static
> initialization function or something). On top of that, I'm not quite sure
> that what I do in my short implementation of uselocale is correct. I think
> it is, and it definitely is inefficient.
> >
> > I tested this on GCC and Clang built for mingw-w64.
> >
> > Please review and commit if you're OK. Thanks!
>
> I've slightly modified your patch (enclosed below) for your review.  My
> modification consisted of changes only to <__config> and <type_traits>.
>
> I've confirmed that there is no impact to OS X.  I have no opinion on what
> this does for _WIN32 (if others do, please speak up).  If you (and everyone
> else) is ok with this patch, then add to this patch your entry in
> CREDITS.TXT and post back.  I'll commit it.
>

I'm definitely OK with the changes, it's a bit more streamlined now. I also
found a tab vs 4 spaces on a line that I fixed. Added me as "initial Windows
patches"-contributor. Hopefully I can expand on that later :)

Thanks for the quick response!

Ruben


>
> Thanks,
> Howard
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110922/77739219/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: windows-locale.patch
Type: application/octet-stream
Size: 11599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110922/77739219/attachment.obj>


More information about the cfe-dev mailing list