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:
Jan (janneke) Nieuwenhuizen 2022-09-13 23:33:47 +02:00
parent a958d7f86b
commit d8f4d8b265
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 5 additions and 16 deletions

View File

@ -191,24 +191,13 @@ modulo (struct scm *a, struct scm *b)
assert_number ("modulo", a);
assert_number ("modulo", b);
long n = a->value;
long v = b->value;
if (v == 0)
long d = b->value;
if (d == 0)
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)
n = n + w;
size_t u = n;
if (u != 0)
u = u % w;
n = u;
if (sign_p)
n = -n;
n = n + d;
if (n != 0)
n = n % d;
return make_number (n);
}