Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Backout using humanize_number(9) in clockfreq().
details: https://anonhg.NetBSD.org/src/rev/88d30883d75f
branches: trunk
changeset: 330955:88d30883d75f
user: nakayama <nakayama%NetBSD.org@localhost>
date: Fri Jul 25 17:21:32 2014 +0000
description:
Backout using humanize_number(9) in clockfreq().
humanize_number(9) cannot handle a fraction part and doesn't
match the intention of clockfreq().
Also backout the changes caused by the fallout of clockfreq().
Fixed outputs:
-cpu0 at mainbus0: MB86904 @ 170 MHz, MB86910 or WTL1164/5 FPU
+cpu0 at mainbus0: MB86904 @ 170 MHz, MB86910 or WTL1164/5 FPU
-sbus0 at iommu0: clock = 21250 MHz
+sbus0 at iommu0: clock = 21.250 MHz
-cpu0 at mainbus0: SUNW,UltraSPARC-II @ 449 MHz, CPU id 0
+cpu0 at mainbus0: SUNW,UltraSPARC-II @ 449.971 MHz, CPU id 0
diffstat:
sys/arch/sparc/sparc/autoconf.c | 11 ++++++++---
sys/arch/sparc/sparc/cpu.c | 8 ++++----
sys/arch/sparc64/sparc64/autoconf.c | 11 ++++++++---
sys/arch/sparc64/sparc64/cpu.c | 6 +++---
4 files changed, 23 insertions(+), 13 deletions(-)
diffs (129 lines):
diff -r 50165d157f01 -r 88d30883d75f sys/arch/sparc/sparc/autoconf.c
--- a/sys/arch/sparc/sparc/autoconf.c Fri Jul 25 16:40:12 2014 +0000
+++ b/sys/arch/sparc/sparc/autoconf.c Fri Jul 25 17:21:32 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.256 2014/04/23 09:06:57 macallan Exp $ */
+/* $NetBSD: autoconf.c,v 1.257 2014/07/25 17:21:32 nakayama Exp $ */
/*
* Copyright (c) 1996
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.256 2014/04/23 09:06:57 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.257 2014/07/25 17:21:32 nakayama Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -1034,8 +1034,13 @@
clockfreq(int freq)
{
static char buf[10];
+ size_t len;
- humanize_number(buf, sizeof(buf), freq / 1000, "", 1000);
+ freq /= 1000;
+ len = snprintf(buf, sizeof(buf), "%d", freq / 1000);
+ freq %= 1000;
+ if (freq)
+ snprintf(buf + len, sizeof(buf) - len, ".%03d", freq);
return buf;
}
diff -r 50165d157f01 -r 88d30883d75f sys/arch/sparc/sparc/cpu.c
--- a/sys/arch/sparc/sparc/cpu.c Fri Jul 25 16:40:12 2014 +0000
+++ b/sys/arch/sparc/sparc/cpu.c Fri Jul 25 17:21:32 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.247 2014/06/04 07:06:03 martin Exp $ */
+/* $NetBSD: cpu.c,v 1.248 2014/07/25 17:21:32 nakayama Exp $ */
/*
* Copyright (c) 1996
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.247 2014/06/04 07:06:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.248 2014/07/25 17:21:32 nakayama Exp $");
#include "opt_multiprocessor.h"
#include "opt_lockdebug.h"
@@ -437,7 +437,7 @@
/* Stuff to only run on the boot CPU */
cpu_setup();
snprintf(buf, sizeof buf, "%s @ %s MHz, %s FPU",
- cpi->cpu_longname, clockfreq(cpi->hz / 1000), cpi->fpu_name);
+ cpi->cpu_longname, clockfreq(cpi->hz), cpi->fpu_name);
cpu_setmodel("%s (%s)", machine_model, buf);
printf(": %s\n", buf);
cache_print(sc);
@@ -526,7 +526,7 @@
/* Now start this CPU */
cpu_spinup(cpi);
printf(": %s @ %s MHz, %s FPU\n", cpi->cpu_longname,
- clockfreq(cpi->hz / 1000), cpi->fpu_name);
+ clockfreq(cpi->hz), cpi->fpu_name);
cache_print(sc);
diff -r 50165d157f01 -r 88d30883d75f sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c Fri Jul 25 16:40:12 2014 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c Fri Jul 25 17:21:32 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.197 2014/03/26 17:29:21 christos Exp $ */
+/* $NetBSD: autoconf.c,v 1.198 2014/07/25 17:21:32 nakayama Exp $ */
/*
* Copyright (c) 1996
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.197 2014/03/26 17:29:21 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.198 2014/07/25 17:21:32 nakayama Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -511,8 +511,13 @@
clockfreq(long freq)
{
static char buf[10];
+ size_t len;
- humanize_number(buf, sizeof(buf), freq / 1000, "", 1000);
+ freq /= 1000;
+ len = snprintf(buf, sizeof(buf), "%ld", freq / 1000);
+ freq %= 1000;
+ if (freq)
+ snprintf(buf + len, sizeof(buf) - len, ".%03ld", freq);
return buf;
}
diff -r 50165d157f01 -r 88d30883d75f sys/arch/sparc64/sparc64/cpu.c
--- a/sys/arch/sparc64/sparc64/cpu.c Fri Jul 25 16:40:12 2014 +0000
+++ b/sys/arch/sparc64/sparc64/cpu.c Fri Jul 25 17:21:32 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.113 2014/06/10 18:27:41 palle Exp $ */
+/* $NetBSD: cpu.c,v 1.114 2014/07/25 17:21:32 nakayama Exp $ */
/*
* Copyright (c) 1996
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.113 2014/06/10 18:27:41 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.114 2014/07/25 17:21:32 nakayama Exp $");
#include "opt_multiprocessor.h"
@@ -342,7 +342,7 @@
ci->ci_system_clockrate[1] = sclk / 1000000;
snprintf(buf, sizeof buf, "%s @ %s MHz",
- prom_getpropstring(node, "name"), clockfreq(clk / 1000));
+ prom_getpropstring(node, "name"), clockfreq(clk));
cpu_setmodel("%s (%s)", machine_model, buf);
aprint_normal(": %s, CPU id %d\n", buf, ci->ci_cpuid);
Home |
Main Index |
Thread Index |
Old Index