From patchwork Tue Oct 14 16:18:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 38726 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 95FB920973 for ; Tue, 14 Oct 2014 16:20:53 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gi9sf5490240lab.10 for ; Tue, 14 Oct 2014 09:20:48 -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=drxdFPbp+zGM7is3ie3a3zg18Ed/aMKPONdN4N/lq3s=; b=X5WKpBBV1pO+rBbKRhfdq+sM5NuJfRNLFP0/NBqx/NOCpgh3kSwpzxhtx+prIMovfm QQiDkon/fv64FRu94NU5kq0kzjYIyRwwxJispcnVygfy8ygUUKK/z1rB4f5lgJdf91Z7 aXAKFUN346uGwoaZcorheA7C/CD1TABBuih47GCqU8FSSoAP5J0M0/Z3XypemDSiLjhf PbjyHYh4Ga0+OLZFWi5669/f/dyt4xU4LWi11OcNZ2pQ/4/AeY9hOvy9qaB+opbI48Dn tYQaanaT+QqEe7an0YumiFp8Pau2nImOwAGvfTAUKah8DHnc3J/A47Zg0xqhWbRgyN3p 8UJg== X-Gm-Message-State: ALoCoQlzUWXsxYBy9ROwSODbzL6dlVQZ9X95oj4vCP5IWM+eE3vmrSLDts0fb4/bXcyNoGCGy1/B X-Received: by 10.180.83.134 with SMTP id q6mr1143289wiy.7.1413303648338; Tue, 14 Oct 2014 09:20:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.227 with SMTP id i3ls517419lae.28.gmail; Tue, 14 Oct 2014 09:20:48 -0700 (PDT) X-Received: by 10.112.140.135 with SMTP id rg7mr6597453lbb.24.1413303648169; Tue, 14 Oct 2014 09:20:48 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) by mx.google.com with ESMTPS id i2si26956441laa.135.2014.10.14.09.20.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Oct 2014 09:20:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gq15so9029520lab.12 for ; Tue, 14 Oct 2014 09:20:47 -0700 (PDT) X-Received: by 10.152.36.103 with SMTP id p7mr6441212laj.44.1413303647901; Tue, 14 Oct 2014 09:20:47 -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.84.229 with SMTP id c5csp432724lbz; Tue, 14 Oct 2014 09:20:47 -0700 (PDT) X-Received: by 10.236.140.196 with SMTP id e44mr8388822yhj.19.1413303646514; Tue, 14 Oct 2014 09:20:46 -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 102si30441751qgl.127.2014.10.14.09.20.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 14 Oct 2014 09:20:46 -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 1Xe4q3-0006RS-2m; Tue, 14 Oct 2014 16:20:43 +0000 Received: from mail-yh0-f42.google.com ([209.85.213.42]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xe4pv-0006Ql-Vf for lng-odp@lists.linaro.org; Tue, 14 Oct 2014 16:20:36 +0000 Received: by mail-yh0-f42.google.com with SMTP id t59so5348774yho.29 for ; Tue, 14 Oct 2014 09:20:30 -0700 (PDT) X-Received: by 10.236.22.228 with SMTP id t64mr4061563yht.164.1413303630754; Tue, 14 Oct 2014 09:20:30 -0700 (PDT) Received: from bala-PowerEdge-T110-II.caveonetworks.com ([111.93.218.67]) by mx.google.com with ESMTPSA id r8sm8082325yhf.1.2014.10.14.09.20.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Oct 2014 09:20:30 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Tue, 14 Oct 2014 21:48:32 +0530 Message-Id: <1413303512-9326-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Topics: patch Subject: [lng-odp] [ODP/PATCHv2] ODP Macro for unimplemented functions 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: bala.manoharan@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.53 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 This patch provides MACRO for unimplemented functions. This patch incorporates the review comments from the previous version. Signed-off-by: Balasubramanian Manoharan --- platform/linux-generic/include/api/odp_debug.h | 54 ++++++++++++++++++---- .../linux-generic/include/api/odp_debug_internal.h | 32 +++++++++++++ 2 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 platform/linux-generic/include/api/odp_debug_internal.h diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index 344b0a9..e850bf3 100644 --- a/platform/linux-generic/include/api/odp_debug.h +++ b/platform/linux-generic/include/api/odp_debug.h @@ -66,30 +66,64 @@ extern "C" { #define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) /** + * ODP log level. + */ +typedef enum odp_log_level { + ODP_LOG_DBG, + ODP_LOG_ERR, + ODP_LOG_UNIMPLEMENTED, + ODP_LOG_ABORT +} odp_log_level_e; + +/** + * ODP default LOG macro. + */ +#define ODP_LOG(level, fmt, ...) \ +do { \ + switch (level) { \ + case ODP_LOG_ERR: \ + fprintf(stderr, "%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__); \ + break; \ + case ODP_LOG_ABORT: \ + fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__); \ + abort(); \ + break; \ + case ODP_LOG_UNIMPLEMENTED: \ + fprintf(stderr, \ + "%s:%d:The function %s() is not implemented\n" \ + fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \ + break; \ + default: \ + fprintf(stderr, "Unknown LOG level"); \ + break;\ + } \ +} while (0) + +/** * Debug printing macro, which prints output when DEBUG flag is set. */ #define ODP_DBG(fmt, ...) \ - do { if (ODP_DEBUG_PRINT == 1) \ - printf(fmt, ##__VA_ARGS__); \ - } while (0) + ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__) /** * Print output to stderr (file, line and function). */ #define ODP_ERR(fmt, ...) \ -do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ - __LINE__, __func__, ##__VA_ARGS__); \ -} while (0) + ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__) /** * 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) + ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__) #ifdef __cplusplus } diff --git a/platform/linux-generic/include/api/odp_debug_internal.h b/platform/linux-generic/include/api/odp_debug_internal.h new file mode 100644 index 0000000..37af468 --- /dev/null +++ b/platform/linux-generic/include/api/odp_debug_internal.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +/** + * @file + * + * ODP debug internal + */ + +#ifndef ODP_DEBUG_INTERNAL_H_ +#define ODP_DEBUG_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * 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__) + +#ifdef __cplusplus +} +#endif + +#endif +