From: Peter Xu Subject: [PATCH kvm-unit-tests 02/17] libcflat: add IS_ALIGNED() macro, and page sizes Date: Wed, 26 Oct 2016 15:47:05 +0800 Message-ID: <1477468040-21034-3-git-send-email-peterx@redhat.com> References: <1477468040-21034-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]:42558 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752282AbcJZHsF (ORCPT ); Wed, 26 Oct 2016 03:48:05 -0400 In-Reply-To: <1477468040-21034-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. Signed-off-by: Peter Xu --- lib/libcflat.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/libcflat.h b/lib/libcflat.h index 72b1bf9..a80df04 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -33,6 +33,11 @@ #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_2M (0x200000) +#define SZ_1G (0x40000000) typedef uint8_t u8; typedef int8_t s8; -- 2.7.4