From: Lukasz Majewski <lukma@denx.de>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: libc-alpha@sourceware.org, Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH v2 1/2] Y2038: make __mktime_internal compatible with __time64_t
Date: Fri, 29 Mar 2019 15:24:52 +0100 [thread overview]
Message-ID: <20190329152452.19d7b78c@jawa> (raw)
In-Reply-To: <e8d7c72f-eb04-8890-dd39-d863c7e8d47b@cs.ucla.edu>
[-- Attachment #1: Type: text/plain, Size: 5475 bytes --]
Hi Paul,
> On 3/28/19 1:59 AM, Lukasz Majewski wrote:
> > In other words - I shall not introduce new "installed" type for
> > struct timeval and just in posix/bits/types.h define:
> >
> > #ifndef __USE_TIME_BITS64
> > __STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
> > #else
> > __STD_TYPE·__TIME64_T_TYPE __time_t;
> > #endif
> >
> > In that way all structures which use __time_t are Y2038 safe.
> >
> > ONE NOTE:
> > I also guess that the above change keeps those structs posix
> > compliant for 32 bit machines ?
>
> Yes, that's the idea.
>
>
> >
> >> However, we should
> >> not support a complicated API like that, as it's typically not
> >> useful in practice and its mere availability causes more confusion
> >> than it's worth - as I've discovered with _FILE_OFFSET_BITS and
> >> __off64_t.
> >
> > If I may ask - what were the biggest problems?
>
> The biggest problem is confusion and complexity. For example, see
> /usr/include/zlib.h (assuming you have zlib installed). zlib is one of
> the few libraries that tries to support both 32- and 64-bit file
> offsets in user code. Almost nobody understands how it is supposed to
> work, and I'm not sure that it even does work. And even in code that
> doesn't attempt to support this sort of thing, there are still
> problems. See, for example, the comedy of errors in
> <https://stackoverflow.com/questions/22663897/unknown-type-name-off64-t>
> where people suggest monstrosities like -Doff64_t=_off64_t to work
> around compilation issues with the Apache Portable Runtime.
>
> Rather than go down those rabbit holes, it's better to say that the
> entire program must be compiled consistently, i.e., one must compile
> all libraries with -D_TIME_BITS=64 if one plans to use
> -D_TIME_BITS=64 in user code that passes time_t to these libraries.
> This includes OpenSSL, GnuTLS, Kerberos, Glib/Gtk, libpng,
> ImageMagick, etc., etc., as all these libraries expose time_t in
> their APIs. And it's not just libraries: for example, one should
> compile Python with -D_TIME_BITS=64 and all Python modules requiring
> native code and using time_t in their API should also be built with
> -D_TIME_BITS=64.
>
> Although it'll be a real hassle to insist on -D_TIME_BITS=64
> everywhere, it's the only approach that will really work in practice.
The above approach is doable if building the embedded system rootfs in
OE/Yocto.
I do have a setup where only for glibc compilation I do disable
-D_TIME_BITS64, but for _all_ other source code it is enabled.
> That's life. Frankly if it were up to me, I'd make 64-bit time_t the
> default and ask people to compile with -D_TIME_BITS=32 everywhere if
> they have backward-compability concerns, as this will be much better
> in the long run, and would help us avoid many of the issues we ran
> into during the off_t debacle.
>
I see your point.
>
> >> Instead, glibc should have a simple user API where _TIME_BITS=64
> >> merely says "I want 64-bit time_t everywhere" and a module either
> >> uses this option or it doesn't.
> >>
> > So according to above I shall only introduce glibc _internal_ struct
> > __timespec64/__timeval64 in include/bits/types/ :
> >
> > #if __WORDSIZE > 32 || ! defined(__USE_TIME_BITS64)
> > # define __timespec64 timespec;
> > #else
> > struct __timespec64 {
> > __time64_t tv_sec;
> > __int64_t tv_nsec;
> > }
> > #endif
>
> No, these internal interfaces should not be in any file installed
> under /usr/include where users can find them and get confused.
Yes, correct.
I've proposed to install struct __timespec64/__timeval64
in ./include/bits/types directory of glibc (and as fair as I understand
those would be private).
But also, those can be placed in ./include/time.h
> They
> should be only in .h files that are private to glibc and are not
> installed. A logical place for them would be include/time.h.
>
Ok.
> >
> > and rewrite the relevant functions/syscalls (like clock_settime() in
> > this particular case) to use it in glibc ?
>
> Yes, implementations of syscalls can use these internal interfaces.
>
Ok. Good.
>
> >
> > PROBLEM(S) with internal struct __timespec64:
> >
> > - Would be misleading for 32 bit architectures (minor issue)
>
> I'm not sure I understand this point. How would we be misleading users
> by keeping the __time64_t interfaces private?
With __timespec64 exported (installed in usr/include/*) - there would
be an explicit type to show that we are Y2038 safe (when e.g.
debugging).
>
>
> >
> > - Needs to met specific Linux kernel's ABI as it is passed as an
> > argument to Linux syscalls (like clock_settime64).
>
> Yes, internally glibc will need to know what the kernel ABI is, and do
> the right thing. This should be reasonably easy to do if the internal
> glibc interfaces are 64-bit, which they should be.
As presented above - kernel expects in e.g. timespec 64 bit values for
both tv_sec and tv_nsec. Also internal types doesn't need to comply with
POSIX (tv_nsec shall be single long as seen from user space).
>
>
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 --]
next prev parent reply other threads:[~2019-03-29 14:25 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-27 11:20 [PATCH v2 1/2] Y2038: make __mktime_internal compatible with __time64_t Lukasz Majewski
2019-02-27 11:20 ` [PATCH v2 2/2] Fix time/mktime.c and time/gmtime.c for gnulib compatibility Lukasz Majewski
2019-03-12 0:12 ` Paul Eggert
2019-03-06 11:31 ` [PATCH v2 1/2] Y2038: make __mktime_internal compatible with __time64_t Lukasz Majewski
2019-03-12 0:11 ` Paul Eggert
2019-03-12 0:36 ` Joseph Myers
2019-03-17 22:48 ` Lukasz Majewski
2019-03-18 16:27 ` Joseph Myers
2019-03-19 10:53 ` Lukasz Majewski
2019-03-12 6:58 ` Lukasz Majewski
2019-03-18 21:23 ` Paul Eggert
2019-03-19 13:39 ` Lukasz Majewski
2019-03-19 23:12 ` Paul Eggert
2019-03-20 7:03 ` Lukasz Majewski
2019-03-22 21:49 ` Paul Eggert
2019-03-23 21:34 ` Lukasz Majewski
2019-03-24 22:17 ` Lukasz Majewski
2019-03-23 11:59 ` Lukasz Majewski
2019-03-27 20:06 ` Paul Eggert
2019-03-28 8:59 ` Lukasz Majewski
2019-03-28 16:09 ` Paul Eggert
2019-03-29 14:24 ` Lukasz Majewski [this message]
2019-03-29 21:10 ` Paul Eggert
2019-03-30 14:39 ` Lukasz Majewski
2019-04-01 20:17 ` Joseph Myers
2019-04-01 20:51 ` Lukasz Majewski
2019-03-28 16:34 ` Joseph Myers
[not found] ` <20190404120715.150a5d44@jawa>
[not found] ` <20190424135748.502c34af@jawa>
2019-04-28 22:45 ` Paul Eggert
2019-04-30 7:59 ` Lukasz Majewski
2019-04-30 16:25 ` Paul Eggert
2019-05-02 7:19 ` Lukasz Majewski
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190329152452.19d7b78c@jawa \
--to=lukma@denx.de \
--cc=eggert@cs.ucla.edu \
--cc=joseph@codesourcery.com \
--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).