| 1 | /* |
| 2 | * Common user code for specification exception testing. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 5 | */ |
| 6 | #include <assert.h> |
| 7 | #include <signal.h> |
| 8 | #include <stdlib.h> |
| 9 | #include <string.h> |
| 10 | #include <unistd.h> |
| 11 | |
| 12 | extern void test(void); |
| 13 | extern long expected_old_psw[2]; |
| 14 | |
| 15 | static void handle_sigill(int sig, siginfo_t *info, void *ucontext) |
| 16 | { |
| 17 | if ((long)info->si_addr != expected_old_psw[1]) { |
| 18 | _exit(EXIT_FAILURE); |
| 19 | } |
| 20 | _exit(EXIT_SUCCESS); |
| 21 | } |
| 22 | |
| 23 | int main(void) |
| 24 | { |
| 25 | struct sigaction act; |
| 26 | int err; |
| 27 | |
| 28 | memset(&act, 0, sizeof(act)); |
| 29 | act.sa_sigaction = handle_sigill; |
| 30 | act.sa_flags = SA_SIGINFO; |
| 31 | err = sigaction(SIGILL, &act, NULL); |
| 32 | assert(err == 0); |
| 33 | |
| 34 | test(); |
| 35 | |
| 36 | return EXIT_FAILURE; |
| 37 | } |