From owner-freebsd-arch@FreeBSD.ORG Fri Sep 6 19:34:26 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C92CFD6F for ; Fri, 6 Sep 2013 19:34:26 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: from mail-pb0-x230.google.com (mail-pb0-x230.google.com [IPv6:2607:f8b0:400e:c01::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A43D82B03 for ; Fri, 6 Sep 2013 19:34:26 +0000 (UTC) Received: by mail-pb0-f48.google.com with SMTP id ma3so3604953pbc.35 for ; Fri, 06 Sep 2013 12:34:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=KJA+ZojMpfKyzKTTZOPhwc24BMorWYhMROfkytKCKK0=; b=Z9ZrvmkP0cpDd3E53oL/qjkxQkQcuG0I3GpTeXgFZPtKW07Ltq8sciJKfyFyxH1V25 Jsm5/Zm1AZ/YdE1S75g8q3bEn4WNyNKnGUW1z/3C6D4feziHEB/+F2HeIQRatul8Idl+ Ukj+M6aP76KI+2XnuAgHghSEAajSItM/08wjefgOuPVsdFCOEBNtYwS4Y+LgSquiToj/ 4JuBSzmGU4+MopkJRvC+JnT7rm5ZnCYE6FMyQMy4txKnOJGYPJCVhHpOA37RzP1Mid6+ 5/svFYxgA9/IyhrfGt2lkhmaYZvgqKDtNrvIkazATI58eT3CDlnjb3X64XQWUU1y2+7O PDZg== X-Received: by 10.68.196.37 with SMTP id ij5mr4655742pbc.175.1378496066284; Fri, 06 Sep 2013 12:34:26 -0700 (PDT) Received: from [10.192.166.0] (stargate.chelsio.com. [67.207.112.58]) by mx.google.com with ESMTPSA id ef10sm6640728pac.1.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Sep 2013 12:34:25 -0700 (PDT) Sender: Navdeep Parhar Message-ID: <522A2E3F.2070509@FreeBSD.org> Date: Fri, 06 Sep 2013 12:34:23 -0700 From: Navdeep Parhar User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130819 Thunderbird/17.0.8 MIME-Version: 1.0 To: freebsd-arch@freebsd.org Subject: vtprintf Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Sep 2013 19:34:26 -0000 I have the need for a vtprintf in the kernel. Is the following patch ok? See http://people.freebsd.org/~np/vtprintf.diff in case it's eaten by the mailing list. I would like to commit this soon. While here, I could also add a vuprintf if anyone thinks it might be useful too. ? Regards, Navdeep diff -r b180598c57ea sys/kern/subr_prf.c --- a/sys/kern/subr_prf.c Fri Sep 06 11:52:17 2013 -0700 +++ b/sys/kern/subr_prf.c Fri Sep 06 12:29:27 2013 -0700 @@ -175,15 +175,24 @@ out: } /* - * tprintf prints on the controlling terminal associated with the given - * session, possibly to the log as well. + * tprintf and vtprintf print on the controlling terminal associated with the + * given session, possibly to the log as well. */ void tprintf(struct proc *p, int pri, const char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + vtprintf(p, pri, fmt, ap); + va_end(ap); +} + +void +vtprintf(struct proc *p, int pri, const char *fmt, va_list ap) +{ struct tty *tp = NULL; int flags = 0; - va_list ap; struct putchar_arg pca; struct session *sess = NULL; @@ -208,13 +217,11 @@ tprintf(struct proc *p, int pri, const c pca.tty = tp; pca.flags = flags; pca.p_bufr = NULL; - va_start(ap, fmt); if (pca.tty != NULL) tty_lock(pca.tty); kvprintf(fmt, putchar, &pca, 10, ap); if (pca.tty != NULL) tty_unlock(pca.tty); - va_end(ap); if (sess != NULL) sess_release(sess); msgbuftrigger = 1; diff -r b180598c57ea sys/sys/systm.h --- a/sys/sys/systm.h Fri Sep 06 11:52:17 2013 -0700 +++ b/sys/sys/systm.h Fri Sep 06 12:29:27 2013 -0700 @@ -212,6 +212,7 @@ u_long strtoul(const char *, char **, in quad_t strtoq(const char *, char **, int) __nonnull(1); u_quad_t strtouq(const char *, char **, int) __nonnull(1); void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4); +void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0); void hexdump(const void *ptr, int length, const char *hdr, int flags); #define HD_COLUMN_MASK 0xff #define HD_DELIM_MASK 0xff00