[cfe-dev] [libcxx]handling missing linux implementations
cppljevans at suddenlink.net
Tue Feb 15 12:37:34 PST 2011
On 02/15/11 12:03, Howard Hinnant wrote:
> On Feb 14, 2011, at 11:26 PM, Larry Evans wrote:
>> Mybe a proper implementation could be done using the 'uselocale'
>> described on p. 131 of:
>> (Thanks to Marc Glisse for suggesting uselocale here:
>> Uselocale could be used something like in the following code:
>> #ifdef __linux__
>> namespace std
>> ( char* et
>> , wchar_t it
>> , mbstate_t* ps
>> , locale_t locale_new
>> locale_t locale_old uselocale(locale_new);
>> The above could be inserted just after the #include's in:
>> Some similar could be done for other "missing _l suffixed functions".
>> Anyone have any alternatives to this solution to the missing _l
>> suffixed functions on linus (or really, in glibc)?
> 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?
What about handling other platforms by inserting:
// Provide functions whose name is suffixed with _l
// and which have locale_t as last argument, but
// which are missing on ubuntu (and presumably other
// unix type OS's).
// 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 __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:
( char* et
, wchar_t it
, mbstate_t* ps
, locale_t locale_new
#warning "wcrtomb_l improperly implemented for this config."
just after the anonymous namespace open curly braces in locale.cpp
(IOW, just after line 26 of:
The #if __GLIB_* test would assure it would work for any platform
using glibc. For windows, since _LIBCPP_HAS_USELOCALE would be
undefined, the #warning would occur, but the result would be no worse
than the current implementation and the user would be notified of a
possible problem (thanks to Matthieu for this suggestion).
More information about the cfe-dev