src/cpuinfo/SDL_cpuinfo.c
changeset 5263 e1122f31fec5
parent 5262 b530ef003506
child 5389 24903690f48a
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Fri Feb 11 22:37:15 2011 -0800
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Fri Feb 11 23:02:35 2011 -0800
     1.3 @@ -41,7 +41,8 @@
     1.4  #define CPU_HAS_SSE     0x00000010
     1.5  #define CPU_HAS_SSE2    0x00000020
     1.6  #define CPU_HAS_SSE3    0x00000040
     1.7 -#define CPU_HAS_SSE4    0x00000080
     1.8 +#define CPU_HAS_SSE41   0x00000080
     1.9 +#define CPU_HAS_SSE42   0x00000100
    1.10  
    1.11  
    1.12  static __inline__ int
    1.13 @@ -234,15 +235,30 @@
    1.14  }
    1.15  
    1.16  static __inline__ int
    1.17 -CPU_haveSSE4(void)
    1.18 +CPU_haveSSE41(void)
    1.19  {
    1.20      if (CPU_haveCPUID()) {
    1.21          int a, b, c, d;
    1.22  
    1.23 -        cpuid(0, a, b, c, d);
    1.24 +        cpuid(1, a, b, c, d);
    1.25          if (a >= 1) {
    1.26              cpuid(1, a, b, c, d);
    1.27 -            return (c & 0x00000100);
    1.28 +            return (c & 0x00080000);
    1.29 +        }
    1.30 +    }
    1.31 +    return 0;
    1.32 +}
    1.33 +
    1.34 +static __inline__ int
    1.35 +CPU_haveSSE42(void)
    1.36 +{
    1.37 +    if (CPU_haveCPUID()) {
    1.38 +        int a, b, c, d;
    1.39 +
    1.40 +        cpuid(1, a, b, c, d);
    1.41 +        if (a >= 1) {
    1.42 +            cpuid(1, a, b, c, d);
    1.43 +            return (c & 0x00100000);
    1.44          }
    1.45      }
    1.46      return 0;
    1.47 @@ -427,8 +443,11 @@
    1.48          if (CPU_haveSSE3()) {
    1.49              SDL_CPUFeatures |= CPU_HAS_SSE3;
    1.50          }
    1.51 -        if (CPU_haveSSE4()) {
    1.52 -            SDL_CPUFeatures |= CPU_HAS_SSE4;
    1.53 +        if (CPU_haveSSE41()) {
    1.54 +            SDL_CPUFeatures |= CPU_HAS_SSE41;
    1.55 +        }
    1.56 +        if (CPU_haveSSE42()) {
    1.57 +            SDL_CPUFeatures |= CPU_HAS_SSE42;
    1.58          }
    1.59      }
    1.60      return SDL_CPUFeatures;
    1.61 @@ -480,9 +499,18 @@
    1.62  }
    1.63  
    1.64  SDL_bool
    1.65 -SDL_HasSSE4(void)
    1.66 +SDL_HasSSE41(void)
    1.67  {
    1.68 -    if (SDL_GetCPUFeatures() & CPU_HAS_SSE4) {
    1.69 +    if (SDL_GetCPUFeatures() & CPU_HAS_SSE41) {
    1.70 +        return SDL_TRUE;
    1.71 +    }
    1.72 +    return SDL_FALSE;
    1.73 +}
    1.74 +
    1.75 +SDL_bool
    1.76 +SDL_HasSSE42(void)
    1.77 +{
    1.78 +    if (SDL_GetCPUFeatures() & CPU_HAS_SSE42) {
    1.79          return SDL_TRUE;
    1.80      }
    1.81      return SDL_FALSE;
    1.82 @@ -504,7 +532,8 @@
    1.83      printf("SSE: %d\n", SDL_HasSSE());
    1.84      printf("SSE2: %d\n", SDL_HasSSE2());
    1.85      printf("SSE3: %d\n", SDL_HasSSE3());
    1.86 -    printf("SSE4: %d\n", SDL_HasSSE4());
    1.87 +    printf("SSE4.1: %d\n", SDL_HasSSE41());
    1.88 +    printf("SSE4.2: %d\n", SDL_HasSSE42());
    1.89      return 0;
    1.90  }
    1.91