This source file includes following definitions.
- trap_signal_handler
- tm_signal_sigreturn_nt
- main
1
2
3
4
5
6
7
8
9
10
11
12 #define _GNU_SOURCE
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <signal.h>
16
17 #include "utils.h"
18 #include "tm.h"
19
20 void trap_signal_handler(int signo, siginfo_t *si, void *uc)
21 {
22 ucontext_t *ucp = (ucontext_t *) uc;
23
24 asm("tbegin.; tsuspend.;");
25
26
27 ucp->uc_mcontext.regs->nip += 4;
28 }
29
30 int tm_signal_sigreturn_nt(void)
31 {
32 struct sigaction trap_sa;
33
34 SKIP_IF(!have_htm());
35
36 trap_sa.sa_flags = SA_SIGINFO;
37 trap_sa.sa_sigaction = trap_signal_handler;
38
39 sigaction(SIGTRAP, &trap_sa, NULL);
40
41 raise(SIGTRAP);
42
43 return EXIT_SUCCESS;
44 }
45
46 int main(int argc, char **argv)
47 {
48 test_harness(tm_signal_sigreturn_nt, "tm_signal_sigreturn_nt");
49 }
50