[compiler-rt] r266910 - [msan] Implement GetPageSize in the test.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 13:32:18 PDT 2016


Author: eugenis
Date: Wed Apr 20 15:32:18 2016
New Revision: 266910

URL: http://llvm.org/viewvc/llvm-project?rev=266910&view=rev
Log:
[msan] Implement GetPageSize in the test.

Instead of calling a sanitizer_common function, implement GetPageSize in the
test directly. MSan runtime does not export __sanitizer::* symbols, and the
current code breaks when the test and the runtime library are in the separate
link units (ex. when the test is built as a shared library).

Modified:
    compiler-rt/trunk/lib/msan/tests/msan_test.cc

Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=266910&r1=266909&r2=266910&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Wed Apr 20 15:32:18 2016
@@ -115,13 +115,9 @@ void *mempcpy(void *dest, const void *sr
 # define SUPERUSER_GROUP "root"
 #endif
 
-// We cannot include sanitizer_common.h (it conflicts with public interface
-// headers), so just pull this function directly.
-
-namespace __sanitizer {
-uintptr_t GetPageSizeCached();
+static uintptr_t GetPageSize() {
+  return sysconf(_SC_PAGESIZE);
 }
-using __sanitizer::GetPageSizeCached;
 
 const size_t kMaxPathLength = 4096;
 
@@ -3239,7 +3235,7 @@ TEST(MemorySanitizer, memalign) {
 
 TEST(MemorySanitizer, valloc) {
   void *a = valloc(100);
-  uintptr_t PageSize = GetPageSizeCached();
+  uintptr_t PageSize = GetPageSize();
   EXPECT_EQ(0U, (uintptr_t)a % PageSize);
   free(a);
 }
@@ -3247,7 +3243,7 @@ TEST(MemorySanitizer, valloc) {
 // There's no pvalloc() on FreeBSD.
 #if !defined(__FreeBSD__)
 TEST(MemorySanitizer, pvalloc) {
-  uintptr_t PageSize = GetPageSizeCached();
+  uintptr_t PageSize = GetPageSize();
   void *p = pvalloc(PageSize + 100);
   EXPECT_EQ(0U, (uintptr_t)p % PageSize);
   EXPECT_EQ(2 * PageSize, __sanitizer_get_allocated_size(p));




More information about the llvm-commits mailing list