ARM core: Revert to modulo from v0.23.
This inexplicably fixes tcc-boot0. * src/math.c (modulo): Use v0.23 implementation.
This commit is contained in:
parent
a958d7f86b
commit
d8f4d8b265
21
src/math.c
21
src/math.c
|
@ -191,24 +191,13 @@ modulo (struct scm *a, struct scm *b)
|
||||||
assert_number ("modulo", a);
|
assert_number ("modulo", a);
|
||||||
assert_number ("modulo", b);
|
assert_number ("modulo", b);
|
||||||
long n = a->value;
|
long n = a->value;
|
||||||
long v = b->value;
|
long d = b->value;
|
||||||
if (v == 0)
|
if (d == 0)
|
||||||
error (cstring_to_symbol ("divide-by-zero"), a);
|
error (cstring_to_symbol ("divide-by-zero"), a);
|
||||||
int sign_p = 0;
|
|
||||||
size_t w = v;
|
|
||||||
if (v < 0)
|
|
||||||
{
|
|
||||||
sign_p = 1;
|
|
||||||
w = -v;
|
|
||||||
}
|
|
||||||
while (n < 0)
|
while (n < 0)
|
||||||
n = n + w;
|
n = n + d;
|
||||||
size_t u = n;
|
if (n != 0)
|
||||||
if (u != 0)
|
n = n % d;
|
||||||
u = u % w;
|
|
||||||
n = u;
|
|
||||||
if (sign_p)
|
|
||||||
n = -n;
|
|
||||||
return make_number (n);
|
return make_number (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue