source:
patches/coreutils-5.94-uname-1.patch@
aba7454
Last change on this file since aba7454 was 69cde8d, checked in by , 19 years ago | |
---|---|
|
|
File size: 4.5 KB |
-
coreutils-5.92
Submitted By: Matthew Burgess <matthew at linuxfromscratch dot org> Date: 2005-10-23 Initial Package Version: 5.92 Upstream Status: pending Origin: Scot McPherson Description: Fix the output of uname once and for all. $ uname -m # This always worked. i686 $ uname -i # Used to report 'unknown'. i386 $ uname -p # Likewise. athlon-4 diff -Naur coreutils-5.92.orig/src/uname.c coreutils-5.92/src/uname.c
old new 29 29 # include <sys/systeminfo.h> 30 30 #endif 31 31 32 #ifdef linux 33 #define cpuid(in,a,b,c,d)\ 34 asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in)); 35 int has_sse( void ); 36 #endif 37 32 38 #if HAVE_SYS_SYSCTL_H 33 39 # if HAVE_SYS_PARAM_H 34 40 # include <sys/param.h> /* needed for OpenBSD 3.0 */ … … 256 262 if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) 257 263 element = processor; 258 264 } 265 #else 266 { 267 struct utsname u; 268 uname (&u); 269 element = u.machine; 270 #ifdef linux 271 /****************************************************************************** 272 * 273 * Hello, major hack. I shouldn't have to do this. struct utsname should 274 * have another element with this info in it. There's probably a struct 275 * somewhere that has this info, I just don't know where it is. 276 * 277 *****************************************************************************/ 278 279 if( !strcmp( element, "i586" ) || !strcmp( element, "i686" ) ) { 280 int eax, ebx, ecx, edx, unused; 281 int model, family, sse; 282 283 cpuid(0,unused,ebx,ecx,edx); 284 cpuid(1,eax,unused,unused,unused); 285 model = (eax >> 4) & 0xf; 286 family = (eax >> 8) & 0xf; 287 288 switch(ebx) { 289 case 0x756e6547: // Intel 290 switch( family ) { 291 case 5: // Pentium 292 if( model <= 3 ) 293 element="pentium"; 294 if( model > 3 ) 295 element="pentium-mmx"; 296 break; 297 case 6: // PentiumPro - Pentium III 298 if( model == 1 ) // Pentium Pro 299 element="pentiumpro"; 300 if( ( model == 3 ) || ( model == 5 ) || 301 ( model == 6 ) ) // Pentium II 302 element="pentium2"; 303 if( ( model == 7 ) || ( model == 8 ) || 304 ( model == 10 ) || ( model == 11 ) ) // These are all Pentium III 305 element="pentium3"; 306 break; 307 case 15: // Pentium4 308 element="pentium4"; 309 break; 310 default: 311 break; 312 } // end switch( family ) 313 break; 314 case 0x68747541: // AMD 315 switch(family) { 316 case 5: 317 if( ( model == 0 ) || ( model == 1 ) || 318 ( model == 2 ) || ( model == 3 ) ) // K5 319 element="i586"; 320 if( ( model == 6 ) || ( model == 7 ) ) // K6 321 element="k6"; 322 if( model == 8 ) // K6-2 323 element="k6-2"; 324 if( model == 9 ) // K6-3 325 element="k6-3"; 326 break; 327 case 6: 328 if( model <= 4 ) 329 element="athlon"; 330 if( model > 4 ) { 331 sse = has_sse(); 332 if( sse == 0 ) 333 element="athlon"; 334 if( sse == 1 ) 335 element="athlon-4"; 336 } 337 break; 338 case 15: 339 element="athlon-4"; 340 break; 341 default: 342 break; 343 } // end switch( family ) 344 break; 345 case 0x69727943: // Cyrix 346 element="i386"; // who knows what cyrix supports, lets be safe 347 break; 348 default: 349 break; 350 } // end switch(ebx) 351 } 352 353 #endif 354 } 259 355 #endif 260 356 #ifdef UNAME_PROCESSOR 261 357 if (element == unknown) … … 293 389 294 390 if (toprint & PRINT_HARDWARE_PLATFORM) 295 391 { 296 char const*element = unknown;392 char *element = unknown; 297 393 #if HAVE_SYSINFO && defined SI_PLATFORM 298 394 { 299 395 static char hardware_platform[257]; … … 301 397 hardware_platform, sizeof hardware_platform)) 302 398 element = hardware_platform; 303 399 } 400 #else 401 { 402 struct utsname u; 403 uname (&u); 404 element = u.machine; 405 if (strlen (element) == 4 && element[0] == 'i' && element[2] == '8' 406 && element[3] == '6') 407 element[1] = '3'; 408 } 304 409 #endif 305 410 #ifdef UNAME_HARDWARE_PLATFORM 306 411 if (element == unknown) … … 323 428 324 429 exit (EXIT_SUCCESS); 325 430 } 431 432 #ifdef linux 433 434 /****************************************************************************** 435 * 436 * int has_sse( void ) 437 * Checks Athlon CPU's to see if they support SSE. 438 * 439 *****************************************************************************/ 440 441 int has_sse( void ) 442 { 443 unsigned long edx, unused; 444 int sse; 445 cpuid(1,unused,unused,unused,edx); 446 // I think, I need this tested on a Duron with SSE 447 // and one without it. 448 sse = edx & 0x2000000; 449 if( sse == 0 ) { 450 return 0; 451 } else { 452 return 1; 453 } 454 455 } 456 #endif
Note:
See TracBrowser
for help on using the repository browser.