[cfe-dev] [libcxx]handling missing linux implementations

Larry Evans cppljevans at suddenlink.net
Tue Feb 22 02:44:51 PST 2011

On 02/16/11 06:13, Sebastian Redl wrote:
> On 15.02.2011, at 19:03, Howard Hinnant wrote:
>> I think this is a really promising direction.  What we need to know
>> now is:  How available is uselocale on the platforms that this
>> audience wants to port libc++ to?  Does just Ubuntu have it?  Other
>> linux platforms?  Windows?
> The Microsoft CRT has _l versions of most functions, but prefixed
> with another underscore (so, for example, _wctomb_l), so there
> should be no need for uselocale. Which it doesn't have.
> Sebastian

My last post had a solution for linux for the wcrtomb_l function which
might work for the Microsoft compiler if it were changed as shown
below.  If it does work for the Microsoft compiler it could be
mimicked for the other missing functions.

#ifndef __APPLE__
//  Provide functions whose name is suffixed with _l
//  and which have locale_t as last argument, but
//  which are missing om tje glibc library and have
//  a different name in MS visualc++ library.
//  Use uselocale to temporarlity change the current
//  threads locale to the last argument, then
//  perform the operation with the abbreviated function
//  (i.e. same name except without _l suffix), and then
//  restore the locale to previous value.

#if defined(__GLIBC__)
  #if( __GLIBC__ > 1) && (__GLIBC_MINOR__ > 2)
    //From page 141 of http://people.redhat.com/drepper/tllocale.ps.gz:
    //  Starting with glibc 2.3 everyting will be available
    //So, indicate that uselocale is available in glibc:
#elif defined(_MSC_FULL_VER)
  //Using Microsoft visualc++ compiler, which
  //uses _XXX_l for corresponding apple function, XXX_l.

  ( char* et
  , wchar_t it
  , mbstate_t* ps
  , locale_t locale_new
    return _wcrtomp_l(et,it,ps,locale_new)
    #if defined(_LIBCPP_HAS_USELOCALE)
      locale_t locale_old=uselocale(locale_new);
      size_t result=wcrtomb(et,it,ps);
    #if defined(_LIBCPP_HAS_USELOCALE)
      #warning "wcrtomb_l improperly implemented for this config."
      return result;


More information about the cfe-dev mailing list