comparison cpudetect.c @ 27757:b5a46071062a

Replace all occurrences of '__volatile__' and '__volatile' by plain 'volatile'. We were using an inconsistent mix of the three variants and 'volatile' should be the most correct and portable variant.
author diego
date Thu, 16 Oct 2008 20:17:56 +0000
parents 08d18fe9da52
children a02c39208d49
comparison
equal deleted inserted replaced
27756:1266470a5651 27757:b5a46071062a
55 static int has_cpuid(void) 55 static int has_cpuid(void)
56 { 56 {
57 long a, c; 57 long a, c;
58 58
59 // code from libavcodec: 59 // code from libavcodec:
60 __asm__ __volatile__ ( 60 __asm__ volatile (
61 /* See if CPUID instruction is supported ... */ 61 /* See if CPUID instruction is supported ... */
62 /* ... Get copies of EFLAGS into eax and ecx */ 62 /* ... Get copies of EFLAGS into eax and ecx */
63 "pushf\n\t" 63 "pushf\n\t"
64 "pop %0\n\t" 64 "pop %0\n\t"
65 "mov %0, %1\n\t" 65 "mov %0, %1\n\t"
83 83
84 static void 84 static void
85 do_cpuid(unsigned int ax, unsigned int *p) 85 do_cpuid(unsigned int ax, unsigned int *p)
86 { 86 {
87 #if 0 87 #if 0
88 __asm__ __volatile( 88 __asm__ volatile(
89 "cpuid;" 89 "cpuid;"
90 : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) 90 : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
91 : "0" (ax) 91 : "0" (ax)
92 ); 92 );
93 #else 93 #else
94 // code from libavcodec: 94 // code from libavcodec:
95 __asm__ __volatile__ 95 __asm__ volatile
96 ("mov %%"REG_b", %%"REG_S"\n\t" 96 ("mov %%"REG_b", %%"REG_S"\n\t"
97 "cpuid\n\t" 97 "cpuid\n\t"
98 "xchg %%"REG_b", %%"REG_S 98 "xchg %%"REG_b", %%"REG_S
99 : "=a" (p[0]), "=S" (p[1]), 99 : "=a" (p[0]), "=S" (p[1]),
100 "=c" (p[2]), "=d" (p[3]) 100 "=c" (p[2]), "=d" (p[3])
398 #elif defined(__MINGW32__) || defined(__CYGWIN__) 398 #elif defined(__MINGW32__) || defined(__CYGWIN__)
399 LPTOP_LEVEL_EXCEPTION_FILTER exc_fil; 399 LPTOP_LEVEL_EXCEPTION_FILTER exc_fil;
400 if ( gCpuCaps.hasSSE ) { 400 if ( gCpuCaps.hasSSE ) {
401 mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " ); 401 mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " );
402 exc_fil = SetUnhandledExceptionFilter(win32_sig_handler_sse); 402 exc_fil = SetUnhandledExceptionFilter(win32_sig_handler_sse);
403 __asm__ __volatile ("xorps %xmm0, %xmm0"); 403 __asm__ volatile ("xorps %xmm0, %xmm0");
404 SetUnhandledExceptionFilter(exc_fil); 404 SetUnhandledExceptionFilter(exc_fil);
405 mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" ); 405 mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" );
406 } 406 }
407 #elif defined(__OS2__) 407 #elif defined(__OS2__)
408 EXCEPTIONREGISTRATIONRECORD RegRec = { 0, &os2_sig_handler_sse }; 408 EXCEPTIONREGISTRATIONRECORD RegRec = { 0, &os2_sig_handler_sse };
409 if ( gCpuCaps.hasSSE ) { 409 if ( gCpuCaps.hasSSE ) {
410 mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " ); 410 mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " );
411 DosSetExceptionHandler( &RegRec ); 411 DosSetExceptionHandler( &RegRec );
412 __asm__ __volatile ("xorps %xmm0, %xmm0"); 412 __asm__ volatile ("xorps %xmm0, %xmm0");
413 DosUnsetExceptionHandler( &RegRec ); 413 DosUnsetExceptionHandler( &RegRec );
414 mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" ); 414 mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" );
415 } 415 }
416 #elif defined(__linux__) 416 #elif defined(__linux__)
417 #if defined(_POSIX_SOURCE) 417 #if defined(_POSIX_SOURCE)
430 * does. 430 * does.
431 */ 431 */
432 if ( gCpuCaps.hasSSE ) { 432 if ( gCpuCaps.hasSSE ) {
433 mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " ); 433 mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " );
434 434
435 // __asm__ __volatile ("xorps %%xmm0, %%xmm0"); 435 // __asm__ volatile ("xorps %%xmm0, %%xmm0");
436 __asm__ __volatile ("xorps %xmm0, %xmm0"); 436 __asm__ volatile ("xorps %xmm0, %xmm0");
437 437
438 mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" ); 438 mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" );
439 } 439 }
440 440
441 /* Restore the original signal handlers. 441 /* Restore the original signal handlers.