aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-17 11:29:46 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-04-20 10:51:11 -0700
commitc59fe6e536adfb2d6f3410f19d592496933f68de (patch)
tree100fa4637d6a8ae317e0bc8ca6cb1cd14632c1cf /util
parent229ef2eb440d92df1bb663b45e57c3e3008aae13 (diff)
downloadqemu-c59fe6e536adfb2d6f3410f19d592496933f68de.zip
qemu-c59fe6e536adfb2d6f3410f19d592496933f68de.tar.gz
qemu-c59fe6e536adfb2d6f3410f19d592496933f68de.tar.bz2
util/log: Move qemu_log_lock, qemu_log_unlock out of line
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-7-richard.henderson@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/log.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/util/log.c b/util/log.c
index bab4d29..1a31216 100644
--- a/util/log.c
+++ b/util/log.c
@@ -34,6 +34,29 @@ int qemu_loglevel;
static int log_append = 0;
static GArray *debug_regions;
+/* Lock/unlock output. */
+
+FILE *qemu_log_lock(void)
+{
+ QemuLogFile *logfile;
+ rcu_read_lock();
+ logfile = qatomic_rcu_read(&qemu_logfile);
+ if (logfile) {
+ qemu_flockfile(logfile->fd);
+ return logfile->fd;
+ } else {
+ return NULL;
+ }
+}
+
+void qemu_log_unlock(FILE *fd)
+{
+ if (fd) {
+ qemu_funlockfile(fd);
+ }
+ rcu_read_unlock();
+}
+
/* Return the number of characters emitted. */
int qemu_log(const char *fmt, ...)
{