Proposal: API for thread-safe time zone functions
Jonathan Lennox
lennox at cs.columbia.edu
Fri Jun 8 05:14:43 UTC 2001
On Thursday, June 7 2001, "Garrett Wollman" wrote to "Paul Eggert, tz at elsie.nci.nih.gov" saying:
> <<On Thu, 7 Jun 2001 13:44:48 -0700 (PDT), Paul Eggert <eggert at twinsun.com> said:
>
> > It doesn't worry about threads, so it mishandles this case: two
> > different threads can clobber the same internal structure.
>
> > I don't offhand know what other systems do.
>
> At least in FreeBSD, these functions are serialized for thread
> safety. (That's one of the reasons we haven't updated to a recent
> tzcode in years.) Obviously, functions like localtime() which return
> static buffers can never be made thread-safe.
Actually, localtime() can be made thread-safe -- it you just have to return
a pthread_getspecific() buffer rather than a static buffer.
And in fact, this is exactly what FreeBSD does.
What I think you meant is that localtime() can't be made *reentrant*?
--
Jonathan Lennox
lennox at cs.columbia.edu
More information about the tz
mailing list