Created
March 9, 2020 23:59
-
-
Save kraj/c2922fd4fd54a0ce22554a7129b38d3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From eda817d365c2d02877c47e547209d1d2a7d96dba Mon Sep 17 00:00:00 2001 | |
From: Khem Raj <raj.khem@gmail.com> | |
Date: Mon, 9 Mar 2020 16:30:19 -0700 | |
Subject: [PATCH] memcheck/tests: Fix timerfd syscall test | |
modern libc provides these functions, moreover this also ensures that we | |
are 64bit time_t safe. Fallback to existing definitions if libc does not | |
have the implementation or syscall is not defined | |
Signed-off-by: Khem Raj <raj.khem@gmail.com> | |
--- | |
configure.ac | 1 + | |
memcheck/tests/linux/timerfd-syscall.c | 10 ++++++++-- | |
2 files changed, 9 insertions(+), 2 deletions(-) | |
diff --git a/configure.ac b/configure.ac | |
index 3336329e9..4c607fb8b 100755 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -4206,6 +4206,7 @@ AC_CHECK_HEADERS([ \ | |
sys/syscall.h \ | |
sys/sysnvl.h \ | |
sys/time.h \ | |
+ sys/timerfd.h \ | |
sys/types.h \ | |
]) | |
diff --git a/memcheck/tests/linux/timerfd-syscall.c b/memcheck/tests/linux/timerfd-syscall.c | |
index 4af622cc4..5fb3dbc0a 100644 | |
--- a/memcheck/tests/linux/timerfd-syscall.c | |
+++ b/memcheck/tests/linux/timerfd-syscall.c | |
@@ -53,7 +53,7 @@ | |
* timerfd_* system call numbers introduced in 2.6.23. These constants are | |
* not yet in the glibc 2.7 headers, that is why they are defined here. | |
*/ | |
-#ifndef __NR_timerfd_create | |
+#if !defined(__NR_timerfd_create) && !defined(HAVE_SYS_TIMERFD_H) | |
#if defined(__x86_64__) | |
#define __NR_timerfd_create 283 | |
#elif defined(__i386__) | |
@@ -67,7 +67,7 @@ | |
#endif | |
#endif | |
-#ifndef __NR_timerfd_settime | |
+#if !defined(__NR_timerfd_settime) && !defined(HAVE_SYS_TIMERFD_H) | |
#if defined(__x86_64__) | |
#define __NR_timerfd_settime 286 | |
#define __NR_timerfd_gettime 287 | |
@@ -126,21 +126,27 @@ void set_timespec(struct timespec *tmr, unsigned long long ustime) | |
tmr->tv_nsec = (long) (1000ULL * (ustime % 1000000ULL)); | |
} | |
+#if !defined(HAVE_TIMERFD_CREATE) | |
int timerfd_create(int clockid, int flags) | |
{ | |
return syscall(__NR_timerfd_create, clockid, flags); | |
} | |
+#endif | |
+#if !defined(HAVE_TIMERFD_SETTIME) | |
int timerfd_settime(int ufc, int flags, const struct itimerspec *utmr, | |
struct itimerspec *otmr) | |
{ | |
return syscall(__NR_timerfd_settime, ufc, flags, utmr, otmr); | |
} | |
+#endif | |
+#if !defined(HAVE_TIMERFD_GETTIME) | |
int timerfd_gettime(int ufc, struct itimerspec *otmr) | |
{ | |
return syscall(__NR_timerfd_gettime, ufc, otmr); | |
} | |
+#endif | |
long waittmr(int tfd, int timeo) | |
{ | |
-- | |
2.25.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment