comparison cpudetect.c @ 3837:6659db99f200

warning fix
author pl
date Fri, 28 Dec 2001 18:03:03 +0000
parents 91f801a94a59
children 4ff660150386
comparison
equal deleted inserted replaced
3836:beba5552ed2d 3837:6659db99f200
1 #include "config.h" 1 #include "config.h"
2 #include "cpudetect.h" 2 #include "cpudetect.h"
3 3
4 CpuCaps gCpuCaps; 4 CpuCaps gCpuCaps;
5
6 #ifdef HAVE_MALLOC_H
7 #include <malloc.h>
8 #endif
9 #include <stdlib.h>
5 10
6 #ifdef ARCH_X86 11 #ifdef ARCH_X86
7 12
8 #include <stdio.h> 13 #include <stdio.h>
9 14
91 if (!has_cpuid()) { 96 if (!has_cpuid()) {
92 printf("CPUID not supported!???\n"); 97 printf("CPUID not supported!???\n");
93 return; 98 return;
94 } 99 }
95 do_cpuid(0x00000000, regs); // get _max_ cpuid level and vendor name 100 do_cpuid(0x00000000, regs); // get _max_ cpuid level and vendor name
96 printf("CPU vendor name: %.4s%.4s%.4s max cpuid level: %d\n",&regs[1],&regs[3],&regs[2],regs[0]); 101 printf("CPU vendor name: %.4s%.4s%.4s max cpuid level: %d\n",
102 (char*) (regs+1),(char*) (regs+3),(char*) (regs+2), regs[0]);
97 if (regs[0]>=0x00000001) 103 if (regs[0]>=0x00000001)
98 { 104 {
99 char *tmpstr; 105 char *tmpstr;
100 106
101 do_cpuid(0x00000001, regs2); 107 do_cpuid(0x00000001, regs2);
171 if (NULL==(retname=(char*)malloc(256))) { 177 if (NULL==(retname=(char*)malloc(256))) {
172 printf("Error: GetCpuFriendlyName() not enough memory\n"); 178 printf("Error: GetCpuFriendlyName() not enough memory\n");
173 exit(1); 179 exit(1);
174 } 180 }
175 181
176 sprintf(vendor,"%.4s%.4s%.4s",&regs[1],&regs[3],&regs[2]); 182 sprintf(vendor,"%.4s%.4s%.4s",(char*)(regs+1),(char*)(regs+3),(char*)(regs+2));
177 183
178 for(i=0; i<MAX_VENDORS; i++){ 184 for(i=0; i<MAX_VENDORS; i++){
179 if(!strcmp(cpuvendors[i].string,vendor)){ 185 if(!strcmp(cpuvendors[i].string,vendor)){
180 if(cpuname[i][CPUID_FAMILY][CPUID_MODEL]){ 186 if(cpuname[i][CPUID_FAMILY][CPUID_MODEL]){
181 snprintf(retname,255,"%s %s",cpuvendors[i].name,cpuname[i][CPUID_FAMILY][CPUID_MODEL]); 187 snprintf(retname,255,"%s %s",cpuvendors[i].name,cpuname[i][CPUID_FAMILY][CPUID_MODEL]);