From c59fe6e536adfb2d6f3410f19d592496933f68de Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sun, 17 Apr 2022 11:29:46 -0700 Subject: util/log: Move qemu_log_lock, qemu_log_unlock out of line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-7-richard.henderson@linaro.org> --- util/log.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'util/log.c') 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, ...) { -- cgit v1.1