From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEB3941835E; Thu, 3 Sep 2026 07:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421110; cv=none; b=EIkofNWAVKR57AJPnQMqRlm0ZEsH+bW6H3yoVL71qJyN41WIRPjAQPOM65d/20hxs0otLarynYfVhm4mdCSd3TJqM8Yhm8qig+5Uphz5XLOLbR3rBsCbp07hWjL7uZ3o/wLYjZ+gFL+Pa553USbQBGymiMGBdIwSZV6vm/HIO1A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421110; c=relaxed/simple; bh=lSRnyAPwkxTiR+7LqZhQLOk8FGTR7q33aG6vR4tUR4k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Nc8OXtRXQv/FLAInNEmrTxdfA1BXKvLkvOAAkaa2z+WRciNq2OflD/Sa9lM4PO7IOb4rlZNXWh+OzTu2s2xwpUAppBhj9WZgq6hN2T/aNdeSLQq1bvyN1mbxcU03MF5At2tlftTAXRnIw8f+kN0sozNoCxlkDjse9Ztgb1KQ5T8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ACkNfwcV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=p67w3Mca; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ACkNfwcV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="p67w3Mca" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DZhPxWlYTtiTqvDB/rjm4ou5PwP5Ufta+ZoHCQD5N8U=; b=ACkNfwcV4/TidgU7f8+L3UC9ET5abkJ1JlL8d9WsDijvKFgB8dOyaHLkT/UVs5rG6Zdq36 NXyl+kG6N7Q9AzPeCwhhZ5fOAkgZlsJIW3wsF/CtefZ+f8ciJTs+ydZobF0cC0d9vlbBHJ VuQOWbg4kYTgfhyExZPaBXR7BR0u5Ess/0h49T9qX4HllpahJCFnV5voK4A/WeDgP3+6kD XM07y7PTQxKtKaaWdbid4EqsUJX/BHQEvk/mzfhwjL3o6SJqsjEqwR8p8xZvq1dDfl3DIb Lh/IVuhm2eAgix+r9Qzy7mVnQL/Wj3a8Y2RTXlU0ykKwSRrls0R66HYOqSWV2Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DZhPxWlYTtiTqvDB/rjm4ou5PwP5Ufta+ZoHCQD5N8U=; b=p67w3Mcaw20hgWdpjigtdw+hQnbQgxqo0wBmStCArBL10JA8noG+fiMGAWObuByEyvmBtw C9qJYDHk2EGX7oDg== Date: Thu, 03 Sep 2026 09:38:18 +0200 Subject: [PATCH v2 6/8] selftests: vDSO: vdso_test_correctness: Make ts_leq() and tv_leq() more generic Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260903-vdso-test-types-v2-6-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=2368; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=lSRnyAPwkxTiR+7LqZhQLOk8FGTR7q33aG6vR4tUR4k=; b=ygg1mL9k4ohqUEq6CzMYiTHZ9YaYWb9uNzAqd5jWFe0c5gLPXhDR+APxYR1J0+9e3bDi92/XI stf7VL3Szl3C0GnNly6tcshPFtzCLEp7Ib3f0JJ/HOscbUHjICy1cl7 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Upcoming changes will shuffle around the timespec and timeval types. To keep ts_leq() and tv_leq() working with all of those types, transform them into macros. Also drop ts64_leq() as it can now be replaced by the regular ts_leq(). Signed-off-by: Thomas Weißschuh --- .../testing/selftests/vDSO/vdso_test_correctness.c | 47 ++++++++++------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c index 5c5a07dd1128..537e0030aa16 100644 --- a/tools/testing/selftests/vDSO/vdso_test_correctness.c +++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c @@ -226,30 +226,27 @@ static void test_getcpu(void) } } -static bool ts_leq(const struct timespec *a, const struct timespec *b) -{ - if (a->tv_sec != b->tv_sec) - return a->tv_sec < b->tv_sec; - else - return a->tv_nsec <= b->tv_nsec; -} - -static bool ts64_leq(const struct __kernel_timespec *a, - const struct __kernel_timespec *b) -{ - if (a->tv_sec != b->tv_sec) - return a->tv_sec < b->tv_sec; - else - return a->tv_nsec <= b->tv_nsec; -} - -static bool tv_leq(const struct timeval *a, const struct timeval *b) -{ - if (a->tv_sec != b->tv_sec) - return a->tv_sec < b->tv_sec; - else - return a->tv_usec <= b->tv_usec; -} +#define ts_leq(_a, _b) ({ \ + bool _ret; \ + \ + if ((_a)->tv_sec != (_b)->tv_sec) \ + _ret = (_a)->tv_sec < (_b)->tv_sec; \ + else \ + _ret = (_a)->tv_nsec <= (_b)->tv_nsec; \ + \ + _ret; \ +}) + +#define tv_leq(_a, _b) ({ \ + bool _ret; \ + \ + if ((_a)->tv_sec != (_b)->tv_sec) \ + _ret = (_a)->tv_sec < (_b)->tv_sec; \ + else \ + _ret = (_a)->tv_usec <= (_b)->tv_usec; \ + \ + _ret; \ +}) static char const * const clocknames[] = { [0] = "CLOCK_REALTIME", @@ -365,7 +362,7 @@ static void test_one_clock_gettime64(int clock, const char *name) (unsigned long long)vdso.tv_sec, vdso.tv_nsec, (unsigned long long)end.tv_sec, end.tv_nsec); - if (!ts64_leq(&start, &vdso) || !ts64_leq(&vdso, &end)) { + if (!ts_leq(&start, &vdso) || !ts_leq(&vdso, &end)) { printf("[FAIL]\tTimes are out of sequence\n"); nerrs++; return; -- 2.55.0