]> Git Repo - qemu.git/commit
coroutine-win32: use QEMU_DEFINE_STATIC_CO_TLS()
authorStefan Hajnoczi <[email protected]>
Mon, 7 Mar 2022 15:38:53 +0000 (15:38 +0000)
committerKevin Wolf <[email protected]>
Wed, 4 May 2022 13:55:23 +0000 (15:55 +0200)
commitc1fe694357a328c807ae3cc6961c19e923448fcc
tree8bc95bda5b352fad43f89fd9b2e98358ec02db16
parentac387a08a9c9f6b36757da912f0339c25f421f90
coroutine-win32: use QEMU_DEFINE_STATIC_CO_TLS()

Thread-Local Storage variables cannot be used directly from coroutine
code because the compiler may optimize TLS variable accesses across
qemu_coroutine_yield() calls. When the coroutine is re-entered from
another thread the TLS variables from the old thread must no longer be
used.

Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.

I think coroutine-win32.c could get away with __thread because the
variables are only used in situations where either the stale value is
correct (current) or outside coroutine context (loading leader when
current is NULL). Due to the difficulty of being sure that this is
really safe in all scenarios it seems worth converting it anyway.

Signed-off-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20220307153853[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
util/coroutine-win32.c
This page took 0.026317 seconds and 4 git commands to generate.