summaryrefslogtreecommitdiffstats
path: root/cpudetect.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-23 01:24:42 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-23 01:24:42 +0000
commit38c4cdcfc587804cdb2dbb9f980ded0ca2659978 (patch)
tree94db1b3e6d5ee9de97b87322b6b0373ae06af343 /cpudetect.c
parent1d2c85409b7101890e084040fd5ca3dd9fe29c77 (diff)
downloadmpv-38c4cdcfc587804cdb2dbb9f980ded0ca2659978.tar.bz2
mpv-38c4cdcfc587804cdb2dbb9f980ded0ca2659978.tar.xz
Ok, here is a better patch, which even adds a fix to compile it on older
NetBSD systems, there was a ; missing. patch by Bernd Ernesti <mplayer@lists.veego.de> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8534 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'cpudetect.c')
-rw-r--r--cpudetect.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/cpudetect.c b/cpudetect.c
index 7d9b102acf..4e9b91f40d 100644
--- a/cpudetect.c
+++ b/cpudetect.c
@@ -16,7 +16,8 @@ CpuCaps gCpuCaps;
#ifdef __NetBSD__
#include <sys/param.h>
-#include <setjmp.h>
+#include <sys/sysctl.h>
+#include <machine/cpu.h>
#endif
#ifdef __FreeBSD__
@@ -242,15 +243,6 @@ char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]){
#undef CPUID_STEPPING
-#ifdef __NetBSD__
-jmp_buf sseCheckEnv;
-
-void sseCheckHandler(int i)
-{
- longjmp(sseCheckEnv, 1);
-}
-#endif
-
#if defined(__linux__) && defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)
static void sigill_handler_sse( int signal, struct sigcontext sc )
{
@@ -308,33 +300,37 @@ static void check_os_katmai_support( void )
gCpuCaps.hasSSE=0;
#elif defined(__NetBSD__)
-#if __NetBSD_Version__ >= 105260000
- if ( gCpuCaps.hasSSE ) {
- void (*oldHandler)(int);
+#if __NetBSD_Version__ >= 105250000
+ int has_sse, has_sse2, ret, mib[2];
+ size_t varlen;
- mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " );
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_SSE;
+ varlen = sizeof(has_sse);
- oldHandler = signal(SIGILL, sseCheckHandler);
- if (setjmp(sseCheckEnv)) {
- gCpuCaps.hasSSE = 0;
- } else {
- __asm__ __volatile__ (
- "subl $0x10, %esp \n"
- "movups %xmm0, (%esp) \n"
- "emms \n"
- "addl $0x10, %esp \n"
- );
- }
- signal(SIGILL, oldHandler);
+ mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " );
+ ret = sysctl(mib, 2, &has_sse, &varlen, NULL, 0);
+ if (ret < 0 || !has_sse) {
+ gCpuCaps.hasSSE=0;
+ mp_msg(MSGT_CPUDETECT,MSGL_V, "no!\n" );
+ } else {
+ gCpuCaps.hasSSE=1;
+ mp_msg(MSGT_CPUDETECT,MSGL_V, "yes!\n" );
+ }
- if ( gCpuCaps.hasSSE ) {
- mp_msg(MSGT_CPUDETECT,MSGL_V, "no!\n" );
- } else {
- mp_msg(MSGT_CPUDETECT,MSGL_V, "yes!\n" );
- }
+ mib[1] = CPU_SSE2;
+ varlen = sizeof(has_sse2);
+ mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE2... " );
+ ret = sysctl(mib, 2, &has_sse2, &varlen, NULL, 0);
+ if (ret < 0 || !has_sse2) {
+ gCpuCaps.hasSSE2=0;
+ mp_msg(MSGT_CPUDETECT,MSGL_V, "no!\n" );
+ } else {
+ gCpuCaps.hasSSE2=1;
+ mp_msg(MSGT_CPUDETECT,MSGL_V, "yes!\n" );
}
#else
- gCpuCaps.hasSSE = 0
+ gCpuCaps.hasSSE = 0;
mp_msg(MSGT_CPUDETECT,MSGL_WARN, "No OS support for SSE, disabling to be safe.\n" );
#endif
#elif defined(__linux__)