From patchwork Fri May 13 00:13:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9086941 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4F82ABF29F for ; Fri, 13 May 2016 00:14:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A546420204 for ; Fri, 13 May 2016 00:14:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0324E200D0 for ; Fri, 13 May 2016 00:14:47 +0000 (UTC) Received: from localhost ([::1]:60299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10kg-0008Up-3e for patchwork-qemu-devel@patchwork.kernel.org; Thu, 12 May 2016 20:14:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10kO-0008KH-Pz for qemu-devel@nongnu.org; Thu, 12 May 2016 20:14:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b10kM-0002eu-IT for qemu-devel@nongnu.org; Thu, 12 May 2016 20:14:27 -0400 Received: from mail-qg0-x242.google.com ([2607:f8b0:400d:c04::242]:33276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10kM-0002eo-Eg for qemu-devel@nongnu.org; Thu, 12 May 2016 20:14:26 -0400 Received: by mail-qg0-x242.google.com with SMTP id 90so6865289qgz.0 for ; Thu, 12 May 2016 17:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=V3wpOe5+6Y7FwiNsMi5uZI8J3dByD4NpEGCzq8mRDs0=; b=nAuGdBqiH5QBnQuUJDVsQ8KDJhFpaRh9V4/KBd02n08ed8MLe1GzN5jotxX50H4dx4 Juf7QG7/SQiZ/xs5IDEODbGOpYf4IbITfdqeVr7cU+Q2tjfwofx/BwsN02ThOQDsLiO+ FO0tBRMQaRi2/kyivjLwYW2miCB4H/4maNp9/Udw5Zyw14K8BbFfnXftVzgGUabwdcS2 Q6BUbPAoCGhADjOPCZp3e/fyj1TBtNRPU5YoD7fv7JgGX2OsaUGgwhUI1pKzUD1+Szhj xEAotHvGbPzqTiZ7qJSeRbFZIPZQtopWfQBZFTONf8Ao3yehIaJrtwgrwI/qUtID9tJB TtRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=V3wpOe5+6Y7FwiNsMi5uZI8J3dByD4NpEGCzq8mRDs0=; b=FVODZh6HLfPb0Y1plycc6dy4hSrosIAWGTERHDVQWcEGj8b+/ksh879BLTs96YTAN8 IZfvgxU/4A7U+BybgIpJz5+hPXrIeYnz1EUfqHOl5MtsrY2mPycU6ckgx2ev/wKKamcz i6HpoPU6ZaKsJio7eMIQCSVLkFnjn4rddT/gPFAckTJ81LO1X8vRlKOlKEuOYNmeY9n1 TjSi5YwmJA8WlPxPdKcmCiJnxD4vIRCOtdstRR5JjF5p8OGtkpdUoEv7tga/K5kPL6Il zM7CZExOWObbGAV215tPu2687e7sa6+gr0CQTtKMSQodPfftWBdWRzhy55Qv51eNe9nE NU+w== X-Gm-Message-State: AOPr4FUj9FEcIc1CLd+h26ORz9WfoZE+JP7xxZ82Z4Lbqa4St2UHTdVGXbGhCl+qU0lFNw== X-Received: by 10.140.242.210 with SMTP id n201mr13638695qhc.2.1463098466097; Thu, 12 May 2016 17:14:26 -0700 (PDT) Received: from bigtime.com ([172.56.44.137]) by smtp.gmail.com with ESMTPSA id w16sm7171321qka.35.2016.05.12.17.14.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2016 17:14:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 12 May 2016 14:13:04 -1000 Message-Id: <1463098420-29113-4-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463098420-29113-1-git-send-email-rth@twiddle.net> References: <1463098420-29113-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::242 Subject: [Qemu-devel] [PULL 03/39] include/qemu/osdep.h: Add macros for pointer alignment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Sergey Fedorov , Sergey Fedorov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sergey Fedorov These macros provide a convenient way to n-byte align pointers up and down and check if a pointer is n-byte aligned. Signed-off-by: Sergey Fedorov Signed-off-by: Sergey Fedorov Message-Id: <1461341333-19646-3-git-send-email-sergey.fedorov@linaro.org> Signed-off-by: Richard Henderson --- include/qemu/osdep.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index e3bc50b..1e3221c 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -161,6 +161,17 @@ extern int daemon(int, int); /* Check if n is a multiple of m */ #define QEMU_IS_ALIGNED(n, m) (((n) % (m)) == 0) +/* n-byte align pointer down */ +#define QEMU_ALIGN_PTR_DOWN(p, n) \ + ((typeof(p))QEMU_ALIGN_DOWN((uintptr_t)(p), (n))) + +/* n-byte align pointer up */ +#define QEMU_ALIGN_PTR_UP(p, n) \ + ((typeof(p))QEMU_ALIGN_UP((uintptr_t)(p), (n))) + +/* Check if pointer p is n-bytes aligned */ +#define QEMU_PTR_IS_ALIGNED(p, n) QEMU_IS_ALIGNED((uintptr_t)(p), (n)) + #ifndef ROUND_UP #define ROUND_UP(n,d) (((n) + (d) - 1) & -(d)) #endif