From patchwork Thu Nov 20 17:27:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 41252 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D2B9D241C9 for ; Thu, 20 Nov 2014 17:28:33 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id l18sf2006442wgh.6 for ; Thu, 20 Nov 2014 09:28:33 -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=wn71lEKoOkvVd6ebbN/F0o+1FW9UMw7sPDUeRS4c7to=; b=bFhQ9Spbb9pstYAt92NjJYoylK9E+rUUorU6W7Vay3CZvlVmv5g8QmzzrCbG5DgNI+ QYIUmuM5n7wTmgCCHx8cbYEMunzCjCcO/egpVSYBtYIE3W3Pj6PtV9csEeSf4inCyQXd ED8734PxDSR9wmfJXUY6lNdQgWUyMtsZzR9LZJhROfZo86NDaB6ZajP+uSgTBnj7fakO 5hUSPE+PWgOi/2aam2APlt5dDJi79/0hv+zwpEOoIRicdqgAi+oYvHXjFcRqZVcUVbar Rixvvapmxk9oYfmC+2fACzAW8Anqf8MyUmLh3k96jpY4gBTEep5XQOigDMDAgJuLqBBf wk3A== X-Gm-Message-State: ALoCoQn1GH5NQbt9a9+qunTd7dIp1Arozo3vYC53obNi3jzvUGuCF4dc3TAYZb+5dWl1aBgCRC19 X-Received: by 10.181.13.147 with SMTP id ey19mr7723999wid.2.1416504513081; Thu, 20 Nov 2014 09:28:33 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.6 with SMTP id u6ls83823laj.26.gmail; Thu, 20 Nov 2014 09:28:32 -0800 (PST) X-Received: by 10.152.43.80 with SMTP id u16mr12575689lal.53.1416504512830; Thu, 20 Nov 2014 09:28:32 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id dv6si2716783lbc.52.2014.11.20.09.28.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:28:30 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id ge10so2831009lab.3 for ; Thu, 20 Nov 2014 09:28:30 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr4075678lbr.74.1416504510734; Thu, 20 Nov 2014 09:28:30 -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 ew9csp303191lbc; Thu, 20 Nov 2014 09:28:30 -0800 (PST) X-Received: by 10.221.3.195 with SMTP id nz3mr2443513vcb.43.1416504509454; Thu, 20 Nov 2014 09:28:29 -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 xg7si1165957vdb.12.2014.11.20.09.28.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:28:29 -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 1XrVWq-0000Y2-Vn; Thu, 20 Nov 2014 17:28:24 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XrVWc-0000XE-HB for lng-odp@lists.linaro.org; Thu, 20 Nov 2014 17:28:10 +0000 Received: by mail-wi0-f169.google.com with SMTP id r20so288632wiv.4 for ; Thu, 20 Nov 2014 09:28:05 -0800 (PST) X-Received: by 10.180.92.169 with SMTP id cn9mr17523038wib.26.1416504484785; Thu, 20 Nov 2014 09:28:04 -0800 (PST) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id w5sm4968820wif.18.2014.11.20.09.28.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:28:04 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Thu, 20 Nov 2014 19:27:56 +0200 Message-Id: <1416504476-25568-3-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1416504476-25568-1-git-send-email-taras.kondratiuk@linaro.org> References: <1416504476-25568-1-git-send-email-taras.kondratiuk@linaro.org> X-Topics: patch Subject: [lng-odp] [RFC 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.44 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 | 33 ++++---------------- .../linux-generic/include/odp_debug_internal.h | 6 ++-- platform/linux-generic/odp_init.c | 3 ++ 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index be73318..518946c 100644 --- a/platform/linux-generic/include/api/odp_debug.h +++ b/platform/linux-generic/include/api/odp_debug.h @@ -87,38 +87,17 @@ extern int odp_override_log(odp_log_level_e level, const char *fmt, ...); * ODP default 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_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 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_init.c b/platform/linux-generic/odp_init.c index 7fbfe36..921650b 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -101,5 +101,8 @@ ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level, r = vfprintf(stdout, fmt, args); va_end(args); + if (level == ODP_LOG_ABORT) + abort(); + return r; }