From patchwork Tue Nov 18 18:30:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 41066 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14E1F241C9 for ; Tue, 18 Nov 2014 18:31:01 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf7832559lbj.8 for ; Tue, 18 Nov 2014 10:31:00 -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:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=vkz69ZB+ud5eKilNSiO6QMMSdbJZ2W/9MbfWq/f95bQ=; b=Ith6Pw0oIxOUkW6O0g/TDWojBJ1ALcHv1DQnDQE/vgPL/9P4DPRxAwSoRF9ZsmyX+e 8OxTp6JDhCssAzAI4A719TCGH5brR6pySVGCU8xS/iMnvWSRXh3/Zcd5yq/EYectdZBK QLhsdjBJyVxtE8R3QBlPVzEcqpMrn3tzwp0IDYFfrFoePcrYDJp4lvoIfgqTYcU168U5 gxsOvhC6wRp+YS28FGlW1foL3e2bbPO4wvFbGgrh/NAgvJWM7GVXwvtKgpWClFJTj+O5 tttTWcLzYDzIRLq0SYnuHwV6N+WQMNjM3SurO72OiKy80P5JpZ8pixxpmPr6YzJEjOVt XUdw== X-Gm-Message-State: ALoCoQlIYANHSys4XdC+OhBsb9o64zO7ei2oiW4qRl1qZpfqdf+e4rYN6v+0J5v8ApqcnbjBiVKe X-Received: by 10.112.89.195 with SMTP id bq3mr88844lbb.9.1416335460026; Tue, 18 Nov 2014 10:31:00 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.229 with SMTP id p5ls1048130laf.4.gmail; Tue, 18 Nov 2014 10:30:59 -0800 (PST) X-Received: by 10.112.131.33 with SMTP id oj1mr494121lbb.97.1416335459782; Tue, 18 Nov 2014 10:30:59 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id u10si43042915lbp.15.2014.11.18.10.30.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Nov 2014 10:30:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id f15so19882707lbj.13 for ; Tue, 18 Nov 2014 10:30:59 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr575002lbo.32.1416335457930; Tue, 18 Nov 2014 10:30:57 -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 ew9csp1379321lbc; Tue, 18 Nov 2014 10:30:56 -0800 (PST) X-Received: by 10.236.2.5 with SMTP id 5mr4197593yhe.179.1416335456391; Tue, 18 Nov 2014 10:30:56 -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 r4si5923283qas.22.2014.11.18.10.30.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 18 Nov 2014 10:30:56 -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 1XqnYC-0005Bk-Px; Tue, 18 Nov 2014 18:30:52 +0000 Received: from mail-qg0-f50.google.com ([209.85.192.50]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XqnXu-00059O-1s for lng-odp@lists.linaro.org; Tue, 18 Nov 2014 18:30:34 +0000 Received: by mail-qg0-f50.google.com with SMTP id e89so6334581qgf.23 for ; Tue, 18 Nov 2014 10:30:24 -0800 (PST) X-Received: by 10.224.63.198 with SMTP id c6mr37512147qai.103.1416335424062; Tue, 18 Nov 2014 10:30:24 -0800 (PST) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id 36sm37560940qgn.10.2014.11.18.10.30.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Nov 2014 10:30:23 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Tue, 18 Nov 2014 13:30:16 -0500 Message-Id: <1416335416-7740-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: Replace printf with ODP_PRI 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.217.182 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 Current ODP APIs that print internal data on demand for the application do so via printf. Introduce ODP_PRI so that APIs that produce output may be channeled though ODP_LOG to match the other logging types. Signed-off-by: Mike Holmes --- This patch does not impact the behaviour of any current example or test. A follow on should implement the application replaceable ODP_LOG function via weak linking. platform/linux-generic/include/api/odp_debug.h | 14 +++++++- platform/linux-generic/odp_buffer.c | 4 +-- platform/linux-generic/odp_buffer_pool.c | 44 +++++++++++++------------- platform/linux-generic/odp_packet.c | 2 +- platform/linux-generic/odp_shared_memory.c | 30 +++++++++--------- 5 files changed, 53 insertions(+), 41 deletions(-) diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index c9b2edd..1a6fbda 100644 --- a/platform/linux-generic/include/api/odp_debug.h +++ b/platform/linux-generic/include/api/odp_debug.h @@ -76,7 +76,8 @@ typedef enum odp_log_level { ODP_LOG_DBG, ODP_LOG_ERR, ODP_LOG_UNIMPLEMENTED, - ODP_LOG_ABORT + ODP_LOG_ABORT, + ODP_LOG_PRI, } odp_log_level_e; /** @@ -94,6 +95,10 @@ do { \ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ __LINE__, __func__, ##__VA_ARGS__); \ break; \ + case ODP_LOG_PRI: \ + fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__); \ + break; \ case ODP_LOG_ABORT: \ fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ __LINE__, __func__, ##__VA_ARGS__); \ @@ -111,6 +116,13 @@ do { \ } while (0) /** + * Printing macro, which prints output when the application + * calls one of the ODP APIs specifically for dumping internal data. + */ +#define ODP_PRI(fmt, ...) \ + ODP_LOG(ODP_LOG_PRI, fmt, ##__VA_ARGS__) + +/** * Debug printing macro, which prints output when DEBUG flag is set. */ #define ODP_DBG(fmt, ...) \ diff --git a/platform/linux-generic/odp_buffer.c b/platform/linux-generic/odp_buffer.c index e54e0e7..2ee0461 100644 --- a/platform/linux-generic/odp_buffer.c +++ b/platform/linux-generic/odp_buffer.c @@ -52,7 +52,7 @@ int odp_buffer_snprint(char *str, size_t n, odp_buffer_t buf) int len = 0; if (!odp_buffer_is_valid(buf)) { - printf("Buffer is not valid.\n"); + ODP_PRI("Buffer is not valid.\n"); return len; } @@ -98,7 +98,7 @@ void odp_buffer_print(odp_buffer_t buf) len = odp_buffer_snprint(str, max_len-1, buf); str[len] = 0; - printf("\n%s\n", str); + ODP_PRI("\n%s\n", str); } void odp_buffer_copy_scatter(odp_buffer_t buf_dst, odp_buffer_t buf_src) diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index a48d7d6..3555166 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -523,20 +523,20 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl) pool_id = pool_handle_to_index(pool_hdl); pool = get_pool_entry(pool_id); - printf("Pool info\n"); - printf("---------\n"); - printf(" pool %i\n", pool->s.pool_hdl); - printf(" name %s\n", pool->s.name); - printf(" pool base %p\n", pool->s.pool_base_addr); - printf(" buf base 0x%"PRIxPTR"\n", pool->s.buf_base); - printf(" pool size 0x%"PRIx64"\n", pool->s.pool_size); - printf(" buf size %zu\n", pool->s.user_size); - printf(" buf align %zu\n", pool->s.user_align); - printf(" hdr size %zu\n", pool->s.hdr_size); - printf(" alloc size %zu\n", pool->s.buf_size); - printf(" offset to hdr %zu\n", pool->s.buf_offset); - printf(" num bufs %"PRIu64"\n", pool->s.num_bufs); - printf(" free bufs %"PRIu64"\n", pool->s.free_bufs); + ODP_PRI("Pool info\n"); + ODP_PRI("---------\n"); + ODP_PRI(" pool %i\n", pool->s.pool_hdl); + ODP_PRI(" name %s\n", pool->s.name); + ODP_PRI(" pool base %p\n", pool->s.pool_base_addr); + ODP_PRI(" buf base 0x%"PRIxPTR"\n", pool->s.buf_base); + ODP_PRI(" pool size 0x%"PRIx64"\n", pool->s.pool_size); + ODP_PRI(" buf size %zu\n", pool->s.user_size); + ODP_PRI(" buf align %zu\n", pool->s.user_align); + ODP_PRI(" hdr size %zu\n", pool->s.hdr_size); + ODP_PRI(" alloc size %zu\n", pool->s.buf_size); + ODP_PRI(" offset to hdr %zu\n", pool->s.buf_offset); + ODP_PRI(" num bufs %"PRIu64"\n", pool->s.num_bufs); + ODP_PRI(" free bufs %"PRIu64"\n", pool->s.free_bufs); /* first chunk */ chunk_hdr = pool->s.head; @@ -546,7 +546,7 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl) return; } - printf("\n First chunk\n"); + ODP_PRI("\n First chunk\n"); for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) { uint32_t index; @@ -555,20 +555,20 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl) index = chunk_hdr->chunk.buf_index[i]; hdr = index_to_hdr(pool, index); - printf(" [%i] addr %p, id %"PRIu32"\n", i, hdr->addr, index); + ODP_PRI(" [%i] addr %p, id %"PRIu32"\n", i, hdr->addr, index); } - printf(" [%i] addr %p, id %"PRIu32"\n", i, chunk_hdr->buf_hdr.addr, - chunk_hdr->buf_hdr.index); + ODP_PRI(" [%i] addr %p, id %"PRIu32"\n", i, chunk_hdr->buf_hdr.addr, + chunk_hdr->buf_hdr.index); /* next chunk */ chunk_hdr = next_chunk(pool, chunk_hdr); if (chunk_hdr) { - printf(" Next chunk\n"); - printf(" addr %p, id %"PRIu32"\n", chunk_hdr->buf_hdr.addr, - chunk_hdr->buf_hdr.index); + ODP_PRI(" Next chunk\n"); + ODP_PRI(" addr %p, id %"PRIu32"\n", chunk_hdr->buf_hdr.addr, + chunk_hdr->buf_hdr.index); } - printf("\n"); + ODP_PRI("\n"); } diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 82ea879..7fe9ed0 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -346,7 +346,7 @@ void odp_packet_print(odp_packet_t pkt) " input %u\n", hdr->input); str[len] = '\0'; - printf("\n%s\n", str); + ODP_PRI("\n%s\n", str); } int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src) diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 24a5d60..cd4415d 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -285,14 +285,14 @@ void odp_shm_print_all(void) { int i; - printf("\nShared memory\n"); - printf("--------------\n"); - printf(" page size: %"PRIu64" kB\n", odp_sys_page_size() / 1024); - printf(" huge page size: %"PRIu64" kB\n", - odp_sys_huge_page_size() / 1024); - printf("\n"); + ODP_PRI("\nShared memory\n"); + ODP_PRI("--------------\n"); + ODP_PRI(" page size: %"PRIu64" kB\n", odp_sys_page_size() / 1024); + ODP_PRI(" huge page size: %"PRIu64" kB\n", + odp_sys_huge_page_size() / 1024); + ODP_PRI("\n"); - printf(" id name kB align huge addr\n"); + ODP_PRI(" id name kB align huge addr\n"); for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) { odp_shm_block_t *block; @@ -300,15 +300,15 @@ void odp_shm_print_all(void) block = &odp_shm_tbl->block[i]; if (block->addr) { - printf(" %2i %-24s %4"PRIu64" %4"PRIu64" %2c %p\n", - i, - block->name, - block->size/1024, - block->align, - (block->huge ? '*' : ' '), - block->addr); + ODP_PRI(" %2i %-24s %4"PRIu64" %4"PRIu64" %2c %p\n", + i, + block->name, + block->size/1024, + block->align, + (block->huge ? '*' : ' '), + block->addr); } } - printf("\n"); + ODP_PRI("\n"); }