Skip to content
Snippets Groups Projects
Commit 990ef918 authored by Richard Henderson's avatar Richard Henderson
Browse files

include/exec: Add WITH_MMAP_LOCK_GUARD


Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
parent 736a1588
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ void mmap_lock(void)
void mmap_unlock(void)
{
assert(mmap_lock_count > 0);
if (--mmap_lock_count == 0) {
pthread_mutex_unlock(&mmap_mutex);
}
......
......@@ -629,6 +629,15 @@ void TSA_NO_TSA mmap_lock(void);
void TSA_NO_TSA mmap_unlock(void);
bool have_mmap_lock(void);
static inline void mmap_unlock_guard(void *unused)
{
mmap_unlock();
}
#define WITH_MMAP_LOCK_GUARD() \
for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \
= (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1)
/**
* adjust_signal_pc:
* @pc: raw pc from the host signal ucontext_t.
......@@ -683,6 +692,7 @@ G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
#else
static inline void mmap_lock(void) {}
static inline void mmap_unlock(void) {}
#define WITH_MMAP_LOCK_GUARD()
void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
void tlb_set_dirty(CPUState *cpu, vaddr addr);
......
......@@ -36,6 +36,7 @@ void mmap_lock(void)
void mmap_unlock(void)
{
assert(mmap_lock_count > 0);
if (--mmap_lock_count == 0) {
pthread_mutex_unlock(&mmap_mutex);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment