src/cpuinfo/SDL_cpuinfo.c
changeset 8241 b6d5a589ce3f
parent 8240 334257cd613d
child 8642 3506de54b829
equal deleted inserted replaced
8240:334257cd613d 8241:b6d5a589ce3f
    96     :
    96     :
    97     : "%eax", "%ecx"
    97     : "%eax", "%ecx"
    98     );
    98     );
    99 #elif defined(__GNUC__) && defined(__x86_64__)
    99 #elif defined(__GNUC__) && defined(__x86_64__)
   100 /* Technically, if this is being compiled under __x86_64__ then it has 
   100 /* Technically, if this is being compiled under __x86_64__ then it has 
   101 CPUid by definition.  But it's nice to be able to prove it.  :)      */
   101    CPUid by definition.  But it's nice to be able to prove it.  :)      */
   102     __asm__ (
   102     __asm__ (
   103 "        pushfq                      # Get original EFLAGS             \n"
   103 "        pushfq                      # Get original EFLAGS             \n"
   104 "        popq    %%rax                                                 \n"
   104 "        popq    %%rax                                                 \n"
   105 "        movq    %%rax,%%rcx                                           \n"
   105 "        movq    %%rax,%%rcx                                           \n"
   106 "        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
   106 "        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
   129         xor     eax, ecx            ; Can not toggle ID bit,
   129         xor     eax, ecx            ; Can not toggle ID bit,
   130         jz      done                ; Processor=80486
   130         jz      done                ; Processor=80486
   131         mov     has_CPUID,1         ; We have CPUID support
   131         mov     has_CPUID,1         ; We have CPUID support
   132 done:
   132 done:
   133     }
   133     }
       
   134 #elif defined(_MSC_VER) && defined(_M_X64)
       
   135     has_CPUID = 1;
   134 #elif defined(__sun) && defined(__i386)
   136 #elif defined(__sun) && defined(__i386)
   135     __asm (
   137     __asm (
   136 "       pushfl                 \n"
   138 "       pushfl                 \n"
   137 "       popl    %eax           \n"
   139 "       popl    %eax           \n"
   138 "       movl    %eax,%ecx      \n"
   140 "       movl    %eax,%ecx      \n"
   189         __asm cpuid \
   191         __asm cpuid \
   190         __asm mov a, eax \
   192         __asm mov a, eax \
   191         __asm mov b, ebx \
   193         __asm mov b, ebx \
   192         __asm mov c, ecx \
   194         __asm mov c, ecx \
   193         __asm mov d, edx \
   195         __asm mov d, edx \
   194     }
   196 }
       
   197 #elif defined(_MSC_VER) && defined(_M_X64)
       
   198 #define cpuid(func, a, b, c, d) \
       
   199 { \
       
   200     int CPUInfo[4]; \
       
   201     __cpuid(CPUInfo, func); \
       
   202     a = CPUInfo[0]; \
       
   203     b = CPUInfo[1]; \
       
   204     c = CPUInfo[2]; \
       
   205     d = CPUInfo[3]; \
       
   206 }
   195 #else
   207 #else
   196 #define cpuid(func, a, b, c, d) \
   208 #define cpuid(func, a, b, c, d) \
   197     a = b = c = d = 0
   209     a = b = c = d = 0
   198 #endif
   210 #endif
   199 
   211