As of a few days ago, clang supports the builtins we use in intsafe.h. However, clang still defines __GNUC__ as 4 and I don't know how long it's going to be like that. So this patch adds special code to detect clang and detect if clang supports the builtins we need, allowing the inline functions in intsafe.h to be used from clang.
I'm only checking __builtin_add_overflow and not __builtin_mul_overflow or __builting_sub_overflow because all three of those functions were added in one clang commit. I tested this patch with GCC 5 in Windows. I tested the new logic from the patch (but not the intsafe.h itself) with GCC 5 in Linux, and two different versions of clang in Linux, one that supports the new builtins and one that does not. If someone could commit this, that would be great! Thanks! --David Grayson
--- a/mingw-w64-headers/include/intsafe.h +++ b/mingw-w64-headers/include/intsafe.h @@ -20,8 +20,15 @@ #define S_OK ((HRESULT)0) #endif -/** The builtins we use were added in GCC 5. */ -#if __GNUC__ >= 5 +#ifdef __clang__ +#if __has_builtin(__builtin_add_overflow) +#define __MINGW_INTSAFE_WORKS +#endif +#elif __GNUC__ >= 5 +#define __MINGW_INTSAFE_WORKS +#endif + +#ifdef __MINGW_INTSAFE_WORKS #ifndef __MINGW_INTSAFE_API #define __MINGW_INTSAFE_API FORCEINLINE
------------------------------------------------------------------------------
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
