this repo has no description
1
fork

Configure Feed

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

changing copyout_int's signature, fixing typos, fixing handle_features

+49 -14
+49 -14
src/kernel/emulation/linux/misc/sysctl_machdep.c
··· 3 3 #include <sys/errno.h> 4 4 #include <alloca.h> 5 5 6 + extern char *strcpy(char *dest, const char *src); 7 + 6 8 enum { 7 9 _MACHDEP_CPU = 1000, 8 10 }; ··· 58 60 #endif 59 61 60 62 61 - inline void copyout_int(int value, char* to_copy, int to_copy_leng) 63 + static inline void copyout_int(int value, char* to_copy, size_t to_copy_length) 62 64 { 63 65 char tmp[64]; 64 66 __simple_sprintf(tmp, "%d", value); 65 - copyout_string(tmp, to_copy, to_copy_leng); 67 + copyout_string(tmp, to_copy, to_copy_length); 66 68 } 67 69 68 70 ··· 113 115 eax = eax >> 7; 114 116 eax &= 15; 115 117 116 - copyout_string(old,"%d",eax); 118 + copyout_int(eax, old, oldlen); 117 119 118 120 return 0; 119 121 } ··· 149 151 { 150 152 setup(0x80000000); 151 153 152 - __cpuid(level,eax,eabx, eacx, eadx); 154 + __cpuid(level,eax,ebx, ecx, edx); 153 155 154 156 if(eax < 0x80000004) // the information is not implemented 155 157 return 2; ··· 180 182 sysctl_handler(handle_features) 181 183 { 182 184 183 - if(old != NULL) 184 - { 185 - setup(1); 185 + setup(1); 186 186 187 - char features[][] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "","SEP","MTRR","PGE", 187 + static const char features[][7] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "","SEP","MTRR","PGE", 188 188 "MCA", "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", 189 189 "HTT", "TM","IA64","PBE"}; 190 190 191 191 __cpuid(0,eax,ebx,ecx,edx); 192 192 193 + if(old != NULL) 194 + { 195 + 193 196 int counter = 0; 194 - int current_old_len = __simple_strlen(old); 197 + int j = 0; 195 198 196 199 for (int i = 0; i < 32; i++) 197 200 { ··· 199 202 if(i == 10 || i == 20) 200 203 continue; 201 204 202 - if(edx>>i&1 && current_old_len < oldlen) 205 + if(edx>>i&1 && counter < oldlen) 203 206 { 204 207 int len = __simple_strlen(features[i]); 205 - __simple_sprintf(old,"%s %s",old,features[i]); 208 + 209 + strncpy(old,features[i]); 210 + 211 + counter = counter + len; 212 + 213 + if(counter < oldlen) 214 + { 215 + 216 + old[counter] = ' '; 206 217 207 - counter = counter + len + 1; 218 + counter++; 208 219 209 - current_old_len = __simple_strlen(old); 220 + } 221 + 222 + } 223 + } 224 + } 225 + else 226 + { 227 + int len = 0; 228 + 229 + for (int i = 0; i < 32; i++) 230 + { 231 + 232 + if(i == 10 || i == 20) 233 + continue; 210 234 235 + if(edx>>i&1) 236 + { 237 + if (len != 0) 238 + len++; 239 + 240 + len += __simple_strlen(features[i]); 211 241 } 242 + 212 243 } 213 244 245 + if (oldlen) 246 + *oldlen = len; 247 + 248 + } 214 249 215 - } 250 + 216 251 217 252 return 0; 218 253