Skip to content

Commit

Permalink
Merge pull request #1110 from MoarVM/multiplatform_mp_set_int
Browse files Browse the repository at this point in the history
attempt to have fast mp_set and not broken windows
  • Loading branch information
jnthn committed Jun 9, 2019
2 parents 6e232cf + 4aa256b commit c374d7f
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/math/bigintops.c
Expand Up @@ -166,18 +166,31 @@ static mp_int * force_bigint(MVMThreadContext *tc, const MVMP6bigintBody *body,
return body->u.bigint;
}
else {
MVMint64 value = body->u.smallint.value;
mp_int *i = tc->temp_bigints[idx];
if (value >= 0) {
mp_digit d = value;
mp_set(i, d);
if (sizeof(mp_digit) > 4) {
MVMint64 value = body->u.smallint.value;
mp_int *i = tc->temp_bigints[idx];
if (value >= 0) {
mp_digit d = value;
mp_set(i, d);
}
else {
mp_digit d = -value;
mp_set(i, d);
mp_neg(i, i);
}
return i;
}
else {
mp_digit d = -value;
mp_set(i, d);
mp_neg(i, i);
MVMint32 value = body->u.smallint.value;
mp_int *i = tc->temp_bigints[idx];
if (value >= 0) {
mp_set_int(i, value);
}
else {
mp_set_int(i, -value);
}
return i;
}
return i;
}
}

Expand Down

0 comments on commit c374d7f

Please sign in to comment.