From patchwork Sun Feb 1 00:16:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44119 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E06552359E for ; Sun, 1 Feb 2015 00:18:19 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id m14sf13741870wev.3 for ; Sat, 31 Jan 2015 16:18:19 -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:in-reply-to :references: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=DCeJDMH4zQbBirmH6EqOnMvLSyro56u+7jprVGJa9Og=; b=jQD4DcY1gO5WzbfHqI4Fe+ElR1gnhXlxiGP4E+z76dq2aNrAbvwmTJyjWq4TT2/C6t 1y+hvnvhRFnD1rW6/y4zTVv2Wujh3WCqTt5SigR0hPw2+Vyyz/PdLrdLp62MYxlL+rB4 jSL4kUn9PXfJSXhzydcKdXiUqng6HBS8OxBuW8U2DttrtpPPS30TDF28BO2ys7LwJ4k8 jH/gcnySI8W/1n7ol4oykWJx8LIW6ACWXK8Zxf3FFs88LiXt8g32U50RfrDCmvpQyntx 35dvbvJ7+kPhmQxXZfjkCaspQ5+ORhmKfU8qNEtgmy6V4DuPDEo8LLA1RlKtJKi+Fdnq cbgA== X-Gm-Message-State: ALoCoQlUGPVllGgJ5YwsjxFdY9VZ3GBdLjj1st54AB9hebrcFyLWZnJw2C/6lBO+oN3jtRgHp3yM X-Received: by 10.112.137.70 with SMTP id qg6mr1568456lbb.14.1422749899159; Sat, 31 Jan 2015 16:18:19 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.164 with SMTP id wr4ls144595lac.79.gmail; Sat, 31 Jan 2015 16:18:19 -0800 (PST) X-Received: by 10.152.5.72 with SMTP id q8mr12563574laq.57.1422749899020; Sat, 31 Jan 2015 16:18:19 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id eu6si9377127lac.92.2015.01.31.16.18.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 16:18:19 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id ge10so31272562lab.11 for ; Sat, 31 Jan 2015 16:18:18 -0800 (PST) X-Received: by 10.152.20.169 with SMTP id o9mr13079600lae.50.1422749898932; Sat, 31 Jan 2015 16:18:18 -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.35.133 with SMTP id h5csp507900lbj; Sat, 31 Jan 2015 16:18:18 -0800 (PST) X-Received: by 10.229.64.67 with SMTP id d3mr27614308qci.9.1422749897685; Sat, 31 Jan 2015 16:18:17 -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 i47si19803100qgd.126.2015.01.31.16.18.16 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 31 Jan 2015 16:18:17 -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 1YHiEw-0002V1-Np; Sun, 01 Feb 2015 00:18:14 +0000 Received: from mail-oi0-f50.google.com ([209.85.218.50]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHiED-0002Ks-Fi for lng-odp@lists.linaro.org; Sun, 01 Feb 2015 00:17:29 +0000 Received: by mail-oi0-f50.google.com with SMTP id h136so39867655oig.9 for ; Sat, 31 Jan 2015 16:17:24 -0800 (PST) X-Received: by 10.202.180.70 with SMTP id d67mr7290451oif.119.1422749844234; Sat, 31 Jan 2015 16:17:24 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id xr17sm5945905oeb.12.2015.01.31.16.17.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Jan 2015 16:17:23 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 31 Jan 2015 18:16:47 -0600 Message-Id: <1422749807-20228-17-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422749807-20228-1-git-send-email-bill.fischofer@linaro.org> References: <1422749807-20228-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv4 10/10] linux-generic: shm: add strong typing support 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: bill.fischofer@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.52 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: Bill Fischofer --- include/odp/api/shared_memory.h | 13 +++++++++++++ .../linux-generic/include/odp/plat/shared_memory_types.h | 13 +++++++++++-- platform/linux-generic/odp_shared_memory.c | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/odp/api/shared_memory.h b/include/odp/api/shared_memory.h index 5b27b6b..3edcc64 100644 --- a/include/odp/api/shared_memory.h +++ b/include/odp/api/shared_memory.h @@ -128,6 +128,19 @@ int odp_shm_info(odp_shm_t shm, odp_shm_info_t *info); void odp_shm_print_all(void); /** + * Get printable value for an odp_shm_t + * + * @param hdl odp_shm_t handle to be printed + * @return uint64_t value that can be used to print/display this + * handle + * + * @note This routine is intended to be used for diagnostic purposes + * to enable applications to generate a printable value that represents + * an odp_shm_t handle. + */ +uint64_t odp_shm_t_print(odp_shm_t hdl); + +/** * @} */ diff --git a/platform/linux-generic/include/odp/plat/shared_memory_types.h b/platform/linux-generic/include/odp/plat/shared_memory_types.h index c044cb9..1b62d15 100644 --- a/platform/linux-generic/include/odp/plat/shared_memory_types.h +++ b/platform/linux-generic/include/odp/plat/shared_memory_types.h @@ -18,16 +18,25 @@ extern "C" { #endif +#include +#include + /** @addtogroup odp_shared_memory ODP SHARED MEMORY * Operations on shared memory. * @{ */ -typedef uint32_t odp_shm_t; +typedef odp_handle_t odp_shm_t; -#define ODP_SHM_INVALID 0 +#define ODP_SHM_INVALID _odp_cast_scalar(odp_shm_t, 0) #define ODP_SHM_NULL ODP_SHM_INVALID +/** Get printable format of odp_shm_t */ +static inline uint64_t odp_shm_t_print(odp_shm_t hdl) +{ + return _odp_pri(hdl); +} + /** * @} */ diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 96d10e8..dbaec22 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -64,13 +64,13 @@ static odp_shm_table_t *odp_shm_tbl; static inline uint32_t from_handle(odp_shm_t shm) { - return shm - 1; + return _odp_typeval(shm) - 1; } static inline odp_shm_t to_handle(uint32_t index) { - return index + 1; + return _odp_cast_scalar(odp_shm_t, index + 1); }