libsmbclient - Thread Saftey

Derrell Lipman derrell.lipman at
Mon Oct 6 14:57:19 GMT 2008

On Mon, Oct 6, 2008 at 10:50 AM, Olaf Frączyk <olaf at> wrote:

> On Mon, 2008-10-06 at 10:43 -0400, Derrell Lipman wrote:
> > >
> > > froggy> cat
> > > atof - convert string to double-precision number
> > >    MT-Level: MT-Safe as  long  as setlocale(3C) is not
> > >    called to change the locale.
> > >
> >
> > How in the world can atof() be non-thread-safe?  Why would locale have
> > anything to do with it?  It returns a double and I can't think of any
> reason
> > why it would need to use any non-thread-safe features...???  Is strtod()
> > deemed to be more thread safe?
> The character that separates the integer part from the fractional part
> can vary depending on locale. Eg. in en_US it is ".", in pl_PL it is
> ",".

Sure, but the string to be converted is passed in to atof().  A version of
atof() that supported various locales would have to retrieve the locale
setting upon entry and return an appropriate result based on that locale
(which could be wrong by the time the function ended if a different thread
changed the locale right after atof() retrieved the locale setting).  That
doesn't make the function non-thread-safe, however.  The locale could also
have been changed a moment later (after the return from atof()) and the
result would be then-incorrect too.  I suppose the request to get the
current locale decimal separator could be non-thread-safe,  but that's a
separate issue...


More information about the samba-technical mailing list