1 // RUN: %clangxx_asan -std=c++11 -O0 %s -o %t && %run %t
10 size_t PS
= sysconf(_SC_PAGESIZE
);
11 void *addr
= mmap(nullptr, 20 * PS
, PROT_READ
| PROT_WRITE
,
12 MAP_NORESERVE
| MAP_PRIVATE
| MAP_ANONYMOUS
, 0, 0);
14 res
= mincore(addr
, 10 * PS
, vec
);
16 for (int i
= 0; i
< 10; ++i
)
17 assert((vec
[i
] & 1) == 0);
19 for (int i
= 0; i
< 5; ++i
)
20 ((char *)addr
)[i
* PS
] = 1;
21 res
= mincore(addr
, 10 * PS
, vec
);
23 for (int i
= 0; i
< 10; ++i
)
24 assert((vec
[i
] & 1) == (i
< 5));
26 for (int i
= 5; i
< 10; ++i
)
27 ((char *)addr
)[i
* PS
] = 1;
28 res
= mincore(addr
, 10 * PS
, vec
);
30 for (int i
= 0; i
< 10; ++i
)
31 assert((vec
[i
] & 1) == 1);