From patchwork Sun Apr 17 18:30:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 562902 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp1890264map; Sun, 17 Apr 2022 12:12:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxweR5awaPJsQRISaFFZrj9Wp6xJA0uMXOTf2GF754lQvq56afu8+pov7350AkplNQ1IeU1 X-Received: by 2002:a37:90e:0:b0:69e:a0f0:215c with SMTP id 14-20020a37090e000000b0069ea0f0215cmr638944qkj.139.1650222746497; Sun, 17 Apr 2022 12:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650222746; cv=none; d=google.com; s=arc-20160816; b=P/71qbWN+MGqbUp4mm2go74OL06ksyVQolC4gvptys+NX4KMEwc+6vHoKeOaUvuyWP gV3nCIs++sVaa/csJcpJKdpZY/LxQzykb4PMD/fsln4tfXEn9OiQMeC6Vtqx5Qu0E3nf IJq+J1Gc94F28wCdu7YunBiDAeqU2+rLutD7vRJ2SF2OpBnMKmsvcBpL2QwpM0P3FN2N WqaUw1emmSsxIRvIUxxyBHIMecqnldgdoblwUgUqHjJz6RUJyfGlpyRoTejsDoAhSWn9 dZwXL8H7WLj3MQU5OhXnEEuCcGXBhHETGRKlxlSxzGdXJA2V5rsrPRMRH2H1LLmlfE6N bTgA== 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=GuwOMriXgAwu84yDvMruRBOLZ7z6LWp1DQPbJdxkC+4=; b=fFiCKJ12uFgZBe+LNNG2B+RC4QEqgXBRB+CbBHvekvKasXUocc+nGI1T7xU9GuOhni Le6/FHz7lFpmH33NdWSEu86Yu4A1FFyUVjL2k2g/U4XkDLgsdH83rFaACFQiXuAUkmd3 J9grucmvWLvVMtJx0RdR9E9TlLA49eM/W4zU9sZgiJaTL9/vayRGRpKia4e1u4huOO1H rgfcl5OHsqEj++5+ewSohX/1ilMlkqPNRGDrFMph3kKHLmC1kkuyKiw/uZOZIoniM9UV Egvy8Qi5zT+WUzpt787fIHRe7MdudFa1yJBf2OzkE6d+wWnkCmjhcQDjDHmK3IFm3oSC 5HRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sSlbVVIj; 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 e4-20020a0562141d0400b004465aced63asi383178qvd.53.2022.04.17.12.12.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Apr 2022 12:12:26 -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=sSlbVVIj; 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]:50908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngAJu-00086a-4J for patch@linaro.org; Sun, 17 Apr 2022 15:12:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ng9ff-0000UT-0G for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:52 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:44594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ng9fY-0001ox-JX for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:47 -0400 Received: by mail-pl1-x62f.google.com with SMTP id j8so10764923pll.11 for ; Sun, 17 Apr 2022 11:30:42 -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=GuwOMriXgAwu84yDvMruRBOLZ7z6LWp1DQPbJdxkC+4=; b=sSlbVVIjTJJ+qatV9FUqY8iZVCS4VoN8OalAf7BhXolANaQZnDJhbb/W3qRU/zZZqC 0frMSowxfQJ0jyykchg6xVBeqjc8j6Zn1J10HnVDfSuhDmM0w1nFg8Kuoi0x8vJUUhQ6 P14g9FtVaM4hCdRaUBs3/DZGcLMCrGhOx9rhQZVy3jDlQMHaft04yHFSP00G9w90avS2 49bLKscEP1CavMCXautOo9rhXzb5LyT3NYjEAPYearoPrvUZDh78TGw65EHtluTKqhLp P8fi11vrAGYAMFCm7UZ7TzIZlsWd6yD9aWgSmcjYt5HeuiwGnHOKRcsNO31hXPox5UYw DAbA== 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=GuwOMriXgAwu84yDvMruRBOLZ7z6LWp1DQPbJdxkC+4=; b=T1eSh1aexO4kbAFnjK0a3FKvxkqdIW1ZD7wf2B5ZqLqAEP7GYNuUUKh8Qu//l45Lqy NcXp6sVOXGMIj1FCGziR/ZMjElwaiQo0GYKRhjZtiYzTxIs11/oybjz3FqYGLXnc3CGD iPLx7KiX2uAbArVK5c48X2JAimrMgcv/PydIn/N2vDSgl9IUf3NfCzmABUZ+nXWEqLgl dhG4KYiQHGdXBeSOMm+DhvWRKzOHjAJZT4sG4rIP35ltzLM9RQ22FT8VPrrFQZcl80VS Iyks0K5m6zJuZ/ZCez7x7LsvSZ+6Ktjrtbks5T1BAp5oxy39JugKSWvSin6xJLk66Bhb 1Omg== X-Gm-Message-State: AOAM5312gIzdWUMB03A8iYC79st9UcpxIRb27ycUHbgH9sadG72S4A6s TBYovBpiHZp21VnwymugovlWKItA2V9iFA== X-Received: by 2002:a17:902:ec8e:b0:158:fd5f:2b2a with SMTP id x14-20020a170902ec8e00b00158fd5f2b2amr1678747plg.72.1650220242004; Sun, 17 Apr 2022 11:30:42 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id on10-20020a17090b1d0a00b001d08a7d569csm8154011pjb.56.2022.04.17.11.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 11:30:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 25/39] include/qemu/log: Move entire implementation out-of-line Date: Sun, 17 Apr 2022 11:30:05 -0700 Message-Id: <20220417183019.755276-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220417183019.755276-1-richard.henderson@linaro.org> References: <20220417183019.755276-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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. Reviewed-by: Alex Bennée 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 75973111bb..42d545f77a 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 dcb8ac70df..9b87af75af 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 caa38e707b..8b8b6a5d83 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_trylock(void)