From patchwork Tue Feb 3 04:44:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44200 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6FCDD2034D for ; Tue, 3 Feb 2015 04:46:38 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id u56sf18893126wes.2 for ; Mon, 02 Feb 2015 20:46:37 -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=Bm34sNiTl77fO2/HIfPXdu6ATPAoTx/Ms5eFGwPgxwc=; b=ZYfIM2H8VZPwVpya2DftG8XyeuoYXX8/w1nUT2E6xvcv+LfgkIUoSeyM3GY9YbyTHN QfbScSE/RRs3WtDr2wSL8T0FV3Xh7klM238yUaCm70BoiEG0BV8J+1Px7nPkG+wn1vtS 9aWbDZQygsWddQTaugPEHotOIvg6VID9RYk9Bn0sr7JCbGFxod2uXi72VsIKg6p5q3mx j/WshPN0qo1MTXC/cSJfYYJIsHUOFU6Y832PXAD97NTVsTN8BmT9/gYGetKYK+fFwTDz jIaBRphKYFmcKnrKxX3lRB7wXnPz2sYrSveBPBR++XUAGAleiKLBunut4ALPjA4Fe2AH trIQ== X-Gm-Message-State: ALoCoQmlpwxojVDezc7Czu231yOKWMlb/ET4tPpQtagJH7dSqkK3M9OFFIx9iEXgpMM9I4hmzhrk X-Received: by 10.112.133.98 with SMTP id pb2mr2840381lbb.2.1422938797648; Mon, 02 Feb 2015 20:46:37 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.234 with SMTP id bb10ls696109lab.90.gmail; Mon, 02 Feb 2015 20:46:37 -0800 (PST) X-Received: by 10.152.7.229 with SMTP id m5mr22896039laa.80.1422938797439; Mon, 02 Feb 2015 20:46:37 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id gn3si7729797lbc.113.2015.02.02.20.46.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Feb 2015 20:46:37 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id pn19so1875100lab.2 for ; Mon, 02 Feb 2015 20:46:37 -0800 (PST) X-Received: by 10.152.219.37 with SMTP id pl5mr18484777lac.6.1422938797341; Mon, 02 Feb 2015 20:46:37 -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 h5csp1712608lbj; Mon, 2 Feb 2015 20:46:36 -0800 (PST) X-Received: by 10.140.89.177 with SMTP id v46mr45761213qgd.58.1422938795827; Mon, 02 Feb 2015 20:46:35 -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 w5si27757943qad.21.2015.02.02.20.46.34 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Feb 2015 20:46:35 -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 1YIVNh-0006DP-2Y; Tue, 03 Feb 2015 04:46:33 +0000 Received: from mail-ob0-f180.google.com ([209.85.214.180]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YIVMt-00061y-6L for lng-odp@lists.linaro.org; Tue, 03 Feb 2015 04:45:43 +0000 Received: by mail-ob0-f180.google.com with SMTP id vb8so20251769obc.11 for ; Mon, 02 Feb 2015 20:45:38 -0800 (PST) X-Received: by 10.60.98.204 with SMTP id ek12mr14054669oeb.14.1422938737951; Mon, 02 Feb 2015 20:45:37 -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.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Feb 2015 20:45:37 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 2 Feb 2015 22:44:57 -0600 Message-Id: <1422938699-12877-18-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 17/19] linux-generic: pool: 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.43 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 --- platform/linux-generic/include/odp/plat/pool_types.h | 13 +++++++++++-- platform/linux-generic/include/odp_buffer_inlines.h | 4 +++- platform/linux-generic/include/odp_buffer_pool_internal.h | 4 ++-- platform/linux-generic/odp_buffer.c | 3 ++- platform/linux-generic/odp_buffer_pool.c | 3 ++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/platform/linux-generic/include/odp/plat/pool_types.h b/platform/linux-generic/include/odp/plat/pool_types.h index 7bfbbfc..71c7783 100644 --- a/platform/linux-generic/include/odp/plat/pool_types.h +++ b/platform/linux-generic/include/odp/plat/pool_types.h @@ -13,6 +13,9 @@ #ifndef ODP_POOL_TYPES_H_ #define ODP_POOL_TYPES_H_ +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -22,9 +25,15 @@ extern "C" { * @{ */ -typedef uint32_t odp_pool_t; +typedef odp_handle_t odp_pool_t; + +#define ODP_POOL_INVALID _odp_cast_scalar(odp_pool_t, 0xffffffff) -#define ODP_POOL_INVALID (0xffffffff) +/** Get printable format of odp_pool_t */ +static inline uint64_t odp_pool_to_u64(odp_pool_t hdl) +{ + return _odp_pri(hdl); +} /** * @} diff --git a/platform/linux-generic/include/odp_buffer_inlines.h b/platform/linux-generic/include/odp_buffer_inlines.h index ba358f1..f6eef3d 100644 --- a/platform/linux-generic/include/odp_buffer_inlines.h +++ b/platform/linux-generic/include/odp_buffer_inlines.h @@ -106,7 +106,9 @@ static inline odp_buffer_hdr_t *validate_buf(odp_buffer_t buf) if (handle.seg != 0 || handle.pool_id >= ODP_CONFIG_POOLS) return NULL; - pool_entry_t *pool = odp_pool_to_entry(handle.pool_id); + pool_entry_t *pool = + odp_pool_to_entry(_odp_cast_scalar(odp_pool_t, + handle.pool_id)); /* If pool not created, handle is invalid */ if (pool->s.pool_shm == ODP_SHM_INVALID) diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h b/platform/linux-generic/include/odp_buffer_pool_internal.h index e02e35a..c5354e5 100644 --- a/platform/linux-generic/include/odp_buffer_pool_internal.h +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h @@ -335,12 +335,12 @@ static inline void flush_cache(local_cache_t *buf_cache, static inline odp_pool_t pool_index_to_handle(uint32_t pool_id) { - return pool_id; + return _odp_cast_scalar(odp_pool_t, pool_id); } static inline uint32_t pool_handle_to_index(odp_pool_t pool_hdl) { - return pool_hdl; + return _odp_typeval(pool_hdl); } static inline void *get_pool_entry(uint32_t pool_id) diff --git a/platform/linux-generic/odp_buffer.c b/platform/linux-generic/odp_buffer.c index eb59a66..5d51c21 100644 --- a/platform/linux-generic/odp_buffer.c +++ b/platform/linux-generic/odp_buffer.c @@ -76,7 +76,8 @@ int odp_buffer_snprint(char *str, uint32_t n, odp_buffer_t buf) len += snprintf(&str[len], n-len, "Buffer\n"); len += snprintf(&str[len], n-len, - " pool %i\n", hdr->pool_hdl); + " pool %" PRIu64 "\n", + odp_pool_to_u64(hdr->pool_hdl)); len += snprintf(&str[len], n-len, " addr %p\n", hdr->addr); len += snprintf(&str[len], n-len, diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index 3e13e6f..69acf1b 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -558,7 +558,8 @@ void odp_pool_print(odp_pool_t pool_hdl) ODP_DBG("Pool info\n"); ODP_DBG("---------\n"); - ODP_DBG(" pool %i\n", pool->s.pool_hdl); + ODP_DBG(" pool %" PRIu64 "\n", + odp_pool_to_u64(pool->s.pool_hdl)); ODP_DBG(" name %s\n", pool->s.flags.has_name ? pool->s.name : "Unnamed Pool"); ODP_DBG(" pool type %s\n",