[OE-core] [PATCH 2/2] valgrind: Fix timerfb syscall test to be 64bit time_t safe
Khem Raj
raj.khem at gmail.com
Mon Mar 9 23:44:54 UTC 2020
This helps compile the testcase with musl on 32bit arches
Signed-off-by: Khem Raj <raj.khem at gmail.com>
---
...check-tests-Fix-timerfd-syscall-test.patch | 210 ++++++++++++++++++
.../valgrind/valgrind_3.15.0.bb | 1 +
2 files changed, 211 insertions(+)
create mode 100644 meta/recipes-devtools/valgrind/valgrind/0001-memcheck-tests-Fix-timerfd-syscall-test.patch
diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-memcheck-tests-Fix-timerfd-syscall-test.patch b/meta/recipes-devtools/valgrind/valgrind/0001-memcheck-tests-Fix-timerfd-syscall-test.patch
new file mode 100644
index 0000000000..d1d96a0eff
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0001-memcheck-tests-Fix-timerfd-syscall-test.patch
@@ -0,0 +1,210 @@
+From 5d411fd147d652e9d7bb259f4048693c6e4742aa Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem at 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
+
+Upstream-Status: Submitted [https://sourceforge.net/p/valgrind/mailman/message/36943866/]
+Signed-off-by: Khem Raj <raj.khem at gmail.com>
+---
+ config.h | 9 +++++++++
+ config.h.in | 9 +++++++++
+ configure | 3 +++
+ configure.ac | 3 +++
+ memcheck/tests/linux/timerfd-syscall.c | 10 ++++++++--
+ 5 files changed, 32 insertions(+), 2 deletions(-)
+
+--- a/config.h
++++ b/config.h
+@@ -47,20 +47,20 @@
+ /* #undef ENABLE_LTO */
+
+ /* path to GDB */
+-#define GDB_PATH "/usr/bin/gdb"
++#define GDB_PATH "/no/gdb/was/found/at/configure/time"
+
+ /* Define to 1 if index() and strlen() have been optimized heavily (x86 glibc
+ >= 2.12) */
+-#define GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT 1
++/* #undef GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT */
+
+ /* Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10) */
+-#define GLIBC_MANDATORY_STRLEN_REDIRECT 1
++/* #undef GLIBC_MANDATORY_STRLEN_REDIRECT */
+
+ /* Define to 1 if you have the <asm/unistd.h> header file. */
+ #define HAVE_ASM_UNISTD_H 1
+
+ /* Define to 1 if as supports fxsave64/fxrstor64. */
+-#define HAVE_AS_AMD64_FXSAVE64 1
++/* #undef HAVE_AS_AMD64_FXSAVE64 */
+
+ /* Define to 1 if as supports floating point phased out category. */
+ /* #undef HAVE_AS_PPC_FPPO */
+@@ -92,7 +92,7 @@
+ #define HAVE_CLOCK_MONOTONIC 1
+
+ /* Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID. */
+-#define HAVE_DLINFO_RTLD_DI_TLS_MODID 1
++/* #undef HAVE_DLINFO_RTLD_DI_TLS_MODID */
+
+ /* Define to 1 if the system has the type `Elf32_Chdr'. */
+ #define HAVE_ELF32_CHDR 1
+@@ -134,7 +134,7 @@
+ /* #undef HAVE_LIBSCF */
+
+ /* Define to 1 if you have the `mallinfo' function. */
+-#define HAVE_MALLINFO 1
++/* #undef HAVE_MALLINFO */
+
+ /* Define to 1 if you have the `memchr' function. */
+ #define HAVE_MEMCHR 1
+@@ -176,26 +176,26 @@
+ /* #undef HAVE_PTHREAD_CREATE_GLIBC_2_0 */
+
+ /* Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant. */
+-#define HAVE_PTHREAD_MUTEX_ADAPTIVE_NP 1
++/* #undef HAVE_PTHREAD_MUTEX_ADAPTIVE_NP */
+
+ /* Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant. */
+-#define HAVE_PTHREAD_MUTEX_ERRORCHECK_NP 1
++/* #undef HAVE_PTHREAD_MUTEX_ERRORCHECK_NP */
+
+ /* Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant. */
+-#define HAVE_PTHREAD_MUTEX_RECURSIVE_NP 1
++/* #undef HAVE_PTHREAD_MUTEX_RECURSIVE_NP */
+
+ /* Define to 1 if you have the `pthread_mutex_timedlock' function. */
+ #define HAVE_PTHREAD_MUTEX_TIMEDLOCK 1
+
+ /* Define to 1 if pthread_mutex_t has a member __data.__kind. */
+-#define HAVE_PTHREAD_MUTEX_T__DATA__KIND 1
++/* #undef HAVE_PTHREAD_MUTEX_T__DATA__KIND */
+
+ /* Define to 1 if pthread_mutex_t has a member called __m_kind. */
+ /* #undef HAVE_PTHREAD_MUTEX_T__M_KIND */
+
+ /* Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP'
+ constant. */
+-#define HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP 1
++/* #undef HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP */
+
+ /* Define to 1 if you have the `pthread_rwlock_t' type. */
+ #define HAVE_PTHREAD_RWLOCK_T 1
+@@ -213,7 +213,7 @@
+ #define HAVE_PTHREAD_SPIN_LOCK 1
+
+ /* Define to 1 if you have the `pthread_yield' function. */
+-#define HAVE_PTHREAD_YIELD 1
++/* #undef HAVE_PTHREAD_YIELD */
+
+ /* Define to 1 if you have the `PTRACE_GETREGS' ptrace request. */
+ #define HAVE_PTRACE_GETREGS 1
+@@ -309,7 +309,16 @@
+ #define HAVE_SYS_TYPES_H 1
+
+ /* Define to 1 if <sys/user.h> defines struct user_regs_struct */
+-#define HAVE_SYS_USER_REGS 1
++/* #undef HAVE_SYS_USER_REGS */
++
++/* Define to 1 if you have the `timerfd_create' function. */
++#define HAVE_TIMERFD_CREATE 1
++
++/* Define to 1 if you have the `timerfd_gettime' function. */
++#define HAVE_TIMERFD_GETTIME 1
++
++/* Define to 1 if you have the `timerfd_settime' function. */
++#define HAVE_TIMERFD_SETTIME 1
+
+ /* can use __thread to define thread-local variables */
+ #define HAVE_TLS 1
+@@ -324,7 +333,7 @@
+ #define HAVE_UTIMENSAT 1
+
+ /* Define to 1 if you're using Musl libc */
+-/* #undef MUSL_LIBC */
++#define MUSL_LIBC 1
+
+ /* Name of package */
+ #define PACKAGE "valgrind"
+--- a/config.h.in
++++ b/config.h.in
+@@ -310,6 +310,15 @@
+ /* Define to 1 if <sys/user.h> defines struct user_regs_struct */
+ #undef HAVE_SYS_USER_REGS
+
++/* Define to 1 if you have the `timerfd_create' function. */
++#undef HAVE_TIMERFD_CREATE
++
++/* Define to 1 if you have the `timerfd_gettime' function. */
++#undef HAVE_TIMERFD_GETTIME
++
++/* Define to 1 if you have the `timerfd_settime' function. */
++#undef HAVE_TIMERFD_SETTIME
++
+ /* can use __thread to define thread-local variables */
+ #undef HAVE_TLS
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -4169,6 +4169,9 @@ AC_CHECK_FUNCS([ \
+ strrchr \
+ strstr \
+ syscall \
++ timerfd_create \
++ timerfd_gettime \
++ timerfd_settime \
+ utimensat \
+ process_vm_readv \
+ process_vm_writev \
+--- a/memcheck/tests/linux/timerfd-syscall.c
++++ b/memcheck/tests/linux/timerfd-syscall.c
+@@ -54,7 +54,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_TIMERFD_CREATE)
+ #if defined(__x86_64__)
+ #define __NR_timerfd_create 283
+ #elif defined(__i386__)
+@@ -68,7 +68,7 @@
+ #endif
+ #endif
+
+-#ifndef __NR_timerfd_settime
++#if !defined(__NR_timerfd_settime) && !defined(HAVE_TIMERFD_SETTIME)
+ #if defined(__x86_64__)
+ #define __NR_timerfd_settime 286
+ #define __NR_timerfd_gettime 287
+@@ -127,21 +127,27 @@ void set_timespec(struct timespec *tmr,
+ 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)
+ {
diff --git a/meta/recipes-devtools/valgrind/valgrind_3.15.0.bb b/meta/recipes-devtools/valgrind/valgrind_3.15.0.bb
index 1475ff841e..7954437a1a 100644
--- a/meta/recipes-devtools/valgrind/valgrind_3.15.0.bb
+++ b/meta/recipes-devtools/valgrind/valgrind_3.15.0.bb
@@ -41,6 +41,7 @@ SRC_URI = "https://sourceware.org/pub/valgrind/valgrind-${PV}.tar.bz2 \
file://s390x_vec_op_t.patch \
file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
file://0001-tests-Make-pthread_detatch-call-portable-across-plat.patch \
+ file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
"
SRC_URI[md5sum] = "46e5fbdcbc3502a5976a317a0860a975"
SRC_URI[sha256sum] = "417c7a9da8f60dd05698b3a7bc6002e4ef996f14c13f0ff96679a16873e78ab1"
--
2.25.1
More information about the Openembedded-core
mailing list