src/cpuinfo/SDL_cpuinfo.c
changeset 9300 0293f45e4814
parent 9278 8900afb78a19
child 9619 b94b6d0bff0f
equal deleted inserted replaced
9299:1d3bee66d518 9300:0293f45e4814
   456 {
   456 {
   457     static char SDL_CPUType[13];
   457     static char SDL_CPUType[13];
   458 
   458 
   459     if (!SDL_CPUType[0]) {
   459     if (!SDL_CPUType[0]) {
   460         int i = 0;
   460         int i = 0;
   461         int a, b, c, d;
       
   462 
   461 
   463         if (CPU_haveCPUID()) {
   462         if (CPU_haveCPUID()) {
       
   463             int a, b, c, d;
   464             cpuid(0x00000000, a, b, c, d);
   464             cpuid(0x00000000, a, b, c, d);
       
   465             (void) a;
   465             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
   466             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
   466             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
   467             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
   467             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
   468             SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
   468             SDL_CPUType[i++] = (char)(b & 0xff);
   469             SDL_CPUType[i++] = (char)(b & 0xff);
   469 
   470 
   561 
   562 
   562 int
   563 int
   563 SDL_GetCPUCacheLineSize(void)
   564 SDL_GetCPUCacheLineSize(void)
   564 {
   565 {
   565     const char *cpuType = SDL_GetCPUType();
   566     const char *cpuType = SDL_GetCPUType();
   566 
   567     int a, b, c, d;
       
   568     (void) a; (void) b; (void) c; (void) d;
   567     if (SDL_strcmp(cpuType, "GenuineIntel") == 0) {
   569     if (SDL_strcmp(cpuType, "GenuineIntel") == 0) {
   568         int a, b, c, d;
       
   569 
       
   570         cpuid(0x00000001, a, b, c, d);
   570         cpuid(0x00000001, a, b, c, d);
   571         return (((b >> 8) & 0xff) * 8);
   571         return (((b >> 8) & 0xff) * 8);
   572     } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0) {
   572     } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0) {
   573         int a, b, c, d;
       
   574 
       
   575         cpuid(0x80000005, a, b, c, d);
   573         cpuid(0x80000005, a, b, c, d);
   576         return (c & 0xff);
   574         return (c & 0xff);
   577     } else {
   575     } else {
   578         /* Just make a guess here... */
   576         /* Just make a guess here... */
   579         return SDL_CACHELINE_SIZE;
   577         return SDL_CACHELINE_SIZE;