Message ID | 1467735496-16256-6-git-send-email-alex.bennee@linaro.org |
---|---|
State | New |
Headers | show |
diff --git a/tcg/tcg.h b/tcg/tcg.h index 66d7fc0..62e4ced 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -647,6 +647,7 @@ void tcg_pool_reset(TCGContext *s); void tcg_pool_delete(TCGContext *s); void tb_lock(void); +bool tb_lock_recursive(void); void tb_unlock(void); void tb_lock_reset(void); diff --git a/translate-all.c b/translate-all.c index 97e834a..414bc7e 100644 --- a/translate-all.c +++ b/translate-all.c @@ -134,6 +134,17 @@ void tb_lock(void) #endif } +bool tb_lock_recursive(void) +{ +#ifdef CONFIG_USER_ONLY + if (have_tb_lock) { + return false; + } + tb_lock(); +#endif + return true; +} + void tb_unlock(void) { #ifdef CONFIG_USER_ONLY
In some cases it is useful to have a recursive lock that can be safely taken when nested in other critical regions. Rather than make all tb_locks() recursive having a separate function serves to notify the reader that it explicitly a possibility in this case. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> --- tcg/tcg.h | 1 + translate-all.c | 11 +++++++++++ 2 files changed, 12 insertions(+) -- 2.7.4