From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: [PATCH v3 04/13] libcflat: add IS_ALIGNED() macro, and page sizes Date: Mon, 14 Nov 2016 17:28:02 -0500 Message-ID: <1479162491-20764-5-git-send-email-peterx@redhat.com> References: <1479162491-20764-1-git-send-email-peterx@redhat.com> Cc: drjones@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, rkrcmar@redhat.com, pbonzini@redhat.com, peterx@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50522 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964977AbcKNW2R (ORCPT ); Mon, 14 Nov 2016 17:28:17 -0500 In-Reply-To: <1479162491-20764-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 038ea1d..d0b0fd1 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