public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Paul Eggert <eggert@cs.ucla.edu>,
	Joseph Myers <joseph@codesourcery.com>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Alistair Francis <alistair23@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Alistair Francis <alistair.francis@wdc.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>,
	Carlos O'Donell <carlos@redhat.com>,
	Stepan Golosunov <stepan@golosunov.pp.ru>,
	Andreas Schwab <schwab@suse.de>, Zack Weinberg <zackw@panix.com>,
	Siddhesh Poyarekar <siddhesh@redhat.com>
Subject: Re: [RFC] y2038: test: Add _Static_assert() check when __USE_TIME_BITS64 is defined
Date: Sun, 13 Dec 2020 12:48:24 +0100	[thread overview]
Message-ID: <20201213124824.2464c67b@jawa> (raw)
In-Reply-To: <2558832c-adac-0670-f39b-417ffa10f8a6@cs.ucla.edu>

[-- Attachment #1: Type: text/plain, Size: 2356 bytes --]

Hi Paul,

Thank you for the reply.

> On 12/9/20 6:53 AM, Lukasz Majewski wrote:
> 
> > +#define CHECK_TIME64_SIZE(__name, __len) \
> > +  _Static_assert (sizeof (__name) == __len, "Size of " #__name "
> > != " #__len) +
> > +#ifdef __USE_TIME_BITS64
> > +  CHECK_TIME64_SIZE(time_t, 8);
> > +  CHECK_TIME64_SIZE(struct timespec, 16);
> > +#endif  
> 
> I've lost context here; what branch is this against? glibc master
> doesn't have __USE_TIME_BITS64.

Yes, it doesn't (yet) support it. This will be available when
_TIME_BITS=64 is supported on ports with __WORDSIZE=32 &&
__TIMESIZE!=64.

> 
> If this is in a publicly-visible file, the macro CHECK_TIME64_SIZE
> would need to have a reserved name.

Ok. I see - we will stumble upon the reserved namespaces for POSIX
compliant exported headers.

> 
> I'm leery of the idea of putting checks like this into include files
> that users see.

The idea here is to prevent compiling user's program on machine, which
will not properly support 64 bit times - for example the underlying
glibc was very old. I do know that this is not preventing from all
threads - as one can just copy binary from some similar system.

It was suggested once (by Adhemerval and Andreas) that _Static_asserts
shall be added to glibc, but I'm a bit confused:

1. If the check is added to exported headers, it will (probably) pollute
the header itself (like in this patch).

2. I could add it into the glibc sources, but then I shall NOT use
__USE_TIME_BITS64 for enabling it, as this is #define from exported
header (and is not visible during glibc build itself). Instead, maybe I
should use __WORDSIZE==32 && __TIMESIZE!=64 as the condition?

> If there's a reason a platform cannot support 64-bit
> time_t even though __USE_TIME_BITS64 is defined, doesn't this sort of
> checking belong in the include file that defines time_t or
> __TIME_T_TYPE or whatever? That way, a user who sees the resulting
> diagnostic will have an easier time figuring out what exactly went
> wrong.

Interesting, thanks for the idea.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-12-13 11:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 14:53 Lukasz Majewski
2020-12-10  0:42 ` Paul Eggert
2020-12-13 11:48   ` Lukasz Majewski [this message]
2020-12-15 18:54     ` Paul Eggert

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=20201213124824.2464c67b@jawa \
    --to=lukma@denx.de \
    --cc=adhemerval.zanella@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=arnd@arndb.de \
    --cc=carlos@redhat.com \
    --cc=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    --cc=siddhesh@redhat.com \
    --cc=stepan@golosunov.pp.ru \
    --cc=zackw@panix.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.
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).