From owner-svn-src-all@FreeBSD.ORG Fri Dec 3 19:37:23 2010 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 93F6E106566C; Fri, 3 Dec 2010 19:37:23 +0000 (UTC) (envelope-from rea@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id 138838FC23; Fri, 3 Dec 2010 19:37:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codelabs.ru; s=two; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=GDQ6EencwDoQ9OWgemHxGCkQM2jCjUb6HvcalQgc8yk=; b=L19zYvhlkCwaRVG9+Yac1UFumoCp0C30A09s+khZy+J1nHWO8N+TvCu1LZT4OdpLrxhXUPpuP2xeYBpE1ijDkrTXYbSz2GOnQX0X4jDwhoU0TBIbLRuMUXAt4BeQFM9iP0VTki/tItsN9gob5RchBefygnfRpkGdKXoMm/P00HUNv18TjLD/gXvTCm5WWv391Ytui1pVylzFOEVUJB7eH7Yt6FkYXvznrICaudy1VaEYtpCGH3iMOClXQM2CjQCqqNnw9dZmhnRUQm/tPgi1C3n7LMynk1za3ls3YXrOUl4ynmewxevNmBA07Lk/twnbPaDgzm3c6C8CyVDpoQ9Kug==; Received: from void.codelabs.ru (void.codelabs.ru [144.206.177.25]) by 0.mx.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1PObRX-000MEN-4U; Fri, 03 Dec 2010 22:37:19 +0300 Date: Fri, 3 Dec 2010 22:37:16 +0300 From: Eygene Ryabinkin To: Bruce Evans Message-ID: References: <201012030709.oB379NOH058721@svn.freebsd.org> <20101204045754.T4046@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101204045754.T4046@besplex.bde.org> Sender: rea@codelabs.ru Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Bruce Cran Subject: Re: svn commit: r216143 - in head: share/man/man9 sys/amd64/include sys/arm/include sys/i386/include sys/ia64/include sys/mips/include sys/pc98/include sys/powerpc/include sys/sparc64/include sys/sun4v... 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: Fri, 03 Dec 2010 19:37:23 -0000 Sat, Dec 04, 2010 at 05:01:55AM +1100, Bruce Evans wrote: > On Fri, 3 Dec 2010, Bruce Cran wrote: > > Log: > > Revert r216134. This checkin broke platforms where bus_space are macros: > > they need to be a single statement, and do { } while (0) doesn't > > work in this situation so revert until a solution can be devised. > > Surprising that do-while doesn't work. Prior to the revert, something like "a = bus_space_read_multi_1(...)" will generate improper code like "a = KASSERT(); __bs_nonsigle(XXX);" and making "do { KASSERT(); __bs_nonsingle(XXX); } while(0)" won't help either, since we can't generally assign the compound statement to the lvalue. > > Modified: head/sys/arm/include/bus.h > > ============================================================================== > > --- head/sys/arm/include/bus.h Fri Dec 3 07:01:07 2010 (r216142) > > +++ head/sys/arm/include/bus.h Fri Dec 3 07:09:23 2010 (r216143) > > ... > > @@ -321,29 +318,21 @@ struct bus_space { > > * Bus read multiple operations. > > */ > > #define bus_space_read_multi_1(t, h, o, a, c) \ > > - KASSERT(c != 0, ("bus_space_read_multi_1: count == 0")); \ > > __bs_nonsingle(rm,1,(t),(h),(o),(a),(c)) > > I just noticed the following possibly more serious problems for the macro > versions: > > - the `c' arg is missing parentheses in the KASSERT() > - the `c' arg is now evaluated twice. This turns safe macros into unsafe > ones. Perhaps we can define the macros as {{{ #define bus_space_read_multi_1(t, h, o, a, c) ({\ size_t count = (c); \ KASSERT(count != 0, ("bus_space_read_multi_1: count == 0")); \ __bs_nonsingle(rm,1,(t),(h),(o),(a),count); \ }) }}} This will both allow to avoid unsafety and will make this statement to be the correct assignment for any compiler that supports the "braced-groups within expressions" GNU extension. GNU C, Clang and Intel C both support it (but not with -pedantic -ansi -Werror flag combo). But, probably, the inline function will be better here from the portability point of view, since it is supported by the C standard and braced-groups -- aren't. So, the question is "why these statements were made to be macros at some platforms?". -- Eygene Ryabinkin ,,,^..^,,, [ Life's unfair - but root password helps! | codelabs.ru ] [ 82FE 06BC D497 C0DE 49EC 4FF0 16AF 9EAE 8152 ECFB | freebsd.org ]