2014-05-01 05:34:17 +08:00
|
|
|
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
|
2014-04-23 15:01:02 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
2014-12-05 23:42:17 +08:00
|
|
|
#include <errno.h>
|
2014-04-23 15:01:02 +08:00
|
|
|
#include <sys/mman.h>
|
|
|
|
|
2015-03-24 03:40:59 +08:00
|
|
|
#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
|
|
|
|
|
2014-04-23 15:01:02 +08:00
|
|
|
int main() {
|
2015-02-20 17:32:45 +08:00
|
|
|
#ifdef __x86_64__
|
2014-12-05 23:42:17 +08:00
|
|
|
const size_t kLog2Size = 39;
|
2015-08-05 23:17:59 +08:00
|
|
|
#elif defined(__mips64) || defined(__aarch64__)
|
2015-02-20 17:32:45 +08:00
|
|
|
const size_t kLog2Size = 32;
|
2015-12-09 05:54:39 +08:00
|
|
|
#elif defined(__powerpc64__)
|
|
|
|
const size_t kLog2Size = 39;
|
2015-02-20 17:32:45 +08:00
|
|
|
#endif
|
2014-04-23 15:01:02 +08:00
|
|
|
const uintptr_t kLocation = 0x40ULL << kLog2Size;
|
|
|
|
void *p = mmap(
|
|
|
|
reinterpret_cast<void*>(kLocation),
|
|
|
|
1ULL << kLog2Size,
|
|
|
|
PROT_READ|PROT_WRITE,
|
2015-12-03 18:46:26 +08:00
|
|
|
MAP_PRIVATE|MAP_ANON|MAP_NORESERVE,
|
2014-04-23 15:01:02 +08:00
|
|
|
-1, 0);
|
2014-12-05 23:42:17 +08:00
|
|
|
fprintf(stderr, "DONE %p %d\n", p, errno);
|
2014-04-23 15:01:02 +08:00
|
|
|
return p == MAP_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: DONE
|