mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
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>
This commit is contained in:
parent
229ef2eb44
commit
c59fe6e536
2 changed files with 26 additions and 25 deletions
23
util/log.c
23
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, ...)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue