This source file includes following definitions.
- signal_action_handler
- setup_signal_handler
- test_copy_first_unaligned
- main
1
2
3
4
5
6
7
8
9 #include <signal.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include "utils.h"
13 #include "instructions.h"
14
15 unsigned int expected_instruction = PPC_INST_COPY_FIRST;
16 unsigned int instruction_mask = 0xfc2007fe;
17
18 void signal_action_handler(int signal_num, siginfo_t *info, void *ptr)
19 {
20 ucontext_t *ctx = ptr;
21 #ifdef __powerpc64__
22 unsigned int *pc = (unsigned int *)ctx->uc_mcontext.gp_regs[PT_NIP];
23 #else
24 unsigned int *pc = (unsigned int *)ctx->uc_mcontext.uc_regs->gregs[PT_NIP];
25 #endif
26
27
28
29
30
31 if ((*pc & instruction_mask) == expected_instruction)
32 _exit(0);
33
34 _exit(1);
35 }
36
37 void setup_signal_handler(void)
38 {
39 struct sigaction signal_action;
40
41 memset(&signal_action, 0, sizeof(signal_action));
42 signal_action.sa_sigaction = signal_action_handler;
43 signal_action.sa_flags = SA_SIGINFO;
44 sigaction(SIGBUS, &signal_action, NULL);
45 }
46
47 char cacheline_buf[128] __cacheline_aligned;
48
49 int test_copy_first_unaligned(void)
50 {
51
52 SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_00));
53
54
55 setup_signal_handler();
56
57
58 copy_first(cacheline_buf+1);
59
60
61 return 1;
62 }
63
64 int main(int argc, char *argv[])
65 {
66 return test_harness(test_copy_first_unaligned, "test_copy_first_unaligned");
67 }