Gentoo Archives: gentoo-commits

From: Pacho Ramos <pacho@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-benchmarks/i7z/, app-benchmarks/i7z/files/
Date: Wed, 31 May 2017 09:33:01
Message-Id: 1496223151.e41771703356e344dd98066f85834e345bcd675f.pacho@gentoo
1 commit: e41771703356e344dd98066f85834e345bcd675f
2 Author: Pacho Ramos <pacho <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 31 09:32:31 2017 +0000
4 Commit: Pacho Ramos <pacho <AT> gentoo <DOT> org>
5 CommitDate: Wed May 31 09:32:31 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e4177170
7
8 app-benchmarks/i7z: Apply Debian patches fixing multiple bugs, drop deprecated qt4 support (https://wiki.gentoo.org/wiki/Project:Qt/Policies#Handling_different_versions_of_Qt), allow -Ox for now as it looks to work ok for me with this version.
9
10 Package-Manager: Portage-2.3.6, Repoman-2.3.2
11
12 .../i7z/files/fix-insecure-tempfile.patch | 76 ++++++++++++++++++++++
13 app-benchmarks/i7z/files/fix_cpuid_asm.patch | 21 ++++++
14 .../i7z/files/hyphen-used-as-minus-sign.patch | 26 ++++++++
15 .../i7z/files/install-i7z_rw_registers.patch | 26 ++++++++
16 app-benchmarks/i7z/files/use_stdbool.patch | 40 ++++++++++++
17 app-benchmarks/i7z/i7z-93_p20131012-r1.ebuild | 69 ++++++++++++++++++++
18 6 files changed, 258 insertions(+)
19
20 diff --git a/app-benchmarks/i7z/files/fix-insecure-tempfile.patch b/app-benchmarks/i7z/files/fix-insecure-tempfile.patch
21 new file mode 100644
22 index 00000000000..fb027158434
23 --- /dev/null
24 +++ b/app-benchmarks/i7z/files/fix-insecure-tempfile.patch
25 @@ -0,0 +1,76 @@
26 +Author: Andreas Beckmann <anbe@××××××.org>
27 +Description: fix insecure temfile usage: /tmp/cpufreq.txt
28 + switch from system() + fopen() to popen()
29 + disable other insecure tempfiles that may be generated but not used
30 +Bug-Debian: http://bugs.debian.org/718418
31 +
32 +diff --git a/GUI/i7z_GUI.cpp b/GUI/i7z_GUI.cpp
33 +index 2705e84..60eaeb2 100644
34 +--- a/GUI/i7z_GUI.cpp
35 ++++ b/GUI/i7z_GUI.cpp
36 +@@ -171,18 +171,17 @@ MyThread::run ()
37 + //CPUINFO is wrong for i7 but correct for the number of physical and logical cores present
38 + //If Hyperthreading is enabled then, multiple logical processors will share a common CORE ID
39 + //http://www.redhat.com/magazine/022aug06/departments/tips_tricks/
40 +- system ("cat /proc/cpuinfo |grep MHz|sed 's/cpu\\sMHz\\s*:\\s//'|tail -n 1 > /tmp/cpufreq.txt");
41 +- system ("grep \"core id\" /proc/cpuinfo |sort -|uniq -|wc -l > /tmp/numPhysical.txt");
42 +- system ("grep \"processor\" /proc/cpuinfo |sort -|uniq -|wc -l > /tmp/numLogical.txt");
43 ++ //system ("grep \"core id\" /proc/cpuinfo |sort -|uniq -|wc -l > /tmp/numPhysical.txt");
44 ++ //system ("grep \"processor\" /proc/cpuinfo |sort -|uniq -|wc -l > /tmp/numLogical.txt");
45 +
46 +
47 +- //Open the parsed cpufreq file and obtain the cpufreq from /proc/cpuinfo
48 ++ // obtain the cpufreq from /proc/cpuinfo
49 + FILE *tmp_file;
50 +- tmp_file = fopen ("/tmp/cpufreq.txt", "r");
51 ++ tmp_file = popen ("sed -n '/MHz/ { s/cpu\\sMHz\\s*:\\s//p; q }' /proc/cpuinfo", "r");
52 + char tmp_str[30];
53 + fgets (tmp_str, 30, tmp_file);
54 ++ pclose (tmp_file);
55 + double cpu_freq_cpuinfo = atof (tmp_str);
56 +- fclose (tmp_file);
57 +
58 + unsigned int numPhysicalCores, numLogicalCores;
59 + numPhysicalCores = socket_0.num_physical_cores + socket_1.num_physical_cores;
60 +diff --git a/helper_functions.c b/helper_functions.c
61 +index 2f8da87..906c298 100644
62 +--- a/helper_functions.c
63 ++++ b/helper_functions.c
64 +@@ -531,16 +531,13 @@ double cpufreq_info()
65 + //CPUINFO is wrong for i7 but correct for the number of physical and logical cores present
66 + //If Hyperthreading is enabled then, multiple logical processors will share a common CORE ID
67 + //http://www.redhat.com/magazine/022aug06/departments/tips_tricks/
68 +- system
69 +- ("cat /proc/cpuinfo |grep MHz|sed 's/cpu\\sMHz\\s*:\\s//'|tail -n 1 > /tmp/cpufreq.txt");
70 +
71 +-
72 +- //Open the parsed cpufreq file and obtain the cpufreq from /proc/cpuinfo
73 ++ // obtain the cpufreq from /proc/cpuinfo
74 + FILE *tmp_file;
75 +- tmp_file = fopen ("/tmp/cpufreq.txt", "r");
76 ++ tmp_file = popen ("sed -n '/MHz/ { s/cpu\\sMHz\\s*:\\s//p; q }' /proc/cpuinfo", "r");
77 + char tmp_str[30];
78 + fgets (tmp_str, 30, tmp_file);
79 +- fclose (tmp_file);
80 ++ pclose (tmp_file);
81 + return atof(tmp_str);
82 + }
83 +
84 +diff --git a/i7z_Single_Socket.c b/i7z_Single_Socket.c
85 +index 015f154..d0afee0 100644
86 +--- a/i7z_Single_Socket.c
87 ++++ b/i7z_Single_Socket.c
88 +@@ -823,10 +823,13 @@ void print_i7z_single ()
89 + //CPUINFO is wrong for i7 but correct for the number of physical and logical cores present
90 + //If Hyperthreading is enabled then, multiple logical processors will share a common CORE ID
91 + //http://www.redhat.com/magazine/022aug06/departments/tips_tricks/
92 ++ERROR INSECURE TMPFILE
93 + system
94 + ("cat /proc/cpuinfo |grep MHz|sed 's/cpu\\sMHz\\s*:\\s//'|tail -n 1 > /tmp/cpufreq.txt");
95 ++ERROR INSECURE TMPFILE
96 + system
97 + ("grep \"core id\" /proc/cpuinfo |sort -|uniq -|wc -l > /tmp/numPhysical.txt");
98 ++ERROR INSECURE TMPFILE
99 + system
100 + ("grep \"processor\" /proc/cpuinfo |sort -|uniq -|wc -l > /tmp/numLogical.txt");
101 + //At this step, /tmp/numPhysical contains number of physical cores in machine and
102
103 diff --git a/app-benchmarks/i7z/files/fix_cpuid_asm.patch b/app-benchmarks/i7z/files/fix_cpuid_asm.patch
104 new file mode 100644
105 index 00000000000..27739a64523
106 --- /dev/null
107 +++ b/app-benchmarks/i7z/files/fix_cpuid_asm.patch
108 @@ -0,0 +1,21 @@
109 +Author: Andreas Beckmann <anbe@××××××.org>
110 +Description: fix cpuid inline assembly
111 + the old code zeroed the upper half of %rbx
112 +
113 +--- a/helper_functions.c
114 ++++ b/helper_functions.c
115 +@@ -101,13 +101,7 @@ static inline void cpuid (unsigned int i
116 + unsigned int *ecx, unsigned int *edx)
117 + {
118 + unsigned int _eax = info, _ebx, _ecx, _edx;
119 +- asm volatile ("mov %%ebx, %%edi;" // save ebx (for PIC)
120 +- "cpuid;"
121 +- "mov %%ebx, %%esi;" // pass to caller
122 +- "mov %%edi, %%ebx;" // restore ebx
123 +- :"+a" (_eax), "=S" (_ebx), "=c" (_ecx), "=d" (_edx)
124 +- : /* inputs: eax is handled above */
125 +- :"edi" /* clobbers: we hit edi directly */);
126 ++ asm volatile ("cpuid\n\t" : "+a" (_eax), "=b" (_ebx), "=c" (_ecx), "=d" (_edx) : : );
127 + if (eax) *eax = _eax;
128 + if (ebx) *ebx = _ebx;
129 + if (ecx) *ecx = _ecx;
130
131 diff --git a/app-benchmarks/i7z/files/hyphen-used-as-minus-sign.patch b/app-benchmarks/i7z/files/hyphen-used-as-minus-sign.patch
132 new file mode 100644
133 index 00000000000..f908b934621
134 --- /dev/null
135 +++ b/app-benchmarks/i7z/files/hyphen-used-as-minus-sign.patch
136 @@ -0,0 +1,26 @@
137 +Author: Andreas Beckmann <anbe@××××××.org>
138 +Description: fix hyphen abuse
139 +
140 +--- a/doc/i7z.man
141 ++++ b/doc/i7z.man
142 +@@ -7,15 +7,15 @@
143 + i7z runs the i7z, ncurses based, program without any options. i7z will print out the C-states and temperature for i3, i5 and i7 based Core processors from Intel (including Nehalems, Sandy Bridge and Ivy Bridge).
144 + .SH OPTIONS
145 + .TP
146 +-\fB-h, --help \fPshow the list of options available with the i7z tool.
147 ++\fB\-h, \-\-help \fPshow the list of options available with the i7z tool.
148 + .TP
149 +-\fB-w [a|l], --write [a,l] \fPLogging of the frequencies can be turned on with this options. Option "-w a" or "--write a" will append to the log file. Option "-w l" or "--write l" will replace the log file.
150 ++\fB\-w [a|l], \-\-write [a,l] \fPLogging of the frequencies can be turned on with this options. Option "\-w a" or "\-\-write a" will append to the log file. Option "\-w l" or "\-\-write l" will replace the log file.
151 + .TP
152 +-\fB-l, --logfile [FILENAME] \fPChange the log file name to the specified FILENAME. Default logging file is cpu_freq_log.txt (single socket) or cpu_freq_log_dual%d.txt (dual socket, %d is either 0, 1).
153 ++\fB\-l, \-\-logfile [FILENAME] \fPChange the log file name to the specified FILENAME. Default logging file is cpu_freq_log.txt (single socket) or cpu_freq_log_dual%d.txt (dual socket, %d is either 0, 1).
154 + .TP
155 +-\fB--socket0 [SOCKETNUM], --socket1 [SOCKETNUM] \fPThe tool can print information for about 2 sockets at once at the most. The top view will be, by default, of the first socket (controlled by --socket0) and the bottom view will be of the second socket (controlled by --socket1). Supply the appropriate value of 0 or 1 or more for SOCKETNUM (if there are more sockets on the machine) to show in the top and bottom view.
156 ++\fB\-\-socket0 [SOCKETNUM], \-\-socket1 [SOCKETNUM] \fPThe tool can print information for about 2 sockets at once at the most. The top view will be, by default, of the first socket (controlled by \-\-socket0) and the bottom view will be of the second socket (controlled by \-\-socket1). Supply the appropriate value of 0 or 1 or more for SOCKETNUM (if there are more sockets on the machine) to show in the top and bottom view.
157 + .TP
158 +-\fB--nogui \fPDisable the GUI. Useful when the only need is logging.
159 ++\fB\-\-nogui \fPDisable the GUI. Useful when the only need is logging.
160 + .SH Example
161 + To print for two sockets and also change the log file (log to /tmp/logfilei7z)
162 +
163
164 diff --git a/app-benchmarks/i7z/files/install-i7z_rw_registers.patch b/app-benchmarks/i7z/files/install-i7z_rw_registers.patch
165 new file mode 100644
166 index 00000000000..65c36e9a26f
167 --- /dev/null
168 +++ b/app-benchmarks/i7z/files/install-i7z_rw_registers.patch
169 @@ -0,0 +1,26 @@
170 +Author: Andreas Beckmann <anbe@××××××.org>
171 +Description: install the i7z_rw_registers script and fix the hashbang
172 +
173 +--- a/i7z_rw_registers.rb
174 ++++ b/i7z_rw_registers.rb
175 +@@ -1,3 +1,5 @@
176 ++#!/usr/bin/ruby
177 ++
178 + #* ----------------------------------------------------------------------- *
179 + # *
180 + # * Under GPL v3
181 +@@ -7,7 +9,6 @@
182 + # *
183 + # * ----------------------------------------------------------------------- */
184 +
185 +-#!/usr/bin/ruby
186 +
187 + def print_command_list()
188 + print "Do you need help? \n"
189 +--- a/Makefile
190 ++++ b/Makefile
191 +@@ -61,3 +61,4 @@
192 + install -D -m 755 $(BIN) $(DESTDIR)$(sbindir)$(BIN)
193 + install -d $(DESTDIR)$(docdir)
194 + install -m 0644 README.txt put_cores_offline.sh put_cores_online.sh MAKEDEV-cpuid-msr $(DESTDIR)$(docdir)
195 ++ install -m 0755 i7z_rw_registers.rb $(DESTDIR)$(sbindir)/i7z_rw_registers
196
197 diff --git a/app-benchmarks/i7z/files/use_stdbool.patch b/app-benchmarks/i7z/files/use_stdbool.patch
198 new file mode 100644
199 index 00000000000..4aa84ac091c
200 --- /dev/null
201 +++ b/app-benchmarks/i7z/files/use_stdbool.patch
202 @@ -0,0 +1,40 @@
203 +Author: Andreas Beckmann <anbe@××××××.org>
204 +Description: use a consistent bool type
205 +Bug-Debian: #749724
206 +
207 +--- a/i7z.h
208 ++++ b/i7z.h
209 +@@ -11,18 +11,13 @@
210 + * ----------------------------------------------------------------------- */
211 +
212 + #include <sys/time.h>
213 ++#include <stdbool.h>
214 +
215 + #define i7z_VERSION_INFO "svn-r93-(27-MAY-2013)"
216 +
217 + //structure to store the information about the processor
218 + #define proccpuinfo "/proc/cpuinfo"
219 +
220 +-#ifndef bool
221 +-#define bool int
222 +-#endif
223 +-#define false 0
224 +-#define true 1
225 +-
226 + #define MAX_PROCESSORS 128
227 + #define MAX_HI_PROCESSORS MAX_PROCESSORS
228 + #define MAX_SK_PROCESSORS (MAX_PROCESSORS/4)
229 +--- a/cpuinfo.c
230 ++++ b/cpuinfo.c
231 +@@ -2,10 +2,8 @@
232 + #include "string.h"
233 + #include "stdlib.h"
234 + #include "assert.h"
235 ++#include <stdbool.h>
236 + #define MAX_PROCESSORS 32
237 +-#define bool int
238 +-#define false 0
239 +-#define true 1
240 +
241 + #define MAX_HI_PROCESSORS MAX_PROCESSORS
242 +
243
244 diff --git a/app-benchmarks/i7z/i7z-93_p20131012-r1.ebuild b/app-benchmarks/i7z/i7z-93_p20131012-r1.ebuild
245 new file mode 100644
246 index 00000000000..4e7ab8619aa
247 --- /dev/null
248 +++ b/app-benchmarks/i7z/i7z-93_p20131012-r1.ebuild
249 @@ -0,0 +1,69 @@
250 +# Copyright 1999-2017 Gentoo Foundation
251 +# Distributed under the terms of the GNU General Public License v2
252 +
253 +EAPI=6
254 +
255 +inherit flag-o-matic qmake-utils toolchain-funcs
256 +
257 +COMMIT="5023138d7c35c4667c938b853e5ea89737334e92"
258 +DESCRIPTION="A better i7 (and now i3, i5) reporting tool for Linux"
259 +HOMEPAGE="https://github.com/ajaiantilal/i7z"
260 +SRC_URI="https://github.com/ajaiantilal/${PN}/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
261 +SLOT="0"
262 +LICENSE="GPL-2"
263 +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
264 +IUSE="qt5"
265 +
266 +RDEPEND="
267 + sys-libs/ncurses:0=
268 + qt5? (
269 + dev-qt/qtcore:5=
270 + dev-qt/qtgui:5=
271 + dev-qt/qtwidgets:5=
272 + )
273 +"
274 +DEPEND="${RDEPEND}"
275 +
276 +PATCHES=(
277 + "${FILESDIR}"/i7z-0.27.2-ncurses.patch
278 + "${FILESDIR}"/qt5.patch
279 + "${FILESDIR}"/gcc5.patch
280 +
281 + # From Debian
282 + "${FILESDIR}"/fix-insecure-tempfile.patch
283 + "${FILESDIR}"/fix_cpuid_asm.patch
284 + "${FILESDIR}"/hyphen-used-as-minus-sign.patch
285 + "${FILESDIR}"/install-i7z_rw_registers.patch
286 + "${FILESDIR}"/use_stdbool.patch
287 +)
288 +
289 +S="${WORKDIR}/${PN}-${COMMIT}"
290 +
291 +src_configure() {
292 + # The GUI segfaults with -O1. None of the documented flags make a
293 + # difference. There may not be a specific flag for the culprit.
294 + # Looks to work fine for me with -O2 (pacho - 20170530)
295 +# filter-flags "-O*"
296 +
297 + tc-export CC
298 + cd GUI || die
299 +
300 + use qt5 && eqmake5 ${PN}_GUI.pro
301 +}
302 +
303 +src_compile() {
304 + default
305 +
306 + if use qt5; then
307 + emake -C GUI clean
308 + emake -C GUI
309 + fi
310 +}
311 +
312 +src_install() {
313 + emake DESTDIR="${ED}" docdir=/usr/share/doc/${PF} install
314 +
315 + if use qt5; then
316 + dosbin GUI/i7z_GUI
317 + fi
318 +}