2 * Copyright 2016, Cyril Bur, IBM Corp.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Sending one self a signal should always get delivered.
24 #define MAX_ATTEMPT 500000
27 extern long tm_signal_self(pid_t pid, int sig, long *ret);
29 static sig_atomic_t signaled;
30 static sig_atomic_t fail;
32 static void signal_handler(int sig)
34 if (tcheck_active()) {
45 static int test_signal_tm()
50 act.sa_handler = signal_handler;
52 sigemptyset(&act.sa_mask);
53 if (sigaction(SIGUSR1, &act, NULL) < 0) {
54 perror("sigaction SIGUSR1");
57 if (sigaction(SIGALRM, &act, NULL) < 0) {
58 perror("sigaction SIGALRM");
64 for (i = 0; i < MAX_ATTEMPT; i++) {
66 * If anything bad happens in ASM and we fail to set ret
67 * because *handwave* TM this will cause failure
72 alarm(0); /* Disable any pending */
75 FAIL_IF(tcheck_transactional());
76 rc = tm_signal_self(getpid(), SIGUSR1, &ret);
79 * This basically means the transaction aborted before we
80 * even got to the suspend... this is crazy but it
82 * Yes this also means we might never make forward
83 * progress... the alarm() will trip eventually...
88 /* Ret is actually an errno */
89 printf("TEXASR 0x%016lx, TFIAR 0x%016lx\n",
90 __builtin_get_texasr(), __builtin_get_tfiar());
91 fprintf(stderr, "(%d) Fail reason: %d rc=0x%lx ret=0x%lx\n",
95 while(!signaled && !fail)
96 asm volatile("": : :"memory");
98 fprintf(stderr, "(%d) Fail reason: %d rc=0x%lx ret=0x%lx\n",
100 FAIL_IF(fail); /* For the line number */
109 return test_harness(test_signal_tm, "signal_tm");