From patchwork Fri Jan 30 04:27:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44015 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D000A24128 for ; Fri, 30 Jan 2015 04:28:40 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf625334wiv.0 for ; Thu, 29 Jan 2015 20:28:40 -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=qcmnrHhUp202Cr0TliaYwaeL27H95nibhIc1iMFypMM=; b=Tcv0OUdQxkivOiGU8LrM82ICFcD8mqORkR7JBVDXke08f2x7gbnSd4esuHaYax8eGh xcu3/zA31wopoU+aYTDMhSriFq5FeTWR3/Ck+feoDGJ5tOUVyH7QuoeN1ZFWARdsSdUI HSQYScQJkjr3KIsyaMDQK2UGJ/upVGGSr6WL7hC8UlIdXKKijte/3LDKyIv72NDPf/kX xZSBRDabcPoUhmerP3+JW0rXUpjzn+mljlF834nvcNyDHRZ6cpud/KTNzhUU/qjRdwz+ kjbRNqnVU5gNjbeNbbBrOm6puofZyeJmbTTaqHuFOlSyC2EUJ+YJJXXu5g3h+NWLvTD1 Ee7Q== X-Gm-Message-State: ALoCoQlngyLrl+n0jv/uNsYltcmbC+KgbfrZJrM7msQB1fIhjjpOD0X+COzqFOmd8EekyP0y8Koz X-Received: by 10.180.94.134 with SMTP id dc6mr55592wib.2.1422592120107; Thu, 29 Jan 2015 20:28:40 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.74 with SMTP id j10ls7398lag.7.gmail; Thu, 29 Jan 2015 20:28:39 -0800 (PST) X-Received: by 10.112.222.135 with SMTP id qm7mr4508568lbc.19.1422592119949; Thu, 29 Jan 2015 20:28:39 -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 v6si9260394laj.52.2015.01.29.20.28.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 20:28:39 -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 ge10so21750112lab.11 for ; Thu, 29 Jan 2015 20:28:39 -0800 (PST) X-Received: by 10.112.63.134 with SMTP id g6mr755761lbs.52.1422592119856; Thu, 29 Jan 2015 20:28:39 -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 h5csp159224lbj; Thu, 29 Jan 2015 20:28:39 -0800 (PST) X-Received: by 10.224.135.200 with SMTP id o8mr8955954qat.1.1422592118435; Thu, 29 Jan 2015 20:28:38 -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 v4si12947591qae.54.2015.01.29.20.28.37 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 20:28:38 -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 1YH3C7-0007Te-LB; Fri, 30 Jan 2015 04:28:35 +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 1YH3Bi-0007NH-V0 for lng-odp@lists.linaro.org; Fri, 30 Jan 2015 04:28:11 +0000 Received: by mail-oi0-f48.google.com with SMTP id v63so33069300oia.7 for ; Thu, 29 Jan 2015 20:28:05 -0800 (PST) X-Received: by 10.182.104.42 with SMTP id gb10mr2632098obb.62.1422592085730; Thu, 29 Jan 2015 20:28:05 -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 x21sm4737369oix.24.2015.01.29.20.28.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 20:28:05 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 29 Jan 2015 22:27:43 -0600 Message-Id: <1422592065-15875-8-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422592065-15875-1-git-send-email-bill.fischofer@linaro.org> References: <1422592065-15875-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [patch 7/9] 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.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/pool.h | 13 +++++++++++++ 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 ++- 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h index 1582102..6771932 100644 --- a/include/odp/api/pool.h +++ b/include/odp/api/pool.h @@ -184,6 +184,19 @@ int odp_pool_info(odp_pool_t pool, odp_pool_info_t *info); void odp_pool_print(odp_pool_t pool); /** + * Get printable value for an odp_pool_t + * + * @param hdl odp_pool_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_pool_t handle. + */ +uint64_t odp_pool_t_print(odp_pool_t hdl); + +/** * Buffer alloc * * The validity of a buffer can be cheked at any time with odp_buffer_is_valid() diff --git a/platform/linux-generic/include/odp/plat/pool_types.h b/platform/linux-generic/include/odp/plat/pool_types.h index 7bfbbfc..a755354 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_t_print(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 20906a7..ac131e6 100644 --- a/platform/linux-generic/odp_buffer.c +++ b/platform/linux-generic/odp_buffer.c @@ -69,7 +69,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_t_print(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..1a1957f 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_t_print(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",