Module Name: src
Committed By: martin
Date: Mon Jan 7 13:09:48 UTC 2019
Modified Files:
src/sys/kern: subr_prf.c
src/sys/sys: kprintf.h systm.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/sys/kern/subr_prf.c
cvs rdiff -u -r1.12 -r1.13 src/sys/sys/kprintf.h
cvs rdiff -u -r1.280 -r1.281 src/sys/sys/systm.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/subr_prf.c
diff -u src/sys/kern/subr_prf.c:1.174 src/sys/kern/subr_prf.c:1.175
--- src/sys/kern/subr_prf.c:1.174 Sun Jul 15 07:24:11 2018
+++ src/sys/kern/subr_prf.c Mon Jan 7 13:09:48 2019
@@ -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 @@ twiddle(void)
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 @@ putchar(int c, int flags, struct tty *tp
}
#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 @@ aprint_debug_ifnet(struct ifnet *ifp, co
}
void
-printf_tolog(const char *fmt, ...)
+vprintf_flags(int flags, const char *fmt, va_list ap)
{
- 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);
- kprintf(fmt, TOLOG, NULL, NULL, ap);
+ vprintf_flags(flags, fmt, ap);
va_end(ap);
+}
- kprintf_unlock();
+void
+printf_tolog(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vprintf_flags(TOLOG, fmt, ap);
+ va_end(ap);
}
/*
@@ -1074,13 +1088,9 @@ printf_nolog(const char *fmt, ...)
{
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 @@ printf(const char *fmt, ...)
{
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 @@ printf(const char *fmt, ...)
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();
Index: src/sys/sys/kprintf.h
diff -u src/sys/sys/kprintf.h:1.12 src/sys/sys/kprintf.h:1.13
--- src/sys/sys/kprintf.h:1.12 Sun Aug 10 16:44:36 2014
+++ src/sys/sys/kprintf.h Mon Jan 7 13:09:47 2019
@@ -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);
Index: src/sys/sys/systm.h
diff -u src/sys/sys/systm.h:1.280 src/sys/sys/systm.h:1.281
--- src/sys/sys/systm.h:1.280 Sun Dec 2 21:00:13 2018
+++ src/sys/sys/systm.h Mon Jan 7 13:09:47 2019
@@ -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 @@ void vprintf(const char *, va_list) __pr
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);