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 @@
12008-09-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
2
3 * tests/util.[ch]
4 Add function print_cpu_name.
5
12008-09-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>62008-09-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
2 7
3 * configure.ac8 * configure.ac
tests/util.c+33−0
@@ -18,6 +18,8 @@ · 17 unmodified lines
18 18
19#include <stdio.h>19#include <stdio.h>
20#include <stdlib.h>20#include <stdlib.h>
21#include <string.h>
22#include <ctype.h>
21#include <math.h>23#include <math.h>
22 24
23#include "util.h"25#include "util.h"
@@ -164,3 +166,34 @@ reverse_data (float *data, int datalen) · 140 unmodified lines
164 166
165} /* reverse_data */167} /* reverse_data */
166 168
169void
170print_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 ;
192complete :
193 fclose (file) ;
194 return ;
195failed :
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
35 35
36double calculate_snr (float *data, int len, int expected_peaks) ;36double calculate_snr (float *data, int len, int expected_peaks) ;
37 37
38void print_cpu_name (void) ;
39
38#if OS_IS_WIN3240#if OS_IS_WIN32
39/*41/*
40** Extra Win32 hacks.42** 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