| 317 | #else |
| 318 | { |
| 319 | struct utsname u; |
| 320 | uname (&u); |
| 321 | element = u.machine; |
| 322 | #ifdef linux |
| 323 | /****************************************************************************** |
| 324 | * |
| 325 | * Hello, major hack. I shouldn't have to do this. struct utsname should |
| 326 | * have another element with this info in it. There's probably a struct |
| 327 | * somewhere that has this info, I just don't know where it is. |
| 328 | * |
| 329 | *****************************************************************************/ |
| 330 | |
| 331 | if( !strcmp( element, "i586" ) || !strcmp( element, "i686" ) ) { |
| 332 | int eax, ebx, ecx, edx, unused; |
| 333 | int model, family, sse; |
| 334 | |
| 335 | cpuid(0,unused,ebx,ecx,edx); |
| 336 | cpuid(1,eax,unused,unused,unused); |
| 337 | model = (eax >> 4) & 0xf; |
| 338 | family = (eax >> 8) & 0xf; |
| 339 | |
| 340 | switch(ebx) { |
| 341 | case 0x756e6547: // Intel |
| 342 | switch( family ) { |
| 343 | case 5: // Pentium |
| 344 | if( model <= 3 ) |
| 345 | element="pentium"; |
| 346 | if( model > 3 ) |
| 347 | element="pentium-mmx"; |
| 348 | break; |
| 349 | case 6: // PentiumPro - Pentium III |
| 350 | if( model == 1 ) // Pentium Pro |
| 351 | element="pentiumpro"; |
| 352 | if( ( model == 3 ) || ( model == 5 ) || |
| 353 | ( model == 6 ) ) // Pentium II |
| 354 | element="pentium2"; |
| 355 | if( ( model == 7 ) || ( model == 8 ) || |
| 356 | ( model == 10 ) || ( model == 11 ) ) // These are all Pentium III |
| 357 | element="pentium3"; |
| 358 | break; |
| 359 | case 15: // Pentium4 |
| 360 | element="pentium4"; |
| 361 | break; |
| 362 | default: |
| 363 | break; |
| 364 | } // end switch( family ) |
| 365 | break; |
| 366 | case 0x68747541: // AMD |
| 367 | switch(family) { |
| 368 | case 5: |
| 369 | if( ( model == 0 ) || ( model == 1 ) || |
| 370 | ( model == 2 ) || ( model == 3 ) ) // K5 |
| 371 | element="i586"; |
| 372 | if( ( model == 6 ) || ( model == 7 ) ) // K6 |
| 373 | element="k6"; |
| 374 | if( model == 8 ) // K6-2 |
| 375 | element="k6-2"; |
| 376 | if( model == 9 ) // K6-3 |
| 377 | element="k6-3"; |
| 378 | break; |
| 379 | case 6: |
| 380 | if( model <= 4 ) |
| 381 | element="athlon"; |
| 382 | if( model > 4 ) { |
| 383 | sse = has_sse(); |
| 384 | if( sse == 0 ) |
| 385 | element="athlon"; |
| 386 | if( sse == 1 ) |
| 387 | element="athlon-4"; |
| 388 | } |
| 389 | break; |
| 390 | case 15: |
| 391 | element="athlon-4"; |
| 392 | break; |
| 393 | default: |
| 394 | break; |
| 395 | } // end switch( family ) |
| 396 | break; |
| 397 | case 0x69727943: // Cyrix |
| 398 | element="i386"; // who knows what cyrix supports, lets be safe |
| 399 | break; |
| 400 | default: |
| 401 | break; |
| 402 | } // end switch(ebx) |
| 403 | } |
| 404 | |
| 405 | #endif |
| 406 | } |
| 483 | |
| 484 | #ifdef linux |
| 485 | |
| 486 | /****************************************************************************** |
| 487 | * |
| 488 | * int has_sse( void ) |
| 489 | * Checks Athlon CPU's to see if they support SSE. |
| 490 | * |
| 491 | *****************************************************************************/ |
| 492 | |
| 493 | int has_sse( void ) |
| 494 | { |
| 495 | unsigned long edx, unused; |
| 496 | int sse; |
| 497 | cpuid(1,unused,unused,unused,edx); |
| 498 | // I think, I need this tested on a Duron with SSE |
| 499 | // and one without it. |
| 500 | sse = edx & 0x2000000; |
| 501 | if( sse == 0 ) { |
| 502 | return 0; |
| 503 | } else { |
| 504 | return 1; |
| 505 | } |
| 506 | |
| 507 | } |
| 508 | #endif |