comparison ppc/check_altivec.c @ 5757:ace63c809071 libavcodec

Remove uses of SIGILL for CPU extension detection, that method is not acceptable in a library. Should not change anything for PPC, the autodetection is currently pointless due to other code being compiled with -maltivec as well (and detection for OSX and AmigaOS remains in place). SPARC binaries built with VIS support can now only run on systems with VIS.
author reimar
date Tue, 02 Oct 2007 18:18:35 +0000
parents 09f99af1db40
children eb2e3c3b7f78
comparison
equal deleted inserted replaced
5756:db5a041fd77c 5757:ace63c809071
26 #include <sys/sysctl.h> 26 #include <sys/sysctl.h>
27 #elif __AMIGAOS4__ 27 #elif __AMIGAOS4__
28 #include <exec/exec.h> 28 #include <exec/exec.h>
29 #include <interfaces/exec.h> 29 #include <interfaces/exec.h>
30 #include <proto/exec.h> 30 #include <proto/exec.h>
31 #else
32 #include <signal.h>
33 #include <setjmp.h>
34
35 static sigjmp_buf jmpbuf;
36 static volatile sig_atomic_t canjump = 0;
37
38 static void sigill_handler (int sig)
39 {
40 if (!canjump) {
41 signal (sig, SIG_DFL);
42 raise (sig);
43 }
44
45 canjump = 0;
46 siglongjmp (jmpbuf, 1);
47 }
48 #endif /* __APPLE__ */ 31 #endif /* __APPLE__ */
49 32
50 /** 33 /**
51 * This function MAY rely on signal() or fork() in order to make sure altivec 34 * This function MAY rely on signal() or fork() in order to make sure altivec
52 * is present 35 * is present
70 err = sysctl(sels, 2, &has_vu, &len, NULL, 0); 53 err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
71 54
72 if (err == 0) return (has_vu != 0); 55 if (err == 0) return (has_vu != 0);
73 return 0; 56 return 0;
74 #else 57 #else
75 /* Do it the brute-force way, borrowed from the libmpeg2 library. */ 58 // since we were compiled for altivec, just assume we have it
76 { 59 // until someone comes up with a proper way (not involving signal hacks).
77 signal (SIGILL, sigill_handler); 60 return 1;
78 if (sigsetjmp (jmpbuf, 1)) {
79 signal (SIGILL, SIG_DFL);
80 } else {
81 canjump = 1;
82
83 asm volatile ("mtspr 256, %0\n\t"
84 "vand %%v0, %%v0, %%v0"
85 :
86 : "r" (-1));
87
88 signal (SIGILL, SIG_DFL);
89 return 1;
90 }
91 }
92 return 0;
93 #endif /* __AMIGAOS4__ */ 61 #endif /* __AMIGAOS4__ */
94 } 62 }
95 63