On Sat, 22 Jul 2023 at 12:35, Richard Henderson
<richard.hender...@linaro.org> wrote:
>
> Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
> ---
>  include/exec/exec-all.h | 10 ++++++++++
>  bsd-user/mmap.c         |  1 +
>  linux-user/mmap.c       |  1 +
>  3 files changed, 12 insertions(+)
>
> diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
> index 5fa0687cd2..d02517e95f 100644
> --- a/include/exec/exec-all.h
> +++ b/include/exec/exec-all.h
> @@ -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)

All our other WITH_FOO macros seem to use g_autoptr rather than
a raw attribute((cleanup)); is it worth being consistent?
(This one also doesn't allow nested uses, I think.)

Either way
Reviewed-by: Peter Maydell <peter.mayd...@linaro.org>

since it would be nice to fix this for the next rc.

thanks
-- PMM

Reply via email to