]>
Commit | Line | Data |
---|---|---|
3e719c99 AP |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <string.h> | |
4 | #include <setjmp.h> | |
5 | #include <signal.h> | |
6 | ||
9833757b | 7 | extern unsigned long OPENSSL_s390xcap_P[]; |
3e719c99 AP |
8 | |
9 | static sigjmp_buf ill_jmp; | |
10621efd MC |
10 | static void ill_handler(int sig) |
11 | { | |
12 | siglongjmp(ill_jmp, sig); | |
13 | } | |
3e719c99 AP |
14 | |
15 | unsigned long OPENSSL_s390x_facilities(void); | |
16 | ||
17 | void OPENSSL_cpuid_setup(void) | |
10621efd MC |
18 | { |
19 | sigset_t oset; | |
20 | struct sigaction ill_act, oact; | |
21 | ||
22 | if (OPENSSL_s390xcap_P[0]) | |
23 | return; | |
24 | ||
25 | OPENSSL_s390xcap_P[0] = 1UL << (8 * sizeof(unsigned long) - 1); | |
26 | ||
27 | memset(&ill_act, 0, sizeof(ill_act)); | |
28 | ill_act.sa_handler = ill_handler; | |
29 | sigfillset(&ill_act.sa_mask); | |
30 | sigdelset(&ill_act.sa_mask, SIGILL); | |
31 | sigdelset(&ill_act.sa_mask, SIGTRAP); | |
32 | sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset); | |
33 | sigaction(SIGILL, &ill_act, &oact); | |
34 | ||
35 | /* protection against missing store-facility-list-extended */ | |
36 | if (sigsetjmp(ill_jmp, 1) == 0) | |
37 | OPENSSL_s390x_facilities(); | |
38 | ||
39 | sigaction(SIGILL, &oact, NULL); | |
40 | sigprocmask(SIG_SETMASK, &oset, NULL); | |
41 | } |