Attached is the newer version of the patch

best regards,
Julian

From a0a58231f556694954f424a071205e5ed24ea2f7 Mon Sep 17 00:00:00 2001
From: TheShermanTanker <[email protected]>
Date: Mon, 28 Oct 2024 14:34:27 +0800
Subject: [PATCH] headers: Add the _InterlockedCompareExchange8 intrinsic

Signed-off-by: TheShermanTanker <[email protected]>
---
 mingw-w64-crt/Makefile.am                        |  2 +-
 mingw-w64-crt/intrincs/ilockcxch8.c              |  4 ++++
 mingw-w64-headers/include/psdk_inc/intrin-impl.h | 11 +++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 mingw-w64-crt/intrincs/ilockcxch8.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index b5e23e084..f223da353 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -1157,7 +1157,7 @@ src_intrincs= \
   intrincs/bittest.c        intrincs/bittestc.c
intrincs/bittestci.c       intrincs/bittestr.c
intrincs/bittestri.c      \
   intrincs/bittests.c       intrincs/bittestsi.c
intrincs/cpuid.c           \
   intrincs/ilockadd.c       intrincs/ilockand.c        intrincs/ilockand64.c \
-  intrincs/ilockcxch.c      \
+  intrincs/ilockcxch.c      intrincs/ilockcxch8.c     \
   intrincs/ilockcxch16.c    intrincs/ilockcxch64.c
intrincs/ilockcxchptr.c    intrincs/ilockdec.c
intrincs/ilockdec16.c     \
   intrincs/ilockdec64.c     intrincs/ilockexch.c
intrincs/ilockexch64.c     intrincs/ilockexchadd.c
intrincs/ilockexchadd64.c \
   intrincs/ilockexchptr.c   intrincs/ilockinc.c
intrincs/ilockinc16.c      intrincs/ilockinc64.c    intrincs/ilockor.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

On Tue, Oct 29, 2024 at 5:31 PM LIU Hao <[email protected]> wrote:
>
> 在 2024-10-29 17:20, Julian Waters 写道:
> > You mean something like this?
> >
> > best regards,
> > Julian
> >
> >  From 0f0ab24f6579dbedf38e5bca49da023203ec2b08 Mon Sep 17 00:00:00 2001
> > From: TheShermanTanker<[email protected]>
> > Date: Mon, 28 Oct 2024 14:34:27 +0800
> > Subject: [PATCH] headers: Add the _InterlockedCompareExchange8 intrinsic
> >
> > Signed-off-by: TheShermanTanker<[email protected]>
> > ---
> >   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
> >
>
> This part is mostly correct. However you missed Makefile.am; the file 
> 'ilockcxch8.c' won't be
> compiled. It should be committed.
>
> If you mean to build mingw-w64-crt yourself, you should regenerate 
> Makefile.in from Makefile.am.
> Just don't commit Makefile.in.
>
>
>
> --
> Best regards,
> LIU Hao


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

Reply via email to