From patchwork Thu Nov 20 17:27:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 41251 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 2D492241C9 for ; Thu, 20 Nov 2014 17:28:25 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf947372lbj.11 for ; Thu, 20 Nov 2014 09:28:24 -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=jcyaGcS1mc8uC9GQ4h57KWqovysq7thjEw9mworCNHQ=; b=hck1i/UIC3l0Oq1/2J0OLFYbrn/sjOQtDCQjR1ACkPlwsWF9Uq2Zwk1LZCCvcbMpA2 crOBioJzLo+e2IsM2fcIG68RkqHSDDrfbExBgyJeIEbk9N2UDT1+rFBo3ckHQALH6mRI 54ror6804DqKhafnGfoJufVePbk6MRvCV6cOzJSjEwLwzUTrL6Xes4qfhkSg80LBDPzT ea4Gr1KPs0WHNC7NyxSZ7gWmu9syX+X7ovgcKS28JjDH/vHNy1rAPsFx4NISai1daj6k oKeUdq8/XJSbBBRinMum6rHENO/LPVPG5rbLW/xEqPz9Zl3CngUQSnGo0a9vuCMw2utp 2gQA== X-Gm-Message-State: ALoCoQkCn1Z1y6XVIZQGp834zKOdLu1Wp+F7bdRkd8PCNm3UuD08vewe2UZq1EhZ6JxAZfL+Uize X-Received: by 10.112.159.199 with SMTP id xe7mr54418lbb.21.1416504503706; Thu, 20 Nov 2014 09:28:23 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.129 with SMTP id t1ls100234lag.53.gmail; Thu, 20 Nov 2014 09:28:23 -0800 (PST) X-Received: by 10.112.157.194 with SMTP id wo2mr12424677lbb.55.1416504503494; Thu, 20 Nov 2014 09:28:23 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id l2si2684342lbp.76.2014.11.20.09.28.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:28:23 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so2674849lbv.10 for ; Thu, 20 Nov 2014 09:28:23 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr12316222laz.27.1416504503375; Thu, 20 Nov 2014 09:28:23 -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 ew9csp303162lbc; Thu, 20 Nov 2014 09:28:22 -0800 (PST) X-Received: by 10.220.128.71 with SMTP id j7mr2503602vcs.22.1416504502010; Thu, 20 Nov 2014 09:28:22 -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 pt17si1125107vdb.69.2014.11.20.09.28.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:28:21 -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 1XrVWl-0000Xg-Nn; Thu, 20 Nov 2014 17:28:19 +0000 Received: from mail-wi0-f175.google.com ([209.85.212.175]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XrVWa-0000XD-UB for lng-odp@lists.linaro.org; Thu, 20 Nov 2014 17:28:09 +0000 Received: by mail-wi0-f175.google.com with SMTP id l15so9495005wiw.8 for ; Thu, 20 Nov 2014 09:28:03 -0800 (PST) X-Received: by 10.180.210.226 with SMTP id mx2mr7509751wic.42.1416504483444; Thu, 20 Nov 2014 09:28:03 -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.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:28:02 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Thu, 20 Nov 2014 19:27:55 +0200 Message-Id: <1416504476-25568-2-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 1/2] platform: debug: replace fprintf() with odp_override_log() 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.217.179 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 ODP application may want to override default ODP logging behaviour and use custom logging function. Add a weak odp_override_log() function for this purpose instead of default fprintf(). Signed-off-by: Taras Kondratiuk --- platform/linux-generic/include/api/odp_debug.h | 24 ++++++++++++++---------- platform/linux-generic/odp_init.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index c9b2edd..be73318 100644 --- a/platform/linux-generic/include/api/odp_debug.h +++ b/platform/linux-generic/include/api/odp_debug.h @@ -14,6 +14,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -79,6 +80,9 @@ typedef enum odp_log_level { ODP_LOG_ABORT } odp_log_level_e; + +extern int odp_override_log(odp_log_level_e level, const char *fmt, ...); + /** * ODP default LOG macro. */ @@ -86,45 +90,45 @@ typedef enum odp_log_level { do { \ switch (level) { \ case ODP_LOG_ERR: \ - fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ + odp_override_log(level, "%s:%d:%s():" fmt, __FILE__, \ __LINE__, __func__, ##__VA_ARGS__); \ break; \ case ODP_LOG_DBG: \ if (ODP_DEBUG_PRINT == 1) \ - fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__); \ + odp_override_log(level, "%s:%d:%s():" fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__); \ break; \ case ODP_LOG_ABORT: \ - fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ + odp_override_log(level, "%s:%d:%s(): " fmt, __FILE__, \ __LINE__, __func__, ##__VA_ARGS__); \ abort(); \ break; \ case ODP_LOG_UNIMPLEMENTED: \ - fprintf(stderr, \ + odp_override_log(level, \ "%s:%d:The function %s() is not implemented\n" \ fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \ break; \ default: \ - fprintf(stderr, "Unknown LOG level"); \ + odp_override_log(level, "Unknown LOG level"); \ break;\ } \ } while (0) /** - * Debug printing macro, which prints output when DEBUG flag is set. + * Log debug message if DEBUG flag is set. */ #define ODP_DBG(fmt, ...) \ ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__) /** - * Print output to stderr (file, line and function). + * Log error message. */ #define ODP_ERR(fmt, ...) \ ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__) /** - * Print output to stderr (file, line and function), - * then abort. + * Log abort message and then stop execution (by default call abort()). + * This function should not return. */ #define ODP_ABORT(fmt, ...) \ ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__) diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 672b3d6..7fbfe36 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -8,6 +8,7 @@ #include #include #include +#include int odp_init_global(odp_init_t *params ODP_UNUSED, @@ -89,3 +90,16 @@ int odp_term_local(void) ODP_UNIMPLEMENTED(); return 0; } + +ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level, + const char *fmt, ...) +{ + va_list args; + int r; + (void)level; + va_start(args, fmt); + r = vfprintf(stdout, fmt, args); + va_end(args); + + return r; +}