From patchwork Tue Jan 20 23:37:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 43425 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 389BC218DB for ; Tue, 20 Jan 2015 23:38:38 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id u56sf21818933wes.3 for ; Tue, 20 Jan 2015 15:38:37 -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: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=Zute2UrmpLJ56eEJQF7B3CX3vTwnsrmivqEXBRf0ckI=; b=EuMJ32ELORZgoMrQw45Gx19Qa9XDz2v39J7s6CjfIlqhyeHtcZFKw3qaIpwrRcT9wF IxrmXBip/HHUiD4iq/NNqaMkFaOAPmzll0/swygv1PsphQWTaMnkFMYz/hUf/x7ub6zz nZXLNS8Kp0P1UlDHGLb0zKePfoG+hAuEKIeWZloZsSmC98vPxdTKMpYgSPGSgy06iXj0 fhhGcPpNBkp2LdrvCWe+bdvh+D9wavbFUCMrS8gl14zKRi6ev3aSSHxKKK3wTUfHySOB Kkdaizcq5vi/mspmz8JgLLmK03KuC0OjePC7FZOKMH7ROPGpF1aX10gQKxo8aeWo0imD Vmxg== X-Gm-Message-State: ALoCoQn0CmoFuoHxitfET+ZYIXWoxDRXL1bJsYP90obN97dhmxI3jt+br9m2DdBPEr1r2VcWxhZJ X-Received: by 10.152.170.201 with SMTP id ao9mr2590lac.5.1421797117478; Tue, 20 Jan 2015 15:38:37 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.1 with SMTP id ku1ls792575lac.80.gmail; Tue, 20 Jan 2015 15:38:37 -0800 (PST) X-Received: by 10.152.161.168 with SMTP id xt8mr41322849lab.35.1421797117272; Tue, 20 Jan 2015 15:38:37 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id ad5si16440364lbc.105.2015.01.20.15.38.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 15:38:36 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gd6so13607294lab.4 for ; Tue, 20 Jan 2015 15:38:36 -0800 (PST) X-Received: by 10.152.8.11 with SMTP id n11mr40339899laa.38.1421797116509; Tue, 20 Jan 2015 15:38:36 -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 c8csp1587225lbb; Tue, 20 Jan 2015 15:38:35 -0800 (PST) X-Received: by 10.140.85.231 with SMTP id n94mr58241413qgd.63.1421797115214; Tue, 20 Jan 2015 15:38:35 -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 d2si2332387qam.66.2015.01.20.15.38.32 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 20 Jan 2015 15:38:35 -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 1YDiNR-0003we-NT; Tue, 20 Jan 2015 23:38:29 +0000 Received: from mail-qa0-f54.google.com ([209.85.216.54]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDiNM-0003wK-Gq for lng-odp@lists.linaro.org; Tue, 20 Jan 2015 23:38:24 +0000 Received: by mail-qa0-f54.google.com with SMTP id w8so30004656qac.13 for ; Tue, 20 Jan 2015 15:38:19 -0800 (PST) X-Received: by 10.140.91.74 with SMTP id y68mr33172338qgd.90.1421797099291; Tue, 20 Jan 2015 15:38:19 -0800 (PST) Received: from mike-desktop.?.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id 66sm8323596qgl.42.2015.01.20.15.38.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jan 2015 15:38:18 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Tue, 20 Jan 2015 18:37:55 -0500 Message-Id: <1421797078-14262-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH v2 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.45 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 77bfd09..4f152ac 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()) {