This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++, generic locale configuration, and c++0x


On Sun, Jun 6, 2010 at 7:55 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 6 June 2010 19:31, Jonathan Wakely wrote:
>> (Shouldn't this be on the libstdc++ list?)
>
> Moved, see http://gcc.gnu.org/ml/gcc/2010-06/msg00254.html for the
> original thread.
>
>> On 6 June 2010 19:02, Doug Semler wrote:
>>>
>>> So...would you consider this a bug in the documentation, or a bug in
>>> the library?
>>
>> I would say the docs, and only partly because it's easier to fix ;-)
>
> Actually, it's not so hard to fix the code, I have a prototype patch
> using a mutex lock around changes to the global locale, but it's
> likely to seriously affect performance in multithreaded programs.

Well, there's a trade off here:  The affected code is in the parsing
and formatting of date/time, floating point, and money formats to and
from strings.  Is the performance loss so great in these small number
of cases that it prevents the inclusion of the guard?  Incorrect
results and/or crashes due to the lack of thread safety in these
sections of code, IMO, is much more problematic than the effect of
locks on performance.  At this time, any target that uses the generic
implementation (or glibc <= 2.2) must put guards at the user code
level around anything that potentially calls these sections --- and
due to the way the documentation is written, programmers probably are
unaware of this requirement.

(NB: This could probably mitigated slightly by changing the locale
only if necessary --- e.g. when the detected locale is not the "C"
locale...it looks like some of the config/locale/gnu code does this).

It's either that or rewrite those functions in such a way that they do
not rely on the C library and the global locale...which I am sure is
quite a bit of work.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]