llvm-project
39 строк · 1.0 Кб
1// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2
3// UNSUPPORTED: ios
4
5#include <stdint.h>6#include <stdio.h>7#include <errno.h>8#include <sys/mman.h>9
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_NORESERVE14#define MAP_NORESERVE 015#endif16
17int main() {18#ifdef __x86_64__19const size_t kLog2Size = 39;20#elif defined(__mips64) || defined(__aarch64__) || \21defined(__loongarch_lp64) || (defined(__riscv) && __riscv_xlen == 64)22const size_t kLog2Size = 32;23#elif defined(__powerpc64__)24const size_t kLog2Size = 39;25#elif defined(__s390x__)26const size_t kLog2Size = 43;27#endif28const uintptr_t kLocation = 0x40ULL << kLog2Size;29void *p = mmap(30reinterpret_cast<void*>(kLocation),311ULL << kLog2Size,32PROT_READ|PROT_WRITE,33MAP_PRIVATE|MAP_ANON|MAP_NORESERVE,34-1, 0);35fprintf(stderr, "DONE %p %d\n", p, errno);36return p == MAP_FAILED;37}
38
39// CHECK: DONE
40