1 Submitted By: Robert Connolly <robert@linuxfromscratch.org> (ashes)
3 Initial Package Version: 5.93
4 Upstream Status: pending
5 Origin: Scot McPherson and Zack Winkles
6 Description: Fix the output of uname once and for all. This is the position independent
9 $ uname -m # This always worked.
11 $ uname -i # Used to report 'unknown'.
13 $ uname -p # Likewise.
16 Now 'uname -p' can be used by GCC's mtune/mcpu and march options. For example:
18 CFLAGS="-march=$(uname -m) -mtune=$(uname -p)"
20 diff -Naur coreutils-5.93.orig/src/uname.c coreutils-5.93/src/uname.c
21 --- coreutils-5.93.orig/src/uname.c 2005-09-15 19:57:04.000000000 +0000
22 +++ coreutils-5.93/src/uname.c 2005-11-13 19:18:35.000000000 +0000
24 # include <sys/systeminfo.h>
28 +/* Thanks to the ffmpeg team for this PIC version of cpuid() */
36 +#define cpuid(index,eax,ebx,ecx,edx)\
38 + ("mov %%"REG_b", %%"REG_S"\n\t"\
40 + "xchg %%"REG_b", %%"REG_S\
41 + : "=a" (eax), "=S" (ebx),\
42 + "=c" (ecx), "=d" (edx)\
49 # include <sys/param.h> /* needed for OpenBSD 3.0 */
51 if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
58 + element = u.machine;
60 +/******************************************************************************
62 + * Hello, major hack. I shouldn't have to do this. struct utsname should
63 + * have another element with this info in it. There's probably a struct
64 + * somewhere that has this info, I just don't know where it is.
66 + *****************************************************************************/
68 + if( !strcmp( element, "i586" ) || !strcmp( element, "i686" ) ) {
69 + int eax, ebx, ecx, edx, unused;
70 + int model, family, sse;
72 + cpuid(0,unused,ebx,ecx,edx);
73 + cpuid(1,eax,unused,unused,unused);
74 + model = (eax >> 4) & 0xf;
75 + family = (eax >> 8) & 0xf;
78 + case 0x756e6547: // Intel
84 + element="pentium-mmx";
86 + case 6: // PentiumPro - Pentium III
87 + if( model == 1 ) // Pentium Pro
88 + element="pentiumpro";
89 + if( ( model == 3 ) || ( model == 5 ) ||
90 + ( model == 6 ) ) // Pentium II
92 + if( ( model == 7 ) || ( model == 8 ) ||
93 + ( model == 10 ) || ( model == 11 ) ) // These are all Pentium III
96 + case 15: // Pentium4
97 + if( model == 3 ) // Prescott
100 + element="pentium4";
104 + } // end switch( family )
106 + case 0x68747541: // AMD
109 + if( ( model == 0 ) || ( model == 1 ) ||
110 + ( model == 2 ) || ( model == 3 ) ) // K5
112 + if( ( model == 6 ) || ( model == 7 ) ) // K6
114 + if( model == 8 ) // K6-2
116 + if( model == 9 ) // K6-3
127 + element="athlon-4";
131 + element="athlon-4";
135 + } // end switch( family )
137 + case 0x69727943: // Cyrix
138 + element="i386"; // who knows what cyrix supports, lets be safe
142 + } // end switch(ebx)
148 #ifdef UNAME_PROCESSOR
149 if (element == unknown)
152 if (toprint & PRINT_HARDWARE_PLATFORM)
154 - char const *element = unknown;
155 + char *element = unknown;
156 #if HAVE_SYSINFO && defined SI_PLATFORM
158 static char hardware_platform[257];
160 hardware_platform, sizeof hardware_platform))
161 element = hardware_platform;
167 + element = u.machine;
168 + if (strlen (element) == 4 && element[0] == 'i' && element[2] == '8'
169 + && element[3] == '6')
173 #ifdef UNAME_HARDWARE_PLATFORM
174 if (element == unknown)
182 +/******************************************************************************
184 + * int has_sse( void )
185 + * Checks Athlon CPU's to see if they support SSE.
187 + *****************************************************************************/
191 + unsigned long edx, unused;
193 + cpuid(1,unused,unused,unused,edx);
194 + // I think, I need this tested on a Duron with SSE
195 + // and one without it.
196 + sse = edx & 0x2000000;