From patchwork Thu Dec 4 20:25:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 41949 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 80F0C2486D for ; Thu, 4 Dec 2014 20:25:43 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id l18sf11378601wgh.10 for ; Thu, 04 Dec 2014 12:25:42 -0800 (PST) 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: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=6R7BrI5rI1It495tNz1c8pRvtgazX8lB5K6SJZbt/5o=; b=FS1CajGjjujbEedb0l2mmO7ksdvR2MDK4cGb8pChn1vOpSkOvKx6hSpM6GehRxA8GG xM/QED1Mh2qm4aOPrJ07KN4ey52VvCFduzP3m8TGa7FzeskLlMRGUXIaLNuePj3P3Psn VKV6xpDAfz8tkJSSeWR0KebFcBVc2eQvyfwvCsxgPa114E6BaWgH+uWgf2LnkCqGyyst w/P/kuAkTobXNZBH7q+Gk4cqy8DBUi8AltjEmOVgtWAU6JuHJ6fb26gfkKiX+K1sS53z 9W7/RWpD424Y1ghzD6efc+J23Aw701hFuzeKMWkVY3Gi/0feWu+2vYGM8VIA53RnWN45 +m5w== X-Gm-Message-State: ALoCoQmW7ogx7hB5dzSD2Acvr/K6CYlHqLvPFc4jdHj/bh/LQ2vVogRT8hs+nQG8gJU/gZvKrJ4p X-Received: by 10.112.169.101 with SMTP id ad5mr2615514lbc.1.1417724742763; Thu, 04 Dec 2014 12:25:42 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.42 with SMTP id g10ls288413laa.56.gmail; Thu, 04 Dec 2014 12:25:42 -0800 (PST) X-Received: by 10.112.150.102 with SMTP id uh6mr11626844lbb.50.1417724742517; Thu, 04 Dec 2014 12:25:42 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id kb3si26946363lbc.130.2014.12.04.12.25.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Dec 2014 12:25:42 -0800 (PST) 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 mail-la0-f44.google.com with SMTP id ge10so15133759lab.17 for ; Thu, 04 Dec 2014 12:25:42 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr11261847laz.71.1417724742327; Thu, 04 Dec 2014 12:25:42 -0800 (PST) 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.184.201 with SMTP id ew9csp105262lbc; Thu, 4 Dec 2014 12:25:40 -0800 (PST) X-Received: by 10.224.30.74 with SMTP id t10mr19916788qac.8.1417724739818; Thu, 04 Dec 2014 12:25:39 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id k2si32515701qge.87.2014.12.04.12.25.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Dec 2014 12:25:39 -0800 (PST) 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 1Xwcy1-0001hA-BL; Thu, 04 Dec 2014 20:25:37 +0000 Received: from mail-qa0-f42.google.com ([209.85.216.42]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xwcxu-0001fX-F4 for lng-odp@lists.linaro.org; Thu, 04 Dec 2014 20:25:30 +0000 Received: by mail-qa0-f42.google.com with SMTP id j7so12513286qaq.15 for ; Thu, 04 Dec 2014 12:25:25 -0800 (PST) X-Received: by 10.224.65.134 with SMTP id j6mr19421581qai.90.1417724725264; Thu, 04 Dec 2014 12:25:25 -0800 (PST) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id k6sm27647243qaz.41.2014.12.04.12.25.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Dec 2014 12:25:24 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org, petri.savolainen@nsn.com Date: Thu, 4 Dec 2014 15:25:15 -0500 Message-Id: <1417724715-21477-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH] api: odp_align: move internal macros 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: mike.holmes@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 Signed-off-by: Mike Holmes Reviewed-by: Bill Fischofer --- platform/linux-generic/include/api/odp_align.h | 50 ----------- .../linux-generic/include/odp_align_internal.h | 100 +++++++++++++++++++++ .../linux-generic/include/odp_packet_io_internal.h | 1 + .../linux-generic/include/odp_queue_internal.h | 1 + platform/linux-generic/odp_buffer_pool.c | 1 + platform/linux-generic/odp_packet_socket.c | 1 + platform/linux-generic/odp_ring.c | 1 + platform/linux-generic/odp_shared_memory.c | 1 + 8 files changed, 106 insertions(+), 50 deletions(-) create mode 100644 platform/linux-generic/include/odp_align_internal.h diff --git a/platform/linux-generic/include/api/odp_align.h b/platform/linux-generic/include/api/odp_align.h index eb5f724..6ec5a0a 100644 --- a/platform/linux-generic/include/api/odp_align.h +++ b/platform/linux-generic/include/api/odp_align.h @@ -84,12 +84,6 @@ extern "C" { * Round up */ -/** - * @internal - * Round up 'x' to alignment 'align' - */ -#define ODP_ALIGN_ROUNDUP(x, align)\ - ((align) * (((x) + align - 1) / (align))) /** * @internal @@ -98,12 +92,6 @@ extern "C" { #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 @@ -112,24 +100,12 @@ extern "C" { #define ODP_CACHE_LINE_SIZE_ROUNDUP_PTR(x)\ ((void *)ODP_CACHE_LINE_SIZE_ROUNDUP((uintptr_t)(x))) -/** - * @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 @@ -138,12 +114,6 @@ extern "C" { #define ODP_ALIGN_ROUNDDOWN_PTR_POWER_2(x, align)\ ((void *)ODP_ALIGN_ROUNDDOWN_POWER_2((uintptr_t)(x), (uintptr_t)(align))) -/** - * @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) /** * @internal @@ -159,26 +129,6 @@ extern "C" { /** Defines type/struct/variable to be page size aligned */ #define ODP_ALIGNED_PAGE ODP_ALIGNED(ODP_PAGE_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 value is a power of two - */ -#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0) - - /** * @} */ diff --git a/platform/linux-generic/include/odp_align_internal.h b/platform/linux-generic/include/odp_align_internal.h new file mode 100644 index 0000000..498a7a9 --- /dev/null +++ b/platform/linux-generic/include/odp_align_internal.h @@ -0,0 +1,100 @@ +/* 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 + +#include + +/** @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 value is a power of two + */ +#define ODP_VAL_IS_POWER_2(x) ((((x)-1) & (x)) == 0) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 0bc1e21..7819dc7 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -20,6 +20,7 @@ extern "C" { #include #include +#include #include diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index 8b6c517..1254763 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -20,6 +20,7 @@ extern "C" { #include #include +#include #include #include diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index 6a0a6b2..250da81 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c index 68983eb..1468340 100644 --- a/platform/linux-generic/odp_packet_socket.c +++ b/platform/linux-generic/odp_packet_socket.c @@ -36,6 +36,7 @@ #include #include +#include #include #include diff --git a/platform/linux-generic/odp_ring.c b/platform/linux-generic/odp_ring.c index 1d3130a..2b4e0a6 100644 --- a/platform/linux-generic/odp_ring.c +++ b/platform/linux-generic/odp_ring.c @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 4bcf73e..abf6da3 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include