[libcxx] r240527 - Make support for thread-unsafe C functions optional.

Ed Schouten ed at nuxi.nl
Wed Jun 24 04:38:39 PDT 2015


Hi Joerg,

2015-06-24 13:19 GMT+02:00 Joerg Sonnenberger <joerg at britannica.bec.de>:
> Note that setlocale() *is* thread-safe on a correctly implemented UNIX.
> It is a bug if you don't get consistent results with a clear
> before-after semantic even when other threads call locale-sensitive
> funcctions concurrently.

Oh, sorry about the last mail. I misread your sentence slightly.

Let me clarify: the intent behind this knob is that it allows you to
filter out functions that would cause you to write code that affects
the execution of other threads in unintended ways.

I've seen libraries out there that call setlocale(LC_ALL, ""), having
full disregard for any other code that runs within the same
application. By adding this knob, such pieces of code can be detected
more easily.

So even though I agree with you that setlocale() can be implemented in
a thread-safe way on UNIX (read: the execution of the setlocale
function itself is thread-safe), it is harmful to use in larger-scale
programs.

-- 
Ed Schouten <ed at nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK/VAT number: 62051717



More information about the cfe-commits mailing list