Mercurial > mplayer.hg
comparison cpudetect.c @ 8401:1b2fc92980d9
Runtime SSE detection for NEtBSD, patch by Nick Hudson <skrll at netbsd.org>
author | atmos4 |
---|---|
date | Sat, 07 Dec 2002 21:04:54 +0000 |
parents | 9fc45fe0d444 |
children | 9b73b801af55 |
comparison
equal
deleted
inserted
replaced
8400:587b62cd4119 | 8401:1b2fc92980d9 |
---|---|
11 | 11 |
12 #ifdef ARCH_X86 | 12 #ifdef ARCH_X86 |
13 | 13 |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include <string.h> | 15 #include <string.h> |
16 | |
17 #ifdef __NetBSD__ | |
18 #include <sys/param.h> | |
19 #include <setjmp.h> | |
20 #endif | |
16 | 21 |
17 #ifdef __FreeBSD__ | 22 #ifdef __FreeBSD__ |
18 #include <sys/types.h> | 23 #include <sys/types.h> |
19 #include <sys/sysctl.h> | 24 #include <sys/sysctl.h> |
20 #endif | 25 #endif |
145 gCpuCaps.has3DNow, | 150 gCpuCaps.has3DNow, |
146 gCpuCaps.has3DNowExt ); | 151 gCpuCaps.has3DNowExt ); |
147 #endif | 152 #endif |
148 | 153 |
149 /* FIXME: Does SSE2 need more OS support, too? */ | 154 /* FIXME: Does SSE2 need more OS support, too? */ |
150 #if defined(__linux__) || defined(__FreeBSD__) | 155 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) |
151 if (caps->hasSSE) | 156 if (caps->hasSSE) |
152 check_os_katmai_support(); | 157 check_os_katmai_support(); |
153 if (!caps->hasSSE) | 158 if (!caps->hasSSE) |
154 caps->hasSSE2 = 0; | 159 caps->hasSSE2 = 0; |
155 #else | 160 #else |
235 #undef CPUID_FAMILY | 240 #undef CPUID_FAMILY |
236 #undef CPUID_MODEL | 241 #undef CPUID_MODEL |
237 #undef CPUID_STEPPING | 242 #undef CPUID_STEPPING |
238 | 243 |
239 | 244 |
245 #ifdef __NetBSD__ | |
246 jmp_buf sseCheckEnv; | |
247 | |
248 void sseCheckHandler(int i) | |
249 { | |
250 longjmp(sseCheckEnv, 1); | |
251 } | |
252 #endif | |
253 | |
240 #if defined(__linux__) && defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC) | 254 #if defined(__linux__) && defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC) |
241 static void sigill_handler_sse( int signal, struct sigcontext sc ) | 255 static void sigill_handler_sse( int signal, struct sigcontext sc ) |
242 { | 256 { |
243 mp_msg(MSGT_CPUDETECT,MSGL_V, "SIGILL, " ); | 257 mp_msg(MSGT_CPUDETECT,MSGL_V, "SIGILL, " ); |
244 | 258 |
291 | 305 |
292 ret = sysctlbyname("hw.instruction_sse", &has_sse, &len, NULL, 0); | 306 ret = sysctlbyname("hw.instruction_sse", &has_sse, &len, NULL, 0); |
293 if (ret || !has_sse) | 307 if (ret || !has_sse) |
294 gCpuCaps.hasSSE=0; | 308 gCpuCaps.hasSSE=0; |
295 | 309 |
310 #elif defined(__NetBSD__) | |
311 #if __NetBSD_Version__ >= 105260000 | |
312 if ( gCpuCaps.hasSSE ) { | |
313 void (*oldHandler)(int); | |
314 | |
315 mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " ); | |
316 | |
317 oldHandler = signal(SIGILL, sseCheckHandler); | |
318 if (setjmp(sseCheckEnv)) { | |
319 gCpuCaps.hasSSE = 0; | |
320 } else { | |
321 __asm__ __volatile__ ( | |
322 "subl $0x10, %esp \n" | |
323 "movups %xmm0, (%esp) \n" | |
324 "emms \n" | |
325 "addl $0x10, %esp \n" | |
326 ); | |
327 } | |
328 signal(SIGILL, oldHandler); | |
329 | |
330 if ( gCpuCaps.hasSSE ) { | |
331 mp_msg(MSGT_CPUDETECT,MSGL_V, "no!\n" ); | |
332 } else { | |
333 mp_msg(MSGT_CPUDETECT,MSGL_V, "yes!\n" ); | |
334 } | |
335 } | |
336 #else | |
337 gCpuCaps.hasSSE = 0 | |
338 mp_msg(MSGT_CPUDETECT,MSGL_WARN, "No OS support for SSE, disabling to be safe.\n" ); | |
339 #endif | |
296 #elif defined(__linux__) | 340 #elif defined(__linux__) |
297 #if defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC) | 341 #if defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC) |
298 struct sigaction saved_sigill; | 342 struct sigaction saved_sigill; |
299 struct sigaction saved_sigfpe; | 343 struct sigaction saved_sigfpe; |
300 | 344 |