MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxBigInt_uadd_prim

Function fxBigInt_uadd_prim

xs/sources/xsBigInt.c:1412–1445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1410
1411#if __has_builtin(__builtin_add_overflow)
1412static int fxBigInt_uadd_prim(txU4 *rp, txU4 *ap, txU4 *bp, int an, int bn)
1413{
1414 txU4 c = 0;
1415 int i;
1416
1417 for (i = 0; i < an; i++) {
1418#ifdef __ets__
1419 unsigned int r;
1420 if (__builtin_uadd_overflow(ap[i], bp[i], &r)) {
1421 rp[i] = r + c;
1422 c = 1;
1423 }
1424 else {
1425 unsigned int t;
1426 c = __builtin_uadd_overflow(r, c, &t);
1427 rp[i] = t;
1428 }
1429#else
1430 unsigned int r = rp[i];
1431 c = __builtin_uadd_overflow(ap[i], bp[i], &r) | (txU4)__builtin_uadd_overflow(r, c, &r);
1432 rp[i] = r;
1433#endif
1434 }
1435 for (; c && (i < bn); i++) { {
1436 unsigned int t;
1437 c = __builtin_uadd_overflow(1, bp[i], &t);
1438 rp[i] = t;
1439 }
1440 }
1441 for (; i < bn; i++) {
1442 rp[i] = bp[i];
1443 }
1444 return(c);
1445}
1446#else
1447static int fxBigInt_uadd_prim(txU4 *rp, txU4 *ap, txU4 *bp, int an, int bn)
1448{

Callers 1

fxBigInt_uaddFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected