Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Introduce new helper printf functions that get passed ou...
details: https://anonhg.NetBSD.org/src/rev/8d214c71313e
branches: trunk
changeset: 995825:8d214c71313e
user: martin <martin%NetBSD.org@localhost>
date: Mon Jan 07 13:09:47 2019 +0000
description:
Introduce new helper printf functions that get passed output
flags. Add a new kprintf flag to avoid adding time stamps
when outputing to the console. Mostly from Christos, any bugs
added by me.
Use above to print the "twiddle" (when using boot -z) without
timestamps.
diffstat:
sys/kern/subr_prf.c | 55 ++++++++++++++++++++++++++--------------------------
sys/sys/kprintf.h | 3 +-
sys/sys/systm.h | 6 ++++-
3 files changed, 34 insertions(+), 30 deletions(-)
diffs (158 lines):
diff -r 2d58c97017f0 -r 8d214c71313e sys/kern/subr_prf.c
--- a/sys/kern/subr_prf.c Mon Jan 07 05:01:10 2019 +0000
+++ b/sys/kern/subr_prf.c Mon Jan 07 13:09:47 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_prf.c,v 1.174 2018/07/15 07:24:11 martin Exp $ */
+/* $NetBSD: subr_prf.c,v 1.175 2019/01/07 13:09:48 martin Exp $ */
/*-
* Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.174 2018/07/15 07:24:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.175 2019/01/07 13:09:48 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -232,8 +232,8 @@
kprintf_lock();
- putchar(twiddle_chars[pos++ & 3], TOCONS, NULL);
- putchar('\b', TOCONS, NULL);
+ putchar(twiddle_chars[pos++ & 3], TOCONS|NOTSTAMP, NULL);
+ putchar('\b', TOCONS|NOTSTAMP, NULL);
kprintf_unlock();
}
@@ -526,7 +526,7 @@
}
#ifndef KLOG_NOTIMESTAMP
- if (c != '\0' && c != '\n' && needtstamp) {
+ if (c != '\0' && c != '\n' && needtstamp && (flags & NOTSTAMP) == 0) {
addtstamp(flags, tp);
needtstamp = 0;
}
@@ -1052,17 +1052,31 @@
}
void
+vprintf_flags(int flags, const char *fmt, va_list ap)
+{
+ kprintf_lock();
+ kprintf(fmt, flags, NULL, NULL, ap);
+ kprintf_unlock();
+}
+
+void
+printf_flags(int flags, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vprintf_flags(flags, fmt, ap);
+ va_end(ap);
+}
+
+void
printf_tolog(const char *fmt, ...)
{
va_list ap;
- kprintf_lock();
-
va_start(ap, fmt);
- kprintf(fmt, TOLOG, NULL, NULL, ap);
+ vprintf_flags(TOLOG, fmt, ap);
va_end(ap);
-
- kprintf_unlock();
}
/*
@@ -1074,13 +1088,9 @@
{
va_list ap;
- kprintf_lock();
-
va_start(ap, fmt);
- kprintf(fmt, TOCONS, NULL, NULL, ap);
+ vprintf_flags(TOCONS, fmt, ap);
va_end(ap);
-
- kprintf_unlock();
}
/*
@@ -1095,16 +1105,9 @@
{
va_list ap;
- kprintf_lock();
-
va_start(ap, fmt);
- kprintf(fmt, TOCONS | TOLOG, NULL, NULL, ap);
+ vprintf_flags(TOCONS | TOLOG, fmt, ap);
va_end(ap);
-
- kprintf_unlock();
-
- if (!panicstr)
- logwakeup();
}
/*
@@ -1115,11 +1118,7 @@
void
vprintf(const char *fmt, va_list ap)
{
- kprintf_lock();
-
- kprintf(fmt, TOCONS | TOLOG, NULL, NULL, ap);
-
- kprintf_unlock();
+ vprintf_flags(TOCONS | TOLOG, fmt, ap);
if (!panicstr)
logwakeup();
diff -r 2d58c97017f0 -r 8d214c71313e sys/sys/kprintf.h
--- a/sys/sys/kprintf.h Mon Jan 07 05:01:10 2019 +0000
+++ b/sys/sys/kprintf.h Mon Jan 07 13:09:47 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kprintf.h,v 1.12 2014/08/10 16:44:36 tls Exp $ */
+/* $NetBSD: kprintf.h,v 1.13 2019/01/07 13:09:47 martin Exp $ */
/*-
* Copyright (c) 1986, 1988, 1991, 1993
@@ -55,6 +55,7 @@
#define TOBUFONLY 0x0008 /* to the buffer (only) [for snprintf] */
#define TODDB 0x0010 /* to ddb console */
#define NOLOCK 0x1000 /* don't acquire a tty lock */
+#define NOTSTAMP 0x2000 /* no time stamp on console */
void kprintf_init(void);
void kprintf_init_callout(void);
diff -r 2d58c97017f0 -r 8d214c71313e sys/sys/systm.h
--- a/sys/sys/systm.h Mon Jan 07 05:01:10 2019 +0000
+++ b/sys/sys/systm.h Mon Jan 07 13:09:47 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: systm.h,v 1.280 2018/12/02 21:00:13 maxv Exp $ */
+/* $NetBSD: systm.h,v 1.281 2019/01/07 13:09:47 martin Exp $ */
/*-
* Copyright (c) 1982, 1988, 1991, 1993
@@ -240,6 +240,10 @@
int vsnprintf(char *, size_t, const char *, va_list) __printflike(3, 0);
+void vprintf_flags(int, const char *, va_list) __printflike(2, 0);
+
+void printf_flags(int, const char *, ...) __printflike(2, 3);
+
int humanize_number(char *, size_t, uint64_t, const char *, int);
void twiddle(void);
Home |
Main Index |
Thread Index |
Old Index