Tue, 07 Feb 2023 21:37:55 +0100
fix last change of mul overflow builtin breaking non-windows compilations
now we use the generic builtin and leave the type resolution to the compiler
src/cx/common.h | file | annotate | diff | comparison | revisions | |
src/cx/utils.h | file | annotate | diff | comparison | revisions | |
test/selftest.cpp | file | annotate | diff | comparison | revisions |
--- a/src/cx/common.h Tue Feb 07 20:08:45 2023 +0100 +++ b/src/cx/common.h Tue Feb 07 21:37:55 2023 +0100 @@ -105,16 +105,11 @@ ); #ifdef _WIN32 + #ifdef __MINGW32__ #include <sys/types.h> #endif // __MINGW32__ -#ifndef __WORDSIZE -#ifdef _WIN64 -#define __WORDSIZE 64 -#else -#define __WORDSIZE 32 -#endif // _WIN64 -#endif // __WORDSIZE + #else // !_WIN32 #include <sys/types.h>
--- a/src/cx/utils.h Tue Feb 07 20:08:45 2023 +0100 +++ b/src/cx/utils.h Tue Feb 07 21:37:55 2023 +0100 @@ -56,9 +56,8 @@ #if (__GNUC__ >= 5 || defined(__clang__)) && !defined(CX_NO_SZMUL_BUILTIN) #define CX_SZMUL_BUILTIN -#if __WORDSIZE == 32 /** - * Alias for \c __builtin_umull_overflow. + * Alias for \c __builtin_mul_overflow. * * Performs a multiplication of size_t values and checks for overflow. * @@ -69,22 +68,7 @@ * @return zero, if no overflow occurred and the result is correct, non-zero * otherwise */ -#define cx_szmul(a, b, result) __builtin_umull_overflow(a, b, result) -#else // __WORDSIZE != 32 -/** - * Alias for \c __builtin_umulll_overflow. - * - * Performs a multiplication of size_t values and checks for overflow. - * - * @param a first operand - * @param b second operand - * @param result a pointer to a size_t, where the result should - * be stored - * @return zero, if no overflow occurred and the result is correct, non-zero - * otherwise - */ -#define cx_szmul(a, b, result) __builtin_umulll_overflow(a, b, result) -#endif // __WORDSIZE +#define cx_szmul(a, b, result) __builtin_mul_overflow(a, b, result) #else // no GNUC or clang bultin