From mboxrd@z Thu Jan 1 00:00:00 1970 From: Auger Eric Subject: Re: [kvm-unit-tests PATCH v6 08/11] libcflat: add IS_ALIGNED() macro, and page sizes Date: Wed, 23 Nov 2016 11:38:11 +0100 Message-ID: <23d97150-4eb6-db78-9a18-9af79c3c5597@redhat.com> References: <1479157719-31021-1-git-send-email-drjones@redhat.com> <1479157719-31021-9-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: marc.zyngier@arm.com, andre.przywara@arm.com, pbonzini@redhat.com To: Andrew Jones , kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, qemu-devel@nongnu.org, qemu-arm@nongnu.org Return-path: In-Reply-To: <1479157719-31021-9-git-send-email-drjones@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org Hi, On 14/11/2016 22:08, Andrew Jones wrote: > From: Peter Xu > > These macros will be useful to do page alignment checks. > > Reviewed-by: Andre Przywara > Signed-off-by: Peter Xu > [drew: also added SZ_64K and changed to shifts] > Signed-off-by: Andrew Jones > > --- > v6: change to shifts [Alex] > --- > lib/libcflat.h | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/libcflat.h b/lib/libcflat.h > index 82005f5d014f..244e40a724be 100644 > --- a/lib/libcflat.h > +++ b/lib/libcflat.h > @@ -33,6 +33,12 @@ > #define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) > #define __ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) > #define ALIGN(x, a) __ALIGN((x), (a)) > +#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) > + > +#define SZ_4K (1 << 12) > +#define SZ_64K (1 << 16) > +#define SZ_2M (1 << 21) > +#define SZ_1G (1 << 30) > > typedef uint8_t u8; > typedef int8_t s8; > Reviewed-by: Eric Auger Eric From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9Uwc-0008Rj-HU for qemu-devel@nongnu.org; Wed, 23 Nov 2016 05:38:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9UwY-0001Wa-ON for qemu-devel@nongnu.org; Wed, 23 Nov 2016 05:38:26 -0500 References: <1479157719-31021-1-git-send-email-drjones@redhat.com> <1479157719-31021-9-git-send-email-drjones@redhat.com> From: Auger Eric Message-ID: <23d97150-4eb6-db78-9a18-9af79c3c5597@redhat.com> Date: Wed, 23 Nov 2016 11:38:11 +0100 MIME-Version: 1.0 In-Reply-To: <1479157719-31021-9-git-send-email-drjones@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [kvm-unit-tests PATCH v6 08/11] libcflat: add IS_ALIGNED() macro, and page sizes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andrew Jones , kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: pbonzini@redhat.com, andre.przywara@arm.com, peter.maydell@linaro.org, alex.bennee@linaro.org, marc.zyngier@arm.com, christoffer.dall@linaro.org, Peter Xu Hi, On 14/11/2016 22:08, Andrew Jones wrote: > From: Peter Xu > > These macros will be useful to do page alignment checks. > > Reviewed-by: Andre Przywara > Signed-off-by: Peter Xu > [drew: also added SZ_64K and changed to shifts] > Signed-off-by: Andrew Jones > > --- > v6: change to shifts [Alex] > --- > lib/libcflat.h | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/libcflat.h b/lib/libcflat.h > index 82005f5d014f..244e40a724be 100644 > --- a/lib/libcflat.h > +++ b/lib/libcflat.h > @@ -33,6 +33,12 @@ > #define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) > #define __ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) > #define ALIGN(x, a) __ALIGN((x), (a)) > +#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) > + > +#define SZ_4K (1 << 12) > +#define SZ_64K (1 << 16) > +#define SZ_2M (1 << 21) > +#define SZ_1G (1 << 30) > > typedef uint8_t u8; > typedef int8_t s8; > Reviewed-by: Eric Auger Eric