[tz] [libc-coord] thread-safe localtime() for an arbitrary timezone

enh enh at google.com
Wed Jun 21 20:17:57 UTC 2023


On Wed, Jun 21, 2023 at 1:08 PM Guy Harris <gharris at sonic.net> wrote:

> On Jun 21, 2023, at 12:50 PM, enh <enh at google.com> wrote:
>
> > On Wed, Jun 21, 2023 at 12:54 AM Guy Harris <gharris at sonic.net> wrote:
> >
> >> Is there some particular reason to make timezone_t an API/ABI
> structure, rather than a pointer to an opaque structure?
> >
> > no, my preference would be for timezone_t to be more like DIR...
> >
> > typedef struct DIR DIR;
>
> Like DIR, which, at least in macOS (and thus probably in most *BSDs), is
> fully defined in <dirent.>, or like pcap_t, which is "defined" as an opaque
> structure in <pcap/pcap.h> and only defined fully in a header internal to
> libpcap?  (And, yes, pcap_t's contents are subject to change over time,
> have been changed over time, and will continue to change over time.
>

NetBSD exposes its `struct _dirdesc` but FreeBSD/OpenBSD don't (though they
use the same name for the private struct).

somewhat unusually, bionic didn't start from any of the BSD's <dirent.h>,
and uses exact the line i showed above, with the definition only in
dirent.cpp itself.


> > means you need to write the * in signatures, but that
> std::unique_ptr-style safe usage "just works" without having to talk about
> the underlying struct or use std::remove_pointer.
>
> Does that work if the structure is opaque outside the routines that
> process tz files?
>
> > Presumably if it's a structure, "tzalloc()" really means "given a tzid,
> fill in a structure as appropriate for that tzid, and return that
> structure", not "allocate a structure, fill it in as appropriate for the
> tzid, and return a pointer to that structure", and "tzfree()" means "free
> up anything pointed to by the structure whose value was passed to it"
> rather than "free everything pointed to by the structure pointed to by the
> argument and then free the structure".  If you want to do that, perhaps
> names that don't imply that they allocate and free a timezone_t should be
> chosen.
>
> I.e., it would be
>
>         timezone_t *tzalloc(const char *tzid);
>
> and
>
>         void tzfree(timezone_t *);


exactly, just like opendir() and closedir().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20230621/7238eaa7/attachment.htm>


More information about the tz mailing list