From owner-freebsd-hackers@FreeBSD.ORG Sun Nov 2 17:23:51 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF176F18; Sun, 2 Nov 2014 17:23:51 +0000 (UTC) Received: from monday.kientzle.com (99-115-135-74.uvs.sntcca.sbcglobal.net [99.115.135.74]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 87658C7C; Sun, 2 Nov 2014 17:23:50 +0000 (UTC) Received: (from root@localhost) by monday.kientzle.com (8.14.4/8.14.4) id sA2HNmTe023456; Sun, 2 Nov 2014 17:23:48 GMT (envelope-from tim@kientzle.com) Received: from [192.168.2.100] (gateway.kientzle.com [192.168.1.65]) by kientzle.com with SMTP id 4njizintkpcasucim67574te8a; Sun, 02 Nov 2014 17:23:48 +0000 (UTC) (envelope-from tim@kientzle.com) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) Subject: Re: how to kernel printf a int64_t? From: Tim Kientzle In-Reply-To: <20141102114614.38aa9034@akips.com> Date: Sun, 2 Nov 2014 09:23:48 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <3E8C7E0D-5858-4BFF-8C09-FAA68200B988@kientzle.com> References: <439339249.2551223.1414702876172.JavaMail.root@uoguelph.ca> <97A82163-E78D-457E-B649-B243B41A6C6F@kientzle.com> <54558778.7050500@freebsd.org> <20141102114614.38aa9034@akips.com> To: Paul Koch X-Mailer: Apple Mail (2.1990.1) Cc: Freebsd hackers list X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Nov 2014 17:23:51 -0000 > On Nov 1, 2014, at 6:46 PM, Paul Koch wrote: >=20 > On Sun, 02 Nov 2014 09:23:04 +0800 > Julian Elischer wrote: >=20 >> On 10/31/14, 1:09 PM, Tim Kientzle wrote: >>> On Oct 30, 2014, at 2:01 PM, Rick Macklem = wrote: >>>=20 >>>> int64_t i; >>>>=20 >>>> printf("%qd\n", (u_quad_t)i); >>>>=20 >>>> Is there a better way to printf() a int64_t in the kernel? >>>=20 >>> printf(=93%jd\n=94, (intmax_t)i); >=20 > We've always used the PRIxxx types when coding for both 32/64 = platforms, > but it would have been really nice to have a standard way for time_t. > Something like PRItt This is the major reason I prefer the intmax_t cast approach: the PRI* = macros only support a small handful of basic integer types. The intmax_t cast approach only requires you to know whether it's signed = (%jd with intmax_t) or unsigned (%ju with uintmax_t). > On Nov 1, 2014, at 7:14 PM, Rick Macklem wrote: > Oh, and is intmax_t going to be int64_t on all arches? Yes, until we start supporting 128-bit arithmetic. So the only runtime = cost for this approach is that it might have to widen the value. (Given = the cost of printf in general, that's likely not a problem.) Tim