This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Y2038: provide kernel support indication


Hi Joseph,

On Wed, 19 Sep 2018 13:03:21 +0000, Joseph Myers
<joseph@codesourcery.com> wrote :

> On Wed, 19 Sep 2018, Albert ARIBAUD (3ADEV) wrote:
> 
> > * New function __y2038_get_kernel_support() returns:
> >   * 0 if the underlying kernel does not support Y2038 at all
> >   * > 0 if the underlying kernel has some support for Y2038
> >   * < 0 if the underlying kernel support for Y2038 is broken
> > * New function __y2038_set_kernel_support() allows indicating
> >   a kernel's Y2038 support (or support failure)
> > * Default implementation (covering non-Linux kernels) always
> >   returns 0 (no support).  
> 
> There should be an __ASSUME_* macro that kernel-features.h defines when 
> the minimum kernel version has the required feature.  Calls to these APIs 
> need to become compile-time constants in that case, with the functions / 
> variables not existing in the glibc binaries at all.

If __ASSUME_KERNEL_Y2038_SUPPORT is defined, then variables and
functions should not be defined at all in the glibc binaries, but I
don't think we need to make calls to these APIs compile-constant in
that case, because there should not be any such calls.

Any code which would depend on __ASSUME_KERNEL_Y2038_SUPPORT to call
either the new 64-bit-time syscall or old 32-bit-time syscall would
basically follow this pattern:

  #ifdef __ASSUME_KERNEL_Y2038_SUPPORT
    unconditionally call new __NR_* syscall using 64-bit-time(s),
    with no fallback on ENOSYS;
  #else
    if __y2038_get_kernel_support() indicates support:
      call new __NR_* syscall with 64-bit time(s);
      if ENOSYS:
        call __y2038_set_kernel_support() to indicate failure;
        perform pre-call 64-to-32-bit time conversions if any;
        call old __NR_* syscall with 32-bit time(s);
        perform post-call 32-to-64-bit time conversions if any.
    else:
      perform pre-call 64-to-32-bit time conversions if any;
      call old __NR_* syscall with 32-bit time(s);
      perform post-call 32-to-64-bit time conversions if any.
  #endif

The 'then' part of the '#if' does not contain any calls to
__y2038_{get,set}_kernel_support() because there is no need for them.

More precisely, the utility of __y2038_get_kernel_support() and
__y2038_set_kernel_support() appears only when we could use either
32-bit-time or 64-bit-time syscalls. We want to try the 64-bit-time
syscalls first because we prefer them and they /may/ be available in
the underlying kernel, but as soon as we learn that 64-bit-time
syscalls are not provided, then we want to stop trying them, and go
straight to 32-bit-time syscalls.

So when __ASSUME_KERNEL_Y2038_SUPPORT is defined, we assume the
64-bit-time syscalls /are/ there, and we don't drop into using
32-bit-time-only anymore; and no falling back means no need to remember
whether we need to fall back later -- i.e., we don't need to call
__y2038_{get,set}_kernel_support() at all.

Cordialement,
Albert ARIBAUD
3ADEV


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]