On Mon, 18 Jan 2021, Zebediah Figura (she/her) wrote:

On 1/17/21 2:05 PM, Martin Storsjö wrote:
Signed-off-by: Martin Storsjö <[email protected]>
---
Added memory clobbers for MemoryBarrier().
---
 mingw-w64-headers/crt/_mingw.h.in | 8 ++++++++
 mingw-w64-headers/include/winnt.h | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/mingw-w64-headers/crt/_mingw.h.in 
b/mingw-w64-headers/crt/_mingw.h.in
index 01eff66fa..25513d7da 100644
--- a/mingw-w64-headers/crt/_mingw.h.in
+++ b/mingw-w64-headers/crt/_mingw.h.in
@@ -580,7 +580,15 @@ extern "C" {
 void __cdecl __debugbreak(void);
 __MINGW_INTRIN_INLINE void __cdecl __debugbreak(void)
 {
+#if defined(__i386__) || defined(__x86_64__)
   __asm__ __volatile__("int {$}3":);
+#elif defined(__arm__)
+  __asm__ __volatile__("udf #1");
+#elif defined(__aarch64__)
+  __asm__ __volatile__("brk #0xf000");
+#else
+  __asm__ __volatile__("unimplemented");
+#endif
 }
 #endif
 #endif
diff --git a/mingw-w64-headers/include/winnt.h 
b/mingw-w64-headers/include/winnt.h
index 0decf495a..558423745 100644
--- 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":::"memory")
+
 #ifdef __cplusplus
   }
 #endif
@@ -2055,6 +2058,9 @@ extern "C" {
 #define InterlockedCompareExchangePointerAcquire 
_InterlockedCompareExchangePointer
 #define InterlockedCompareExchangePointerRelease 
_InterlockedCompareExchangePointer

+#define YieldProcessor() __asm__ __volatile__("dmb ishst\n\tyield")
+#define MemoryBarrier() __asm__ __volatile__("dmb sy":::"memory")
+
 #ifdef __cplusplus
   }
 #endif


Should YieldProcessor() have a compiler barrier? Unfortunately I can't
seem to find any reference as to whether it should, and I don't have
Visual Studio to test with.

I have Visual Studio - how do you suggest to investigate it?

// Martin

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

Reply via email to