From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaMMU-0008PQ-HC for qemu-devel@nongnu.org; Mon, 29 Feb 2016 06:51:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aaMMP-0003yp-Jc for qemu-devel@nongnu.org; Mon, 29 Feb 2016 06:51:38 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:38247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaMMP-0003yi-9G for qemu-devel@nongnu.org; Mon, 29 Feb 2016 06:51:33 -0500 Received: by mail-wm0-x231.google.com with SMTP id l68so54906990wml.1 for ; Mon, 29 Feb 2016 03:51:32 -0800 (PST) References: <889f6c7641bb04403de2a03406177dcf24ca8a53.1455055858.git.alistair.francis@xilinx.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <889f6c7641bb04403de2a03406177dcf24ca8a53.1455055858.git.alistair.francis@xilinx.com> Date: Mon, 29 Feb 2016 11:51:29 +0000 Message-ID: <87h9grka4e.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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: Alistair Francis Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, crosthwaitepeter@gmail.com, edgar.iglesias@gmail.com, afaerber@suse.de, fred.konrad@greensocs.com 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) == 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 = ~ONES(27) }, Becomes: .ro = MAKE_64BIT_MASK(27, 64 - 27); > #endif -- Alex Bennée