[libc-commits] [libc] [libc] Make errno asserts noop on gpu targets (PR #166606)
Marcell Leleszi via libc-commits
libc-commits at lists.llvm.org
Wed Nov 5 10:22:18 PST 2025
https://github.com/mleleszi updated https://github.com/llvm/llvm-project/pull/166606
>From ecddf868e3383d0b17c8b1a95da1d03c47865738 Mon Sep 17 00:00:00 2001
From: Marcell Leleszi <mleleszi at google.com>
Date: Wed, 5 Nov 2025 18:17:16 +0000
Subject: [PATCH] Make errno asserts noop on gpu targets
---
libc/test/IntegrationTest/test.h | 14 ++++++++++++++
libc/test/UnitTest/ErrnoCheckingTest.h | 14 ++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/libc/test/IntegrationTest/test.h b/libc/test/IntegrationTest/test.h
index 4a03f7aa6318b..126143912f052 100644
--- a/libc/test/IntegrationTest/test.h
+++ b/libc/test/IntegrationTest/test.h
@@ -68,9 +68,23 @@
////////////////////////////////////////////////////////////////////////////////
// Errno checks.
+#ifdef LIBC_TARGET_ARCH_IS_GPU
+#define ASSERT_ERRNO_EQ(VAL)
+#else
#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(errno))
+#endif
+
+#ifdef LIBC_TARGET_ARCH_IS_GPU
+#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(errno))
+#else
#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(errno))
+#endif
+
+#ifdef LIBC_TARGET_ARCH_IS_GPU
+#define ASSERT_ERRNO_FAILURE()
+#else
#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(errno))
+#endif
// Integration tests are compiled with -ffreestanding which stops treating
// the main function as a non-overloadable special function. Hence, we use a
diff --git a/libc/test/UnitTest/ErrnoCheckingTest.h b/libc/test/UnitTest/ErrnoCheckingTest.h
index 5b1bc9441d830..51ff2b6a0a4cc 100644
--- a/libc/test/UnitTest/ErrnoCheckingTest.h
+++ b/libc/test/UnitTest/ErrnoCheckingTest.h
@@ -16,17 +16,31 @@
// Define macro to validate the value stored in the errno and restore it
// to zero.
+#ifdef LIBC_TARGET_ARCH_IS_GPU
+#define ASSERT_ERRNO_EQ(VAL)
+#else
#define ASSERT_ERRNO_EQ(VAL) \
do { \
ASSERT_EQ(VAL, static_cast<int>(libc_errno)); \
libc_errno = 0; \
} while (0)
+#endif
+
+#ifdef LIBC_TARGET_ARCH_IS_GPU
+#define ASSERT_ERRNO_SUCCESS()
+#else
#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
+#endif
+
+#ifdef LIBC_TARGET_ARCH_IS_GPU
+#define ASSERT_ERRNO_FAILURE()
+#else
#define ASSERT_ERRNO_FAILURE() \
do { \
ASSERT_NE(0, static_cast<int>(libc_errno)); \
libc_errno = 0; \
} while (0)
+#endif
namespace LIBC_NAMESPACE_DECL {
namespace testing {
More information about the libc-commits
mailing list