summaryrefslogtreecommitdiff
path: root/graphics/mplayer-share/patches/patch-ad
blob: a7fe489d7af68482754fb35eddb342a4965cf1a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
$NetBSD: patch-ad,v 1.1 2002/10/07 11:36:18 skrll Exp $

--- cpudetect.c.orig	Mon May 20 02:00:51 2002
+++ cpudetect.c
@@ -13,6 +13,11 @@ CpuCaps gCpuCaps;
 
 #include <stdio.h>
 
+#ifdef __NetBSD__
+#include <sys/param.h>
+#include <setjmp.h>
+#endif
+
 #ifdef __FreeBSD__
 #include <sys/types.h>
 #include <sys/sysctl.h>
@@ -146,7 +151,7 @@ void GetCpuCaps( CpuCaps *caps)
 #endif
 
 		/* FIXME: Does SSE2 need more OS support, too? */
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
 		if (caps->hasSSE)
 			check_os_katmai_support();
 		if (!caps->hasSSE)
@@ -236,6 +241,15 @@ char *GetCpuFriendlyName(unsigned int re
 #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 )
 {
@@ -292,6 +306,36 @@ static void check_os_katmai_support( voi
    if (ret || !has_sse)
       gCpuCaps.hasSSE=0;
 
+#elif defined(__NetBSD__)
+#if __NetBSD_Version__ >= 105260000
+   if ( gCpuCaps.hasSSE ) {
+      void (*oldHandler)(int);
+
+      mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for 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);
+
+      if ( gCpuCaps.hasSSE ) {
+	mp_msg(MSGT_CPUDETECT,MSGL_V, "no!\n" );
+      } else {
+	mp_msg(MSGT_CPUDETECT,MSGL_V, "yes!\n" );
+      }
+   }
+#else
+   gCpuCaps.hasSSE = 0
+   mp_msg(MSGT_CPUDETECT,MSGL_WARN, "No OS support for SSE, disabling to be safe.\n" );
+#endif
 #elif defined(__linux__)
 #if defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)
    struct sigaction saved_sigill;