summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-08-31 14:16:26 +0000
committerMike Frysinger <vapier@gentoo.org>2011-08-31 14:16:26 +0000
commit2628914943802b71bdce6ab338133786d5870ac2 (patch)
tree18d0cb3c2dbd36364f9aa2d8dd964162d8f17f86 /app-benchmarks
parentChange version scheme (diff)
downloadgentoo-2-2628914943802b71bdce6ab338133786d5870ac2.tar.gz
gentoo-2-2628914943802b71bdce6ab338133786d5870ac2.tar.bz2
gentoo-2-2628914943802b71bdce6ab338133786d5870ac2.zip
Fix multiple issues with cpuid().
(Portage version: 2.2.0_alpha51/cvs/Linux x86_64)
Diffstat (limited to 'app-benchmarks')
-rw-r--r--app-benchmarks/i7z/ChangeLog8
-rw-r--r--app-benchmarks/i7z/files/i7z-0.27-cpuid.patch127
-rw-r--r--app-benchmarks/i7z/i7z-0.27-r1.ebuild46
3 files changed, 180 insertions, 1 deletions
diff --git a/app-benchmarks/i7z/ChangeLog b/app-benchmarks/i7z/ChangeLog
index f28b2fd05c95..b066afd62bd3 100644
--- a/app-benchmarks/i7z/ChangeLog
+++ b/app-benchmarks/i7z/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for app-benchmarks/i7z
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-benchmarks/i7z/ChangeLog,v 1.4 2011/08/14 10:21:37 jlec Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-benchmarks/i7z/ChangeLog,v 1.5 2011/08/31 14:16:25 vapier Exp $
+
+*i7z-0.27-r1 (31 Aug 2011)
+
+ 31 Aug 2011; Mike Frysinger <vapier@gentoo.org> +i7z-0.27-r1.ebuild,
+ +files/i7z-0.27-cpuid.patch:
+ Fix multiple issues with cpuid().
*i7z-0.27 (14 Aug 2011)
diff --git a/app-benchmarks/i7z/files/i7z-0.27-cpuid.patch b/app-benchmarks/i7z/files/i7z-0.27-cpuid.patch
new file mode 100644
index 000000000000..16b5a097234f
--- /dev/null
+++ b/app-benchmarks/i7z/files/i7z-0.27-cpuid.patch
@@ -0,0 +1,127 @@
+http://code.google.com/p/i7z/issues/detail?id=31
+
+this makes cpuid work on 32bit and 64bit systems, both PIC and non-PIC
+
+the things it fixes:
+ - no more silent clobbering of ebx/ecx/edx
+ - works under 32bit pic builds (gcc doesnt like to clobber ebx)
+ - ebx gets saved/restored via edi register
+ - get_vendor incorrectly used ebx,ecx,edx when it should be ebx,edx,ecx
+ - unify all the cpuid implementations to make usage much simpler
+
+I WROTE THIS
+
+--- a/helper_functions.c
++++ b/helper_functions.c
+@@ -87,41 +87,40 @@ print_family_info (struct family_info *proc_info)
+ // printf(" Extended Family %d\n", proc_info->extended_family);
+ }
+
++static inline void cpuid (unsigned int info, unsigned int *eax, unsigned int *ebx,
++ unsigned int *ecx, unsigned int *edx)
++{
++ unsigned int _eax = info, _ebx, _ecx, _edx;
++ asm volatile ("mov %%ebx, %%edi;" // save ebx (for PIC)
++ "cpuid;"
++ "mov %%ebx, %%esi;" // pass to caller
++ "mov %%edi, %%ebx;" // restore ebx
++ :"+a" (_eax), "=S" (_ebx), "=c" (_ecx), "=d" (_edx)
++ : /* inputs: eax is handled above */
++ :"edi" /* clobbers: we hit edi directly */);
++ if (eax) *eax = _eax;
++ if (ebx) *ebx = _ebx;
++ if (ecx) *ecx = _ecx;
++ if (edx) *edx = _edx;
++}
+
+-#ifdef x64_BIT
+ void get_vendor (char *vendor_string)
+ {
+ //get vendor name
+- unsigned int b, c, d, e;
+- // int i;
+- asm volatile ("mov %4, %%eax; " // 0 into eax
+- "cpuid;" "mov %%eax, %0;" // eeax into b
+- "mov %%ebx, %1;" // eebx into c
+- "mov %%edx, %2;" // eeax into d
+- "mov %%ecx, %3;" // eeax into e
+- :"=r" (b), "=r" (c), "=r" (d), "=r" (e) /* output */
+- :"r" (0) /* input */
+- :"%eax", "%ebx", "%ecx", "%edx" /* clobbered register, will be modifying inside the asm routine so dont use them */
+- );
+- memcpy (vendor_string, &c, 4);
++ unsigned int a, b, c, d;
++ cpuid (0, &a, &b, &c, &d);
++ memcpy (vendor_string, &b, 4);
+ memcpy (vendor_string + 4, &d, 4);
+- memcpy (vendor_string + 8, &e, 4);
++ memcpy (vendor_string + 8, &c, 4);
+ vendor_string[12] = '\0';
+ // printf("Vendor %s\n",vendor_string);
+ }
+-#endif
+
+ int turbo_status ()
+ {
+ //turbo state flag
+ unsigned int eax;
+- // int i;
+- asm volatile ("mov %1, %%eax; " // 0 into eax
+- "cpuid;" "mov %%eax, %0;" // eeax into b
+- :"=r" (eax) /* output */
+- :"r" (6) /* input */
+- :"%eax" /* clobbered register, will be modifying inside the asm routine so dont use them */
+- );
++ cpuid (6, &eax, NULL, NULL, NULL);
+
+ //printf("eax %d\n",(eax&0x2)>>1);
+
+@@ -132,12 +131,7 @@ void get_familyinformation (struct family_info *proc_info)
+ {
+ //get info about CPU
+ unsigned int b;
+- asm volatile ("mov %1, %%eax; " // 0 into eax
+- "cpuid;" "mov %%eax, %0;" // eeax into b
+- :"=r" (b) /* output */
+- :"r" (1) /* input */
+- :"%eax" /* clobbered register, will be modifying inside the asm routine so dont use them */
+- );
++ cpuid (1, &b, NULL, NULL, NULL);
+ // printf ("eax %x\n", b);
+ proc_info->stepping = b & 0x0000000F; //bits 3:0
+ proc_info->model = (b & 0x000000F0) >> 4; //bits 7:4
+@@ -348,7 +342,6 @@ void Print_Information_Processor(bool* nehalem, bool* sandy_bridge)
+ {
+ struct family_info proc_info;
+
+-#ifdef x64_BIT
+ char vendor_string[13];
+ get_vendor (vendor_string);
+ if (strcmp (vendor_string, "GenuineIntel") == 0)
+@@ -359,14 +352,6 @@ void Print_Information_Processor(bool* nehalem, bool* sandy_bridge)
+ ("this was designed to be a intel proc utility. You can perhaps mod it for your machine?\n");
+ exit (1);
+ }
+-#endif
+-
+-#ifndef x64_BIT
+- //anecdotal evidence: get_vendor doesnt seem to work on 32-bit
+- printf
+- ("I dont know the CPUID code to check on 32-bit OS, so i will assume that you have an Intel processor\n");
+- printf ("Don't worry if i don't find a nehalem next, i'll quit anyways\n");
+-#endif
+
+ get_familyinformation (&proc_info);
+ print_family_info (&proc_info);
+--- a/i7z.h
++++ b/i7z.h
+@@ -106,9 +106,7 @@ __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi));
+
+ void print_family_info (struct family_info *proc_info);
+
+-#ifdef x64_BIT
+ void get_vendor (char *vendor_string);
+-#endif
+
+ int turbo_status ();
+ double cpufreq_info();
diff --git a/app-benchmarks/i7z/i7z-0.27-r1.ebuild b/app-benchmarks/i7z/i7z-0.27-r1.ebuild
new file mode 100644
index 000000000000..daeb55753b78
--- /dev/null
+++ b/app-benchmarks/i7z/i7z-0.27-r1.ebuild
@@ -0,0 +1,46 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-benchmarks/i7z/i7z-0.27-r1.ebuild,v 1.1 2011/08/31 14:16:25 vapier Exp $
+
+EAPI="4"
+
+inherit eutils qt4-r2 toolchain-funcs
+
+DESCRIPTION="A better i7 (and now i3, i5) reporting tool for Linux"
+HOMEPAGE="http://code.google.com/p/i7z/"
+SRC_URI="http://${PN}.googlecode.com/files/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="X"
+
+RDEPEND="
+ sys-libs/ncurses
+ X? ( x11-libs/qt-gui:4 )"
+DEPEND="${RDEPEND}"
+
+S="${WORKDIR}"/${PN}
+
+src_prepare() {
+ epatch "${FILESDIR}"/${PV}-gentoo.patch
+ epatch "${FILESDIR}"/${P}-cpuid.patch
+ tc-export CC
+}
+
+src_compile() {
+ default
+ if use X; then
+ cd GUI
+ eqmake4 GUI.pro
+ emake
+ fi
+}
+
+src_install() {
+ emake DESTDIR="${ED}" install
+ if use X; then
+ newsbin GUI/GUI i7z_GUI
+ fi
+ dodoc put_cores_o*line.sh MAKEDEV-cpuid-msr
+}