Previously, these caused errors when compiled as C++:
In file included from test1.cpp:1:C:/MSYS64/ucrt64/include/ddk/wdm.h:205:1: error: 'BOOLEAN InterlockedBitTestAndSet(volatile LONG*, LONG)' redeclared inline without 'gnu_inline' attribute
205 | InterlockedBitTestAndSet( | ^~~~~~~~~~~~~~~~~~~~~~~~ In file included from C:/MSYS64/ucrt64/include/intrin.h:41, from C:/MSYS64/ucrt64/include/ddk/wdm.h:68:C:/MSYS64/ucrt64/include/psdk_inc/intrin-impl.h:1850:1: note: 'unsigned char InterlockedBitTestAndSet(volatile long int*, long int)' previously defined here 1850 | __buildbittesti(InterlockedBitTestAndSet, __LONG32, "lock bts{l %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "I")
| ^~~~~~~~~~~~~~~C:/MSYS64/ucrt64/include/ddk/wdm.h:224:1: error: 'BOOLEAN InterlockedBitTestAndReset(volatile LONG*, LONG)' redeclared inline without 'gnu_inline' attribute
224 | InterlockedBitTestAndReset( | ^~~~~~~~~~~~~~~~~~~~~~~~~~C:/MSYS64/ucrt64/include/psdk_inc/intrin-impl.h:1859:1: note: 'unsigned char InterlockedBitTestAndReset(volatile long int*, long int)' previously defined here 1859 | __buildbittesti(InterlockedBitTestAndReset, __LONG32, "lock btr{l %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "I")
| ^~~~~~~~~~~~~~~ When compiled as C, the static definitions were treated as external ones and caused linker errors instead. This fixes https://github.com/mingw-w64/mingw-w64/issues/111. Signed-off-by: LIU Hao <lh_mo...@126.com> --- mingw-w64-headers/ddk/include/ddk/wdm.h | 45 ------------------------- 1 file changed, 45 deletions(-) diff --git a/mingw-w64-headers/ddk/include/ddk/wdm.h b/mingw-w64-headers/ddk/include/ddk/wdm.h index c2c547730..5548e4732 100644 --- a/mingw-w64-headers/ddk/include/ddk/wdm.h +++ b/mingw-w64-headers/ddk/include/ddk/wdm.h @@ -195,51 +195,6 @@ inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) /****************************************************************************** * INTERLOCKED Functions * ******************************************************************************/ -// -// Intrinsics (note: taken from our winnt.h) -// FIXME: 64-bit -// -#if defined(__GNUC__) - -static __inline__ BOOLEAN -InterlockedBitTestAndSet( - IN LONG volatile *Base, - IN LONG Bit) -{ -#if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btsl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; -#else - return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; -#endif -} - -static __inline__ BOOLEAN -InterlockedBitTestAndReset( - IN LONG volatile *Base, - IN LONG Bit) -{ -#if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btrl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; -#else - return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; -#endif -} - -#endif /* defined(__GNUC__) */ #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse -- 2.50.1
From 1b94268f113cb68c3213f6766a1aab5cd9777589 Mon Sep 17 00:00:00 2001 From: LIU Hao <lh_mo...@126.com> Date: Mon, 4 Aug 2025 11:44:15 +0800 Subject: [PATCH] headers/wdm: Remove local definitions of `InterlockedBitTestAndSet()` and `InterlockedBitTestAndReset()` Previously, these caused errors when compiled as C++: In file included from test1.cpp:1: C:/MSYS64/ucrt64/include/ddk/wdm.h:205:1: error: 'BOOLEAN InterlockedBitTestAndSet(volatile LONG*, LONG)' redeclared inline without 'gnu_inline' attribute 205 | InterlockedBitTestAndSet( | ^~~~~~~~~~~~~~~~~~~~~~~~ In file included from C:/MSYS64/ucrt64/include/intrin.h:41, from C:/MSYS64/ucrt64/include/ddk/wdm.h:68: C:/MSYS64/ucrt64/include/psdk_inc/intrin-impl.h:1850:1: note: 'unsigned char InterlockedBitTestAndSet(volatile long int*, long int)' previously defined here 1850 | __buildbittesti(InterlockedBitTestAndSet, __LONG32, "lock bts{l %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "I") | ^~~~~~~~~~~~~~~ C:/MSYS64/ucrt64/include/ddk/wdm.h:224:1: error: 'BOOLEAN InterlockedBitTestAndReset(volatile LONG*, LONG)' redeclared inline without 'gnu_inline' attribute 224 | InterlockedBitTestAndReset( | ^~~~~~~~~~~~~~~~~~~~~~~~~~ C:/MSYS64/ucrt64/include/psdk_inc/intrin-impl.h:1859:1: note: 'unsigned char InterlockedBitTestAndReset(volatile long int*, long int)' previously defined here 1859 | __buildbittesti(InterlockedBitTestAndReset, __LONG32, "lock btr{l %[Offset],%[Base] | %[Base],%[Offset]}" __FLAGSET, "I") | ^~~~~~~~~~~~~~~ When compiled as C, the static definitions were treated as external ones and caused linker errors instead. This fixes https://github.com/mingw-w64/mingw-w64/issues/111. Signed-off-by: LIU Hao <lh_mo...@126.com> --- mingw-w64-headers/ddk/include/ddk/wdm.h | 45 ------------------------- 1 file changed, 45 deletions(-) diff --git a/mingw-w64-headers/ddk/include/ddk/wdm.h b/mingw-w64-headers/ddk/include/ddk/wdm.h index c2c547730..5548e4732 100644 --- a/mingw-w64-headers/ddk/include/ddk/wdm.h +++ b/mingw-w64-headers/ddk/include/ddk/wdm.h @@ -195,51 +195,6 @@ inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) /****************************************************************************** * INTERLOCKED Functions * ******************************************************************************/ -// -// Intrinsics (note: taken from our winnt.h) -// FIXME: 64-bit -// -#if defined(__GNUC__) - -static __inline__ BOOLEAN -InterlockedBitTestAndSet( - IN LONG volatile *Base, - IN LONG Bit) -{ -#if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btsl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; -#else - return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; -#endif -} - -static __inline__ BOOLEAN -InterlockedBitTestAndReset( - IN LONG volatile *Base, - IN LONG Bit) -{ -#if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btrl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; -#else - return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; -#endif -} - -#endif /* defined(__GNUC__) */ #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse -- 2.50.1
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public