54 // cx_szmul() definition |
54 // cx_szmul() definition |
55 |
55 |
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 |
|
60 /** |
59 /** |
61 * Alias for \c __builtin_umull_overflow. |
60 * Alias for \c __builtin_mul_overflow. |
62 * |
61 * |
63 * Performs a multiplication of size_t values and checks for overflow. |
62 * Performs a multiplication of size_t values and checks for overflow. |
64 * |
63 * |
65 * @param a first operand |
64 * @param a first operand |
66 * @param b second operand |
65 * @param b second operand |
67 * @param result a pointer to a size_t, where the result should |
66 * @param result a pointer to a size_t, where the result should |
68 * be stored |
67 * be stored |
69 * @return zero, if no overflow occurred and the result is correct, non-zero |
68 * @return zero, if no overflow occurred and the result is correct, non-zero |
70 * otherwise |
69 * otherwise |
71 */ |
70 */ |
72 #define cx_szmul(a, b, result) __builtin_umull_overflow(a, b, result) |
71 #define cx_szmul(a, b, result) __builtin_mul_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 |
|
88 |
72 |
89 #else // no GNUC or clang bultin |
73 #else // no GNUC or clang bultin |
90 |
74 |
91 /** |
75 /** |
92 * Performs a multiplication of size_t values and checks for overflow. |
76 * Performs a multiplication of size_t values and checks for overflow. |