From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: [PATCH kvm-unit-tests v2 04/17] libcflat: add IS_ALIGNED() macro, and page sizes Date: Wed, 9 Nov 2016 10:10:11 -0500 Message-ID: <1478704224-20472-5-git-send-email-peterx@redhat.com> References: <1478704224-20472-1-git-send-email-peterx@redhat.com> Cc: drjones@redhat.com, rkrcmar@redhat.com, peterx@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58112 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932912AbcKIPKf (ORCPT ); Wed, 9 Nov 2016 10:10:35 -0500 In-Reply-To: <1478704224-20472-1-git-send-email-peterx@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: These macros will be useful to do page alignment checks. Reviewed-by: Andrew Jones Signed-off-by: Peter Xu --- lib/libcflat.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/libcflat.h b/lib/libcflat.h index 19bd0c6..dd600b7 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 (0x1000) +#define SZ_64K (0x10000) +#define SZ_2M (0x200000) +#define SZ_1G (0x40000000) typedef uint8_t u8; typedef int8_t s8; -- 2.7.4