aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/clock_getres.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-12-13 17:30:15 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-01-03 10:02:05 -0300
commitd0def09ff6bbf1537beec305fdfe96a21174fb31 (patch)
treea5fa523331ba965b0f6a876ea69f463c6c5a2e9f /sysdeps/unix/sysv/linux/clock_getres.c
parentb03688bfbb072f42970747bc2e6362c24b4b7ee8 (diff)
downloadglibc-d0def09ff6bbf1537beec305fdfe96a21174fb31.tar
glibc-d0def09ff6bbf1537beec305fdfe96a21174fb31.tar.gz
glibc-d0def09ff6bbf1537beec305fdfe96a21174fb31.tar.bz2
glibc-d0def09ff6bbf1537beec305fdfe96a21174fb31.zip
linux: Fix vDSO macros build with time64 interfaces
As indicated on libc-help [1] the ec138c67cb commit broke 32-bit builds when configured with --enable-kernel=5.1 or higher. The scenario 10 from [2] might also occur in this configuration and INLINE_VSYSCALL will try to use the vDSO symbol and HAVE_CLOCK_GETTIME64_VSYSCALL does not set HAVE_VSYSCALL prior its usage. Also, there is no easy way to just enable the code to use one vDSO symbol since the macro INLINE_VSYSCALL is redefined if HAVE_VSYSCALL is set. Instead of adding more pre-processor handling and making the code even more convoluted, this patch removes the requirement of defining HAVE_VSYSCALL before including sysdep-vdso.h to enable vDSO usage. The INLINE_VSYSCALL is now expected to be issued inside a HAVE_*_VSYSCALL check, since it will try to use the internal vDSO pointers. Both clock_getres and clock_gettime vDSO code for time64_t were removed since there is no vDSO setup code for the symbol (an architecture can not set HAVE_CLOCK_GETTIME64_VSYSCALL). Checked on i686-linux-gnu (default and with --enable-kernel=5.1), x86_64-linux-gnu, aarch64-linux-gnu, and powerpc64le-linux-gnu. I also checked against a build to mips64-linux-gnu and sparc64-linux-gnu. [1] https://sourceware.org/ml/libc-help/2019-12/msg00014.html [2] https://sourceware.org/ml/libc-alpha/2019-12/msg00142.html Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'sysdeps/unix/sysv/linux/clock_getres.c')
-rw-r--r--sysdeps/unix/sysv/linux/clock_getres.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c
index f55cf39d31..d3cabfcb2f 100644
--- a/sysdeps/unix/sysv/linux/clock_getres.c
+++ b/sysdeps/unix/sysv/linux/clock_getres.c
@@ -20,9 +20,6 @@
#include <errno.h>
#include <time.h>
-#ifdef HAVE_CLOCK_GETRES_VSYSCALL
-# define HAVE_VSYSCALL
-#endif
#include <sysdep-vdso.h>
#include <shlib-compat.h>
#include <kernel-features.h>
@@ -32,23 +29,34 @@ int
__clock_getres64 (clockid_t clock_id, struct __timespec64 *res)
{
#ifdef __ASSUME_TIME64_SYSCALLS
-# ifndef __NR_clock_getres_time64
- return INLINE_VSYSCALL (clock_getres, 2, clock_id, res);
+ /* 64 bit ABIs or Newer 32-bit ABIs that only support 64-bit time_t. */
+# ifdef __NR_clock_getres_time64
+ return INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res);
# else
- return INLINE_SYSCALL (clock_getres_time64, 2, clock_id, res);
+# ifdef HAVE_CLOCK_GETRES_VSYSCALL
+ return INLINE_VSYSCALL (clock_getres, 2, clock_id, res);
+# else
+ return INLINE_SYSCALL_CALL (clock_getres, clock_id, res);
+# endif
# endif
#else
+ int r;
+ /* Old 32-bit ABI with possible 64-bit time_t support. */
# ifdef __NR_clock_getres_time64
- int ret = INLINE_SYSCALL (clock_getres_time64, 2, clock_id, res);
- if (ret == 0 || errno != ENOSYS)
- return ret;
+ r = INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res);
+ if (r == 0 || errno != ENOSYS)
+ return r;
# endif
+ /* Fallback code that uses 32-bit support. */
struct timespec ts32;
- int retval = INLINE_VSYSCALL (clock_getres, 2, clock_id, &ts32);
- if (! retval && res)
+# ifdef HAVE_CLOCK_GETRES_VSYSCALL
+ r = INLINE_VSYSCALL (clock_getres, 2, clock_id, &ts32);
+# else
+ r = INLINE_SYSCALL_CALL (clock_getres, clock_id, &ts32);
+# endif
+ if (r == 0)
*res = valid_timespec_to_timespec64 (ts32);
-
- return retval;
+ return r;
#endif
}
@@ -60,7 +68,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res)
int retval;
retval = __clock_getres64 (clock_id, &ts64);
- if (! retval && res)
+ if (retval == 0 && res != NULL)
*res = valid_timespec64_to_timespec (ts64);
return retval;