From patchwork Wed Nov 19 23:14:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 41214 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4009020CBB for ; Wed, 19 Nov 2014 23:14:48 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id k14sf970785wgh.8 for ; Wed, 19 Nov 2014 15:14:47 -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:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=kibRx3Cnr3da4GmMZezOTnz5VZCe8hl/cqbRIIsca5M=; b=UITduN1Z2nIeXQv2RccNccOwRDXs+adMIgMZ8TOuUPcbW7NdNHlIPv6uWUUBvnI3ia W/1e9YxFtGNlxgecHY5Oxt2QcbHkkf5HgwHAJT8f7u9tK0IXasIAOUGPn8PEj2DuYsg0 Gwc82YZ1UGcxezPuGooj7E+pIZR8L5NN8m1b8grtSl3hgnwn9Fj6+2PuHEc/RR4fw9pT ZXwp3ccsoRdIxNPHV1C6oKS6EMdXIYQs5Ri5LZz8DKRYu/iScN/QNJU01XwXKbH6uN9c Tgw7bxiqgydz+9J4tNWg0Ml7vvswWHUME4dIWVTDzLLnaC3nRtpagTTA9zhPoKbuC2R3 uRJQ== X-Gm-Message-State: ALoCoQkfyKXb9MRMAcj3S/6uRbueyg+tgw2EBO2xDuEbBiEYaALU53sn9W7kHDIU3vHh3WVhHj0i X-Received: by 10.112.188.199 with SMTP id gc7mr12082445lbc.6.1416438887487; Wed, 19 Nov 2014 15:14:47 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.133 with SMTP id ue5ls154lac.6.gmail; Wed, 19 Nov 2014 15:14:47 -0800 (PST) X-Received: by 10.152.21.199 with SMTP id x7mr7855044lae.66.1416438887206; Wed, 19 Nov 2014 15:14:47 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id os10si614789lbb.3.2014.11.19.15.14.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 15:14:46 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id gf13so1451699lab.13 for ; Wed, 19 Nov 2014 15:14:46 -0800 (PST) X-Received: by 10.153.7.170 with SMTP id dd10mr7913149lad.44.1416438886801; Wed, 19 Nov 2014 15:14:46 -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 ew9csp179044lbc; Wed, 19 Nov 2014 15:14:46 -0800 (PST) X-Received: by 10.224.148.18 with SMTP id n18mr16067359qav.100.1416438885525; Wed, 19 Nov 2014 15:14:45 -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 h93si736022qgd.105.2014.11.19.15.14.44 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 19 Nov 2014 15:14:45 -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 1XrESQ-0007hS-WE; Wed, 19 Nov 2014 23:14:43 +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 1XrESJ-0007hK-Ks for lng-odp@lists.linaro.org; Wed, 19 Nov 2014 23:14:35 +0000 Received: by mail-qg0-f50.google.com with SMTP id e89so1263162qgf.23 for ; Wed, 19 Nov 2014 15:14:30 -0800 (PST) X-Received: by 10.140.104.131 with SMTP id a3mr56046012qgf.31.1416438870404; Wed, 19 Nov 2014 15:14:30 -0800 (PST) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id u65sm612430qge.12.2014.11.19.15.14.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Nov 2014 15:14:29 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 19 Nov 2014 18:14:17 -0500 Message-Id: <1416438857-17362-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH v2] linux-generic: Replace printf with ODP_PRINT 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.215.54 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 Reviewed-by: Bill Fischofer --- platform/linux-generic/include/api/odp_debug.h | 14 +++++++- platform/linux-generic/odp_buffer.c | 4 +-- platform/linux-generic/odp_buffer_pool.c | 45 +++++++++++++------------- platform/linux-generic/odp_packet.c | 2 +- platform/linux-generic/odp_shared_memory.c | 32 +++++++++--------- 5 files changed, 56 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..5c3adde 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_PRINT } odp_log_level_e; /** @@ -94,6 +95,10 @@ do { \ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ __LINE__, __func__, ##__VA_ARGS__); \ break; \ + case ODP_LOG_PRINT: \ + fprintf(stdout, "%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_PRINT(fmt, ...) \ + ODP_LOG(ODP_LOG_PRINT, 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..d9e211b 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_PRINT("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_PRINT("\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..6a0a6b2 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_PRINT("Pool info\n"); + ODP_PRINT("---------\n"); + ODP_PRINT(" pool %i\n", pool->s.pool_hdl); + ODP_PRINT(" name %s\n", pool->s.name); + ODP_PRINT(" pool base %p\n", pool->s.pool_base_addr); + ODP_PRINT(" buf base 0x%"PRIxPTR"\n", pool->s.buf_base); + ODP_PRINT(" pool size 0x%"PRIx64"\n", pool->s.pool_size); + ODP_PRINT(" buf size %zu\n", pool->s.user_size); + ODP_PRINT(" buf align %zu\n", pool->s.user_align); + ODP_PRINT(" hdr size %zu\n", pool->s.hdr_size); + ODP_PRINT(" alloc size %zu\n", pool->s.buf_size); + ODP_PRINT(" offset to hdr %zu\n", pool->s.buf_offset); + ODP_PRINT(" num bufs %"PRIu64"\n", pool->s.num_bufs); + ODP_PRINT(" 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_PRINT("\n First chunk\n"); for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) { uint32_t index; @@ -555,20 +555,21 @@ 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_PRINT(" [%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_PRINT(" [%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_PRINT(" Next chunk\n"); + ODP_PRINT(" addr %p, id %"PRIu32"\n", chunk_hdr->buf_hdr.addr, + chunk_hdr->buf_hdr.index); } - printf("\n"); + ODP_PRINT("\n"); } diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 82ea879..a574de1 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_PRINT("\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..9d3e4cb 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -285,14 +285,15 @@ 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_PRINT("\nShared memory\n"); + ODP_PRINT("--------------\n"); + ODP_PRINT(" page size: %"PRIu64" kB\n", + odp_sys_page_size() / 1024); + ODP_PRINT(" huge page size: %"PRIu64" kB\n", + odp_sys_huge_page_size() / 1024); + ODP_PRINT("\n"); - printf(" id name kB align huge addr\n"); + ODP_PRINT(" id name kB align huge addr\n"); for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) { odp_shm_block_t *block; @@ -300,15 +301,16 @@ 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_PRINT(" %2i %-24s %4"PRIu64" %4"PRIu64 + " %2c %p\n", + i, + block->name, + block->size/1024, + block->align, + (block->huge ? '*' : ' '), + block->addr); } } - printf("\n"); + ODP_PRINT("\n"); }