From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104363 invoked by alias); 17 Jul 2019 05:39:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 104355 invoked by uid 89); 17 Jul 2019 05:39:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com From: Florian Weimer To: Alistair Francis Cc: libc-alpha@sourceware.org, arnd@arndb.de, adhemerval.zanella@linaro.org, palmer@sifive.com, macro@wdc.com, zongbox@gmail.com, alistair23@gmail.com Subject: Re: [RFC v3 04/23] sysdeps/clock_gettime: Use clock_gettime64 if avaliable References: <1f589e5a3fcaa4c103bc83169fffcdea9e1a6b2d.1563321715.git.alistair.francis@wdc.com> Date: Wed, 17 Jul 2019 05:39:00 -0000 In-Reply-To: <1f589e5a3fcaa4c103bc83169fffcdea9e1a6b2d.1563321715.git.alistair.francis@wdc.com> (Alistair Francis's message of "Tue, 16 Jul 2019 17:08:51 -0700") Message-ID: <87ftn5dxu8.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2019-07/txt/msg00341.txt.bz2 * Alistair Francis: > diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c > index 52c258e33d..8d9cae7d87 100644 > --- a/nptl/pthread_mutex_timedlock.c > +++ b/nptl/pthread_mutex_timedlock.c > @@ -402,10 +402,17 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, > /* Delay the thread until the timeout is reached. > Then return ETIMEDOUT. */ > struct timespec reltime; > +#ifdef __NR_clock_gettime64 > + struct __timespec64 now; > + > + INTERNAL_SYSCALL (clock_gettime64, __err, 2, CLOCK_REALTIME, > + &now); > +#else > struct timespec now; > > INTERNAL_SYSCALL (clock_gettime, __err, 2, clockid, > &now); > +#endif > reltime.tv_sec = abstime->tv_sec - now.tv_sec; > reltime.tv_nsec = abstime->tv_nsec - now.tv_nsec; > if (reltime.tv_nsec < 0) I believe this needs to be updated for correctness (truncation of tv_sec) if ever ported to architectures where __nanosleep_nocancel takes a 32-bit time_t argument. I don't know what our plans are regarding to that. If you had #define __NR_clock_gettime64 __NR_clock_gettime in , you wouldn't need this change. > diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c > index 5fc47fb7dc..4832069c34 100644 > --- a/sysdeps/unix/sysv/linux/clock_gettime.c > +++ b/sysdeps/unix/sysv/linux/clock_gettime.c > @@ -27,10 +27,40 @@ > #include > > /* Get current value of CLOCK and store it in TP. */ > + > +#if __WORDSIZE == 32 > +int > +__clock_gettime (clockid_t clock_id, struct timespec *tp) > +{ > + int ret; > + > +#ifdef __NR_clock_gettime64 > + struct __timespec64 tp64; > + ret = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, &tp64); > + > + tp->tv_sec = tp64.tv_sec; > + tp->tv_nsec = tp64.tv_nsec; > + > + if (! in_time_t_range (tp->tv_sec)) > + { > + __set_errno (EOVERFLOW); > + return -1; > + } > +#endif > + > +#ifndef __ASSUME_TIME64_SYSCALLS > + ret = INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); > +#endif > + > + return ret; > +} I think this has the same problems as the timespec_get patch. Thanks, Florian