[cfe-dev] [PATCH] Libc++ Windows fixes (Attention all libc++ ports!!!)

Howard Hinnant hhinnant at apple.com
Wed Sep 28 09:05:16 PDT 2011


On Sep 28, 2011, at 11:57 AM, Ruben Van Boxem wrote:

> 2011/9/28 Ruben Van Boxem <vanboxem.ruben at gmail.com>
> 2011/9/28 Howard Hinnant <hhinnant at apple.com>
> On Sep 28, 2011, at 11:02 AM, Ruben Van Boxem wrote:
> 
> > If this is just replacing all occurences  of the __*_l functions in libc++ code with the normal *_l functions, and removing all the always inline wrappers, I can volunteer to do this mechanical work. I guess the only port directly affected by this would be Linux, but that could easily be fixed by introducing a support header and moving the wrapper code from <locale> to there.
> 
> Perhaps the best way to proceed is for someone such as yourself to just untangle the Windows port from this block of code:
> 
> // OSX has nice foo_l() functions that let you turn off use of the global
> // locale.  Linux, not so much.  The following functions avoid the locale when
> // that's possible and otherwise do the wrong thing.  FIXME.
> #ifndef _LIBCPP_STABLE_APPLE_ABI
> 
> Someone else (perhaps David) could just untangle the FreeBSD port from the same block of code.
> 
> Perhaps someone else can untangle the Linux port from this block of code.
> 
> Once everybody is untangled from it, we can safely delete it because no one will be using it.  But I hesitate to have anyone work this area without the ability to test it for the impacted platform.
> 
> OK, gotcha. I guess the easiest way would be adding _WIN32 to the platforms that define _LIBCPP_STABLE_APPLE_ABI and fix all errors that pop up?
> 
> Err.. nmv, I'll add _WIN32 to the ifndef starting the block of code. Sorry for the noise... 


The one thing that someone must do that will impact all platforms is transform this:

#ifdef _LIBCPP_STABLE_APPLE_ABI
    if (sscanf_l(__a, 0, "%p", &__v) != 1)
#else
    if (__sscanf_l(__a, __cloc(), "%p", &__v) != 1)
#endif

to:

#ifdef _LIBCPP_STABLE_APPLE_ABI
    if (sscanf_l(__a, _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
#else
    if (__sscanf_l(__a, __cloc(), "%p", &__v) != 1)
#endif

And in a couple of places:

#ifdef _LIBCPP_STABLE_APPLE_ABI
        long long __ll = strtoll_l(__a, &__p2, __base, 0);
#else
        long long __ll = strtoll_l(__a, &__p2, __base, __cloc());
#endif

to:

        long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);

If you want to take that on, go for it.  If you want me to do it, that's fine too.  But it will have to wait for a few hours (don't have the cycles at the moment).

Howard




More information about the cfe-dev mailing list