summaryrefslogtreecommitdiff
path: root/tune/freq.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-11-05 01:48:32 +0100
committerKevin Ryde <user42@zip.com.au>2003-11-05 01:48:32 +0100
commitee2ed2c1067e17ec8e855e46301f85b3285defd8 (patch)
tree6a7265a2178e4739bf131d2b257d8d970537e238 /tune/freq.c
parent1e70c6cff226085f5ae1a52ed3a3eea1455c8bd2 (diff)
downloadgmp-ee2ed2c1067e17ec8e855e46301f85b3285defd8.tar.gz
* tune/freq.c (freq_sysctl_hw_model): Relax to just look for "%u MHz",
for the benefit of sparc cypress under netbsd 1.6.1.
Diffstat (limited to 'tune/freq.c')
-rw-r--r--tune/freq.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/tune/freq.c b/tune/freq.c
index a2838ea54..4b16f3027 100644
--- a/tune/freq.c
+++ b/tune/freq.c
@@ -270,9 +270,13 @@ freq_sysctl_hw_cpufrequency (int help)
}
-/* Alpha FreeBSD 4.1 and NetBSD 1.4 sysctl hw.model string gives "Digital
- AlphaPC 164LX 599 MHz". NetBSD 1.4 doesn't seem to have sysctlbyname, so
- sysctl() is used. */
+/* The following ssyctl hw.model strings have been observed,
+
+ Alpha FreeBSD 4.1: Digital AlphaPC 164LX 599 MHz
+ NetBSD 1.4: Digital AlphaPC 164LX 599 MHz
+ NetBSD 1.6.1: CY7C601 @ 40 MHz, TMS390C602A FPU
+
+ NetBSD 1.4 doesn't seem to have sysctlbyname, so sysctl() is used. */
static int
freq_sysctl_hw_model (int help)
@@ -292,29 +296,18 @@ freq_sysctl_hw_model (int help)
size = sizeof(str);
if (sysctl (mib, 2, str, &size, NULL, 0) == 0)
{
- /* find the second last space */
- p = &str[size-1];
- for (i = 0; i < 2; i++)
+ for (p = str; *p != '\0'; p++)
{
- for (;;)
+ end = 0;
+ if (sscanf (p, "%u MHz%n", &val, &end) == 1 && end != 0)
{
- if (p <= str)
- return 0;
- p--;
- if (*p == ' ')
- break;
+ speed_cycletime = 1e-6 / (double) val;
+ if (speed_option_verbose)
+ printf ("Using sysctl() hw.model %u for cycle time %.3g\n",
+ val, speed_cycletime);
+ return 1;
}
}
-
- end = 0;
- if (sscanf (p, "%u MHz%n", &val, &end) == 1 && end != 0)
- {
- speed_cycletime = 1e-6 / (double) val;
- if (speed_option_verbose)
- printf ("Using sysctl() hw.model %u for cycle time %.3g\n",
- val, speed_cycletime);
- return 1;
- }
}
#endif
return 0;