Skip to content

Commit dfd536f

Browse files
committed
wrap more libTomMath subs in dynops
1 parent f75ce8f commit dfd536f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/ops/nqp_bigint.ops

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,33 @@ inline op nqp_bigint_mul(out PMC, in PMC, in PMC) :base_core {
5151
mp_mul(a, b, get_bigint(interp, $1));
5252
}
5353

54+
inline op nqp_bigint_div(out PMC, in PMC, in PMC) :base_core {
55+
mp_int *a = get_bigint(interp, $2);
56+
mp_int *b = get_bigint(interp, $3);
57+
mp_int *remainder = get_bigint(interp, REPR($2)->instance_of(interp, $2));
58+
$1 = REPR($2)->instance_of(interp, $2);
59+
mp_div(a, b, get_bigint(interp, $1), remainder);
60+
/* XXX do I need to destroy remainder myself? */
61+
}
62+
63+
inline op nqp_bigint_mod(out PMC, in PMC, in PMC) :base_core {
64+
mp_int *a = get_bigint(interp, $2);
65+
mp_int *b = get_bigint(interp, $3);
66+
$1 = REPR($2)->instance_of(interp, $2);
67+
mp_mod(a, b, get_bigint(interp, $1));
68+
}
69+
70+
inline op nqp_bigint_neg(out PMC, in PMC) :base_core {
71+
mp_int *a = get_bigint(interp, $2);
72+
$1 = REPR($2)->instance_of(interp, $2);
73+
mp_neg(a, get_bigint(interp, $1));
74+
}
75+
inline op nqp_bigint_abs(out PMC, in PMC) :base_core {
76+
mp_int *a = get_bigint(interp, $2);
77+
$1 = REPR($2)->instance_of(interp, $2);
78+
mp_abs(a, get_bigint(interp, $1));
79+
}
80+
5481
inline op nqp_bigint_from_str(out PMC, in PMC, in STR) :base_core {
5582
char *buf = Parrot_str_cstring(interp, $3);
5683
$1 = REPR($2)->instance_of(interp, $2);

0 commit comments

Comments
 (0)