public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.aribaud@3adev.fr>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v5 1/2] Y2038: Add 64-bit time for all architectures
Date: Wed, 20 Jun 2018 07:16:00 -0000	[thread overview]
Message-ID: <20180620091615.2e0c0a70@athena> (raw)
In-Reply-To: <20180620080427.08b290f7@athena>

On Wed, 20 Jun 2018 08:04:27 +0200, Albert ARIBAUD
<albert.aribaud@3adev.fr> wrote :

> But we can do something that keeps the code explicit /and/ reduces
> it properly, based on the fact that we always call fits_in_time_t() to
> perform a cast to time_t or set errno and reduce to -1 if we cannot
> cast.
> 
> We could put the consequence with the test, and instead of defining
> fits_in_time_t(), we could define reduce_to_time_t() as follows:
> 
> 	/* Check whether a time64_t value fits in a time_t.  */
> 	static inline time_t
> 	reduce_to_time_t (__time64_t t)
> 	{
> 	  if (t == (time_t) t)
> 	    return t;
> 	  __set_errno (EOVERFLOW);
> 	  return -1;
> 	}
> 

Trying to define the function above in include/time.h fails because
include/time.h needs to include include/errno.h to get the definition
of __set_errno, but both header files include each other, and some
C files include errno.h alone (or first), which results in the
preprocessor meeting the definition of reduce_to_time_t() before that
of __set_errno and rightly complaining that (function) __set_errno has
not been declared yet.

There is no easy way out of this, since the definition of __set_errno
requires that of errno, which in turn requires tls.h.

Or am I missing something?

Cordialement,
Albert ARIBAUD
3ADEV

  parent reply	other threads:[~2018-06-20  7:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 19:14 [PATCH v5 0/2] Y2038 support batch 1 - __time64_t and __tz_convert Albert ARIBAUD (3ADEV)
2018-06-18 19:14 ` [PATCH v5 1/2] Y2038: Add 64-bit time for all architectures Albert ARIBAUD (3ADEV)
2018-06-19 23:25   ` Paul Eggert
2018-06-20  6:04     ` Albert ARIBAUD
2018-06-20  6:29       ` Albert ARIBAUD
2018-06-20  7:16       ` Albert ARIBAUD [this message]
2018-06-20 16:01       ` Paul Eggert
2018-06-20 16:46         ` Albert ARIBAUD
2018-06-20 17:50           ` Paul Eggert
2018-06-18 19:14 ` [PATCH v5 2/2] Y2038: make __tz_convert compatible with 64-bit-time Albert ARIBAUD (3ADEV)
2018-06-19 23:35   ` Paul Eggert
2018-06-20  6:06     ` Albert ARIBAUD

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=20180620091615.2e0c0a70@athena \
    --to=albert.aribaud@3adev.fr \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.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).