Hi all,

This patch adds the Microsoft _InterlockedCompareExchange8 intrinsic
that was missing from mingw-w64. This is required for HotSpot to
compile successfully. I know that this intrinsic was absent from
intrin.h as well, and the guidelines say that if it is not present in
intrin.h then it should not be in intrin-impl.h, but as this is indeed
an intrinsic from the Microsoft compiler that is genuinely missing, I
decided to go forward with it anyway. Note that I do not know whether
this is the correct way to introduce a new intrinsic to the headers,
if it isn't, feel free to correct me on how to do it

best regards,
Julian

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

Signed-off-by: TheShermanTanker <tanksherma...@gmail.com>
---
 mingw-w64-headers/include/psdk_inc/intrin-impl.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

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