From owner-svn-src-all@FreeBSD.ORG Mon May 9 19:34:50 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 84F81106566C; Mon, 9 May 2011 19:34:50 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 42F6B8FC0C; Mon, 9 May 2011 19:34:49 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.4/8.14.2) with ESMTP id p49J0BQJ017523; Mon, 9 May 2011 15:00:11 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by zim.MIT.EDU (8.14.4/8.14.2/Submit) id p49J0A9Z017522; Mon, 9 May 2011 15:00:10 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Date: Mon, 9 May 2011 15:00:10 -0400 From: David Schultz To: Bruce Evans Message-ID: <20110509190010.GA17384@zim.MIT.EDU> Mail-Followup-To: Bruce Evans , Hans Petter Selasky , mdf@freebsd.org, "src-committers@freebsd.org" , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" References: <201105071628.p47GSO16006145@svn.freebsd.org> <201105071836.00660.hselasky@c2i.net> <201105071955.35305.hselasky@c2i.net> <20110508195020.V981@besplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110508195020.V981@besplex.bde.org> Cc: "svn-src-head@freebsd.org" , mdf@FreeBSD.ORG, "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Hans Petter Selasky Subject: Re: svn commit: r221604 - head/usr.sbin/usbdump X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2011 19:34:50 -0000 On Sun, May 08, 2011, Bruce Evans wrote: > #define bzero(p, n) ({ \ > if (__builtin_constant_p(n) && (n) <= 32) \ > __builtin_memset((p), 0, (n)); \ > else \ > (bzero)((p), (n)); \ > }) > > This hard-codes the limit of 32 for the builtin since some versions of > gcc use a worse limit. > > In userland, on at least amd64 and i386, the extern bzero() and memset() > are unoptimized, but the compiler builtin is used for memset() only. A > better implementation of bzero() would use the compiler builtin for it > too. The above is not good enough for libc, since it evaluates args more > than once and has a hard-coded gccism. __builtin_constant_p(exp) is a special macro that doesn't (or shouldn't) cause exp to be evaluated, so your defintion shouldn't cause the argument to be evaluated more than once unless it is, in fact, a constant expression... and if it's a constant expression, we don't care. gcc purportedly has a bzero() builtin, by the way. I'm not sure if it's normally enabled, or whether it's any good. I doubt it's smart enough to translate memset(p, 0, len) into bzero(p, len).