aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-17 11:30:05 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-04-20 10:51:11 -0700
commit7fc493f8bd5b5eccf761ec9b1caa13c872e289ec (patch)
tree15af3f63d9641a1aaa982dede2533e9bae2b9c39
parentbf619eae2eed3bde9f7c003c09bf29bdcc908b08 (diff)
include/qemu/log: Move entire implementation out-of-line
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 <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-26-richard.henderson@linaro.org>
-rw-r--r--include/qemu/log.h38
-rw-r--r--tests/unit/test-logging.c1
-rw-r--r--util/log.c30
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)