blob: 0fdc25f52f290298a50212f9aed917ff8a05604e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#define _GNU_SOURCE
#include <assert.h>
#include <stdint.h>
#include <sys/mman.h>
#include <unistd.h>
struct node { struct node *next; uint64_t value; };
struct node head, middle, tail;
volatile uint64_t counter;
__attribute__((noinline)) void checkpoint(void) { __asm__ volatile("" ::: "memory"); }
int main(void) {
const size_t size = (size_t)1 << 32;
int fd = memfd_create("ztrace-test-segment", 0);
assert(fd >= 0 && ftruncate(fd, size) == 0);
unsigned char *bytes = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
assert(bytes != MAP_FAILED);
close(fd);
bytes[0] = 'A';
bytes[size - 1] = 'Z';
head = (struct node){&middle, 1};
middle = (struct node){&tail, 2};
tail = (struct node){&head, 3};
for (;;) { ++counter; checkpoint(); }
}
|