comparison cpudetect.c @ 27754:08d18fe9da52

Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg. Neither variant is valid C99 syntax, but __asm__ is the most portable variant.
author diego
date Thu, 16 Oct 2008 18:59:27 +0000
parents 48c1ae64255b
children b5a46071062a
comparison
equal deleted inserted replaced
27753:6c915906bbc6 27754:08d18fe9da52
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.
530 if (sigsetjmp (jmpbuf, 1)) { 530 if (sigsetjmp (jmpbuf, 1)) {
531 signal (SIGILL, SIG_DFL); 531 signal (SIGILL, SIG_DFL);
532 } else { 532 } else {
533 canjump = 1; 533 canjump = 1;
534 534
535 asm volatile ("mtspr 256, %0\n\t" 535 __asm__ volatile ("mtspr 256, %0\n\t"
536 "vand %%v0, %%v0, %%v0" 536 "vand %%v0, %%v0, %%v0"
537 : 537 :
538 : "r" (-1)); 538 : "r" (-1));
539 539
540 signal (SIGILL, SIG_DFL); 540 signal (SIGILL, SIG_DFL);