Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / arm64 / bug484935.c
blobff96f078aeed8ad4ec4414f334591a03785f46fd
1 #include <assert.h>
2 #include <signal.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <sys/time.h>
7 static void signalHandler(int sig, siginfo_t* info, void* uctx_v)
9 if (sig != SIGALRM)
10 abort();
11 if (info == 0)
12 abort();
13 if (uctx_v == 0)
14 abort();
17 void* load_memory_content(void** ptr)
19 void* result;
20 __asm__ volatile(
21 // load x0, x1, x2 with data from ptr, and loop for a while. If we get
22 // a signal in the loop, these registers have uninitialized data in
23 // them, but should be valid inside the signal handler. Without our
24 // patch, valgrind complains. We can remove the individual lines from
25 // the patch, and see each argument in turn affecting valgrind
26 "LDR x0, [%1]\n"
27 "LDR x1, [%1, #8]\n"
28 "LDR x2, [%1, #16]\n"
29 "mov %0, x0\n"
30 "mov x3, #2000\n"
31 "loop:"
32 " subs x3, x3, #1\n"
33 " b.ne loop\n"
34 : "=r"(result)
35 : "r"(ptr)
36 : "x0", "x1", "x2", "x3");
37 return result;
40 int main()
42 struct sigaction sa;
43 memset(&sa, 0, sizeof sa);
44 sa.sa_flags = SA_SIGINFO;
45 sa.sa_sigaction = signalHandler;
46 int rc = sigaction(SIGALRM, &sa, 0);
47 assert(rc == 0);
48 struct itimerval timer = {{0, 1000}, {0, 1000}};
49 setitimer(ITIMER_REAL, &timer, 0);
50 void** q = malloc(100);
51 for (int i = 0; i < 1000; ++i)
52 load_memory_content(q);