this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adding changes according to review

+39 -29
+39 -29
src/kernel/emulation/linux/misc/sysctl_machdep.c
··· 1 1 #include "sysctl_machdep.h" 2 + #include "simple.h" 2 3 #include <sys/errno.h> 4 + #include <alloca.h> 3 5 4 6 enum { 5 7 _MACHDEP_CPU = 1000, ··· 53 55 unsigned int ebx;\ 54 56 unsigned int edx;\ 55 57 unsigned int ecx 58 + #endif 56 59 57 60 sysctl_handler(handle_vendor) 58 61 { ··· 113 116 eax = eax >> 3; 114 117 eax &= 15; 115 118 116 - sprintf(old,"%d",eax); 119 + __simple_sprintf(old,"%d",eax); 117 120 118 121 return 0; 119 122 } ··· 133 136 134 137 sysctl_handler(handle_brand_string) 135 138 { 136 - unsigned int level = 0; 137 - unsigned int eax = 0x80000000; 139 + setup(0x80000000); 138 140 139 - unsigned int test[3]; 140 - 141 - __cpuid(level,eax,test, test+1,test+2); 141 + __cpuid(level,eax,eabx, eacx, eadx); 142 142 143 143 if(eax < 0x80000004) // the information is not implemented 144 144 return 2; 145 145 146 - eax = 0x80000001; 146 + 147 147 148 148 union 149 149 { ··· 151 151 char name[49]; 152 152 } v; 153 153 154 - __cpuid(level, eax, v.brand+0x1, v.brand+0x2, v.brand+0x3); 155 - v.brand[0x0] = eax; 156 - eax = 0x80000002; 157 - 158 - __cpuid(level, eax, v.brand+0x5, v.brand+0x6, v.brand+0x7); 159 - v.brand[0x4] = eax; 160 - eax = 0x80000003; 161 - 162 - __cpuid(level, eax, v.brand+0x9, v.brand+0xa, v.brand+0xb); 163 - v.brand[0x8] = eax; 154 + for (int i = 1; i < 4; i++) 155 + { 156 + eax = 0x80000000+i; 157 + __cpuid(level, eax, ebx, ecx, edx); 158 + v.brand[0x0+(i-1)*4] = eax; 159 + v.brand[0x1+(i-1)*4] = ebx; 160 + v.brand[0x2+(i-1)*4] = ecx; 161 + v.brand[0x3+(i-1)*4] = edx; 162 + } 164 163 165 164 v.name[48] = 0; 166 165 copyout_string(v.name, (char*) old, oldlen); ··· 171 170 { 172 171 setup(1); 173 172 174 - char *features[] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", NULL,"SEP","PGE","MCA", 175 - "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", 176 - "HTT", "TM", NULL, "PBE"}; 173 + char *features[] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", NULL,"SEP","MTRR","PGE", 174 + "MCA", "CMOV", "PSE-36", "PSN", "CLFSH", NULL, "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", 175 + "HTT", "TM","IA64","PBE"}; 177 176 178 - char *out = (char*)(calloc(119, sizeof(char))); //"worst" case: we have all of it plus null termination 177 + char *out = ""; //"worst" case: we have all of it plus null termination 179 178 180 179 __cpuid(0,eax,ebx,ecx,edx); 181 180 182 181 int j = 0; 183 - int size = sizeof(char); 184 182 int counter = 0; 185 183 186 - for (int i = 0; i < 32; ++i) 184 + for (int i = 0; i < 32; i++) 187 185 { 188 186 if(edx>>i&1) 189 187 { 190 - for(j=0;j< sizeof(features[i])/size; j++) 188 + int len = __simple_strlen(features[i]); 189 + int out_len = ____simple_strlen(out); 190 + char *new_out = alloca((len+out_len+1)*sizeof(char)) 191 + for(j=0; j < out_len; j++) 192 + { 193 + new_out[j] = out[j]; 194 + } 195 + 196 + for(j=0; j < len; j++) 191 197 { 192 - out[counter+j] = features[i][j] 198 + new_out[counter+j] = features[i][j]; 193 199 } 194 200 195 - counter = counter + j + 1; 201 + counter = counter + j; 202 + 203 + new_out[counter] = ' '; 196 204 197 - out[counter] = ' '; 205 + out=new_out; 198 206 199 - counter += 1; 207 + counter++; 200 208 201 209 } 202 210 } 203 211 204 - copyout_string(out,(*char) old, oldlen); 212 + out[counter] = 0; 213 + 214 + copyout_string(out,(char*) old, oldlen); 205 215 206 216 return 0; 207 217