Thread-safe timezones: running code

Jonathan Lennox lennox at cs.columbia.edu
Mon Jun 18 20:57:42 UTC 2001


I've finished a first cut (call it beta 1?) of a tzcode-based implementation
of my thread-safe time zone API.

The API as defined here was fairly straightforward to implement.  Only a few
changes were necessary.

* The most noticable change is that the type representing a time zone
  object is now 'struct tzinfo', not 'struct timezone'.  I discovered that
  'struct timezone' is the type of the deprecated second argument to BSD
  gettimeofday().

* Other than that, I clarified some things, notably the fact that tzname and
  the other externs aren't defined when you're using pthread_settz().  (I
  could have implemented them using the trick used for thread-safe errno,
  but it seemed like too much trouble for a badly-defined API.)

The attached patch also contains code to make the 'normal' time functions
thread-safe.   This is based on FreeBSD's changes to tzcode to make it
thread-safe, but rather than sticking #ifdef's directly into the code, as
FreeBSD does, I instead implemented them as macros.  You can control your
thread model based on a Makefile setting.

The only part of the thread-safety API that isn't currently implemented in
my patch is that the error return value of strftime_z() is still the same as
that of strftime(), rather than using the snprintf() error return style.
This requires annoyingly intrusive changes to tzcode's strftime(), so I've
put it off for now.


Attached, find two files:
1.  The revised (v3) API proposal.
2.  A patch to tzcode2001c implementing the proposal.

Comments are very welcome!

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: proposal.txt
URL: <http://mm.icann.org/pipermail/tz/attachments/20010618/c0e97449/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: thread-safe.patch
URL: <http://mm.icann.org/pipermail/tz/attachments/20010618/c0e97449/attachment.ksh>
-------------- next part --------------

-- 
Jonathan Lennox
lennox at cs.columbia.edu


More information about the tz mailing list