mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: libc-alpha@sourceware.org, musl@lists.openwall.com
Subject: Re: [musl] Re: time64 abi choices for glibc and musl
Date: Sat, 10 Aug 2019 22:18:18 -0400	[thread overview]
Message-ID: <20190811021818.GM9017@brightrain.aerifal.cx> (raw)
In-Reply-To: <e87dc192-4799-df0b-8a9f-524f10fbd267@cs.ucla.edu>

On Sat, Aug 10, 2019 at 01:15:34PM -0700, Paul Eggert wrote:
> Rich Felker wrote:
> >For struct stat, I think it's almost necessary to preserve the
> >existing layout and add new time64 members on the end, and to continue
> >filling in the time32 members.
> 
> This won't be reliable for applications that call 'stat', fiddle
> with the timestamps in the resulting 'struct stat', and then pass
> the fiddled-with struct to some other function. If they fiddle with
> the 64-bit timestamp the 32-bit copy will become wrong, and vice
> versa.
> 
> There are similar issues for applications that create struct stat
> values by hand, without calling a 'stat'-like function.

Changing any of the types defined by libc obviously alters the ABI
between any two consumers of these types that uses the changed types
as part of the interface between them. The only thing we can
*guarantee* works is the interface between libc and a single consumer
of libc. Since there's no function in libc which reads from a stat
structure provided by the application, your concern seems to apply
only to the case that's inherently a best-effort thing. Still, here it
is useful to make a best effort, since the only typical way stat
structures are passed around is share (unmodified) results obtained by
performing one of the stat functions on a file.

The [n]ftw matter, by itself, is something entirely different, and
pertains to use of libc by a single consumer. Internally, [n]ftw
performs stat on files and passes the result to a callback provided by
the application. If the stat structure is not such that it can be
accepted by either time32 or time64 callers, then [n]ftw need to be
redirected symbols and there need to be two copies of the
implementation, one that calls the old time32 stat and one that calls
the time64 stat. This is a gratuitous pain on the implementation side.

Now the two are actually related in some sense, because this same
idiom, of passing stat results back to a caller, is fairly common in
library code outside libc that does directory listings, tree walks,
etc. The same condition that makes it [n]ftw painless on the libc
implementation side also makes it so that this kind of library works
with time32 callers when the library was built for time64 (assuming
there are no other points of breakage). Again, this is a best-effort
thing anyway, and can't inherently be expected to work, but the choice
that makes things easy on the libc implementation side is *also* the
choice that makes this work best. Thereby I consider it the most
reasonable choice.

Rich


  reply	other threads:[~2019-08-11  2:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-10 17:58 Rich Felker
2019-08-10 20:15 ` Paul Eggert
2019-08-11  2:18   ` Rich Felker [this message]
2019-08-12  0:31     ` [musl] " Paul Eggert
2019-08-12  1:55       ` Rich Felker
2019-08-12 18:01         ` Rich Felker
2019-08-12 18:20           ` Rich Felker
2019-08-12 16:29 ` Zack Weinberg
2019-08-12 17:11   ` Rich Felker
2019-08-12 17:55 ` [musl] " Rich Felker
2019-08-12 21:12   ` Lukasz Majewski
2019-08-12 20:13 ` Joseph Myers
2019-08-12 21:54   ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190811021818.GM9017@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).