[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL for-7.1 22/36] include/qemu/log: Move entire implementation out-of
From: |
Richard Henderson |
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 |
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 <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 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)
--
2.25.1
- Re: [PULL for-7.1 30/36] util/log: Rename qemu_logfile to global_file, (continued)
- [PULL for-7.1 09/36] util/log: Remove qemu_log_vprintf, Richard Henderson, 2022/03/20
- [PULL for-7.1 10/36] tcg: Pass the locked filepointer to tcg_dump_ops, Richard Henderson, 2022/03/20
- [PULL for-7.1 13/36] accel/tcg: Use cpu_dump_state between qemu_log_lock/unlock, Richard Henderson, 2022/03/20
- [PULL for-7.1 12/36] exec/log: Remove log_disas and log_target_disas, Richard Henderson, 2022/03/20
- [PULL for-7.1 15/36] util/log: Use qemu_log_lock/unlock in qemu_log, Richard Henderson, 2022/03/20
- [PULL for-7.1 18/36] bsd-user: Expand log_page_dump inline, Richard Henderson, 2022/03/20
- [PULL for-7.1 19/36] linux-user: Expand log_page_dump inline, Richard Henderson, 2022/03/20
- [PULL for-7.1 17/36] util/log: Drop call to setvbuf, Richard Henderson, 2022/03/20
- [PULL for-7.1 21/36] include/exec/log: Do not reference QemuLogFile directly, Richard Henderson, 2022/03/20
- [PULL for-7.1 22/36] include/qemu/log: Move entire implementation out-of-line,
Richard Henderson <=
- [PULL for-7.1 24/36] util/log: Introduce qemu_set_log_filename_flags, Richard Henderson, 2022/03/20
- [PULL for-7.1 23/36] sysemu/os-win32: Test for and use _lock_file/_unlock_file, Richard Henderson, 2022/03/20
- [PULL for-7.1 26/36] linux-user: Use qemu_set_log_filename_flags, Richard Henderson, 2022/03/20
- [PULL for-7.1 27/36] softmmu: Use qemu_set_log_filename_flags, Richard Henderson, 2022/03/20
- [PULL for-7.1 28/36] util/log: Remove qemu_log_close, Richard Henderson, 2022/03/20
- [PULL for-7.1 31/36] util/log: Rename qemu_logfile_mutex to global_mutex, Richard Henderson, 2022/03/20
- [PULL for-7.1 33/36] util/log: Combine two logfile closes, Richard Henderson, 2022/03/20
- [PULL for-7.1 35/36] util/log: Limit RCUCloseFILE to file closing, Richard Henderson, 2022/03/20
- [PULL for-7.1 32/36] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal, Richard Henderson, 2022/03/20