src/ucx.c

changeset 270
3d80d425543b
parent 263
3ff0abc49ed5
child 273
9c1591b3c4a4
     1.1 --- a/src/ucx.c	Tue Jan 02 17:00:21 2018 +0100
     1.2 +++ b/src/ucx.c	Sun Jan 21 10:13:21 2018 +0100
     1.3 @@ -44,3 +44,20 @@
     1.4   */
     1.5  
     1.6  #include "ucx/ucx.h"
     1.7 +
     1.8 +#ifndef UCX_MUL_BUILTIN
     1.9 +int ucx_szmul(size_t a, size_t b, size_t *result) {
    1.10 +    if(a == 0 || b == 0) {
    1.11 +        *result = 0;
    1.12 +        return 1;
    1.13 +    }
    1.14 +    size_t r = a * b;
    1.15 +    if(r / b == a) {
    1.16 +        *result = r;
    1.17 +        return 0;
    1.18 +    } else {
    1.19 +        *result = 0;
    1.20 +        return 1;
    1.21 +    }
    1.22 +}
    1.23 +#endif

mercurial