aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2018-11-06 23:41:44 +0000
committerMark Johnston <markj@FreeBSD.org>2018-11-06 23:41:44 +0000
commitf8a222010f712fdce875495697fb71ab9eab8299 (patch)
treeb0d5330ae756a1f05a7f047961a059f5a96e6cb5 /sys/kern/tty.c
parent6ad8a6eaa40cca031acadd3125b9d772e50f1d23 (diff)
downloadsrc-f8a222010f712fdce875495697fb71ab9eab8299.tar.gz
src-f8a222010f712fdce875495697fb71ab9eab8299.zip
Avoid fixing the tty_info() buffer size in tty.h.
Different compilation units may otherwise get a different view of the layout of struct tty depending on whether they include opt_printf.h. This caused a blowup in the number of types defined in the kernel's CTF file after r339468; thanks to dim@ for bisecting down to that revision. PR: 232675 Reported by: dim Reviewed by: cem (previous version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17877
Notes
Notes: svn path=/head/; revision=340208
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 26ce6124bf86..022c392d5c17 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -33,6 +33,7 @@
__FBSDID("$FreeBSD$");
#include "opt_capsicum.h"
+#include "opt_printf.h"
#include <sys/param.h>
#include <sys/capsicum.h>
@@ -106,6 +107,12 @@ SYSCTL_INT(_kern, OID_AUTO, tty_drainwait, CTLFLAG_RWTUN,
#define TTYBUF_MAX 65536
+#ifdef PRINTF_BUFR_SIZE
+#define TTY_PRBUF_SIZE PRINTF_BUFR_SIZE
+#else
+#define TTY_PRBUF_SIZE 256
+#endif
+
/*
* Allocate buffer space if necessary, and set low watermarks, based on speed.
* Note that the ttyxxxq_setsize() functions may drop and then reacquire the tty
@@ -1051,7 +1058,9 @@ tty_alloc_mutex(struct ttydevsw *tsw, void *sc, struct mtx *mutex)
PATCH_FUNC(busy);
#undef PATCH_FUNC
- tp = malloc(sizeof(struct tty), M_TTY, M_WAITOK|M_ZERO);
+ tp = malloc(sizeof(struct tty) + TTY_PRBUF_SIZE, M_TTY,
+ M_WAITOK | M_ZERO);
+ tp->t_prbufsz = TTY_PRBUF_SIZE;
tp->t_devsw = tsw;
tp->t_devswsoftc = sc;
tp->t_flags = tsw->tsw_flags;