From patchwork Mon Sep 22 17:10:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 37696 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 13EC420C03 for ; Mon, 22 Sep 2014 17:11:16 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u10sf3577639lbd.7 for ; Mon, 22 Sep 2014 10:11:15 -0700 (PDT) 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=ODsxrFA8eT+PolS3Kvm9v4Fx/YqB7n0wZ0tfSBCpSXE=; b=FNLjZ6SAsgKzNfufrMbmCdochUkUYdo6suXt4T+nUQN+Qq488KU1MuwpRdWxvxE2te E00TfD/1zzTYnOyQAYWhgLCs4QeLQEVhoPAp9TG9QikVnygcwqKWq5R6J1mrlUKacKjH SXzh2O13Lkgd3sWRnQLobYIoLKkQN2XdtJ0DR666aMVzApqxTF07zfz5YaNj3l0LXXGX VHq6eACvv24a/6D+R3XePaAeq3IUixDZ6QS5l+ThGr1qLZI45xpNTi3pBzij/qmhD+r/ l//96v8qSXJeNPP+yBr1o+3ZSINIWVUaBdEr2rIhacT8tudtaMqfMrzdH6SrJR0L67Qa tswg== X-Gm-Message-State: ALoCoQnI7/FXBivezzglR2cce/mTk1RB+OVOf1DpVxNROxoksGnoTumN7kaVVDarHBnHY9UYK/kU X-Received: by 10.180.87.228 with SMTP id bb4mr562750wib.3.1411405875809; Mon, 22 Sep 2014 10:11:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.42 with SMTP id b10ls81543lae.28.gmail; Mon, 22 Sep 2014 10:11:15 -0700 (PDT) X-Received: by 10.112.54.169 with SMTP id k9mr26312980lbp.32.1411405875650; Mon, 22 Sep 2014 10:11:15 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) by mx.google.com with ESMTPS id 2si15216662lak.120.2014.09.22.10.11.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 10:11:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id ty20so7221268lab.35 for ; Mon, 22 Sep 2014 10:11:15 -0700 (PDT) X-Received: by 10.112.53.230 with SMTP id e6mr3752539lbp.100.1411405875574; Mon, 22 Sep 2014 10:11:15 -0700 (PDT) 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.130.169 with SMTP id of9csp278248lbb; Mon, 22 Sep 2014 10:11:14 -0700 (PDT) X-Received: by 10.224.130.138 with SMTP id t10mr24990637qas.2.1411405874246; Mon, 22 Sep 2014 10:11:14 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id y8si9696152qci.49.2014.09.22.10.11.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 22 Sep 2014 10:11:14 -0700 (PDT) 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 1XW78q-0003Xx-BT; Mon, 22 Sep 2014 17:11:12 +0000 Received: from mail-qg0-f51.google.com ([209.85.192.51]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XW78l-0003Xs-8s for lng-odp@lists.linaro.org; Mon, 22 Sep 2014 17:11:07 +0000 Received: by mail-qg0-f51.google.com with SMTP id a108so3146462qge.38 for ; Mon, 22 Sep 2014 10:11:02 -0700 (PDT) X-Received: by 10.224.171.74 with SMTP id g10mr4470724qaz.102.1411405862013; Mon, 22 Sep 2014 10:11:02 -0700 (PDT) Received: from fedora1.holmesfamily.ws (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by mx.google.com with ESMTPSA id u4sm8228432qau.30.2014.09.22.10.11.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Sep 2014 10:11:01 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 22 Sep 2014 13:10:49 -0400 Message-Id: <1411405849-31746-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] Add ODP_ABORT to eliminate calls to exit 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.48 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: Mike Holmes --- Also cleaned up checkpatch wanrings platform/linux-generic/include/api/odp_debug.h | 16 +++++++- platform/linux-generic/odp_buffer_pool.c | 51 ++++++++++++-------------- platform/linux-generic/odp_time.c | 3 +- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index e8f6003..344b0a9 100644 --- a/platform/linux-generic/include/api/odp_debug.h +++ b/platform/linux-generic/include/api/odp_debug.h @@ -13,6 +13,7 @@ #define ODP_DEBUG_H_ #include +#include #ifdef __cplusplus extern "C" { @@ -76,8 +77,19 @@ extern "C" { * Print output to stderr (file, line and function). */ #define ODP_ERR(fmt, ...) \ - fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__) +do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__); \ +} while (0) + +/** + * Print output to stderr (file, line and function), + * then abort. + */ +#define ODP_ABORT(fmt, ...) \ +do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__); \ + abort(); \ +} while (0) #ifdef __cplusplus } diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index f54a0c4..68d7630 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -47,7 +47,7 @@ union buffer_type_any_u { }; ODP_STATIC_ASSERT((sizeof(union buffer_type_any_u) % 8) == 0, - "BUFFER_TYPE_ANY_U__SIZE_ERR"); + "BUFFER_TYPE_ANY_U__SIZE_ERR"); /* Any buffer type header */ typedef struct { @@ -88,7 +88,7 @@ static inline odp_buffer_pool_t pool_index_to_handle(uint32_t pool_id) static inline uint32_t pool_handle_to_index(odp_buffer_pool_t pool_hdl) { - return pool_hdl -1; + return pool_hdl - 1; } @@ -98,10 +98,8 @@ static inline void set_handle(odp_buffer_hdr_t *hdr, odp_buffer_pool_t pool_hdl = pool->s.pool_hdl; uint32_t pool_id = pool_handle_to_index(pool_hdl); - if (pool_id >= ODP_CONFIG_BUFFER_POOLS) { - ODP_ERR("set_handle: Bad pool handle %u\n", pool_hdl); - exit(0); - } + if (pool_id >= ODP_CONFIG_BUFFER_POOLS) + ODP_ABORT("set_handle: Bad pool handle %u\n", pool_hdl); if (index > ODP_BUFFER_MAX_INDEX) ODP_ERR("set_handle: Bad buffer index\n"); @@ -146,7 +144,8 @@ static odp_buffer_hdr_t *index_to_hdr(pool_entry_t *pool, uint32_t index) { odp_buffer_hdr_t *hdr; - hdr = (odp_buffer_hdr_t *)(pool->s.buf_base + index * pool->s.buf_size); + hdr = (odp_buffer_hdr_t *)(pool->s.buf_base + index + * pool->s.buf_size); return hdr; } @@ -172,7 +171,7 @@ static uint32_t rem_buf_index(odp_buffer_chunk_hdr_t *chunk_hdr) static odp_buffer_chunk_hdr_t *next_chunk(pool_entry_t *pool, - odp_buffer_chunk_hdr_t *chunk_hdr) + odp_buffer_chunk_hdr_t *chunk_hdr) { uint32_t index; @@ -218,15 +217,13 @@ static void add_chunk(pool_entry_t *pool, odp_buffer_chunk_hdr_t *chunk_hdr) static void check_align(pool_entry_t *pool, odp_buffer_hdr_t *hdr) { if (!ODP_ALIGNED_CHECK_POWER_2(hdr->addr, pool->s.user_align)) { - ODP_ERR("check_align: user data align error %p, align %zu\n", - hdr->addr, pool->s.user_align); - exit(0); + ODP_ABORT("check_align: user data align error %p, align %zu\n", + hdr->addr, pool->s.user_align); } if (!ODP_ALIGNED_CHECK_POWER_2(hdr, ODP_CACHE_LINE_SIZE)) { - ODP_ERR("check_align: hdr align error %p, align %i\n", - hdr, ODP_CACHE_LINE_SIZE); - exit(0); + ODP_ABORT("check_align: hdr align error %p, align %i\n", + hdr, ODP_CACHE_LINE_SIZE); } } @@ -264,8 +261,7 @@ static void fill_hdr(void *ptr, pool_entry_t *pool, uint32_t index, buf_data = any_hdr->buf_data; break; default: - ODP_ERR("Bad buffer type\n"); - exit(0); + ODP_ABORT("Bad buffer type\n"); } memset(hdr, 0, size); @@ -303,18 +299,17 @@ static void link_bufs(pool_entry_t *pool) pool_size = pool->s.pool_size; pool_base = (uintptr_t) pool->s.pool_base_addr; - if (buf_type == ODP_BUFFER_TYPE_RAW) { + if (buf_type == ODP_BUFFER_TYPE_RAW) hdr_size = sizeof(odp_raw_buffer_hdr_t); - } else if (buf_type == ODP_BUFFER_TYPE_PACKET) { + else if (buf_type == ODP_BUFFER_TYPE_PACKET) hdr_size = sizeof(odp_packet_hdr_t); - } else if (buf_type == ODP_BUFFER_TYPE_TIMEOUT) { + else if (buf_type == ODP_BUFFER_TYPE_TIMEOUT) hdr_size = sizeof(odp_timeout_hdr_t); - } else if (buf_type == ODP_BUFFER_TYPE_ANY) { + else if (buf_type == ODP_BUFFER_TYPE_ANY) hdr_size = sizeof(odp_any_buffer_hdr_t); - } else { - ODP_ERR("odp_buffer_pool_create: Bad type %i\n", buf_type); - exit(0); - } + else + ODP_ABORT("odp_buffer_pool_create: Bad type %i\n", buf_type); + /* Chunk must fit into buffer data area.*/ min_size = sizeof(odp_buffer_chunk_hdr_t) - hdr_size; @@ -366,7 +361,7 @@ static void link_bufs(pool_entry_t *pool) add_chunk(pool, chunk_hdr); chunk_hdr = (odp_buffer_chunk_hdr_t *)index_to_hdr(pool, - index); + index); pool->s.num_bufs += ODP_BUFS_PER_CHUNK; pool_size -= ODP_BUFS_PER_CHUNK * tot_size; } @@ -374,9 +369,9 @@ static void link_bufs(pool_entry_t *pool) odp_buffer_pool_t odp_buffer_pool_create(const char *name, - void *base_addr, uint64_t size, - size_t buf_size, size_t buf_align, - int buf_type) + void *base_addr, uint64_t size, + size_t buf_size, size_t buf_align, + int buf_type) { odp_buffer_pool_t pool_hdl = ODP_BUFFER_POOL_INVALID; pool_entry_t *pool; diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c index 181294a..faece0e 100644 --- a/platform/linux-generic/odp_time.c +++ b/platform/linux-generic/odp_time.c @@ -59,8 +59,7 @@ uint64_t odp_time_get_cycles(void) ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); if (ret != 0) { - ODP_ERR("clock_gettime failed\n"); - exit(EXIT_FAILURE); + ODP_ABORT("clock_gettime failed\n"); } hz = odp_sys_cpu_hz();