From owner-cvs-all@FreeBSD.ORG Sun May 30 05:24:45 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 04F9916A4CE; Sun, 30 May 2004 05:24:45 -0700 (PDT) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 40FD243D31; Sun, 30 May 2004 05:24:44 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87])i4UCOh4u025714; Sun, 30 May 2004 22:24:43 +1000 Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) i4UCOfLS023667; Sun, 30 May 2004 22:24:41 +1000 Date: Sun, 30 May 2004 22:24:40 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Pawel Jakub Dawidek In-Reply-To: <20040530081550.GC12007@darkness.comp.waw.pl> Message-ID: <20040530215900.N1952@gamplex.bde.org> References: <200405282116.i4SLGin4067490@repoman.freebsd.org> <20040530081550.GC12007@darkness.comp.waw.pl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@freebsd.org cc: src-committers@freebsd.org cc: David Malone cc: cvs-all@freebsd.org Subject: Re: cvs commit: src/sbin/kldstat kldstat.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 May 2004 12:24:45 -0000 On Sun, 30 May 2004, Pawel Jakub Dawidek wrote: > On Fri, May 28, 2004 at 02:16:44PM -0700, David Malone wrote: > +> dwmalone 2004/05/28 14:16:44 PDT > +> > +> FreeBSD src repository > +> > +> Modified files: > +> sbin/kldstat kldstat.c > +> Log: > +> Decide how much space we need to print a pointer using > +> sizeof(void *) rather than if __alpha__ is defined. > [...] > +> -#if defined(__alpha__) > +> -#define POINTER_WIDTH 18 > +> -#else > +> -#define POINTER_WIDTH 10 > +> -#endif > +> +#define POINTER_WIDTH (sizeof(void *) > 4 ? 18 : 10) > > Why not just: > > #define POINTER_WIDTH (sizeof(void *) * 2 + 2) Well, neither gives the width of a pointer; plain "sizeof(void *)" gives the width of "void *" pointers but not necessarily others :-). The pointer width here is actually the field width for printing with %p, under the assumption that this is a constant. %p actually gives 0x%x or 0x%lx format, and kldstat depends on the magic that the pointers that it prints all have a bit in their highest nybble set so that their printed width is always the maximum. The assumption could be avoided using the nonstandard format %*p (where the * is POINTER_WIDTH), but I think it is better to not use %p. Its enforced 0x just gets in the way, and on 64-bit machines POINTER_WIDTH is too wide for most tables (though not kldstat's). Common leading 0xff's should probably be stripped on 64-bit machines. The width would then be data-dependent. Bruce