You mean something like this?

best regards,
Julian

>From 0f0ab24f6579dbedf38e5bca49da023203ec2b08 Mon Sep 17 00:00:00 2001
From: TheShermanTanker <tanksherma...@gmail.com>
Date: Mon, 28 Oct 2024 14:34:27 +0800
Subject: [PATCH] headers: Add the _InterlockedCompareExchange8 intrinsic

Signed-off-by: TheShermanTanker <tanksherma...@gmail.com>
---
 mingw-w64-crt/intrincs/ilockcxch8.c              |  4 ++++
 mingw-w64-headers/include/psdk_inc/intrin-impl.h | 11 +++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 mingw-w64-crt/intrincs/ilockcxch8.c

diff --git a/mingw-w64-crt/intrincs/ilockcxch8.c
b/mingw-w64-crt/intrincs/ilockcxch8.c
new file mode 100644
index 000000000..a1c31c810
--- /dev/null
+++ b/mingw-w64-crt/intrincs/ilockcxch8.c
@@ -0,0 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchange8
+
+#include <intrin.h>
diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h
b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
index 16ccecc13..a62822a39 100644
--- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h
+++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
@@ -1619,6 +1619,17 @@ __buildlogicali(_InterlockedXor, __LONG32, xor)
 #define __INTRINSIC_DEFINED__InterlockedXor
 #endif /* __INTRINSIC_PROLOG */

+#if __INTRINSIC_PROLOG(_InterlockedCompareExchange8)
+char _InterlockedCompareExchange8(char volatile *destination, char
exchange, char comperand);
+#if !__has_builtin(_InterlockedCompareExchange8)
+__INTRINSICS_USEINLINE
+char _InterlockedCompareExchange8(char volatile *destination, char
exchange, char comperand) {
+    return __sync_val_compare_and_swap(destination, comperand, exchange);
+}
+#endif
+#define __INTRINSIC_DEFINED__InterlockedCompareExchange8
+#endif /* __INTRINSIC_PROLOG */
+
 #if __INTRINSIC_PROLOG(_InterlockedIncrement16)
 short _InterlockedIncrement16(short volatile *Addend);
 #if !__has_builtin(_InterlockedIncrement16)
-- 
2.45.2


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to