From patchwork Thu Nov 27 14:23:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 41620 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 31A5A2486D for ; Thu, 27 Nov 2014 14:23:58 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf3101965lam.6 for ; Thu, 27 Nov 2014 06:23: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=6N9TnHQ5AmqJx2y5TAOnnw9njK8sjVo1yPOOFYyw6ws=; b=W4nN1MPzuAyJGYdnLGaJVG+/CjG1df8vDSvFHiLp4N9BUPfHasBIu7fd3tu6E4yneU 3GxxsZgakzljY/ofS/qDZMOSQFV6twlOCq8RWRTy7euoJhHf++NFunOdSPpk8b+jvqlo MflMAYVN0uSxo4ZABCN0+UgUWHB9v5t5GuQ+pzO9NPfnihhldlor2UIWY56xSeESqc7d Vb43fdOv+VRsfQB+AfIxrR4LVGcXm+OtYLz70ZYlJ1oVPS3LIIbohId2Piib25aZKNPt quYBHZKKTTfUrYp2nM0kcGxMhz7PkDID8WZkQ2P+CD1f+IvYfHNkDZfus+3e1bsqcjp4 S48Q== X-Gm-Message-State: ALoCoQlNTqkH1QkKZdCUggK4imxeWK0+6cUuUQcY6AIiYIbmJ9GYiWtU8puZi+m/NeHqBXmPUWQn X-Received: by 10.112.55.10 with SMTP id n10mr542059lbp.14.1417098237179; Thu, 27 Nov 2014 06:23:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.134 with SMTP id ay6ls15236lab.107.gmail; Thu, 27 Nov 2014 06:23:56 -0800 (PST) X-Received: by 10.152.5.38 with SMTP id p6mr28329855lap.64.1417098236698; Thu, 27 Nov 2014 06:23:56 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id y1si7463129laa.37.2014.11.27.06.23.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 06:23:56 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so4187116lab.22 for ; Thu, 27 Nov 2014 06:23:56 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr38865404lbc.23.1417098236575; Thu, 27 Nov 2014 06:23: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 ew9csp805181lbc; Thu, 27 Nov 2014 06:23:55 -0800 (PST) X-Received: by 10.236.70.70 with SMTP id o46mr20100966yhd.191.1417098234898; Thu, 27 Nov 2014 06:23:54 -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 x17si4556489qae.68.2014.11.27.06.23.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 27 Nov 2014 06:23:54 -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 1Xtzz7-00087Y-7N; Thu, 27 Nov 2014 14:23:53 +0000 Received: from mail-wi0-f170.google.com ([209.85.212.170]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xtzyp-0007z1-82 for lng-odp@lists.linaro.org; Thu, 27 Nov 2014 14:23:35 +0000 Received: by mail-wi0-f170.google.com with SMTP id bs8so18358084wib.1 for ; Thu, 27 Nov 2014 06:23:29 -0800 (PST) X-Received: by 10.181.8.193 with SMTP id dm1mr3939476wid.55.1417098209500; Thu, 27 Nov 2014 06:23:29 -0800 (PST) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id dm10sm25476209wib.18.2014.11.27.06.23.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 06:23:28 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Thu, 27 Nov 2014 16:23:20 +0200 Message-Id: <1417098200-28258-3-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1417098200-28258-1-git-send-email-taras.kondratiuk@linaro.org> References: <1417098200-28258-1-git-send-email-taras.kondratiuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 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.49 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 | 38 ++++---------------- .../linux-generic/include/odp_debug_internal.h | 6 ++-- platform/linux-generic/odp_weak.c | 5 ++- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index 4b51038..875c813 100644 --- a/platform/linux-generic/include/api/odp_debug.h +++ b/platform/linux-generic/include/api/odp_debug.h @@ -99,48 +99,24 @@ 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, " " fmt, ##__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 * specifically for dumping internal data. */ #define ODP_PRINT(fmt, ...) \ - ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__) + odp_override_log(ODP_LOG_PRINT, " " fmt, ##__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..ee3c543 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; }