this issue seems t be related to a bug fixed for gcc' trunk and for
the 4.8 branch.
Could you test more recent version to see if issue remains?
Umm. Hmm. Ok, well, the compiler now does (silently) pick one of the
two defined implementations and uses it consistently. I'd be interested
to know exactly what the rule is here for what it picks.
In the meantime, there's the question of what we do now. Jacek's patch
still gives errors under certain circumstances. How about something
like this (attached)? Note that WINBASEAPI is just dllimport.
This gets us back to always_inline if we can use inlines, and uses
dllimport as a fallback.
dw
Index: mingw-w64-headers/include/winbase.h
===================================================================
--- mingw-w64-headers/include/winbase.h (revision 5955)
+++ mingw-w64-headers/include/winbase.h (working copy)
@@ -995,6 +995,14 @@
#else /* not ia64, nor x64. */
+ /* While MS resolves these from kernel32.dll, we are mapping them to
intrinsics. If we can. */
+
+ /* GCC in version <= 4.8.1 can't inline functions that have dllimport
attribute. This may cause an error in
+ * combination with always_inline. Even if we don't explicitly use dllimport,
some users have their own
+ * declarations. If the compiler supports it, we'll use the always_inline
(for best performance), otherwise
+ * we'll use the DLLIMPORT (for max compatibility). */
+#if !defined(__GNUC__) || __MINGW_GNUC_PREREQ(4, 9) || (__MINGW_GNUC_PREREQ(4,
8) && __GNUC_PATCHLEVEL__ >= 2)
+
LONG WINAPI InterlockedIncrement(LONG volatile *lpAddend);
LONG WINAPI InterlockedDecrement(LONG volatile *lpAddend);
LONG WINAPI InterlockedExchange(LONG volatile *Target,LONG Value);
@@ -1002,9 +1010,6 @@
LONG WINAPI InterlockedCompareExchange(LONG volatile *Destination,LONG
Exchange,LONG Comperand);
LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile
*Destination,LONGLONG Exchange,LONGLONG Comperand);
-
- /* While MS resolves these from kernel32.dll, we are mapping them to
intrinsics. */
-#ifdef __MINGW_INTRIN_INLINE
__MINGW_INTRIN_INLINE LONG WINAPI InterlockedIncrement(LONG volatile
*lpAddend) {
return _InterlockedIncrement(lpAddend);
}
@@ -1023,8 +1028,18 @@
__MINGW_INTRIN_INLINE LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG
volatile *Destination, LONGLONG Exchange, LONGLONG Comperand) {
return _InterlockedCompareExchange64(Destination, Exchange, Comperand);
}
-#endif /* __MINGW_INTRIN_INLINE */
+#else
+
+ WINBASEAPI LONG WINAPI InterlockedIncrement(LONG volatile *lpAddend);
+ WINBASEAPI LONG WINAPI InterlockedDecrement(LONG volatile *lpAddend);
+ WINBASEAPI LONG WINAPI InterlockedExchange(LONG volatile *Target,LONG Value);
+ WINBASEAPI LONG WINAPI InterlockedExchangeAdd(LONG volatile *Addend,LONG
Value);
+ WINBASEAPI LONG WINAPI InterlockedCompareExchange(LONG volatile
*Destination,LONG Exchange,LONG Comperand);
+ WINBASEAPI LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile
*Destination,LONGLONG Exchange,LONGLONG Comperand);
+
+#endif
+
#define InterlockedExchangePointer(Target,Value)
(PVOID)InterlockedExchange((PLONG)(Target),(LONG)(Value))
/* While MS resolves these 3 from kernel32.dll, we are mapping them
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public