From patchwork Thu Oct 16 06:54:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 38796 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 08D1E20350 for ; Thu, 16 Oct 2014 06:54:45 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id a1sf1510817wgh.5 for ; Wed, 15 Oct 2014 23:54:44 -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=pvkZl28G7i5g2ZoZhIH8QFFfZq8GJCc1kMwOg7+J0Z0=; b=k+oOg/zYK0PU0EcqmnJCm4AoVxnuuOb752F+S6lSJhCEmI+kcL0NhuC3iZrXfNcltu aBCvbv/0vcRg9MLl/JYLWLVNv8nhNYn511bOZW8SHc1pcHxebIvZ0mXmouIsU/Aq61GI rx8hXQJUNo/9B1i1yMAfxbqWbfnQePO9pRk1HvlPFOZBUsltCvjjTxOdf4yi380TeL5T Zr/c7qI00iM5TEyM0+Jn6d4Fj1A/8VKcu5WCGsCAzbcYLcADhThlmFzi+jaVwFaG/dmL qjvdB5Yh+nZ05fH5idb/rbDnZVLp606NjMC5wAarMnKMI7CNVBGUSe+EAXa7CT+w0lQn Z6EQ== X-Gm-Message-State: ALoCoQkspcs6QPn2fzmcnnM+C6u+9WavBh251vKbnz0+4/QkUtru64P3jRXsxruiy2S/G5LqYGBw X-Received: by 10.112.63.103 with SMTP id f7mr330838lbs.9.1413442484779; Wed, 15 Oct 2014 23:54:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.41 with SMTP id s9ls128972lae.41.gmail; Wed, 15 Oct 2014 23:54:44 -0700 (PDT) X-Received: by 10.152.36.230 with SMTP id t6mr761586laj.88.1413442484492; Wed, 15 Oct 2014 23:54:44 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by mx.google.com with ESMTPS id rr9si33296863lbb.113.2014.10.15.23.54.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Oct 2014 23:54:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id mc6so2354709lab.2 for ; Wed, 15 Oct 2014 23:54:44 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr17489202lbb.46.1413442484298; Wed, 15 Oct 2014 23:54:44 -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 c5csp745252lbz; Wed, 15 Oct 2014 23:54:43 -0700 (PDT) X-Received: by 10.224.119.201 with SMTP id a9mr5122254qar.86.1413442482992; Wed, 15 Oct 2014 23:54:42 -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 w19si38850957qaw.18.2014.10.15.23.54.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 15 Oct 2014 23:54:42 -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 1XeexL-0000YZ-Af; Thu, 16 Oct 2014 06:54:39 +0000 Received: from mail-yh0-f46.google.com ([209.85.213.46]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XeexE-0000X2-To for lng-odp@lists.linaro.org; Thu, 16 Oct 2014 06:54:32 +0000 Received: by mail-yh0-f46.google.com with SMTP id f73so1438764yha.5 for ; Wed, 15 Oct 2014 23:54:27 -0700 (PDT) X-Received: by 10.236.222.74 with SMTP id s70mr23221032yhp.5.1413442467645; Wed, 15 Oct 2014 23:54:27 -0700 (PDT) Received: from bala-PowerEdge-T110-II.caveonetworks.com ([111.93.218.67]) by mx.google.com with ESMTPSA id 46sm10213934yhe.14.2014.10.15.23.54.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Oct 2014 23:54:27 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 16 Oct 2014 12:24:10 +0530 Message-Id: <1413442450-12532-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Topics: patch Subject: [lng-odp] [ODP/PATCH v4] 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.43 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 Signed-off-by: Balasubramanian Manoharan Reviewed-by: Mike Holmes --- V4: This patch incorporates previous review comments and enhancements to ODP debug internal file description. platform/linux-generic/include/api/odp_debug.h | 54 ++++++++++++++++++---- .../linux-generic/include/api/odp_debug_internal.h | 35 ++++++++++++++ 2 files changed, 79 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..a87552f --- /dev/null +++ b/platform/linux-generic/include/api/odp_debug_internal.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +/** + * @file + * + * ODP Debug internal + * This file contains implementer support functions for Debug capabilities. + * + * @warning These definitions are not part of ODP API, they are for + * internal use by implementers and should not be called from any other scope. + */ + +#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