[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 25/39] include/qemu/log: Move entire implementation out-of-lin
From: |
Richard Henderson |
Subject: |
[PATCH v2 25/39] include/qemu/log: Move entire implementation out-of-line |
Date: |
Sat, 26 Mar 2022 07:25:20 -0600 |
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 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)
--
2.25.1
- [PATCH v2 07/39] util/log: Rename qemu_log_lock to qemu_log_trylock, (continued)
- [PATCH v2 07/39] util/log: Rename qemu_log_lock to qemu_log_trylock, Richard Henderson, 2022/03/26
- [PATCH v2 08/39] hw/xen: Split out xen_pv_output_msg, Richard Henderson, 2022/03/26
- [PATCH v2 8/8] tests/tcg/nios2: Re-enable linux-user tests, Richard Henderson, 2022/03/26
- [PATCH v2 10/39] util/log: Remove qemu_log_vprintf, Richard Henderson, 2022/03/26
- [PATCH v2 09/39] *: Use fprintf between qemu_log_trylock/unlock, Richard Henderson, 2022/03/26
- [PATCH v2 11/39] tcg: Pass the locked filepointer to tcg_dump_ops, Richard Henderson, 2022/03/26
- [PATCH v2 13/39] exec/log: Remove log_disas and log_target_disas, Richard Henderson, 2022/03/26
- [PATCH v2 12/39] exec/translator: Pass the locked filepointer to disas_log hook, Richard Henderson, 2022/03/26
- [PATCH v2 19/39] util/log: Remove qemu_log_flush, Richard Henderson, 2022/03/26
- [PATCH v2 16/39] util/log: Use qemu_log_trylock/unlock in qemu_log, Richard Henderson, 2022/03/26
- [PATCH v2 25/39] include/qemu/log: Move entire implementation out-of-line,
Richard Henderson <=
- [PATCH v2 24/39] include/exec/log: Do not reference QemuLogFile directly, Richard Henderson, 2022/03/26
- [PATCH v2 15/39] target/nios2: Remove log_cpu_state from reset, Richard Henderson, 2022/03/26
- [PATCH v2 20/39] util/log: Drop call to setvbuf, Richard Henderson, 2022/03/26
- [PATCH v2 26/39] sysemu/os-win32: Test for and use _lock_file/_unlock_file, Richard Henderson, 2022/03/26
- [PATCH v2 28/39] bsd-user: Use qemu_set_log_filename_flags, Richard Henderson, 2022/03/26
- [PATCH v2 14/39] accel/tcg: Use cpu_dump_state between qemu_log_trylock/unlock, Richard Henderson, 2022/03/26
- [PATCH v2 31/39] util/log: Remove qemu_log_close, Richard Henderson, 2022/03/26
- [PATCH v2 30/39] softmmu: Use qemu_set_log_filename_flags, Richard Henderson, 2022/03/26
- [PATCH v2 29/39] linux-user: Use qemu_set_log_filename_flags, Richard Henderson, 2022/03/26
- [PATCH v2 18/39] util/log: Mark qemu_log_trylock as G_GNUC_WARN_UNUSED_RESULT, Richard Henderson, 2022/03/26