]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/tsan/mmap_large.cc
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / tsan / mmap_large.cc
1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include <stdint.h>
3 #include <stdio.h>
4 #include <errno.h>
5 #include <sys/mman.h>
6
7 #if defined(__FreeBSD__)
8 // The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
9 // that, it was never implemented. So just define it to zero.
10 #undef MAP_NORESERVE
11 #define MAP_NORESERVE 0
12 #endif
13
14 int main() {
15 #ifdef __x86_64__
16 const size_t kLog2Size = 39;
17 #elif defined(__mips64) || defined(__aarch64__)
18 const size_t kLog2Size = 32;
19 #elif defined(__powerpc64__)
20 const size_t kLog2Size = 39;
21 #endif
22 const uintptr_t kLocation = 0x40ULL << kLog2Size;
23 void *p = mmap(
24 reinterpret_cast<void*>(kLocation),
25 1ULL << kLog2Size,
26 PROT_READ|PROT_WRITE,
27 MAP_PRIVATE|MAP_ANON|MAP_NORESERVE,
28 -1, 0);
29 fprintf(stderr, "DONE %p %d\n", p, errno);
30 return p == MAP_FAILED;
31 }
32
33 // CHECK: DONE