summaryrefslogtreecommitdiff
path: root/test/tsan/mmap_large.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-08-02 07:18:07 +0000
committerFangrui Song <maskray@google.com>2019-08-02 07:18:07 +0000
commit681afdf34bb16d1877e984d157dfd389a79a4256 (patch)
tree4e3f851ec5cfff68846a11843577ed58d4fdd430 /test/tsan/mmap_large.cpp
parent871e3822d6679af8f7cfa763b65258e47f2d8d69 (diff)
downloadcompiler-rt-681afdf34bb16d1877e984d157dfd389a79a4256.tar.gz
compiler-rt: Rename .cc file in test/tsan to .cpp
Like r367463, but for test/tsan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan/mmap_large.cpp')
-rw-r--r--test/tsan/mmap_large.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/tsan/mmap_large.cpp b/test/tsan/mmap_large.cpp
new file mode 100644
index 000000000..c8d258e80
--- /dev/null
+++ b/test/tsan/mmap_large.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+
+// UNSUPPORTED: ios
+
+#include <stdint.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+#if defined(__FreeBSD__)
+// The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
+// that, it was never implemented. So just define it to zero.
+#undef MAP_NORESERVE
+#define MAP_NORESERVE 0
+#endif
+
+int main() {
+#ifdef __x86_64__
+ const size_t kLog2Size = 39;
+#elif defined(__mips64) || defined(__aarch64__)
+ const size_t kLog2Size = 32;
+#elif defined(__powerpc64__)
+ const size_t kLog2Size = 39;
+#endif
+ const uintptr_t kLocation = 0x40ULL << kLog2Size;
+ void *p = mmap(
+ reinterpret_cast<void*>(kLocation),
+ 1ULL << kLog2Size,
+ PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANON|MAP_NORESERVE,
+ -1, 0);
+ fprintf(stderr, "DONE %p %d\n", p, errno);
+ return p == MAP_FAILED;
+}
+
+// CHECK: DONE