From patchwork Mon Nov 24 11:13:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 41402 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 58D5E23FFA for ; Mon, 24 Nov 2014 11:13:58 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf5479446eek.11 for ; Mon, 24 Nov 2014 03:13:57 -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:in-reply-to :references: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=hnYV6XnOR/9nbBiLkh2zjlUdK+3f0Ore2rHcrdOJ/Yo=; b=XCLWIMcVNLzE1ly3dqHaWwZYUSD5IVsUXQLTzIcQ1KOcVLJ5CReeCjlTy3CpiKbuce 3DfLG5fAJhT1JEeBeilTgDCXywfCombqMQWoyLUi0yZxEEJU1WEpkrLNSYB8YaUZ0QhA xL24PL6QdNSY7FZGPbkwULvGsKnFdLZqekthrrFbI94Y2PVnn/9MNiYLEM8m8JTOZKfe x40yE9d+PQ2Zft+vbf2VrT/QrZ76UUaTKzcdJPUPxaGIIMF86WWtY3pxlYaH2HTl+LSy hZBE5jZGnWY5Fq/YueiU0z48L25oshdaVePY+RRsdbPxutGMcp8tAx9q1DyBvVrlENLP wBtg== X-Gm-Message-State: ALoCoQk5Jl8Q2q1/7zGRGp2Y3YmAorWVC4fqNv5YhyaBpWVhslgpM7siGGuruCm4Vog6N59EWqyE X-Received: by 10.152.30.66 with SMTP id q2mr6041097lah.2.1416827637481; Mon, 24 Nov 2014 03:13:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.165 with SMTP id x5ls31890lal.34.gmail; Mon, 24 Nov 2014 03:13:57 -0800 (PST) X-Received: by 10.152.7.146 with SMTP id j18mr19701595laa.58.1416827637337; Mon, 24 Nov 2014 03:13:57 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id wl2si14793922lbb.95.2014.11.24.03.13.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Nov 2014 03:13:56 -0800 (PST) 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 s18so7290211lam.21 for ; Mon, 24 Nov 2014 03:13:56 -0800 (PST) X-Received: by 10.112.38.4 with SMTP id c4mr4119229lbk.46.1416827636914; Mon, 24 Nov 2014 03:13:56 -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 ew9csp233491lbc; Mon, 24 Nov 2014 03:13:56 -0800 (PST) X-Received: by 10.52.57.69 with SMTP id g5mr9572805vdq.83.1416827635567; Mon, 24 Nov 2014 03:13:55 -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 sz2si6215347vdc.39.2014.11.24.03.13.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Nov 2014 03:13:55 -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 1Xsraa-0001MX-Sz; Mon, 24 Nov 2014 11:13:52 +0000 Received: from mail-lb0-f175.google.com ([209.85.217.175]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xsra2-0001L8-Ig for lng-odp@lists.linaro.org; Mon, 24 Nov 2014 11:13:18 +0000 Received: by mail-lb0-f175.google.com with SMTP id u10so4185643lbd.6 for ; Mon, 24 Nov 2014 03:13:12 -0800 (PST) X-Received: by 10.112.168.97 with SMTP id zv1mr20157052lbb.6.1416827592626; Mon, 24 Nov 2014 03:13:12 -0800 (PST) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id pd3sm3467041lbb.28.2014.11.24.03.13.11 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Nov 2014 03:13:12 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Mon, 24 Nov 2014 13:13:04 +0200 Message-Id: <1416827584-21879-3-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1416827584-21879-1-git-send-email-taras.kondratiuk@linaro.org> References: <1416827584-21879-1-git-send-email-taras.kondratiuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 2/2] platform: debug: Simplify ODP_LOG() macro 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: taras.kondratiuk@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 Move additional functionality out of ODP_LOG. Move abort() call to odp_override_log(), so application will be able to implement custom abort handling. Signed-off-by: Taras Kondratiuk --- platform/linux-generic/include/api/odp_debug.h | 37 ++++---------------- .../linux-generic/include/odp_debug_internal.h | 6 ++-- platform/linux-generic/odp_weak.c | 5 ++- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index cb5bc83..0fbd6b9 100644 --- a/platform/linux-generic/include/api/odp_debug.h +++ b/platform/linux-generic/include/api/odp_debug.h @@ -99,36 +99,8 @@ extern int odp_override_log(odp_log_level_e level, const char *fmt, ...); * ODP LOG macro. */ #define ODP_LOG(level, fmt, ...) \ -do { \ - switch (level) { \ - case ODP_LOG_ERR: \ - odp_override_log(level, "%s:%d:%s():" fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__); \ - break; \ - case ODP_LOG_DBG: \ - if (ODP_DEBUG_PRINT == 1) \ - odp_override_log(level, "%s:%d:%s():" fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__); \ - break; \ - case ODP_LOG_PRINT: \ - odp_override_log(level, "%s:%d:%s():" fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__); \ - break; \ - case ODP_LOG_ABORT: \ - odp_override_log(level, "%s:%d:%s(): " fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__); \ - abort(); \ - break; \ - case ODP_LOG_UNIMPLEMENTED: \ - odp_override_log(level, \ - "%s:%d:The function %s() is not implemented\n" \ - fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \ - break; \ - default: \ - odp_override_log(level, "Unknown LOG level"); \ - break;\ - } \ -} while (0) + odp_override_log(level, "%s:%d:%s():" fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__) /** * Log print message when the application calls one of the ODP APIs @@ -141,7 +113,10 @@ do { \ * Log debug message if DEBUG flag is set. */ #define ODP_DBG(fmt, ...) \ - ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__) + do { \ + if (ODP_DEBUG_PRINT == 1) \ + ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__);\ + } while (0) /** * Log error message. diff --git a/platform/linux-generic/include/odp_debug_internal.h b/platform/linux-generic/include/odp_debug_internal.h index a87552f..006e8ab 100644 --- a/platform/linux-generic/include/odp_debug_internal.h +++ b/platform/linux-generic/include/odp_debug_internal.h @@ -25,8 +25,10 @@ extern "C" { /** * This macro is used to indicate when a given function is not implemented */ -#define ODP_UNIMPLEMENTED(fmt, ...) \ - ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__) +#define ODP_UNIMPLEMENTED() \ + odp_override_log(ODP_LOG_UNIMPLEMENTED, \ + "%s:%d:The function %s() is not implemented\n" \ + __FILE__, __LINE__, __func__) #ifdef __cplusplus } diff --git a/platform/linux-generic/odp_weak.c b/platform/linux-generic/odp_weak.c index fccbc3f..3cc3d45 100644 --- a/platform/linux-generic/odp_weak.c +++ b/platform/linux-generic/odp_weak.c @@ -9,7 +9,7 @@ #include #include -ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level ODP_UNUSED, +ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level, const char *fmt, ...) { va_list args; @@ -19,5 +19,8 @@ ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level ODP_UNUSED, r = vfprintf(stderr, fmt, args); va_end(args); + if (level == ODP_LOG_ABORT) + abort(); + return r; }