diff -r 8628147734d6 -r 362679052788 src/ucx/ucx.h
--- a/src/ucx/ucx.h Mon May 14 12:54:37 2018 +0200
+++ b/src/ucx/ucx.h Mon May 14 13:13:36 2018 +0200
@@ -135,9 +135,54 @@
#if defined(__GNUC__) || defined(__clang__)
#define UCX_MUL_BUILTIN
+
+#if __WORDSIZE == 32
+/**
+ * Alias for __builtin_umul_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 ucx_szmul(a, b, result) __builtin_umul_overflow(a, b, result)
+#else /* __WORDSIZE != 32 */
+/**
+ * Alias for __builtin_umull_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 ucx_szmul(a, b, result) __builtin_umull_overflow(a, b, result)
-#else
+#endif /* __WORDSIZE */
+
+#else /* no GNUC or clang bultin */
+
+/**
+ * Performs a multiplication of size_t values and checks for overflow.
+ *
+ * This is a custom implementation in case there is no compiler builtin
+ * available.
+ *
+ * @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
+ */
int ucx_szmul(size_t a, size_t b, size_t *result);
+
#endif
#ifdef __cplusplus