1 Submitted By: Matthew Burgess <matthew at linuxfromscratch dot org>
3 Initial Package Version: 5.92
4 Upstream Status: pending
6 Description: Fix the output of uname once and for all.
8 $ uname -m # This always worked.
10 $ uname -i # Used to report 'unknown'.
12 $ uname -p # Likewise.
15 diff -Naur coreutils-5.92.orig/src/uname.c coreutils-5.92/src/uname.c
16 --- coreutils-5.92.orig/src/uname.c 2005-09-15 20:34:42.000000000 +0000
17 +++ coreutils-5.92/src/uname.c 2005-10-23 10:14:06.000000000 +0000
19 # include <sys/systeminfo.h>
23 +#define cpuid(in,a,b,c,d)\
24 + asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in));
30 # include <sys/param.h> /* needed for OpenBSD 3.0 */
32 if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
39 + element = u.machine;
41 +/******************************************************************************
43 + * Hello, major hack. I shouldn't have to do this. struct utsname should
44 + * have another element with this info in it. There's probably a struct
45 + * somewhere that has this info, I just don't know where it is.
47 + *****************************************************************************/
49 + if( !strcmp( element, "i586" ) || !strcmp( element, "i686" ) ) {
50 + int eax, ebx, ecx, edx, unused;
51 + int model, family, sse;
53 + cpuid(0,unused,ebx,ecx,edx);
54 + cpuid(1,eax,unused,unused,unused);
55 + model = (eax >> 4) & 0xf;
56 + family = (eax >> 8) & 0xf;
59 + case 0x756e6547: // Intel
65 + element="pentium-mmx";
67 + case 6: // PentiumPro - Pentium III
68 + if( model == 1 ) // Pentium Pro
69 + element="pentiumpro";
70 + if( ( model == 3 ) || ( model == 5 ) ||
71 + ( model == 6 ) ) // Pentium II
73 + if( ( model == 7 ) || ( model == 8 ) ||
74 + ( model == 10 ) || ( model == 11 ) ) // These are all Pentium III
77 + case 15: // Pentium4
82 + } // end switch( family )
84 + case 0x68747541: // AMD
87 + if( ( model == 0 ) || ( model == 1 ) ||
88 + ( model == 2 ) || ( model == 3 ) ) // K5
90 + if( ( model == 6 ) || ( model == 7 ) ) // K6
92 + if( model == 8 ) // K6-2
94 + if( model == 9 ) // K6-3
105 + element="athlon-4";
109 + element="athlon-4";
113 + } // end switch( family )
115 + case 0x69727943: // Cyrix
116 + element="i386"; // who knows what cyrix supports, lets be safe
120 + } // end switch(ebx)
126 #ifdef UNAME_PROCESSOR
127 if (element == unknown)
130 if (toprint & PRINT_HARDWARE_PLATFORM)
132 - char const *element = unknown;
133 + char *element = unknown;
134 #if HAVE_SYSINFO && defined SI_PLATFORM
136 static char hardware_platform[257];
138 hardware_platform, sizeof hardware_platform))
139 element = hardware_platform;
145 + element = u.machine;
146 + if (strlen (element) == 4 && element[0] == 'i' && element[2] == '8'
147 + && element[3] == '6')
151 #ifdef UNAME_HARDWARE_PLATFORM
152 if (element == unknown)
160 +/******************************************************************************
162 + * int has_sse( void )
163 + * Checks Athlon CPU's to see if they support SSE.
165 + *****************************************************************************/
169 + unsigned long edx, unused;
171 + cpuid(1,unused,unused,unused,edx);
172 + // I think, I need this tested on a Duron with SSE
173 + // and one without it.
174 + sse = edx & 0x2000000;