tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Per thread locales



On Mon, Dec 28, 2015 at 01:16:56PM +0100, Martin Husemann wrote:
> IIUC Jörg strongly prefers to fix all locale sensitiv calls to use variants
> explicitly passing the locale (which is most simple for "C").

Correct. The problem with uselocale() is two fold:
(1) It requires ABI breaks.
(2) It just recreates the problems of interactions between different
components in a multithreaded binary from the thread level to the DSO
level.

There is a good reason why the C++ locale support doesn't use
per-thread locales. They are still a pretty stupid idea.

> However, this is not always trivial (when the code uses lots of deeply nested
> library code) so patches are hard to verify and even harder to upstream.

I contest that. So far, the majority of the code wanting to use
uselocale always wanted the "C" locale. That's an audit of the locale
sensitive code and not so much a question of nesting.

> A relatively simple & cheap hack would be a per-thread flag "override process
> locale with C" and a uselocale() function that recognizes "C" and the
> process locale and then sets/clears the flag accordingly, failing in all
> other cases.

This doesn't work well, consider ctype.h as example.

Joerg


Home | Main Index | Thread Index | Old Index