s390xcap.c 1.0 KB

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