public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Rich Felker <dalias@libc.org>
To: Zack Weinberg <zack@owlfolio.org>
Cc: "'Alejandro Colomar (man-pages)'" <alx.manpages@gmail.com>,
	libc-alpha@sourceware.org,
	наб <nabijaczleweli@nabijaczleweli.xyz>,
	"Jakub Wilk" <jwilk@jwilk.net>,
	"Stefan Puiu" <stefan.puiu@gmail.com>,
	"Michael Kerrisk" <mtk.manpages@gmail.com>,
	"H . J . Lu" <hjl.tools@gmail.com>,
	"Joseph Myers" <joseph@codesourcery.com>
Subject: Re: [RFC v2 1/2] sys/types.h: Define new type: snseconds_t
Date: Wed, 8 Dec 2021 12:38:57 -0500	[thread overview]
Message-ID: <20211208173857.GV7074@brightrain.aerifal.cx> (raw)
In-Reply-To: <e5013a34-ef24-4d6e-bd3d-bde053707885@www.fastmail.com>

On Wed, Dec 08, 2021 at 09:34:39AM -0500, Zack Weinberg wrote:
> On Tue, Dec 7, 2021, at 10:05 PM, Rich Felker wrote:
> > On Tue, Dec 07, 2021 at 09:26:59PM -0500, Zack Weinberg wrote:
> >> On Tue, Dec 7, 2021, at 7:29 PM, Rich Felker wrote:
> >> >
> >> > This is a non-starter because the relevant standards already require
> >> > the tv_nsec member to have type long.
> >> 
> >> That requirement is a defect in the standards, and I see no reason
> >> why this particular defect should be granted 'we're stuck with this'
> >> status.
> >
> > When the standard codifies existing *universal* practice without
> > introducing a gratuitous typedef
> 
> Universal practice is not necessarily correct. It was an error to
> define a structure type that's passed across the user/kernel
> boundary, with a field whose type isn't a typedef name. It has
> *always* been an error. And I have yet to see a compelling reason
> why the error should not be corrected.

This is your ideology. I don't agree with it, and I hope others won't
too. Stop treating it as Truth folks are supposed to automatically
agree with you on.

> >> > x32 just needs to be fixed to match the requirement.
> >> 
> >> This doesn't just affect x32, it affects every ABI with 32-bit long
> >> and 64-bit time_t. Look at the ifdef mess in glibc
> >> bits/types/struct_timespec.h if you don't believe me.
> >
> > They all got it right -- tv_nsec has type long (32-bit). There is
> > nothing affected by the issue described here except x32, and it's
> > easily fixed. We've always had it right on musl x32 too.
> 
> I looked through the source code to musl and I could not find the
> definition of struct timespec. It appears that it's supposed to be
> defined by <bits/alltypes.h> but that's a generated file and the
> only piece of the generator I could find (tools/mkalltypes.sed)
> doesn't seem to have code to emit a definition of struct timespec,
> but it's not in arch/*/bits/alltypes.h.in either. Where should I be
> looking?

include/alltypes.h.in is also used, and contains:

STRUCT timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); };

which is just time_t tv_sec and long tv_nsec surrounded by the
appropriate anonymous padding for endianness and sizeof(long).

The same could be achieved writing it out explicitly for the different
options but we wanted it to be automatically consistent using a single
definition.

> Having said that, I don't actually _care_ whether the spec bug can
> be papered over with sufficient cleverness in the user-side
> definition of struct timespec. It is still a bug in the spec.

No "cleverness" is needed here. Nothing at all would be needed if the
kernel weren't trying to be "clever" and match the layout between
32-bit and 64-bit archs; since it is, you just need padding in the
right place to match that. You're making a huge meal over something
that is incredibly simple.

Rich

  reply	other threads:[~2021-12-08 17:38 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07 11:19 [PATCH] sys/types.h: Define new types: [s]nseconds_t Alejandro Colomar
2021-12-07 12:36 ` Andreas Schwab
2021-12-07 13:17 ` наб
2021-12-07 18:20   ` Alejandro Colomar (man-pages)
2021-12-07 21:48     ` наб
2021-12-07 19:10   ` Joseph Myers
2021-12-07 15:50 ` Zack Weinberg
2021-12-07 18:24   ` Alejandro Colomar (man-pages)
2021-12-07 21:48 ` [RFC v2 1/2] sys/types.h: Define new type: snseconds_t Alejandro Colomar
2021-12-07 23:56   ` Joseph Myers
2021-12-08  0:17     ` Paul Eggert
2021-12-08  0:29   ` Rich Felker
2021-12-08  2:26     ` Zack Weinberg
2021-12-08  3:05       ` Rich Felker
2021-12-08 14:34         ` Zack Weinberg
2021-12-08 17:38           ` Rich Felker [this message]
2021-12-08 19:52             ` Zack Weinberg
2021-12-08 18:15           ` Adhemerval Zanella
2021-12-08 21:41           ` Joseph Myers
2021-12-07 22:05 ` [RFC v2 2/2] sys/types.h: struct timespec: Use snseconds_t for tv_nsec Alejandro Colomar
2021-12-08 14:47 ` [RFC v3 1/3] bits/types[izes].h: Define new internal type: __snseconds_t Alejandro Colomar
2021-12-08 14:47 ` [RFC v3 2/3] sys/types.h: struct timespec: Use __snseconds_t for tv_nsec Alejandro Colomar
2021-12-08 14:53   ` Zack Weinberg
2021-12-08 15:17     ` Alejandro Colomar (man-pages)
2021-12-08 15:24     ` Joseph Myers
2021-12-08 15:47       ` Alejandro Colomar (man-pages)
2021-12-08 15:59       ` Zack Weinberg
2021-12-08 17:44         ` Rich Felker
2021-12-08 14:48 ` [RFC v3 3/3] sys/types.h: Make snseconds_t user visible Alejandro Colomar
2021-12-08 14:55   ` Zack Weinberg
2021-12-08 15:15     ` Alejandro Colomar (man-pages)
2021-12-08 18:12   ` Paul Eggert
2021-12-08 18:25     ` Rich Felker
2021-12-08 20:10       ` Zack Weinberg
2021-12-08 20:34         ` Rich Felker
2021-12-08 21:12         ` Adhemerval Zanella
2021-12-08 21:53           ` Alejandro Colomar (man-pages)
2021-12-09 19:20             ` Adhemerval Zanella
2021-12-09 19:42           ` Paul Eggert
2021-12-09 19:52             ` Adhemerval Zanella
2021-12-09 20:13             ` Joseph Myers
2021-12-09 20:17               ` Rich Felker
2021-12-09 20:23             ` Alejandro Colomar (man-pages)
2021-12-09 20:29               ` Joseph Myers
2021-12-09 20:34                 ` Alejandro Colomar (man-pages)
2021-12-09 20:40                   ` Joseph Myers

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=20211208173857.GV7074@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=alx.manpages@gmail.com \
    --cc=hjl.tools@gmail.com \
    --cc=joseph@codesourcery.com \
    --cc=jwilk@jwilk.net \
    --cc=libc-alpha@sourceware.org \
    --cc=mtk.manpages@gmail.com \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    --cc=stefan.puiu@gmail.com \
    --cc=zack@owlfolio.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).