Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / mmap_large.cpp
bloba6aca720bf8a10141ab2f23861f972c17709b690
1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
3 // UNSUPPORTED: ios
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <errno.h>
8 #include <sys/mman.h>
10 #if defined(__FreeBSD__)
11 // The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
12 // that, it was never implemented. So just define it to zero.
13 #undef MAP_NORESERVE
14 #define MAP_NORESERVE 0
15 #endif
17 int main() {
18 #ifdef __x86_64__
19 const size_t kLog2Size = 39;
20 #elif defined(__mips64) || defined(__aarch64__) || \
21 defined(__loongarch_lp64) || (defined(__riscv) && __riscv_xlen == 64)
22 const size_t kLog2Size = 32;
23 #elif defined(__powerpc64__)
24 const size_t kLog2Size = 39;
25 #elif defined(__s390x__)
26 const size_t kLog2Size = 43;
27 #endif
28 const uintptr_t kLocation = 0x40ULL << kLog2Size;
29 void *p = mmap(
30 reinterpret_cast<void*>(kLocation),
31 1ULL << kLog2Size,
32 PROT_READ|PROT_WRITE,
33 MAP_PRIVATE|MAP_ANON|MAP_NORESERVE,
34 -1, 0);
35 fprintf(stderr, "DONE %p %d\n", p, errno);
36 return p == MAP_FAILED;
39 // CHECK: DONE