is tzcode localtime_r() missing a call to tzset() ?

Paul Eggert eggert at
Wed Oct 7 23:20:57 UTC 1998

   Date: Wed, 07 Oct 1998 14:23:03 -0700
   From: Donald Johnson <djohnson at>

   I've checked the past few versions of tzcode1998?.tar.gz and
   all seem to code localtime_r() without a call to tzset().
   This doesn't seem right.

localtime_r is thread-safe, tzset isn't.  This is why the POSIX.1-1996
standard (section page 223 line 654) says that localtime_r
needn't set tzname, and why it says (section 8.1.1 page 207 line 115)
that localtime must invoke tzset, but localtime_r doesn't need to.

That being said, it is a bit odd that localtime_r doesn't invoke tzset
if tzset has never been invoked before.  I suspect that this is
because doing it in a thread-safe way requires that localtime_r's
invocation of tzset be surrounded by a mutex, and there's no mutex
interface currently in the code.

More information about the tz mailing list