0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #define _GNU_SOURCE
0013 #include <stdio.h>
0014 #include <stdlib.h>
0015 #include <signal.h>
0016
0017 #include "utils.h"
0018 #include "tm.h"
0019
0020 void trap_signal_handler(int signo, siginfo_t *si, void *uc)
0021 {
0022 ucontext_t *ucp = (ucontext_t *) uc;
0023
0024 asm("tbegin.; tsuspend.;");
0025
0026
0027 ucp->uc_mcontext.regs->nip += 4;
0028 }
0029
0030 int tm_signal_sigreturn_nt(void)
0031 {
0032 struct sigaction trap_sa;
0033
0034 SKIP_IF(!have_htm());
0035 SKIP_IF(htm_is_synthetic());
0036
0037 trap_sa.sa_flags = SA_SIGINFO;
0038 trap_sa.sa_sigaction = trap_signal_handler;
0039
0040 sigaction(SIGTRAP, &trap_sa, NULL);
0041
0042 raise(SIGTRAP);
0043
0044 return EXIT_SUCCESS;
0045 }
0046
0047 int main(int argc, char **argv)
0048 {
0049 test_harness(tm_signal_sigreturn_nt, "tm_signal_sigreturn_nt");
0050 }
0051