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 v9] y2038: Provide conversion helpers for struct __timespec64


On Thu, 26 Sep 2019, Lukasz Majewski wrote:

> Those functions allow easy conversion between Y2038 safe struct
> __timespec64 and other time related data structures (like struct timeval).
> 
> * include/time.h (valid_timeval_to_timespec64): Add.
> * include/time.h (valid_timespec_to_timespec64): Likewise.
> * include/time.h (valid_timespec64_to_timespec): Likewise.
> * include/time.h (valid_timespec64_to_timeval): Likewise.
> * include/time.h (IS_VALID_NANOSECONDS): Likewise.
> * include/time.h (timespec_to_timespec64): Likewise.
> * include/time.h (timespec64_to_timespec): Likewise.
> * include/time.h (timespec64_to_timeval): Likewise.

OK, though we'll need to watch users of these interfaces carefully to see 
if timespec64_to_timespec and timespec64_to_timeval are the best 
interfaces for the contexts in which they are used.  (The issue is that 
they return false in two different cases, invalid nanoseconds which would 
typically be an EINVAL error and out-of-range seconds which would be 
EOVERFLOW.  So in any case where the caller needs to distinguish those 
conditions to determine what value to use for errno, it would need to 
repeat one of the checks from those functions.  But maybe the compiler 
could optimize the code generated so it doesn't actually end up with a 
duplicate of the nanoseconds range test.)

-- 
Joseph S. Myers
joseph@codesourcery.com


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