[RFC v2 03/20] y2038: linux: Provide __clock_settime64 implementation

Lukasz Majewski lukma@denx.de
Mon Jul 8 09:32:00 GMT 2019


Hi,

> Hi Alistair,
> 
> > On Thu, Jun 27, 2019 at 3:08 PM Lukasz Majewski <lukma@denx.de>
> > wrote:  
> > >
> > > Hi Arnd,
> > >    
> > > > On Thu, Jun 27, 2019 at 6:17 PM Lukasz Majewski <lukma@denx.de>
> > > > wrote:   
> > > > > >
> > > > > > Ok, so you redirect both __clock_settime64 to
> > > > > > __clock_settime and __NR_settime64 to __NR_settime, in
> > > > > > order to get back to the same definition that you have
> > > > > > today on 64-bit.
> > > > > >
> > > > > > Sorry for taking so long to understand that.    
> > > > >
> > > > > Not only you had a hard time to understand it.    
> > > >
> > > > Here is how I had imagined it would be done in a way that I find
> > > > easier to understand:
> > > >
> > > > #if __WORDSIZE == 32 /* yes, all of them including rv32 and x32
> > > > */ __clock_settime64 (clockid_t clock_id, const struct
> > > > __timespec64 *tp) {
> > > >    int ret;
> > > >
> > > >    /* Make sure the time cvalue is OK.  */
> > > >    if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
> > > >     {
> > > >        __set_errno (EINVAL);
> > > >        return -1;
> > > >      }
> > > > #ifdef __NR_clock_settime64
> > > >  ret = INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp);
> > > > #endif
> > > >
> > > > #ifndef __ASSUME_TIME64_SYSCALLS
> > > >   if (ret == 0 || errno != ENOSYS)
> > > >     return ret;
> > > >
> > > >   if (! in_time_t_range (tp->tv_sec))
> > > >     {
> > > >       __set_errno (EOVERFLOW);
> > > >       return -1;
> > > >     }
> > > >
> > > >   struct timespec ts32;
> > > >   valid_timespec64_to_timespec (tp, &ts32);
> > > >   ret = INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32);
> > > > #endif
> > > >
> > > >   return ret;
> > > > }
> > > > #endif
> > > >
> > > > This should be functionally identical to what you have, but
> > > > avoid some of the complexity, especially once linux-5.1 becomes
> > > > the minimum version.    
> > 
> > This implementation looks good to me. It shouldn't be too hard to
> > extend this to all the problematic y2038 syscalls.  
> 
> This is the plan. After we agree on __ASSUME_TIME64_SYSCALLS semantics
> (the other patch - I've add you to CC on the ping for it) it shall be
> possible to follow a similar pattern as for __clock_settime for other
> syscalls.

The exact list of syscalls which should be eligible for similar to
__clock_settime conversion can be found here:

https://patchwork.ozlabs.org/patch/1117100/

(In the patch comment to be precise).

> 
> >   
> > >
> > > The semantics for __ASSUME_TIME64_SYSCALLS is under the discussion
> > > for some time [1].    
> > 
> > I don't see any comments on this, do you know the status?  
> 
> I'm waiting for Joseph's (and the community) review and final
> acceptance (pulling to main tree). 
> 
> >   
> > >
> > > Also the __clock_settime64() implementation from [2] takes into
> > > account some corner cases (like support for all archs since 3.2
> > > kernel, x32, legacy systems, etc). The implementation from [2]
> > > IMHO seems to be more concise and fits into the 64 bit conversion
> > > paradigm for glibc [3].    
> > 
> > This one also works for RV32 :)  
> 
> Good :-). Nice to have some users and testers :-).
> 
> > 
> > Alistair
> >   
> > >
> > > However, this is only my opinion and we shall wait for other
> > > community members to express their opinions.
> > >    
> > > >
> > > >       Arnd    
> > >
> > >
> > > Note:
> > >
> > > [1] - https://patchwork.ozlabs.org/patch/1117100/
> > > [2] - https://patchwork.ozlabs.org/patch/1107235/
> > > [3] -
> > > https://www.gnu.org/software/libc/manual/html_mono/libc.html
> > > "D.2.1 64-bit time symbol handling in the GNU C Library"
> > >
> > >
> > >
> > > 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    
> 
> 
> 
> 
> 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




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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20190708/f81937b7/attachment.sig>


More information about the Libc-alpha mailing list