Unified · Split
| @@ -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 | + | |
| 1 | 6 | 2008-09-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com> |
| 2 | 7 | |
| 3 | 8 | * configure.ac |
| @@ -18,6 +18,8 @@ · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | #include <stdio.h> |
| 20 | 20 | #include <stdlib.h> |
| 21 | +#include <string.h> | |
| 22 | +#include <ctype.h> | |
| 21 | 23 | #include <math.h> |
| 22 | 24 | |
| 23 | 25 | #include "util.h" |
| @@ -164,3 +166,34 @@ reverse_data (float *data, int datalen) · 140 unmodified lines | ||
| 164 | 166 | |
| 165 | 167 | } /* reverse_data */ |
| 166 | 168 | |
| 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 | + | |
| @@ -35,6 +35,8 @@ void reverse_data (float *data, int datalen) ; · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | double calculate_snr (float *data, int len, int expected_peaks) ; |
| 37 | 37 | |
| 38 | +void print_cpu_name (void) ; | |
| 39 | + | |
| 38 | 40 | #if OS_IS_WIN32 |
| 39 | 41 | /* |
| 40 | 42 | ** Extra Win32 hacks. |