[compiler-rt] c981f0b - [scudo] Check support for pvalloc/valloc tests.

Christopher Ferris via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 17:51:51 PDT 2023


Author: Christopher Ferris
Date: 2023-06-12T17:51:35-07:00
New Revision: c981f0b428b5cd1c6100dee67eaf0f68d5c3162d

URL: https://github.com/llvm/llvm-project/commit/c981f0b428b5cd1c6100dee67eaf0f68d5c3162d
DIFF: https://github.com/llvm/llvm-project/commit/c981f0b428b5cd1c6100dee67eaf0f68d5c3162d.diff

LOG: [scudo] Check support for pvalloc/valloc tests.

Some platforms do not support pvalloc/valloc so add checks so
that these tests are only run on the appropriate platforms.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D152756

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
index 616cf5491b5e2..05d1d4826bd55 100644
--- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
@@ -20,6 +20,21 @@
 #define __GLIBC_PREREQ(x, y) 0
 #endif
 
+#if SCUDO_FUCHSIA
+// Fuchsia only has valloc
+#define HAVE_VALLOC 1
+#elif SCUDO_ANDROID
+// Android only has pvalloc/valloc on 32 bit
+#if !defined(__LP64__)
+#define HAVE_PVALLOC 1
+#define HAVE_VALLOC 1
+#endif // !defined(__LP64__)
+#else
+// All others assumed to support both functions.
+#define HAVE_PVALLOC 1
+#define HAVE_VALLOC 1
+#endif
+
 extern "C" {
 void malloc_enable(void);
 void malloc_disable(void);
@@ -240,7 +255,7 @@ TEST(ScudoWrappersCTest, MallOpt) {
 #endif
 
 TEST(ScudoWrappersCTest, OtherAlloc) {
-#if !SCUDO_FUCHSIA
+#if HAVE_PVALLOC
   const size_t PageSize = sysconf(_SC_PAGESIZE);
 
   void *P = pvalloc(Size);
@@ -257,7 +272,9 @@ TEST(ScudoWrappersCTest, OtherAlloc) {
   free(P);
 #endif
 
+#if HAVE_VALLOC
   EXPECT_EQ(valloc(SIZE_MAX), nullptr);
+#endif
 }
 
 #if !SCUDO_FUCHSIA


        


More information about the llvm-commits mailing list