Hi,

On Thu, 14 Jan 2021, Liu Hao wrote:

在 2021/1/14 上午5:14, Martin Storsjö 写道:

--- a/mingw-w64-headers/crt/_mingw.h.in
+++ b/mingw-w64-headers/crt/_mingw.h.in
(...)
+  __asm__ __volatile__("unimplemented");

I suggest an `#error` here so the error could be caught earlier.

I kind of intentionally didn't want to do that. For other/new architectures where everything isn't hooked up yet, it's mostly fine to just fix up a few cases, until one actually ends up trying to call __debugbreak().

But if others also would prefer an #error, I won't resist.


--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -1846,6 +1846,9 @@ extern "C" {
 #define InterlockedCompareExchangePointerAcquire 
_InterlockedCompareExchangePointer
 #define InterlockedCompareExchangePointerRelease 
_InterlockedCompareExchangePointer

+#define YieldProcessor() __asm__ __volatile__("dmb ishst\n\tyield")
+#define MemoryBarrier() __asm__ __volatile__("dmb")
+

The asm statement in `MemoryBarrier()` has no constraints, so the compiler is 
free to reorder
loads/stores with it, which nullifies the effect of a barrier.

In order to prevent this, it is necessary to clobber memory explicitly like 
this:

  __asm__ __volatile__ ("dmb":::"memory")

Ah, good catch, thanks. I presume it's good to have that in the YieldProcessor() bit as well - as that one also is free of any other constraints.

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to