From patchwork Tue Feb 3 04:44:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44202 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 CD0F52034D for ; Tue, 3 Feb 2015 04:46:46 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id m14sf18909230wev.3 for ; Mon, 02 Feb 2015 20:46:46 -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=ySIkFLjBoir3P1u/LEW2P4WQ6BW9lWO5zVG9lB0oNmg=; b=ZnIAWiWwzl4VjAPClOa7n2NVIIh5u5xkVa6DzMrgq52wcwneyXpDAlOrDAZ3Ual1t1 27BqBVh0x0La0tJgwdRwv1ZDgE7cl7ZhxYxdHnYaoAIesGD/xekpiLT0rQ4uLe8EMd+V bk1AkRFVlJLld++zb9Pz3Klwr+wH2wLY/iFE5aBKxfqjscoh7zk/G3Kpcz0p/ZCOluCG PZkGnSGpdNUE4v2Lh7g1SmwHjx5mNfvEJeyafyR6aPkBsFKq7+04G7cl0WLNFWUxZ1TQ i1yy9fYLzZImW1k29TYQsiGzCsVpJsURwa1g7IY4qFjUn8AUyEIyATMkfAfK613geJAK FS3A== X-Gm-Message-State: ALoCoQkgI346Kf4RSr9V9e5xQ5qyIRTIF4qHt4hjpjdJ0r3zisl3xWnbh8BQ/1tDO+g/Vm1OtqMt X-Received: by 10.112.148.198 with SMTP id tu6mr2761555lbb.3.1422938806109; Mon, 02 Feb 2015 20:46:46 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.71 with SMTP id k7ls714667laf.9.gmail; Mon, 02 Feb 2015 20:46:45 -0800 (PST) X-Received: by 10.112.132.67 with SMTP id os3mr22417075lbb.90.1422938805838; Mon, 02 Feb 2015 20:46:45 -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 b8si7108909lbv.128.2015.02.02.20.46.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Feb 2015 20:46:45 -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 s18so48044136lam.3 for ; Mon, 02 Feb 2015 20:46:45 -0800 (PST) X-Received: by 10.152.7.229 with SMTP id m5mr22896374laa.80.1422938805716; Mon, 02 Feb 2015 20:46:45 -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 h5csp1712669lbj; Mon, 2 Feb 2015 20:46:45 -0800 (PST) X-Received: by 10.224.23.6 with SMTP id p6mr50028559qab.55.1422938804362; Mon, 02 Feb 2015 20:46:44 -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 z4si26388609qge.110.2015.02.02.20.46.43 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Feb 2015 20:46:44 -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 1YIVNp-0006FF-8u; Tue, 03 Feb 2015 04:46:41 +0000 Received: from mail-oi0-f48.google.com ([209.85.218.48]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YIVMw-00062e-Hs for lng-odp@lists.linaro.org; Tue, 03 Feb 2015 04:45:46 +0000 Received: by mail-oi0-f48.google.com with SMTP id v63so47494697oia.7 for ; Mon, 02 Feb 2015 20:45:41 -0800 (PST) X-Received: by 10.60.70.141 with SMTP id m13mr14232736oeu.86.1422938741299; Mon, 02 Feb 2015 20:45:41 -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 vs5sm10277537oeb.14.2015.02.02.20.45.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Feb 2015 20:45:40 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 2 Feb 2015 22:44:59 -0600 Message-Id: <1422938699-12877-20-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422938699-12877-1-git-send-email-bill.fischofer@linaro.org> References: <1422938699-12877-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv5 19/19] 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.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: Bill Fischofer --- .../linux-generic/include/odp/plat/shared_memory_types.h | 13 +++++++++++-- platform/linux-generic/odp_shared_memory.c | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) 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..d2e92cf 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_to_u64(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); }