From patchwork Sun Mar 20 17:11:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553209 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp891535mag; Sun, 20 Mar 2022 10:51:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7VWSdIvCr8URjrtDR8rJt6Ln4G+ciiYY7gHcUkMh3tIjK/31ZinZR3rx7W9+Y71oVork4 X-Received: by 2002:a05:622a:11c9:b0:2e1:dd8d:33bc with SMTP id n9-20020a05622a11c900b002e1dd8d33bcmr13847101qtk.368.1647798683762; Sun, 20 Mar 2022 10:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647798683; cv=none; d=google.com; s=arc-20160816; b=ujJkxN3RyBxNUPWDsG0qU+6e7OUroqsBf/xuBR1Hyuh+eAO2xVCliXISB9VTKbAInA 3GiWntbGJ3//h3xz/ULZX6Sa0jOrLDHt3YOK2akid/PFOIlEZJxw6K1iOuBu7RxrOxhv GpmV+h8GUjT+5Y3IutsUnbX6ZSVvyg48kEzNO78weWjWK180NzUsrkFjIh5YVRBvXDFI iUgef+q8RkwQUL68l80pZKcx/XUCdVsbsC8nbt1tjpXKnpay66zwtYxb2dgsrnv0Y7gX ag4P4NKOVm8kiz1u4YMWKfGlCYCxE4s8PKa4BTz3+notyFSwBc+t3L5gGj1GoDPYZZDS km5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=THGd3lL3k1TYcfn7NVeHgS8AdzPbg7kpOdsIIF9l+TA=; b=phEJJONs+tTMDJ0xlo55tFLDVdoAg5vcHGNnUwwFgfbsOrKYMcHNBGpqH4uJCKnEDt WsVDe6sjbJhKF5XRCiQ/fnZJ56FbTX8K4B+U8vuzgpAU9As837Zz+sIWhU73SsQdh5Ca CfD9oOuAxnl91PIGiQr5Or9Ti1jD2/KR9HczYlIaPiq5OID7M2vmUHptEH8T/bvXI0hX kFtB0D/CF+CVMMYQRK3iYHHlv+xHbayXfdyH/3ITQ1bzFuUvwuUseV4YgAQSqOlBIp0m QsDc+kL4hs8f1hRrkp2atAyFpV8su1KnioaYC8GZYv87sPBFMYlSwH6mmH7snJvmcWnZ qLsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gu/J9y3X"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j6-20020a05620a410600b0067e4be23848si1541754qko.141.2022.03.20.10.51.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:51:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gu/J9y3X"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzi7-0004qF-Aw for patch@linaro.org; Sun, 20 Mar 2022 13:51:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz61-00005l-4f for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:01 -0400 Received: from [2607:f8b0:4864:20::62a] (port=34479 helo=mail-pl1-x62a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5y-0003Tx-7j for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:59 -0400 Received: by mail-pl1-x62a.google.com with SMTP id i11so10197054plr.1 for ; Sun, 20 Mar 2022 10:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=THGd3lL3k1TYcfn7NVeHgS8AdzPbg7kpOdsIIF9l+TA=; b=gu/J9y3Xbp7DURODPmJkaHY2rvKu0Uhz0c7qBDWYkGBMcIV+VKGB76Wnn6zQiiGg5t FpRsFjn+fBK0E89gBlZtAHZ08Zd0pcJimjNK/JSDfdAHJ0LwLN8fLnkE/x2K0Kn4PjNT tHc8mPIJnT1WrgX09uYstwFvkedUZ+wOqeRZXXh5U3VI61b2U6J0oUoQkU3YeXyIveOv XvyXrHMdRrRqrC4FZE3LjejOSHy7Oq2ikqFl/FIepcjE4YgnWOR9ro5B8/AeP92KZAyO 8/cGiJhLslAiePPepdQs48OeE6/TFSLKF0yM+8fgVrdGO8MQvPNefmRtx9d0Gc0+LKfR tXwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=THGd3lL3k1TYcfn7NVeHgS8AdzPbg7kpOdsIIF9l+TA=; b=O78rpJ6QJq+txyDBguxvpQ2yR2jc8/YGkkmfol5X3hl/TRGbstDDwr4gUc9tayXh1e Xbs8DPFbc0146xpRPQifYrQmDzHHzw3MkI/dByGeBvsQORjeg0XhJLCoQYMoNl/i+pe0 ey1kaaHUbl3St7B+ts1LSMJ0ARbSHG8MnrjkJfCyA8vEp2caxqRSAEY6EdccUpSiZcp5 dQ8sKE0QyXkTJ5kHVBVWmUlvaoUKNaZsZiMuFYnApdQrYrjUXMYGWVzHGTLHoKowJeWB a2TmulcQ5wdDOPtFr6j5cGiz9/R92pn/zGZUu3fv/O2ulYrfeRahpkQt4GHQspnFGWX2 50/A== X-Gm-Message-State: AOAM533K0kOqsLL83PVN8FKy2zrON12uHcqXyWl3w/ajoB4yamL15aFH 1OWcn3ZHUAaIHUqPp23/jgAUN4tyWmftvA== X-Received: by 2002:a17:902:7781:b0:153:35ef:e3d1 with SMTP id o1-20020a170902778100b0015335efe3d1mr9309074pll.116.1647796316622; Sun, 20 Mar 2022 10:11:56 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id q12-20020a17090aa00c00b001bc6f1baaaesm17149697pjp.39.2022.03.20.10.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 22/36] include/qemu/log: Move entire implementation out-of-line Date: Sun, 20 Mar 2022 10:11:21 -0700 Message-Id: <20220320171135.2704502-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220320171135.2704502-1-richard.henderson@linaro.org> References: <20220320171135.2704502-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move QemuLogFile, qemu_logfile, and all inline functions into qemu/log.c. No need to expose these implementation details in the api. Signed-off-by: Richard Henderson --- include/qemu/log.h | 38 ++++---------------------------------- tests/unit/test-logging.c | 1 + util/log.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 10578ba21c..c63416c9e0 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -3,46 +3,16 @@ /* A small part of this API is split into its own header */ #include "qemu/log-for-trace.h" -#include "qemu/rcu.h" - -typedef struct QemuLogFile { - struct rcu_head rcu; - FILE *fd; -} QemuLogFile; - -/* Private global variable, don't use */ -extern QemuLogFile *qemu_logfile; - /* * The new API: - * */ -/* Log settings checking macros: */ +/* Returns true if qemu_log() will really write somewhere. */ +bool qemu_log_enabled(void); -/* Returns true if qemu_log() will really write somewhere - */ -static inline bool qemu_log_enabled(void) -{ - return qemu_logfile != NULL; -} - -/* Returns true if qemu_log() will write somewhere else than stderr - */ -static inline bool qemu_log_separate(void) -{ - QemuLogFile *logfile; - bool res = false; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile && logfile->fd != stderr) { - res = true; - } - rcu_read_unlock(); - return res; -} +/* Returns true if qemu_log() will write somewhere other than stderr. */ +bool qemu_log_separate(void); #define CPU_LOG_TB_OUT_ASM (1 << 0) #define CPU_LOG_TB_IN_ASM (1 << 1) diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index fc22bf40b4..7016710a74 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -30,6 +30,7 @@ #include "qemu-common.h" #include "qapi/error.h" #include "qemu/log.h" +#include "qemu/rcu.h" static void test_parse_range(void) { diff --git a/util/log.c b/util/log.c index be20ae6c1c..7e8b152742 100644 --- a/util/log.c +++ b/util/log.c @@ -26,14 +26,42 @@ #include "trace/control.h" #include "qemu/thread.h" #include "qemu/lockable.h" +#include "qemu/rcu.h" + + +typedef struct QemuLogFile { + struct rcu_head rcu; + FILE *fd; +} QemuLogFile; static char *logfilename; static QemuMutex qemu_logfile_mutex; -QemuLogFile *qemu_logfile; +static QemuLogFile *qemu_logfile; int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; +/* Returns true if qemu_log() will really write somewhere. */ +bool qemu_log_enabled(void) +{ + return qemu_logfile != NULL; +} + +/* Returns true if qemu_log() will write somewhere other than stderr. */ +bool qemu_log_separate(void) +{ + QemuLogFile *logfile; + bool res = false; + + rcu_read_lock(); + logfile = qatomic_rcu_read(&qemu_logfile); + if (logfile && logfile->fd != stderr) { + res = true; + } + rcu_read_unlock(); + return res; +} + /* Lock/unlock output. */ FILE *qemu_log_lock(void)