From patchwork Tue Mar 10 15:31:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 45584 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3F04E214BF for ; Tue, 10 Mar 2015 15:31:53 +0000 (UTC) Received: by wghk14 with SMTP id k14sf2004306wgh.3 for ; Tue, 10 Mar 2015 08:31:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=nx58f1HRRSSahBXNei3qAR5zwW2zedZckZLzh5yBnxE=; b=YnQLByiBwk6QA5daDRbmznePK7S2ss/NADB7SpgumMEUazPeJGuEH9Jr4GqK0BPjGf uG1LoHtk8Ra7Idt9jc8SPcckrb3dyrHciv1K+M+v7tWldXV4e2zoaiZf0UOS4TsSXdE+ ZLbecz72RtGFXjuhQicnGg9SJlbgOUgiwbpJjE50kMH+vni3MmAoWg3Sp3pzz9xzcuLC UtTNH7PkVrKKbPQHOxq1TzzNIk0Fod1IjHZd3UkJDWfk1eWD5Q/4SPZ1iWskbvrIElEz 1Fs8S8y19vL2YL8rgsrWxQ9BAfQqR+l39cV/mHnoeUDqu30b/9/4FTWBd3D56juvbmzU CiPg== X-Gm-Message-State: ALoCoQm84rgcAT3kWeh8WSrr8c2dujA17vtr8F+WbSiMo10xdivrT2470l6+JWfxesQ38TeNQcP0 X-Received: by 10.180.80.132 with SMTP id r4mr1454357wix.4.1426001512588; Tue, 10 Mar 2015 08:31:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.104 with SMTP id r8ls37702lar.48.gmail; Tue, 10 Mar 2015 08:31:52 -0700 (PDT) X-Received: by 10.112.162.232 with SMTP id yd8mr30450477lbb.41.1426001512429; Tue, 10 Mar 2015 08:31:52 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id kv10si544115lac.89.2015.03.10.08.31.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 08:31:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labgm9 with SMTP id gm9so2483000lab.13 for ; Tue, 10 Mar 2015 08:31:52 -0700 (PDT) X-Received: by 10.112.204.197 with SMTP id la5mr30600893lbc.29.1426001512307; Tue, 10 Mar 2015 08:31:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2206587lbj; Tue, 10 Mar 2015 08:31:51 -0700 (PDT) X-Received: by 10.55.31.32 with SMTP id f32mr5269971qkf.41.1426001507708; Tue, 10 Mar 2015 08:31:47 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id f23si780338qkh.51.2015.03.10.08.31.46 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 10 Mar 2015 08:31:47 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVM8G-0003qr-K8; Tue, 10 Mar 2015 15:31:44 +0000 Received: from mail-la0-f47.google.com ([209.85.215.47]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YVM80-0003ot-AK for lng-odp@lists.linaro.org; Tue, 10 Mar 2015 15:31:28 +0000 Received: by labmn12 with SMTP id mn12so2520937lab.8 for ; Tue, 10 Mar 2015 08:31:22 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr22146463lbc.53.1426001482744; Tue, 10 Mar 2015 08:31:22 -0700 (PDT) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id a2sm106609lbm.32.2015.03.10.08.31.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Mar 2015 08:31:21 -0700 (PDT) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Tue, 10 Mar 2015 17:31:01 +0200 Message-Id: <1426001473-14618-4-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426001473-14618-1-git-send-email-taras.kondratiuk@linaro.org> References: <1426001473-14618-1-git-send-email-taras.kondratiuk@linaro.org> X-Topics: patch Cc: Taras Kondratiuk Subject: [lng-odp] [KEYSTONE2 PATCH 03/15] linux-ks2: align: move internal macros to a public place X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: taras.kondratiuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Move macros to be able to access them from installed ODP headers. Signed-off-by: Taras Kondratiuk Signed-off-by: Taras Kondratiuk --- platform/linux-keystone2/Makefile.am | 1 + platform/linux-keystone2/include/odp/plat/align.h | 109 ++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 platform/linux-keystone2/include/odp/plat/align.h diff --git a/platform/linux-keystone2/Makefile.am b/platform/linux-keystone2/Makefile.am index d17ea45..505cb97 100644 --- a/platform/linux-keystone2/Makefile.am +++ b/platform/linux-keystone2/Makefile.am @@ -58,6 +58,7 @@ odpinclude_HEADERS = \ odpplatincludedir = $(includedir)/odp/plat odpplatinclude_HEADERS = \ + $(srcdir)/include/odp/plat/align.h \ $(srcdir)/include/odp/plat/debug.h \ $(srcdir)/include/odp/plat/mcsdk_tune.h \ $(srcdir)/include/odp/plat/state.h \ diff --git a/platform/linux-keystone2/include/odp/plat/align.h b/platform/linux-keystone2/include/odp/plat/align.h new file mode 100644 index 0000000..55271a5 --- /dev/null +++ b/platform/linux-keystone2/include/odp/plat/align.h @@ -0,0 +1,109 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP internal alignments + */ + +#ifndef ODP_ALIGN_INTERNAL_H_ +#define ODP_ALIGN_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup odp_compiler_optim + * @{ + */ + +/* + * Round up + */ + +/** + * @internal + * Round up 'x' to alignment 'align' + */ +#define ODP_ALIGN_ROUNDUP(x, align)\ + ((align) * (((x) + align - 1) / (align))) + +/** + * @internal + * Round up pointer 'x' to alignment 'align' + */ +#define ODP_ALIGN_ROUNDUP_PTR(x, align)\ + ((void *)ODP_ALIGN_ROUNDUP((uintptr_t)(x), (uintptr_t)(align))) + +/** + * @internal + * Round up 'x' to cache line size alignment + */ +#define ODP_CACHE_LINE_SIZE_ROUNDUP(x)\ + ODP_ALIGN_ROUNDUP(x, ODP_CACHE_LINE_SIZE) + +/** + * @internal + * Round up 'x' to page size alignment + */ +#define ODP_PAGE_SIZE_ROUNDUP(x)\ + ODP_ALIGN_ROUNDUP(x, ODP_PAGE_SIZE) + +/* + * Round down + */ + +/** + * @internal + * Round down 'x' to 'align' alignment, which is a power of two + */ +#define ODP_ALIGN_ROUNDDOWN_POWER_2(x, align)\ + ((x) & (~((align) - 1))) +/** + * @internal + * Round down 'x' to cache line size alignment + */ +#define ODP_CACHE_LINE_SIZE_ROUNDDOWN(x)\ + ODP_ALIGN_ROUNDDOWN_POWER_2(x, ODP_CACHE_LINE_SIZE) + +/* + * Check align + */ + +/** + * @internal + * Check if pointer 'x' is aligned to 'align', which is a power of two + */ +#define ODP_ALIGNED_CHECK_POWER_2(x, align)\ + ((((uintptr_t)(x)) & (((uintptr_t)(align))-1)) == 0) + +/** + * @internal + * Check if pointer 'x' is aligned to 'align', which is a power of two + */ +#define ODP_ALIGNED_CHECK(x, align)\ + (((uintptr_t)(x)) % (align) == 0) + +/** + * @internal + * Check if value is a power of two + */ +#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0) + + +#define ODP_CONTAINEROF(ptr, type, member) \ + (type *)((uintptr_t)(ptr) - ODP_OFFSETOF(type, member)) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif