1 // RUN: %clangxx_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s
12 const long kSmallPage
= 4 << 10;
13 const long kLargePage
= 2 << 20;
14 const long kStride
= 1 << 10;
16 typedef unsigned long uptr
;
18 int main(int argc
, const char **argv
) {
19 uptr mem_size
= 4 << 20;
21 mem_size
= (uptr
)atoi(argv
[1]) << 20;
22 uptr stride
= kSmallPage
;
24 stride
= (uptr
)atoi(argv
[2]) << 10;
27 niter
= atoi(argv
[3]);
30 stride2
= atoi(argv
[4]);
32 uptr sz
= mem_size
+ stride2
* kStride
+ kLargePage
;
33 void *p
= mmap(0, sz
, PROT_READ
| PROT_WRITE
, MAP_ANON
| MAP_PRIVATE
, -1, 0);
34 uptr a
= ((uptr
)p
+ kLargePage
- 1) & ~(kLargePage
- 1);
35 volatile char *mem
= (volatile char *)a
;
37 for (int i
= 0; i
< niter
; i
++) {
38 for (uptr off
= 0; off
< mem_size
; off
+= stride
) {
39 for (uptr off2
= 0; off2
< stride2
; off2
++)
40 mem
[off
+ off2
* kStride
] = 42;
44 fprintf(stderr
, "DONE\n");