I can confirm that with GCC 4.9. In cause of our headers, it always
chooses inline version, which is good.
That is the best possible outcome. For this particular situation. But
it's possible that's not always the case.
What with normal implementations, inline implementations, dllimport
implementations, weak attribute, etc, I'm not sure I know which one the
compiler may pick for any given symbol. I'm hoping there's some sort of
precedence list.
Why don't you add WINBASEAPI to GCC version independent declaration
You mean something more like this (attached)?
add version guard only to the part that currently checks
__CRT__NO_INLINE to avoid duplication?
I'm not sure we are looking at the same code. Since I'm using
__MINGW_INTRIN_INLINE (which is what is currently checked in), I don't
have a check for __CRT__NO_INLINE. In fact, I removed the check for
__MINGW_INTRIN_INLINE. If that's important, then intrin-impl.h needs to
be updated as well.
I'd hope for better fallback on older (well, all currently released) GCC
versions, but I'm out of ideas now.
Between the gcc bug and people copying prototypes locally, there was
only so much we could do.
dw
Index: mingw-w64-headers/include/winbase.h
===================================================================
--- mingw-w64-headers/include/winbase.h (revision 5962)
+++ mingw-w64-headers/include/winbase.h (working copy)
@@ -995,16 +995,20 @@
#else /* not ia64, nor x64. */
- LONG WINAPI InterlockedIncrement(LONG volatile *lpAddend);
- LONG WINAPI InterlockedDecrement(LONG volatile *lpAddend);
- LONG WINAPI InterlockedExchange(LONG volatile *Target,LONG Value);
- LONG WINAPI InterlockedExchangeAdd(LONG volatile *Addend,LONG Value);
- 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. If we can. */
+ 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);
+ /* 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)
- /* 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 +1027,9 @@
__MINGW_INTRIN_INLINE LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG
volatile *Destination, LONGLONG Exchange, LONGLONG Comperand) {
return _InterlockedCompareExchange64(Destination, Exchange, Comperand);
}
-#endif /* __MINGW_INTRIN_INLINE */
+#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
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public