From patchwork Mon Mar 9 23:36:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 184340 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp50209ile; Mon, 9 Mar 2020 16:37:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtpnF+GRe8fP+4V75iJvg082vtCTOJghZ/x7A+3rTNCCQfnFoltVc4cp9kV9g6MtA59rjR6 X-Received: by 2002:a17:902:c389:: with SMTP id g9mr4016918plg.19.1583797027663; Mon, 09 Mar 2020 16:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583797027; cv=none; d=google.com; s=arc-20160816; b=g8N7ESZkZuVw4C17vN+4ajZkt0TJ5oNKgN5FkqS3rv13/D8s+9PFCHghWlIAjoEI0l tITiARrxuHUG1StBADrdPBUlXQstBvLLkWzPknS4wCEkoYZPCSI329nWzKXsnf9yMcRu wzFFiex7RzUOgtG3vXItreUMppYgst6jKyj7Ka6mYLBNrpMghVDKmsB1HwzVEW4s7A79 M7RfWQd6Fr+gzypJUQe+zF1/J7JcEBxTkLuUKXjW8mCwIT8dYNj5HDiubsiz/cmZtOBe 5ltRv85IDp+8rBqL7v+GDBIcRTkgpDbBv9ksjJsIoG610Ovy3DDnJCq9yPxC0WyZfpDH ndxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:dkim-signature :dkim-signature; bh=UqBFmeFGaiWnUKjHJutXWnY0ONH7yr8/xAsyf3tjco4=; b=WeorQLuG/XncEbAEoWmdPY22ifczd1Uom8XG61Q6bGH92hX+n+ASMmFfszyq19BAY2 YsutQc33HEU/DUXCDdyeJOQ3YIrtcwa5+0Hqbsy9xtHiyo3Z+OZSfzqR7rckCHi05Jl7 ktH9cjArvUV/RKd/4xgfX+KiRXP8HmJp8I7Kqitn92ThRYE5Yi7af+1rlyoIh5TYa6kb evXuxjyb8k7MWsVtcDFHaf8aZMA7MEbyi1K4tw+dByL7FOt6ZtvXrBuQrTWd2NNnYTcU 4HPbV4J1DeA5U9HcQHPyNMFquQaz5lYj5K8FvE5SgQKhHf0lqBQ9ZZBTE+P9IAalyTU7 xTdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=EAHJ36WX; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=kHobBD0E; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=uvqKszwv; spf=pass (google.com: domain of valgrind-developers-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=valgrind-developers-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id e9si1449686pgh.153.2020.03.09.16.37.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Mar 2020 16:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of valgrind-developers-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=EAHJ36WX; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=kHobBD0E; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=uvqKszwv; spf=pass (google.com: domain of valgrind-developers-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=valgrind-developers-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jBRwu-0005By-Tn; Mon, 09 Mar 2020 23:36:40 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jBRwt-0005Bi-Fz for valgrind-developers@lists.sourceforge.net; Mon, 09 Mar 2020 23:36:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EdPskh/k51/fZPBpUdQGBU3FsLn4VRYth/cd4LqVZMU=; b=EAHJ36WXOmsUR+3bYSZm99RBJT XkWTA/7agpmVQ0zNOE4yFqQT3haRdAIq5lp1Pv6KYnyFOpC180PgKCnmF1/zQO6aQGqvL+/rQ9G5A bpTWX95JAjsKHhjHYSuMwwj1JWAb6+5EMz6tFy7tK1pmiwT15by4lv9RjOaqLXCJdElA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=EdPskh/k51/fZPBpUdQGBU3FsLn4VRYth/cd4LqVZMU=; b=k HobBD0EXoDHtaPbjNWzcVz1TDTCh7glhMrPO+S2uxppxjL9gG2wXPc8D3dUB988qZzJAbOzddjLUQ L4jAT978aASgj+0QytVRrwCJ6ffYXI3qWRnaspF/gRabbfe04CbN8V8Zk8qHr0JNLxIVMmhl1pKeF msIXz91ITg+XyZLI=; Received: from mail-pf1-f195.google.com ([209.85.210.195]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jBRwo-007BYj-62 for valgrind-developers@lists.sourceforge.net; Mon, 09 Mar 2020 23:36:39 +0000 Received: by mail-pf1-f195.google.com with SMTP id z65so5551161pfz.8 for ; Mon, 09 Mar 2020 16:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EdPskh/k51/fZPBpUdQGBU3FsLn4VRYth/cd4LqVZMU=; b=uvqKszwvCfoSFGXG9jlmPDJd9zNTg3o1S3KXzpv5BaHyoLfXjouRYj3ivvO0b8Qfpk FiKLpfbRnBD+f/z0GLV6jcF16H3Fw7pambdrDmVfQVDWg1bv4c/x+r8uow8+vi+NjaUN 2CaR3zT4dflyJbe9Xc+M1tqYk7c2NMH0pVOKDAXRfGMuPMHSSdhKd8lYOrYcvudBs5ht PmE/mMOiyjwXbHzYtneKoOIj4gR4Q68JFIsS1GfV4GQqSjmXzP/stQmynWPvSly46P8T bcAZf6RNcNKVyN5JGIyzWgvsfNpRi3bHl5wx1bkjgF9erEJerhYsIpkABPnSE7TIqXZq JenQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EdPskh/k51/fZPBpUdQGBU3FsLn4VRYth/cd4LqVZMU=; b=dei1WC3UDTUP6UNZRXcYKry62BIf7Pqe8mr1I0NOUhDvL3/n/8W3C48Lqp9HVQR+fg TtSDk6GJXWGr0TZYDYnKybgxT4TQQ7YFsXEByvQOlEsa+uLfxF0+a2hArVhOjM/ui6t3 v12gk2Lv3c2yABqyz9wt9i/zA/w41TP1rfr+WJNuDXJqmiAQeGnyBpUETxTVzpbfRPRh KAv/bHrvvFpatovzAix8dra2PIxRIa3zk+Tgi8pHkoba5DXG4I5DkiOqmRciTyyJKjNy CykmWGdlx5BtpyGmj3OGG1HnvYO5uZ0KHL1+ltJtQBLQWrUejIfT82mriPQ6fDF6y+Iz H6jw== X-Gm-Message-State: ANhLgQ09O07E1xu0bac1TrEATdGrfdfGaOe6CcTPc0O/aZwKGcWOyyTF Q/Bl0CZ0e0xNgvcRNzHquP9tNBM4Sds= X-Received: by 2002:a63:334c:: with SMTP id z73mr16179996pgz.421.1583796987703; Mon, 09 Mar 2020 16:36:27 -0700 (PDT) Received: from apollo.hsd1.ca.comcast.net ([2601:646:9200:4e0::1c34]) by smtp.gmail.com with ESMTPSA id j15sm13521715pfn.86.2020.03.09.16.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 16:36:27 -0700 (PDT) From: Khem Raj To: valgrind-developers@lists.sourceforge.net Date: Mon, 9 Mar 2020 16:36:39 -0700 Message-Id: <20200309233639.1352764-1-raj.khem@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Score: -0.1 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.210.195 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (raj.khem[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.210.195 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1jBRwo-007BYj-62 Subject: [Valgrind-developers] [PATCH] memcheck/tests: Fix timerfd syscall test X-BeenThere: valgrind-developers@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: Technical discussion for valgrind developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: valgrind-developers-bounces@lists.sourceforge.net 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 --- 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(-) -- 2.25.1 _______________________________________________ Valgrind-developers mailing list Valgrind-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-developers diff --git a/config.h b/config.h index 18bb1c2..6f56dbe 100644 --- a/config.h +++ b/config.h @@ -311,6 +311,15 @@ /* Define to 1 if defines struct user_regs_struct */ /* #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 diff --git a/config.h.in b/config.h.in index 9747421..0f7cfca 100644 --- a/config.h.in +++ b/config.h.in @@ -310,6 +310,15 @@ /* Define to 1 if 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 diff --git a/configure b/configure index e6b79b6..9f5d9aa 100755 --- a/configure +++ b/configure @@ -14681,6 +14681,9 @@ for ac_func in \ strrchr \ strstr \ syscall \ + timerfd_create \ + timerfd_gettime \ + timerfd_settime \ utimensat \ process_vm_readv \ process_vm_writev \ diff --git a/configure.ac b/configure.ac index 8ea157b..44f129c 100755 --- 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 \ diff --git a/memcheck/tests/linux/timerfd-syscall.c b/memcheck/tests/linux/timerfd-syscall.c index 74f0682..a024715 100644 --- 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, 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) {