From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: [PATCH kvm-unit-tests v5 05/14] libcflat: add IS_ALIGNED() macro, and page sizes Date: Tue, 15 Nov 2016 17:25:00 -0500 Message-ID: <1479248709-10281-6-git-send-email-peterx@redhat.com> References: <1479248709-10281-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]:38218 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934233AbcKOWZR (ORCPT ); Tue, 15 Nov 2016 17:25:17 -0500 In-Reply-To: <1479248709-10281-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..cbce346 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; -- 2.7.4