From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abyQp-0002ex-2c for qemu-devel@nongnu.org; Fri, 04 Mar 2016 17:42:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abyQo-0003cI-2S for qemu-devel@nongnu.org; Fri, 04 Mar 2016 17:42:47 -0500 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:34151) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abyQn-0003cE-Tu for qemu-devel@nongnu.org; Fri, 04 Mar 2016 17:42:45 -0500 Received: by mail-oi0-x242.google.com with SMTP id m82so3714706oif.1 for ; Fri, 04 Mar 2016 14:42:45 -0800 (PST) MIME-Version: 1.0 Sender: alistair23@gmail.com In-Reply-To: <87h9grka4e.fsf@linaro.org> References: <889f6c7641bb04403de2a03406177dcf24ca8a53.1455055858.git.alistair.francis@xilinx.com> <87h9grka4e.fsf@linaro.org> From: Alistair Francis Date: Fri, 4 Mar 2016 14:42:15 -0800 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 08/16] bitops: Add ONES macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QWxleCBCZW5uw6ll?= Cc: Edgar Iglesias , Peter Maydell , "qemu-devel@nongnu.org Developers" , Alistair Francis , Peter Crosthwaite , Edgar Iglesias , =?UTF-8?Q?Andreas_F=C3=A4rber?= , =?UTF-8?B?S09OUkFEIEZyw6lkw6lyaWM=?= On Mon, Feb 29, 2016 at 3:51 AM, Alex Benn=C3=A9e = wrote: > > Alistair Francis writes: > >> From: Peter Crosthwaite >> >> Little macro that just gives you N ones (justified to LSB). >> >> Signed-off-by: Peter Crosthwaite >> Signed-off-by: Alistair Francis >> --- >> >> include/qemu/bitops.h | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h >> index 8164225..27bf98d 100644 >> --- a/include/qemu/bitops.h >> +++ b/include/qemu/bitops.h >> @@ -430,4 +430,6 @@ static inline uint64_t deposit64(uint64_t value, int= start, int length, >> return (value & ~mask) | ((fieldval << start) & mask); >> } >> >> +#define ONES(num) ((num) =3D=3D 64 ? ~0ull : (1ull << (num)) - 1) >> + > > I'm a little ambivalent about this one. The definition should probably > be up at the top of the file with the other #defines. I don't like the > name as it is a little too generic. I also notice in all the actual uses > you immediately invert the result because you want to mask the top bits. > > I suspect what's needed here is a more generic helper: > > #define MAKE_64BIT_MASK (shift, length) \ > ... > > And then the: > > .ro =3D ~ONES(27) }, > > Becomes: > > .ro =3D MAKE_64BIT_MASK(27, 64 - 27); > > >> #endif I like that idea. I have updated the implementation to use this style instead of the ONES() style. Thanks, Alistair > > > -- > Alex Benn=C3=A9e >