mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: "H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	klibc-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org,
	libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org,
	y2038-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	musl-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Rich Felker <dalias-8zAoT0mYgF4@public.gmane.org>,
	cferris-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	enh-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	"Joseph S. Myers"
	<joseph-qD8j1LwMmJjtCj0u4l0SBw@public.gmane.org>
Subject: Re: [klibc] kernel/libc uapi changes for y2038
Date: Wed, 27 May 2015 22:19:52 +0200	[thread overview]
Message-ID: <2268301.gQGnhXiZzi@wuerfel> (raw)
In-Reply-To: <5565E2AC.3070306-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>

On Wednesday 27 May 2015 08:28:44 H. Peter Anvin wrote:
> On 05/18/2015 02:53 AM, Arnd Bergmann wrote:
> > In the patch series I posted recently [1], I introduce new system calls to deal
> > with modified data structures, but left the question open on how these should
> > be best accessed from libc. The patches introduce a new __kernel_time64_t type
> > and based on that five new data structured: struct __kernel_timespec,
> > struct __kernel_itimerspec, struct __kernel_stat, struct __kernel_rusage,
> > and struct __kernel_timex. This works fine for the case when all libc
> > implementations provide their own definitions to user space, but not for
> > the simplest case (e.g. klibc) where the user-visible structures come directly
> > from the kernel uapi headers.
> > 
> > I still don't know what model the various libc developers prefer, so here is
> > an alternative approach, as a patch on top of the previous series:
> > 
> > Now, we rename the original structures to struct __old_kernel_*, and use a
> > macro to define either the __old_kernel_* or the __kernel_* structure name
> > to the name we actually want in user space, based on a __KERNEL_TIME_BITS
> > macro that can be set to either 32 or 64 for 32-bit architectures by
> > the libc. Depending on that macro, the compiler will either see one
> > of these combinations (for each of the five structures):
> > 
> > a) __BITS_PER_LONG == 32 && __KERNEL_TIME_BITS == 32:
> > 
> >    struct timespec              based on 32-bit __kernel_time_t
> >    struct __kernel_timespec     based on 64-bit __kernel_time64_t
> > 
> > b) __BITS_PER_LONG == 64 && __KERNEL_TIME_BITS == 64:
> > 
> >    struct timespec              based on 64-bit __kernel_time_t
> >    struct __kernel_timespec     based on 64-bit __kernel_time64_t
> > 
> > c) __BITS_PER_LONG == 32 && __KERNEL_TIME_BITS == 64:
> > 
> >    struct __old_kernel_timespec based on 32-bit __kernel_time_t
> >    struct timespec              based on 64-bit __kernel_time64_t
> > 
> > Would this work for everyone?  Any alternative suggestions?
> > 
> 
> It seems to work, except I don't really understand why there is a
> difference between (b) and (c).

I tried to keep a) and b) similar, and change nothing other than the
introduction of the extra __kernel_time64_t and __kernel_timespec
here, for the case of __KERNEL_TIME_BITS == __BITS_PER_LONG, in order
to minimize the risk of introducing regressions for existing libc
builds against new kernel headers.

Case c) is the only one that actually changes the existing definitions,
which makes it different from both a) and b).

> I also have no problem just having klibc contain its own definitions of
> these structures, as long as one can prevent the kernel from defining them.

Ok, good to know. If that works for all libc implementations, we
could take a simpler approach and just define __old_kernel_timespec
plus __kernel_timespec but not timespec (and respectively for the
other structures) when __KERNEL_TIME_BITS == 64 is set, and leave
the real user space definitions up to libc (which can then
add the #defines or not if they want to).

	Arnd

      parent reply	other threads:[~2015-05-27 20:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18  9:53 Arnd Bergmann
2015-05-18 12:16 ` [klibc] " Thorsten Glaser
2015-05-18 13:32   ` [Y2038] " Arnd Bergmann
2015-05-18 17:03     ` Thorsten Glaser
2015-05-18 20:35       ` Arnd Bergmann
2015-05-19 17:54 ` [Y2038] " John Stultz
2015-05-27 15:28 ` [klibc] " H. Peter Anvin
     [not found]   ` <5565E2AC.3070306-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2015-05-27 20:19     ` Arnd Bergmann [this message]

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=2268301.gQGnhXiZzi@wuerfel \
    --to=arnd-r2ngtmty4d4@public.gmane.org \
    --cc=cferris-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=dalias-8zAoT0mYgF4@public.gmane.org \
    --cc=enh-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
    --cc=joseph-qD8j1LwMmJjtCj0u4l0SBw@public.gmane.org \
    --cc=klibc-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
    --cc=libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=musl-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org \
    --cc=y2038-cunTk1MwBs8s++Sfvej+rw@public.gmane.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.
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).