[vlc-devel] [PATCH] [RFC] vlc_fixups.h: add a uselocale implementation for win32

Thomas Guillem thomas at gllm.fr
Mon Dec 18 11:45:07 CET 2017



On Sun, Dec 17, 2017, at 20:32, Martin Storsjö wrote:
> On Fri, 15 Dec 2017, Adrien Maglo wrote:
> 
> > This implementation comes from libcxx.
> > ---
> > include/vlc_fixups.h | 46 ++++++++++++++++++++++++++++++++++++++++++----
> > 1 file changed, 42 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
> > index 6175a539bd..c45294d19e 100644
> > --- a/include/vlc_fixups.h
> > +++ b/include/vlc_fixups.h
> > @@ -320,10 +320,47 @@ void *aligned_alloc(size_t, size_t);
> > 
> > /* locale.h */
> > #ifndef HAVE_USELOCALE
> > -#define LC_ALL_MASK      0
> > -#define LC_NUMERIC_MASK  0
> > -#define LC_MESSAGES_MASK 0
> > -#define LC_GLOBAL_LOCALE ((locale_t)(uintptr_t)1)
> > +# if defined(_WIN32)
> > +#  include <xlocinfo.h> // _locale_t
> > +#  undef _UP // It conflicts with unique_ptr.h on MinGW...
> > +#  define locale_t _locale_t
> > +#  define LC_COLLATE_MASK _M_COLLATE
> > +#  define LC_CTYPE_MASK _M_CTYPE
> > +#  define LC_MONETARY_MASK _M_MONETARY
> > +#  define LC_NUMERIC_MASK _M_NUMERIC
> > +#  define LC_TIME_MASK _M_TIME
> > +#  define LC_MESSAGES_MASK _M_MESSAGES
> > +#  define LC_ALL_MASK (  LC_COLLATE_MASK \
> > +                       | LC_CTYPE_MASK \
> > +                       | LC_MESSAGES_MASK \
> > +                       | LC_MONETARY_MASK \
> > +                       | LC_NUMERIC_MASK \
> > +                       | LC_TIME_MASK )
> > +#  define freelocale _free_locale
> > +
> > +// Base is not used...
> > +static inline locale_t newlocale( int mask, const char * locale, locale_t base )
> > +{
> > +    (void)base;
> > +    return _create_locale( mask, locale );
> > +}
> > +
> > +static inline locale_t uselocale( locale_t newloc )
> > +{
> > +    locale_t old_locale = _get_current_locale();
> > +    // uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
> > +    _configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
> 
> FWIW, this function is a no-op that just returns a failure in mingw, as 
> long as you're linking to the legacy msvcrt.dll. If linking to 
> ucrtbase.dll (or msvcrXXX.dll) instead this might make sense though.

I think we plan of using msvcr100.dl for VLC 4.0, so this looks valid.

> 
> // Martin
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list