56 #if (__GNUC__ >= 5 || defined(__clang__)) && !defined(CX_NO_SZMUL_BUILTIN) |
56 #if (__GNUC__ >= 5 || defined(__clang__)) && !defined(CX_NO_SZMUL_BUILTIN) |
57 #define CX_SZMUL_BUILTIN |
57 #define CX_SZMUL_BUILTIN |
58 |
58 |
59 #if __WORDSIZE == 32 |
59 #if __WORDSIZE == 32 |
60 /** |
60 /** |
61 * Alias for \c __builtin_umul_overflow. |
|
62 * |
|
63 * Performs a multiplication of size_t values and checks for overflow. |
|
64 * |
|
65 * @param a first operand |
|
66 * @param b second operand |
|
67 * @param result a pointer to a size_t, where the result should |
|
68 * be stored |
|
69 * @return zero, if no overflow occurred and the result is correct, non-zero |
|
70 * otherwise |
|
71 */ |
|
72 #define cx_szmul(a, b, result) __builtin_umul_overflow(a, b, result) |
|
73 #else // __WORDSIZE != 32 |
|
74 /** |
|
75 * Alias for \c __builtin_umull_overflow. |
61 * Alias for \c __builtin_umull_overflow. |
76 * |
62 * |
77 * Performs a multiplication of size_t values and checks for overflow. |
63 * Performs a multiplication of size_t values and checks for overflow. |
78 * |
64 * |
79 * @param a first operand |
65 * @param a first operand |
82 * be stored |
68 * be stored |
83 * @return zero, if no overflow occurred and the result is correct, non-zero |
69 * @return zero, if no overflow occurred and the result is correct, non-zero |
84 * otherwise |
70 * otherwise |
85 */ |
71 */ |
86 #define cx_szmul(a, b, result) __builtin_umull_overflow(a, b, result) |
72 #define cx_szmul(a, b, result) __builtin_umull_overflow(a, b, result) |
|
73 #else // __WORDSIZE != 32 |
|
74 /** |
|
75 * Alias for \c __builtin_umulll_overflow. |
|
76 * |
|
77 * Performs a multiplication of size_t values and checks for overflow. |
|
78 * |
|
79 * @param a first operand |
|
80 * @param b second operand |
|
81 * @param result a pointer to a size_t, where the result should |
|
82 * be stored |
|
83 * @return zero, if no overflow occurred and the result is correct, non-zero |
|
84 * otherwise |
|
85 */ |
|
86 #define cx_szmul(a, b, result) __builtin_umulll_overflow(a, b, result) |
87 #endif // __WORDSIZE |
87 #endif // __WORDSIZE |
88 |
88 |
89 #else // no GNUC or clang bultin |
89 #else // no GNUC or clang bultin |
90 |
90 |
91 /** |
91 /** |