1 // RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %run %t
6 #include <sanitizer/msan_interface.h>
11 size_t PS
= sysconf(_SC_PAGESIZE
);
12 void *addr
= mmap(nullptr, 20 * PS
, PROT_READ
| PROT_WRITE
,
13 MAP_PRIVATE
| MAP_ANONYMOUS
, 0, 0);
15 __msan_poison(&vec
, sizeof(vec
));
16 res
= mincore(addr
, 10 * PS
, vec
);
18 assert(__msan_test_shadow(vec
, sizeof(vec
)) == 10);
20 __msan_poison(&vec
, sizeof(vec
));
21 res
= mincore(addr
, 10 * PS
+ 42, vec
);
23 assert(__msan_test_shadow(vec
, sizeof(vec
)) == 11);
25 __msan_poison(&vec
, sizeof(vec
));
26 res
= mincore(addr
, 10 * PS
- 1, vec
);
28 assert(__msan_test_shadow(vec
, sizeof(vec
)) == 10);
30 __msan_poison(&vec
, sizeof(vec
));
31 res
= mincore(addr
, 1, vec
);
33 assert(__msan_test_shadow(vec
, sizeof(vec
)) == 1);