From patchwork Mon Jan 19 01:56:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 43282 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F16A82034D for ; Mon, 19 Jan 2015 01:57:02 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id b57sf209150eek.0 for ; Sun, 18 Jan 2015 17:57:01 -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=ZCTPCg41FFTd920d0pHle4lDFj0PB7mBgq426Kq0e8U=; b=c3ySMgVY+VJnP4Sd7149tudUaisWYO735rZrkxQvekgRRaZoW+ckrohGzm6fv8h3ZN 2gGcmwgAE3qY4gv1+FC1EsAN6OV6/qj6u8xSxN+cIWXL/5ckpoauKouFoOUu4Kf49RIi Psi/fBGFjr49pMDxB3VrkjqNCt93bHOW6LFgboMbBfDvfSSkwTWBbXjHbaKzHwsKq8rV gxLoSCLLi5/lJjw4rLqFJz3a9k029AI1wHQY9lb0bV0BsevgVjdI3tPXm2QHtAxcYldE 3AfnRjKM2NdJjswgKI6veErfOomhM03yC/SCh8W3pCG7cznPZVfRovprLG1gcEHtJSbV PyMQ== X-Gm-Message-State: ALoCoQkAp6epAu1g72AWcN77uA6RcrRH3hSf8Acg9ZqpUsX9nFE0BrY7DS18Fb2Ey7u1au9fcdie X-Received: by 10.180.82.34 with SMTP id f2mr1690194wiy.1.1421632621775; Sun, 18 Jan 2015 17:57:01 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.133 with SMTP id o5ls439295lal.78.gmail; Sun, 18 Jan 2015 17:57:01 -0800 (PST) X-Received: by 10.112.57.226 with SMTP id l2mr20709419lbq.27.1421632621612; Sun, 18 Jan 2015 17:57:01 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id lv4si5356445lac.87.2015.01.18.17.57.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Jan 2015 17:57:00 -0800 (PST) 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 q1so10926717lam.2 for ; Sun, 18 Jan 2015 17:57:00 -0800 (PST) X-Received: by 10.152.182.235 with SMTP id eh11mr9609832lac.9.1421632620826; Sun, 18 Jan 2015 17:57:00 -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.9.200 with SMTP id c8csp945731lbb; Sun, 18 Jan 2015 17:57:00 -0800 (PST) X-Received: by 10.140.22.49 with SMTP id 46mr31101127qgm.29.1421632619572; Sun, 18 Jan 2015 17:56:59 -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 t65si15401473qgd.98.2015.01.18.17.56.58 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 18 Jan 2015 17:56:59 -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 1YD1aK-0007Lf-SZ; Mon, 19 Jan 2015 01:56:56 +0000 Received: from mail-qg0-f41.google.com ([209.85.192.41]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YD1aA-0007L4-Q0 for lng-odp@lists.linaro.org; Mon, 19 Jan 2015 01:56:46 +0000 Received: by mail-qg0-f41.google.com with SMTP id q108so5119828qgd.0 for ; Sun, 18 Jan 2015 17:56:41 -0800 (PST) X-Received: by 10.224.73.135 with SMTP id q7mr44202749qaj.6.1421632601623; Sun, 18 Jan 2015 17:56:41 -0800 (PST) Received: from mike-desktop.?.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id u15sm9532139qag.21.2015.01.18.17.56.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Jan 2015 17:56:40 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Sun, 18 Jan 2015 20:56:21 -0500 Message-Id: <1421632584-26181-2-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1421632584-26181-1-git-send-email-mike.holmes@linaro.org> References: <1421632584-26181-1-git-send-email-mike.holmes@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 1/4] linux-generic: debug: use global fn ptr for logging fn 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: mike.holmes@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 To allow init_global to replace the default logging function without the need to use weak symbols a global location is needed to hold the current logging function pointer. Signed-off-by: Mike Holmes --- platform/linux-generic/include/api/odp_debug.h | 2 ++ platform/linux-generic/include/odp_debug_internal.h | 7 ++++--- platform/linux-generic/include/odp_internal.h | 5 +++++ platform/linux-generic/odp_init.c | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index a4ce1d9..4c32500 100644 --- a/platform/linux-generic/include/api/odp_debug.h +++ b/platform/linux-generic/include/api/odp_debug.h @@ -76,6 +76,8 @@ typedef enum odp_log_level { extern int odp_override_log(odp_log_level_e level, const char *fmt, ...); +/** Replaceable logging function */ +typedef int (*odp_log_func_t)(odp_log_level_e level, const char *fmt, ...); /** * @} diff --git a/platform/linux-generic/include/odp_debug_internal.h b/platform/linux-generic/include/odp_debug_internal.h index f6180d1..0b64fca 100644 --- a/platform/linux-generic/include/odp_debug_internal.h +++ b/platform/linux-generic/include/odp_debug_internal.h @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { #endif @@ -60,7 +61,7 @@ extern "C" { * This macro is used to indicate when a given function is not implemented */ #define ODP_UNIMPLEMENTED() \ - odp_override_log(ODP_LOG_UNIMPLEMENTED, \ + odp_global_data.log_fn(ODP_LOG_UNIMPLEMENTED, \ "%s:%d:The function %s() is not implemented\n", \ __FILE__, __LINE__, __func__) /** @@ -92,7 +93,7 @@ extern "C" { * ODP LOG macro. */ #define ODP_LOG(level, fmt, ...) \ - odp_override_log(level, "%s:%d:%s():" fmt, __FILE__, \ + odp_global_data.log_fn(level, "%s:%d:%s():" fmt, __FILE__, \ __LINE__, __func__, ##__VA_ARGS__) /** @@ -100,7 +101,7 @@ extern "C" { * specifically for dumping internal data. */ #define ODP_PRINT(fmt, ...) \ - odp_override_log(ODP_LOG_PRINT, " " fmt, ##__VA_ARGS__) + odp_global_data.log_fn(ODP_LOG_PRINT, " " fmt, ##__VA_ARGS__) #ifdef __cplusplus } diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 549d406..7401a30 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -18,6 +18,11 @@ extern "C" { #endif +#include + +struct odp_global_data { + odp_log_func_t log_fn; +} odp_global_data; int odp_system_info_init(void); diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 4d0aa07..a9f003f 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -13,6 +13,8 @@ int odp_init_global(odp_init_t *params ODP_UNUSED, odp_platform_init_t *platform_params ODP_UNUSED) { + odp_global_data.log_fn = odp_override_log; + odp_system_info_init(); if (odp_shm_init_global()) {