From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UO2PS-0007bL-LQ for qemu-devel@nongnu.org; Fri, 05 Apr 2013 04:54:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UO2PL-0000lu-Pu for qemu-devel@nongnu.org; Fri, 05 Apr 2013 04:54:10 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:34939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UO2PL-0000li-IO for qemu-devel@nongnu.org; Fri, 05 Apr 2013 04:54:03 -0400 Received: by mail-lb0-f173.google.com with SMTP id w20so3500407lbh.4 for ; Fri, 05 Apr 2013 01:54:02 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Peter Maydell Date: Fri, 5 Apr 2013 09:53:42 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH v2 1/5] bitops: Add ONES macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: blauwirbel@gmail.com, edgar.iglesias@gmail.com, kraxel@redhat.com, qemu-devel@nongnu.org, mst@redhat.com On 5 April 2013 09:43, Peter Crosthwaite wrote: > Little macro that just gives you N ones (justified to LSB). > > Signed-off-by: Peter Crosthwaite > --- > > include/qemu/bitops.h | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h > index affcc96..da47fc8 100644 > --- a/include/qemu/bitops.h > +++ b/include/qemu/bitops.h > @@ -273,4 +273,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) You can avoid the ?: here (assuming you're happy to say that ONES(0) is a silly thing to ask for): #define ONES(num) (~0ULL >> (64 - (num))) Needs a documentation comment, anyway. thanks -- PMM