Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 21 Jun 2023 13:17:57 -0700
From: enh <>
To: Guy Harris <>
Cc: Paul Eggert <>, Time zone mailing list <>,
Subject: Re: [tz] thread-safe localtime() for an arbitrary timezone

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

> On Jun 21, 2023, at 12:50 PM, enh <> wrote:
> > On Wed, Jun 21, 2023 at 12:54 AM Guy Harris <> 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().

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.