Message ID | 20250113134658.68376-3-iii@linux.ibm.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | gdbstub: Protect gdb_handlesig() with EXCLUSIVE_GUARD() | expand |
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c3ca0babcb3..a7d9d6e2b8c 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1063,6 +1063,17 @@ void start_exclusive(void); */ void end_exclusive(void); +static inline void exclusive_unlock_guard(int *exclusive_guard G_GNUC_UNUSED) +{ + end_exclusive(); +} + +#define EXCLUSIVE_GUARD() \ + int glue(exclusive_guard, __COUNTER__) \ + G_GNUC_UNUSED \ + __attribute__((cleanup(exclusive_unlock_guard))) = \ + (start_exclusive(), 0); + /** * qemu_init_vcpu: * @cpu: The vCPU to initialize.
Add a macro that produces a start_exclusive() / end_exclusive() pair. Useful to guarantee an exit from an exclusive section in large functions. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> --- include/hw/core/cpu.h | 11 +++++++++++ 1 file changed, 11 insertions(+)