pike.git/
src/
operators.c
Branch:
Tag:
Non-build tags
All tags
No tags
2014-12-04
2014-12-04 19:23:04 by Arne Goedeke <el@laramies.com>
42d0cd177da87e9ba4e812ef6ffe90a500dd41e3 (
38
lines) (+
23
/-
15
)
[
Show
|
Annotate
]
Branch:
bill/master_archive_support
bignum: use combined overflow check and operation
1717:
} case BIT_INT:
+
{
#ifdef AUTO_BIGNUM
-
+
int of = 0;
size = 0; for(e = -args; e < 0; e++) {
-
if(
INT_TYPE_ADD_OVERFLOW(sp[e].u.integer,
size
))
+
size = DO_
INT_TYPE_ADD_OVERFLOW(
size,
sp[e].u.integer,
&of
)
;
+
}
+
if(of
)
{ convert_svalue_to_bignum(sp-args); f_add(args); return; }
-
else
-
{
-
size += sp[e].u.integer;
-
}
-
}
+
sp-=args; push_int(size); #else
1742:
#endif /* AUTO_BIGNUM */ break;
+
}
case BIT_FLOAT: if (args > 2) { /* Attempt to minimize the accumulated summation error
3739:
return; case TWO_TYPES(T_INT,T_INT):
-
#ifdef AUTO_BIGNUM
-
if(INT_TYPE_MUL_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer))
+
{
-
+
INT_TYPE res;
+
#ifndef AUTO_BIGNUM
+
res = sp[-2].u.integer * sp[-1].u.integer;
+
#else
+
int of = 0;
+
+
res = DO_INT_TYPE_MUL_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer, &of);
+
+
if(of)
+
{
convert_stack_top_to_bignum(); goto do_lfun_multiply; } #endif /* AUTO_BIGNUM */ sp--;
-
SET_SVAL(sp[-1], T_INT, NUMBER_NUMBER, integer,
-
sp[-1].u.integer * sp[0].u.integer
);
+
SET_SVAL(sp[-1], T_INT, NUMBER_NUMBER, integer,
res
);
return;
-
+
}
default: do_lfun_multiply: if(call_lfun(LFUN_MULTIPLY, LFUN_RMULTIPLY))