From patchwork Fri Sep 26 15:42:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 38007 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6B38B20F2E for ; Fri, 26 Sep 2014 15:42:39 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id c13sf6224795eek.11 for ; Fri, 26 Sep 2014 08:42:38 -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=Qt7ynl2rZzzkEAyei8VSDDyiUHogJuiLIj1roodlB98=; b=lxMP4GpZWIkOM/xpGHZoBTjruivZLbHNk9eKsaRG2sYT9Ov71Sd/rDm1Bzg9EKK/fM Emyk0bDtqyGEaqgjKTVNiNAFDAB4Nmt5P52n635PqMhB7BOUHda1MQu9U1oVifrnD350 iqzVGOtatFJUYzE6lNBSZmuTKfDZzXWSR1gON1cgV6wcpPR31GouQaTxFa8C2KPeV0PN offIhOIWCP6cn5U/JflgLE3vNf4N47oJnAoxliGikh8G4aiim1seV2NjZGJYVPep+5ul /TVrE4butgH8qZkggVHKWYczQ3y2mHIXC57SpXHopOeeK0GZbMmVYqlzQ2fJ6oPhYEvX /IbQ== X-Gm-Message-State: ALoCoQmTjD6TapIek5iFmkXexAlrOI/qbIj46+M65/XOk9SbMxLlkibzsRV5Y4xpvpbViddSmktB X-Received: by 10.194.121.72 with SMTP id li8mr3251885wjb.1.1411746158566; Fri, 26 Sep 2014 08:42:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.246.35 with SMTP id xt3ls363437lac.67.gmail; Fri, 26 Sep 2014 08:42:38 -0700 (PDT) X-Received: by 10.112.146.1 with SMTP id sy1mr19632589lbb.77.1411746158390; Fri, 26 Sep 2014 08:42:38 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46]) by mx.google.com with ESMTPS id bh7si7655184lbb.91.2014.09.26.08.42.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Sep 2014 08:42:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gi9so4498607lab.33 for ; Fri, 26 Sep 2014 08:42:38 -0700 (PDT) X-Received: by 10.112.163.103 with SMTP id yh7mr20055866lbb.73.1411746157901; Fri, 26 Sep 2014 08:42:37 -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 of9csp83726lbb; Fri, 26 Sep 2014 08:42:37 -0700 (PDT) X-Received: by 10.140.42.5 with SMTP id b5mr25481523qga.27.1411746156357; Fri, 26 Sep 2014 08:42:36 -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 d6si6244084qga.63.2014.09.26.08.42.35 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 26 Sep 2014 08:42:36 -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 1XXXfF-0004b4-GM; Fri, 26 Sep 2014 15:42:33 +0000 Received: from mail-qc0-f171.google.com ([209.85.216.171]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XXXf8-0004aq-ON for lng-odp@lists.linaro.org; Fri, 26 Sep 2014 15:42:26 +0000 Received: by mail-qc0-f171.google.com with SMTP id x3so4691076qcv.2 for ; Fri, 26 Sep 2014 08:42:21 -0700 (PDT) X-Received: by 10.140.83.209 with SMTP id j75mr33776601qgd.91.1411746141361; Fri, 26 Sep 2014 08:42:21 -0700 (PDT) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id o92sm4930198qgd.0.2014.09.26.08.42.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Sep 2014 08:42:20 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Fri, 26 Sep 2014 11:42:14 -0400 Message-Id: <1411746134-4925-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCHv2] 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.215.46 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 --- v2: Removed odp_check formatting 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 f54a0c4..a981b51 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"); @@ -218,15 +216,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 +260,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); @@ -311,10 +306,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();