From patchwork Wed Apr 20 18:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563997 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4415738map; Wed, 20 Apr 2022 11:31:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIF+9Ps8/4Qo65AnGAZ7YjaueRKedz/ZcMIKjoqJP3g04ip8o/JGQ0ZT1NyRxKDtFRdfB+ X-Received: by 2002:a25:8e90:0:b0:637:3d1f:cc39 with SMTP id q16-20020a258e90000000b006373d1fcc39mr21570149ybl.321.1650479503422; Wed, 20 Apr 2022 11:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479503; cv=none; d=google.com; s=arc-20160816; b=AeN+tmOtL7McClPi5u3TJPyk7K33bS6tXHnA/JO+nMPqvu7tU4WTCJ3GAduPHFoIa1 LfDL1qV+VFtLGhvWwrV04nm4zR8FvpZH8vvHKjlbU3YHyp55tvQros+7Fq0th8q2TA8/ g3OrH/+QHbUZqBugq+qUOdvpZDGdLOZ8Gjnhv/K+rPCBG9UhmPfcwJaURpHVM3eA+zOk gbbk8U94SL2cpec1gjKVkQZ+3HaPji549QKtCeR4u7aaSSEO8N5TGAgjSL1bZz+Pmu0F 6Uy0uL8EMITO5i7OhsiD8Cjm6bDaG8mVS3vPKFET/WkEYS7QeebnXgwm3NPznPPfp/L2 /IzA== 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=xNgxgSaf8cG296x/VWOV0Bb0OftTv/JlrbrLRCW/aGg=; b=UsEiVZXJ62Yp0YS6cpjrJ16WPaVnw8X4wSiLwkZkrLuNbOyw/gbtsUrshLOwsnf3hP ozMUUNPHv7mTTKa2NnNcWJHwiUYqT+C7hHv2u6Pao6AWZWXAjD6ny9JxY4RQeQRvnSXt UHCWumZAj5PySISrKZB5GXlH5GbjEwMMEyIIj1Ka9MxrB+ExJ5cCLVUJBBt7oR79wfq0 WeKwrVbFHNX3yIkYa9h6Rxqeu6xdxUOiPCJmtYc+k+vcqoj4e4DBqX1OBKH8nuPkQJtd F3PLf7mvCTPEKq2BjMDHQL9Z/s9Veu4Mohzln6hFiI0+DYEw7lHGXInxbDVgxCQufbrz H/zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nTAfeNHu; 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 62-20020a250841000000b0063d4dd5c0b4si588087ybi.373.2022.04.20.11.31.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:31:43 -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=nTAfeNHu; 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]:37474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF78-0005xP-Ta for patch@linaro.org; Wed, 20 Apr 2022 14:31:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj3-00063P-2S for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:49 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:39763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj1-0001LO-Bo for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:48 -0400 Received: by mail-pj1-x1034.google.com with SMTP id mp16-20020a17090b191000b001cb5efbcab6so5618690pjb.4 for ; Wed, 20 Apr 2022 11:06:46 -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=xNgxgSaf8cG296x/VWOV0Bb0OftTv/JlrbrLRCW/aGg=; b=nTAfeNHuNz4i4FKgFQ1zornoofMjWP6meJNXoMhkztlMGr2molp84K1KFWeTl+kaXz JpUl4inAP6caaRV5FqJW6zUVxaDmwfjMWXNYMF12m8bJ9oS/9f/Q3GW0pGk1rosmt2UH g8Byi0+jq0Jlh6omAmawic1xfXulx35wIx/SR3DYQf8ytP3x7UCXS/QE/KBfgrRqBYJe 6LAPBByME7GzihzSAvEcJAEa2qBlAbpOsSQC47BeT/4n9CtopPHPIiz+HClQJ9YuHtPa DOfJxfFkAFyL/9lxDH1FXdXizvHUK2j/0RIkcVzg+4nu4MpNrTFH5wZWNqr4OoLOrD82 Ssew== 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=xNgxgSaf8cG296x/VWOV0Bb0OftTv/JlrbrLRCW/aGg=; b=aF2m3XDowglChDu+JisvJ8KN7w5fPmsQDL5HzNb0qlWFy7JRwwo2OoQ1X0/zmnqJQ/ KVN7xcFh6fXqp8P4jpLMfspDnm3xcoNpy2vNG+/W0SgfaetmZeK2J6t7+zCZQRV79wYN z/Suw+vs5XpB/7i8pmjsPA/bNMpi5To727YES0zF23gPWp6YR9HH4BoU05ms96RI85ii UR826t6teHXHm+vcBT2VbmD439Ad/JUDbAAmHaU5uGSG3x+0nTtq5P1NuM8pW55WSsL7 Q1PdShD9cMh/C4ePQ+rHlXuRxpDMLKJCcQIp6urWT2jiCVCmUeEkBhfN/RSBkxBY9MUD KXmQ== X-Gm-Message-State: AOAM532bIJiWUcO6l5bx7KAnAR0cT7kqw3DrxZEO8ElD+zZ76aQal66a VQDO02bKNucztjtUHsn94EmK3dTB1MjfCw== X-Received: by 2002:a17:902:cacb:b0:158:694f:240e with SMTP id y11-20020a170902cacb00b00158694f240emr22178630pld.153.1650478006091; Wed, 20 Apr 2022 11:06:46 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 25/39] include/qemu/log: Move entire implementation out-of-line Date: Wed, 20 Apr 2022 11:06:04 -0700 Message-Id: <20220420180618.1183855-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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: =?utf-8?q?Alex_Benn=C3=A9e?= 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 Message-Id: <20220417183019.755276-26-richard.henderson@linaro.org> --- 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 87db7fe04a..7327de7b5f 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -29,6 +29,7 @@ #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)