src/cpuinfo/SDL_cpuinfo.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
child 1691 c901fd2a42da
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
    46 /* This is the brute force way of detecting instruction sets...
    46 /* This is the brute force way of detecting instruction sets...
    47    the idea is borrowed from the libmpeg2 library - thanks!
    47    the idea is borrowed from the libmpeg2 library - thanks!
    48  */
    48  */
    49 static jmp_buf jmpbuf;
    49 static jmp_buf jmpbuf;
    50 static void
    50 static void
    51 illegal_instruction (int sig)
    51 illegal_instruction(int sig)
    52 {
    52 {
    53     longjmp (jmpbuf, 1);
    53     longjmp(jmpbuf, 1);
    54 }
    54 }
    55 #endif /* HAVE_SETJMP */
    55 #endif /* HAVE_SETJMP */
    56 
    56 
    57 static __inline__ int
    57 static __inline__ int
    58 CPU_haveCPUID (void)
    58 CPU_haveCPUID(void)
    59 {
    59 {
    60     int has_CPUID = 0;
    60     int has_CPUID = 0;
    61 #if defined(__GNUC__) && defined(i386)
    61 #if defined(__GNUC__) && defined(i386)
    62   __asm__ ("        pushfl                      # Get original EFLAGS             \n" "        popl    %%eax                                                 \n" "        movl    %%eax,%%ecx                                           \n" "        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n" "        pushl   %%eax               # Save new EFLAGS value on stack  \n" "        popfl                       # Replace current EFLAGS value    \n" "        pushfl                      # Get new EFLAGS                  \n" "        popl    %%eax               # Store new EFLAGS in EAX         \n" "        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n" "        jz      1f                  # Processor=80486                 \n" "        movl    $1,%0               # We have CPUID support           \n" "1:                                                                    \n": "=m" (has_CPUID):
    62   __asm__("        pushfl                      # Get original EFLAGS             \n" "        popl    %%eax                                                 \n" "        movl    %%eax,%%ecx                                           \n" "        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n" "        pushl   %%eax               # Save new EFLAGS value on stack  \n" "        popfl                       # Replace current EFLAGS value    \n" "        pushfl                      # Get new EFLAGS                  \n" "        popl    %%eax               # Store new EFLAGS in EAX         \n" "        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n" "        jz      1f                  # Processor=80486                 \n" "        movl    $1,%0               # We have CPUID support           \n" "1:                                                                    \n": "=m"(has_CPUID):
    63   :"%eax", "%ecx");
    63   :"%eax", "%ecx");
    64 #elif defined(__GNUC__) && defined(__x86_64__)
    64 #elif defined(__GNUC__) && defined(__x86_64__)
    65 /* Technically, if this is being compiled under __x86_64__ then it has 
    65 /* Technically, if this is being compiled under __x86_64__ then it has 
    66 CPUid by definition.  But it's nice to be able to prove it.  :)      */
    66 CPUid by definition.  But it's nice to be able to prove it.  :)      */
    67   __asm__ ("        pushfq                      # Get original EFLAGS             \n" "        popq    %%rax                                                 \n" "        movq    %%rax,%%rcx                                           \n" "        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n" "        pushq   %%rax               # Save new EFLAGS value on stack  \n" "        popfq                       # Replace current EFLAGS value    \n" "        pushfq                      # Get new EFLAGS                  \n" "        popq    %%rax               # Store new EFLAGS in EAX         \n" "        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n" "        jz      1f                  # Processor=80486                 \n" "        movl    $1,%0               # We have CPUID support           \n" "1:                                                                    \n": "=m" (has_CPUID):
    67   __asm__("        pushfq                      # Get original EFLAGS             \n" "        popq    %%rax                                                 \n" "        movq    %%rax,%%rcx                                           \n" "        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n" "        pushq   %%rax               # Save new EFLAGS value on stack  \n" "        popfq                       # Replace current EFLAGS value    \n" "        pushfq                      # Get new EFLAGS                  \n" "        popq    %%rax               # Store new EFLAGS in EAX         \n" "        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n" "        jz      1f                  # Processor=80486                 \n" "        movl    $1,%0               # We have CPUID support           \n" "1:                                                                    \n": "=m"(has_CPUID):
    68   :"%rax", "%rcx");
    68   :"%rax", "%rcx");
    69 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
    69 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
    70     __asm {
    70     __asm {
    71         pushfd;
    71         pushfd;
    72         Get original EFLAGS pop eax mov ecx, eax xor eax, 200000 h;
    72         Get original EFLAGS pop eax mov ecx, eax xor eax, 200000 h;
    77         Store new EFLAGS in EAX xor eax, ecx;
    77         Store new EFLAGS in EAX xor eax, ecx;
    78         Can not toggle ID bit, jz done;
    78         Can not toggle ID bit, jz done;
    79         Processor = 80486 mov has_CPUID, 1;
    79         Processor = 80486 mov has_CPUID, 1;
    80     We have CPUID support done:}
    80     We have CPUID support done:}
    81 #elif defined(__sun) && defined(__x86)
    81 #elif defined(__sun) && defined(__x86)
    82     __asm ("       pushfl                 \n"
    82     __asm("       pushfl                 \n"
    83            "	popl    %eax           \n"
    83           "	popl    %eax           \n"
    84            "	movl    %eax,%ecx      \n"
    84           "	movl    %eax,%ecx      \n"
    85            "	xorl    $0x200000,%eax \n"
    85           "	xorl    $0x200000,%eax \n"
    86            "	pushl   %eax           \n"
    86           "	pushl   %eax           \n"
    87            "	popfl                  \n"
    87           "	popfl                  \n"
    88            "	pushfl                 \n"
    88           "	pushfl                 \n"
    89            "	popl    %eax           \n"
    89           "	popl    %eax           \n"
    90            "	xorl    %ecx,%eax      \n"
    90           "	xorl    %ecx,%eax      \n"
    91            "	jz      1f             \n"
    91           "	jz      1f             \n"
    92            "	movl    $1,-8(%ebp)    \n"
    92           "	movl    $1,-8(%ebp)    \n"
    93            "1:                            \n");
    93           "1:                            \n");
    94 #elif defined(__sun) && defined(__amd64)
    94 #elif defined(__sun) && defined(__amd64)
    95     __asm ("       pushfq                 \n"
    95     __asm("       pushfq                 \n"
    96            "       popq    %rax           \n"
    96           "       popq    %rax           \n"
    97            "       movq    %rax,%rcx      \n"
    97           "       movq    %rax,%rcx      \n"
    98            "       xorl    $0x200000,%eax \n"
    98           "       xorl    $0x200000,%eax \n"
    99            "       pushq   %rax           \n"
    99           "       pushq   %rax           \n"
   100            "       popfq                  \n"
   100           "       popfq                  \n"
   101            "       pushfq                 \n"
   101           "       pushfq                 \n"
   102            "       popq    %rax           \n"
   102           "       popq    %rax           \n"
   103            "       xorl    %ecx,%eax      \n"
   103           "       xorl    %ecx,%eax      \n"
   104            "       jz      1f             \n"
   104           "       jz      1f             \n"
   105            "       movl    $1,-8(%rbp)    \n"
   105           "       movl    $1,-8(%rbp)    \n"
   106            "1:                            \n");
   106           "1:                            \n");
   107 #endif
   107 #endif
   108     return has_CPUID;
   108     return has_CPUID;
   109 }
   109 }
   110 
   110 
   111 static __inline__ int
   111 static __inline__ int
   112 CPU_getCPUIDFeatures (void)
   112 CPU_getCPUIDFeatures(void)
   113 {
   113 {
   114     int features = 0;
   114     int features = 0;
   115 #if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) )
   115 #if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) )
   116   __asm__ ("        movl    %%ebx,%%edi\n" "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n" "        cpuid                       # Get and save vendor ID          \n" "        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n" "        jl      1f                  # We dont have the CPUID instruction\n" "        xorl    %%eax,%%eax                                           \n" "        incl    %%eax                                                 \n" "        cpuid                       # Get family/model/stepping/features\n" "        movl    %%edx,%0                                              \n" "1:                                                                    \n" "        movl    %%edi,%%ebx\n": "=m" (features):
   116   __asm__("        movl    %%ebx,%%edi\n" "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n" "        cpuid                       # Get and save vendor ID          \n" "        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n" "        jl      1f                  # We dont have the CPUID instruction\n" "        xorl    %%eax,%%eax                                           \n" "        incl    %%eax                                                 \n" "        cpuid                       # Get family/model/stepping/features\n" "        movl    %%edx,%0                                              \n" "1:                                                                    \n" "        movl    %%edi,%%ebx\n": "=m"(features):
   117   :"%eax", "%ecx", "%edx", "%edi");
   117   :"%eax", "%ecx", "%edx", "%edi");
   118 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
   118 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
   119     __asm {
   119     __asm {
   120         xor eax, eax;
   120         xor eax, eax;
   121     Set up for CPUID instruction
   121     Set up for CPUID instruction
   146 #endif
   146 #endif
   147     return features;
   147     return features;
   148 }
   148 }
   149 
   149 
   150 static __inline__ int
   150 static __inline__ int
   151 CPU_getCPUIDFeaturesExt (void)
   151 CPU_getCPUIDFeaturesExt(void)
   152 {
   152 {
   153     int features = 0;
   153     int features = 0;
   154 #if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) )
   154 #if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) )
   155   __asm__ ("        movl    %%ebx,%%edi\n" "        movl    $0x80000000,%%eax   # Query for extended functions    \n" "        cpuid                       # Get extended function limit     \n" "        cmpl    $0x80000001,%%eax                                     \n" "        jl      1f                  # Nope, we dont have function 800000001h\n" "        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n" "        cpuid                       # and get the information         \n" "        movl    %%edx,%0                                              \n" "1:                                                                    \n" "        movl    %%edi,%%ebx\n": "=m" (features):
   155   __asm__("        movl    %%ebx,%%edi\n" "        movl    $0x80000000,%%eax   # Query for extended functions    \n" "        cpuid                       # Get extended function limit     \n" "        cmpl    $0x80000001,%%eax                                     \n" "        jl      1f                  # Nope, we dont have function 800000001h\n" "        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n" "        cpuid                       # and get the information         \n" "        movl    %%edx,%0                                              \n" "1:                                                                    \n" "        movl    %%edi,%%ebx\n": "=m"(features):
   156   :"%eax", "%ecx", "%edx", "%edi");
   156   :"%eax", "%ecx", "%edx", "%edi");
   157 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
   157 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
   158     __asm {
   158     __asm {
   159         mov eax, 80000000 h;
   159         mov eax, 80000000 h;
   160         Query for extended functions
   160         Query for extended functions
   162             cmp eax, 80000001 h jl done; Nope
   162             cmp eax, 80000001 h jl done; Nope
   163             , we dont have function 800000001 h mov eax, 80000001 h;
   163             , we dont have function 800000001 h mov eax, 80000001 h;
   164         Setup extended function 800000001 h cpuid;
   164         Setup extended function 800000001 h cpuid;
   165     and get the information mov features, edx done:}
   165     and get the information mov features, edx done:}
   166 #elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
   166 #elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
   167     __asm ("        movl    %ebx,%edi\n"
   167     __asm("        movl    %ebx,%edi\n"
   168            "        movl    $0x80000000,%eax \n"
   168           "        movl    $0x80000000,%eax \n"
   169            "        cpuid                    \n"
   169           "        cpuid                    \n"
   170            "        cmpl    $0x80000001,%eax \n"
   170           "        cmpl    $0x80000001,%eax \n"
   171            "        jl      1f               \n"
   171           "        jl      1f               \n"
   172            "        movl    $0x80000001,%eax \n"
   172           "        movl    $0x80000001,%eax \n"
   173            "        cpuid                    \n"
   173           "        cpuid                    \n"
   174 #ifdef __i386
   174 #ifdef __i386
   175            "        movl    %edx,-8(%ebp)   \n"
   175           "        movl    %edx,-8(%ebp)   \n"
   176 #else
   176 #else
   177            "        movl    %edx,-8(%rbp)   \n"
   177           "        movl    %edx,-8(%rbp)   \n"
   178 #endif
   178 #endif
   179            "1:                               \n"
   179           "1:                               \n"
   180            "        movl    %edi,%ebx\n");
   180           "        movl    %edi,%ebx\n");
   181 #endif
   181 #endif
   182     return features;
   182     return features;
   183 }
   183 }
   184 
   184 
   185 static __inline__ int
   185 static __inline__ int
   186 CPU_haveRDTSC (void)
   186 CPU_haveRDTSC(void)
   187 {
   187 {
   188     if (CPU_haveCPUID ()) {
   188     if (CPU_haveCPUID()) {
   189         return (CPU_getCPUIDFeatures () & 0x00000010);
   189         return (CPU_getCPUIDFeatures() & 0x00000010);
   190     }
   190     }
   191     return 0;
   191     return 0;
   192 }
   192 }
   193 
   193 
   194 static __inline__ int
   194 static __inline__ int
   195 CPU_haveMMX (void)
   195 CPU_haveMMX(void)
   196 {
   196 {
   197     if (CPU_haveCPUID ()) {
   197     if (CPU_haveCPUID()) {
   198         return (CPU_getCPUIDFeatures () & 0x00800000);
   198         return (CPU_getCPUIDFeatures() & 0x00800000);
   199     }
   199     }
   200     return 0;
   200     return 0;
   201 }
   201 }
   202 
   202 
   203 static __inline__ int
   203 static __inline__ int
   204 CPU_haveMMXExt (void)
   204 CPU_haveMMXExt(void)
   205 {
   205 {
   206     if (CPU_haveCPUID ()) {
   206     if (CPU_haveCPUID()) {
   207         return (CPU_getCPUIDFeaturesExt () & 0x00400000);
   207         return (CPU_getCPUIDFeaturesExt() & 0x00400000);
   208     }
   208     }
   209     return 0;
   209     return 0;
   210 }
   210 }
   211 
   211 
   212 static __inline__ int
   212 static __inline__ int
   213 CPU_have3DNow (void)
   213 CPU_have3DNow(void)
   214 {
   214 {
   215     if (CPU_haveCPUID ()) {
   215     if (CPU_haveCPUID()) {
   216         return (CPU_getCPUIDFeaturesExt () & 0x80000000);
   216         return (CPU_getCPUIDFeaturesExt() & 0x80000000);
   217     }
   217     }
   218     return 0;
   218     return 0;
   219 }
   219 }
   220 
   220 
   221 static __inline__ int
   221 static __inline__ int
   222 CPU_have3DNowExt (void)
   222 CPU_have3DNowExt(void)
   223 {
   223 {
   224     if (CPU_haveCPUID ()) {
   224     if (CPU_haveCPUID()) {
   225         return (CPU_getCPUIDFeaturesExt () & 0x40000000);
   225         return (CPU_getCPUIDFeaturesExt() & 0x40000000);
   226     }
   226     }
   227     return 0;
   227     return 0;
   228 }
   228 }
   229 
   229 
   230 static __inline__ int
   230 static __inline__ int
   231 CPU_haveSSE (void)
   231 CPU_haveSSE(void)
   232 {
   232 {
   233     if (CPU_haveCPUID ()) {
   233     if (CPU_haveCPUID()) {
   234         return (CPU_getCPUIDFeatures () & 0x02000000);
   234         return (CPU_getCPUIDFeatures() & 0x02000000);
   235     }
   235     }
   236     return 0;
   236     return 0;
   237 }
   237 }
   238 
   238 
   239 static __inline__ int
   239 static __inline__ int
   240 CPU_haveSSE2 (void)
   240 CPU_haveSSE2(void)
   241 {
   241 {
   242     if (CPU_haveCPUID ()) {
   242     if (CPU_haveCPUID()) {
   243         return (CPU_getCPUIDFeatures () & 0x04000000);
   243         return (CPU_getCPUIDFeatures() & 0x04000000);
   244     }
   244     }
   245     return 0;
   245     return 0;
   246 }
   246 }
   247 
   247 
   248 static __inline__ int
   248 static __inline__ int
   249 CPU_haveAltiVec (void)
   249 CPU_haveAltiVec(void)
   250 {
   250 {
   251     volatile int altivec = 0;
   251     volatile int altivec = 0;
   252 #if defined(__MACOSX__) && defined(__ppc__)
   252 #if defined(__MACOSX__) && defined(__ppc__)
   253     int selectors[2] = { CTL_HW, HW_VECTORUNIT };
   253     int selectors[2] = { CTL_HW, HW_VECTORUNIT };
   254     int hasVectorUnit = 0;
   254     int hasVectorUnit = 0;
   255     size_t length = sizeof (hasVectorUnit);
   255     size_t length = sizeof(hasVectorUnit);
   256     int error = sysctl (selectors, 2, &hasVectorUnit, &length, NULL, 0);
   256     int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
   257     if (0 == error)
   257     if (0 == error)
   258         altivec = (hasVectorUnit != 0);
   258         altivec = (hasVectorUnit != 0);
   259 #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
   259 #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
   260     void (*handler) (int sig);
   260     void (*handler) (int sig);
   261     handler = signal (SIGILL, illegal_instruction);
   261     handler = signal(SIGILL, illegal_instruction);
   262     if (setjmp (jmpbuf) == 0) {
   262     if (setjmp(jmpbuf) == 0) {
   263         asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1));
   263         asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1));
   264         altivec = 1;
   264         altivec = 1;
   265     }
   265     }
   266     signal (SIGILL, handler);
   266     signal(SIGILL, handler);
   267 #endif
   267 #endif
   268     return altivec;
   268     return altivec;
   269 }
   269 }
   270 
   270 
   271 static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
   271 static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
   272 
   272 
   273 static Uint32
   273 static Uint32
   274 SDL_GetCPUFeatures (void)
   274 SDL_GetCPUFeatures(void)
   275 {
   275 {
   276     if (SDL_CPUFeatures == 0xFFFFFFFF) {
   276     if (SDL_CPUFeatures == 0xFFFFFFFF) {
   277         SDL_CPUFeatures = 0;
   277         SDL_CPUFeatures = 0;
   278         if (CPU_haveRDTSC ()) {
   278         if (CPU_haveRDTSC()) {
   279             SDL_CPUFeatures |= CPU_HAS_RDTSC;
   279             SDL_CPUFeatures |= CPU_HAS_RDTSC;
   280         }
   280         }
   281         if (CPU_haveMMX ()) {
   281         if (CPU_haveMMX()) {
   282             SDL_CPUFeatures |= CPU_HAS_MMX;
   282             SDL_CPUFeatures |= CPU_HAS_MMX;
   283         }
   283         }
   284         if (CPU_haveMMXExt ()) {
   284         if (CPU_haveMMXExt()) {
   285             SDL_CPUFeatures |= CPU_HAS_MMXEXT;
   285             SDL_CPUFeatures |= CPU_HAS_MMXEXT;
   286         }
   286         }
   287         if (CPU_have3DNow ()) {
   287         if (CPU_have3DNow()) {
   288             SDL_CPUFeatures |= CPU_HAS_3DNOW;
   288             SDL_CPUFeatures |= CPU_HAS_3DNOW;
   289         }
   289         }
   290         if (CPU_have3DNowExt ()) {
   290         if (CPU_have3DNowExt()) {
   291             SDL_CPUFeatures |= CPU_HAS_3DNOWEXT;
   291             SDL_CPUFeatures |= CPU_HAS_3DNOWEXT;
   292         }
   292         }
   293         if (CPU_haveSSE ()) {
   293         if (CPU_haveSSE()) {
   294             SDL_CPUFeatures |= CPU_HAS_SSE;
   294             SDL_CPUFeatures |= CPU_HAS_SSE;
   295         }
   295         }
   296         if (CPU_haveSSE2 ()) {
   296         if (CPU_haveSSE2()) {
   297             SDL_CPUFeatures |= CPU_HAS_SSE2;
   297             SDL_CPUFeatures |= CPU_HAS_SSE2;
   298         }
   298         }
   299         if (CPU_haveAltiVec ()) {
   299         if (CPU_haveAltiVec()) {
   300             SDL_CPUFeatures |= CPU_HAS_ALTIVEC;
   300             SDL_CPUFeatures |= CPU_HAS_ALTIVEC;
   301         }
   301         }
   302     }
   302     }
   303     return SDL_CPUFeatures;
   303     return SDL_CPUFeatures;
   304 }
   304 }
   305 
   305 
   306 SDL_bool
   306 SDL_bool
   307 SDL_HasRDTSC (void)
   307 SDL_HasRDTSC(void)
   308 {
   308 {
   309     if (SDL_GetCPUFeatures () & CPU_HAS_RDTSC) {
   309     if (SDL_GetCPUFeatures() & CPU_HAS_RDTSC) {
   310         return SDL_TRUE;
   310         return SDL_TRUE;
   311     }
   311     }
   312     return SDL_FALSE;
   312     return SDL_FALSE;
   313 }
   313 }
   314 
   314 
   315 SDL_bool
   315 SDL_bool
   316 SDL_HasMMX (void)
   316 SDL_HasMMX(void)
   317 {
   317 {
   318     if (SDL_GetCPUFeatures () & CPU_HAS_MMX) {
   318     if (SDL_GetCPUFeatures() & CPU_HAS_MMX) {
   319         return SDL_TRUE;
   319         return SDL_TRUE;
   320     }
   320     }
   321     return SDL_FALSE;
   321     return SDL_FALSE;
   322 }
   322 }
   323 
   323 
   324 SDL_bool
   324 SDL_bool
   325 SDL_HasMMXExt (void)
   325 SDL_HasMMXExt(void)
   326 {
   326 {
   327     if (SDL_GetCPUFeatures () & CPU_HAS_MMXEXT) {
   327     if (SDL_GetCPUFeatures() & CPU_HAS_MMXEXT) {
   328         return SDL_TRUE;
   328         return SDL_TRUE;
   329     }
   329     }
   330     return SDL_FALSE;
   330     return SDL_FALSE;
   331 }
   331 }
   332 
   332 
   333 SDL_bool
   333 SDL_bool
   334 SDL_Has3DNow (void)
   334 SDL_Has3DNow(void)
   335 {
   335 {
   336     if (SDL_GetCPUFeatures () & CPU_HAS_3DNOW) {
   336     if (SDL_GetCPUFeatures() & CPU_HAS_3DNOW) {
   337         return SDL_TRUE;
   337         return SDL_TRUE;
   338     }
   338     }
   339     return SDL_FALSE;
   339     return SDL_FALSE;
   340 }
   340 }
   341 
   341 
   342 SDL_bool
   342 SDL_bool
   343 SDL_Has3DNowExt (void)
   343 SDL_Has3DNowExt(void)
   344 {
   344 {
   345     if (SDL_GetCPUFeatures () & CPU_HAS_3DNOWEXT) {
   345     if (SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT) {
   346         return SDL_TRUE;
   346         return SDL_TRUE;
   347     }
   347     }
   348     return SDL_FALSE;
   348     return SDL_FALSE;
   349 }
   349 }
   350 
   350 
   351 SDL_bool
   351 SDL_bool
   352 SDL_HasSSE (void)
   352 SDL_HasSSE(void)
   353 {
   353 {
   354     if (SDL_GetCPUFeatures () & CPU_HAS_SSE) {
   354     if (SDL_GetCPUFeatures() & CPU_HAS_SSE) {
   355         return SDL_TRUE;
   355         return SDL_TRUE;
   356     }
   356     }
   357     return SDL_FALSE;
   357     return SDL_FALSE;
   358 }
   358 }
   359 
   359 
   360 SDL_bool
   360 SDL_bool
   361 SDL_HasSSE2 (void)
   361 SDL_HasSSE2(void)
   362 {
   362 {
   363     if (SDL_GetCPUFeatures () & CPU_HAS_SSE2) {
   363     if (SDL_GetCPUFeatures() & CPU_HAS_SSE2) {
   364         return SDL_TRUE;
   364         return SDL_TRUE;
   365     }
   365     }
   366     return SDL_FALSE;
   366     return SDL_FALSE;
   367 }
   367 }
   368 
   368 
   369 SDL_bool
   369 SDL_bool
   370 SDL_HasAltiVec (void)
   370 SDL_HasAltiVec(void)
   371 {
   371 {
   372     if (SDL_GetCPUFeatures () & CPU_HAS_ALTIVEC) {
   372     if (SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC) {
   373         return SDL_TRUE;
   373         return SDL_TRUE;
   374     }
   374     }
   375     return SDL_FALSE;
   375     return SDL_FALSE;
   376 }
   376 }
   377 
   377 
   378 #ifdef TEST_MAIN
   378 #ifdef TEST_MAIN
   379 
   379 
   380 #include <stdio.h>
   380 #include <stdio.h>
   381 
   381 
   382 int
   382 int
   383 main ()
   383 main()
   384 {
   384 {
   385     printf ("RDTSC: %d\n", SDL_HasRDTSC ());
   385     printf("RDTSC: %d\n", SDL_HasRDTSC());
   386     printf ("MMX: %d\n", SDL_HasMMX ());
   386     printf("MMX: %d\n", SDL_HasMMX());
   387     printf ("MMXExt: %d\n", SDL_HasMMXExt ());
   387     printf("MMXExt: %d\n", SDL_HasMMXExt());
   388     printf ("3DNow: %d\n", SDL_Has3DNow ());
   388     printf("3DNow: %d\n", SDL_Has3DNow());
   389     printf ("3DNowExt: %d\n", SDL_Has3DNowExt ());
   389     printf("3DNowExt: %d\n", SDL_Has3DNowExt());
   390     printf ("SSE: %d\n", SDL_HasSSE ());
   390     printf("SSE: %d\n", SDL_HasSSE());
   391     printf ("SSE2: %d\n", SDL_HasSSE2 ());
   391     printf("SSE2: %d\n", SDL_HasSSE2());
   392     printf ("AltiVec: %d\n", SDL_HasAltiVec ());
   392     printf("AltiVec: %d\n", SDL_HasAltiVec());
   393     return 0;
   393     return 0;
   394 }
   394 }
   395 
   395 
   396 #endif /* TEST_MAIN */
   396 #endif /* TEST_MAIN */
   397 /* vi: set ts=4 sw=4 expandtab: */
   397 /* vi: set ts=4 sw=4 expandtab: */