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