History

tests/util.[ch] : Add function print_cpu_name.

Erik de Castro Lopo committed 18 years ago

Commit 215bd031 parent 20e6eb83 files · +40 −0Browse files

Unified · Split

3 files
  1. ChangeLog +5 −0
  2. tests/util.c +33 −0
  3. tests/util.h +2 −0
ChangeLog+5−0
@@ -1,3 +1,8 @@
1+2008-09-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
2+
3+ * tests/util.[ch]
4+ Add function print_cpu_name.
5+
16 2008-09-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
27
38 * configure.ac
tests/util.c+33−0
@@ -18,6 +18,8 @@ · 17 unmodified lines
1818
1919 #include <stdio.h>
2020 #include <stdlib.h>
21+#include <string.h>
22+#include <ctype.h>
2123 #include <math.h>
2224
2325 #include "util.h"
@@ -164,3 +166,34 @@ reverse_data (float *data, int datalen) · 140 unmodified lines
164166
165167 } /* reverse_data */
166168
169+void
170+print_cpu_name (void)
171+{ char buffer [512] ;
172+ FILE * file ;
173+
174+ if ((file = fopen ("/proc/cpuinfo", "r")) == NULL)
175+ { puts ("Unknown") ;
176+ return ;
177+ } ;
178+
179+ while (fgets (buffer, sizeof (buffer), file) != NULL)
180+ if (strstr (buffer, "model name") == buffer)
181+ { const char * cptr ;
182+
183+ if ((cptr = strchr (buffer, ':')) != NULL)
184+ { cptr ++ ;
185+ while (isspace (cptr [0])) cptr ++ ;
186+ printf ("%s", cptr) ;
187+ goto complete ;
188+ } ;
189+ } ;
190+
191+ goto failed ;
192+complete :
193+ fclose (file) ;
194+ return ;
195+failed :
196+ puts ("Unknown") ;
197+ return ;
198+} /* print_cpu_name */
199+
tests/util.h+2−0
@@ -35,6 +35,8 @@ void reverse_data (float *data, int datalen) ; · 34 unmodified lines
3535
3636 double calculate_snr (float *data, int len, int expected_peaks) ;
3737
38+void print_cpu_name (void) ;
39+
3840 #if OS_IS_WIN32
3941 /*
4042 ** Extra Win32 hacks.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t