From patchwork Mon Sep 29 18:39:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 38108 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 70AB1201F1 for ; Mon, 29 Sep 2014 18:40:15 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gi9sf5304572lab.10 for ; Mon, 29 Sep 2014 11:40:14 -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=bkkXiJ9pc/9v5dfWb41hpmNYylUXUK5WT6nI8zjB4FY=; b=GRppRoSEsNtdac9K3o2IUR2BV4BmmnHN4xbi7xnR+8pa4h7js+qlieSD9baRGdbxlZ mnm0h2u6CKG90tNEt1KZl3ODLINlxO3F8Ljceq/PwncLoqI0eBJ/iJS3sLksUg7HcstA Q1PYK6eCbgHQvfQNgiv+i9eUyqc+3VgUJGjfu3alg+l1OegskD6BYov+Vty5Zy1LYw3v qIP31rHOgx98zV4TjNFB5tZnrIrmmgvb7sR79YRiMArmNuWbgLPukFc+gTSjxfCf0H/C kKgoh1BUaiqJk+312+gUh4P1jNvM6yPE6/VeNuNDiyS2XHrfKlAZCO1afEbqiRN+K4Te wyfQ== X-Gm-Message-State: ALoCoQl3ZL1ZQTXsJS6YfHWcLsz9rl7Ilz0sKmZ3AR4DlnX/xeRQqtAjqLQFLkObQKgpCyT7Kv1i X-Received: by 10.180.109.67 with SMTP id hq3mr399688wib.1.1412016014125; Mon, 29 Sep 2014 11:40:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.194 with SMTP id a2ls91607lak.41.gmail; Mon, 29 Sep 2014 11:40:13 -0700 (PDT) X-Received: by 10.152.9.132 with SMTP id z4mr41858140laa.8.1412016013969; Mon, 29 Sep 2014 11:40:13 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id ba4si19474399lab.45.2014.09.29.11.40.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Sep 2014 11:40:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id w7so1770983lbi.23 for ; Mon, 29 Sep 2014 11:40:13 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr7040195lad.40.1412016013895; Mon, 29 Sep 2014 11:40:13 -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 of9csp226064lbb; Mon, 29 Sep 2014 11:40:13 -0700 (PDT) X-Received: by 10.140.21.104 with SMTP id 95mr25266897qgk.69.1412016012449; Mon, 29 Sep 2014 11:40:12 -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 x2si14443467qar.38.2014.09.29.11.40.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 29 Sep 2014 11:40:12 -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 1XYfrl-0007Vd-2d; Mon, 29 Sep 2014 18:40:09 +0000 Received: from mail-qc0-f169.google.com ([209.85.216.169]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XYfre-0007UQ-NJ for lng-odp@lists.linaro.org; Mon, 29 Sep 2014 18:40:02 +0000 Received: by mail-qc0-f169.google.com with SMTP id x13so203082qcv.28 for ; Mon, 29 Sep 2014 11:39:57 -0700 (PDT) X-Received: by 10.140.37.9 with SMTP id q9mr60308968qgq.40.1412015997157; Mon, 29 Sep 2014 11:39:57 -0700 (PDT) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id l46sm11832872qgd.27.2014.09.29.11.39.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Sep 2014 11:39:56 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 29 Sep 2014 14:39:46 -0400 Message-Id: <1412015986-4499-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH v3] Add ODP_ABORT 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.178 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 --- v3: Fix missing brace platform/linux-generic/include/api/odp_debug.h | 16 ++++++++++++++-- platform/linux-generic/odp_buffer_pool.c | 26 ++++++++++---------------- platform/linux-generic/odp_time.c | 3 +-- 3 files changed, 25 insertions(+), 20 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 4d9ff45..a48d7d6 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -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"); @@ -221,15 +219,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); } } @@ -267,8 +263,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); @@ -314,10 +309,9 @@ static void link_bufs(pool_entry_t *pool) hdr_size = sizeof(odp_timeout_hdr_t); } 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; 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();