s390xcap.c 926 B

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