On Wed, 24 Apr 2024, LIU Hao wrote:
在 2024-04-24 00:18, Antonin Décimo 写道:
I couldn't find the difference between MemoryBarrier and _ReadWriteBarrier.
Maybe the MemoryBarrier macro is available on more architectures than
_ReadWriteBarrier which is only documented for x86 and x64?
`MemoryBarrier()` is a macro defined in 'winnt.h'. As a rule of thumb I think
we had better avoid inclusion of Windows headers in our headers, especially
headers that may be included by standard libraries.
Agreed, although it's less of a regression if we require windows headers
for pthread_cleanup_push only when built with MSVC, than making it
required for everybody, as the library wasn't usable at all with MSVC
until recently.
However, I looked at the output of _ReadWriteBarrier(), and in most cases,
it seems like this doesn't seem like something equivalent to
__sync_synchronize. In the mingw headers, it's just defined as __asm__
__volatile__ ("" ::: "memory"), i.e. something that stops the compiler
from reordering code across this point, but does nothing for synchronizing
with other threads. See e.g. https://godbolt.org/z/ccGdd7P44.
I.e., for now, I still think this patch in the shape I posted it, is the
best candidate for unbreaking this case.
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public