This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/6model/reprs/P6bigint.c b/src/6model/reprs/P6bigint.c | |
| index fe336ec..54105a3 100644 | |
| --- a/src/6model/reprs/P6bigint.c | |
| +++ b/src/6model/reprs/P6bigint.c | |
| @@ -2,14 +2,19 @@ | |
| /* A forced 64-bit version of mp_get_long, since on some platforms long is | |
| * not all that long. */ | |
| -static MVMuint64 mp_get_int64(mp_int * a) { | |
| - int i; | |
| +static MVMuint64 mp_get_int64(MVMThreadContext *tc, mp_int * a) { | |
| + int i, bits; | |
| MVMuint64 res; | |
| if (a->used == 0) { | |
| return 0; | |
| } | |
| + bits = mp_count_bits(a); | |
| + if (bits > 64) { | |
| + MVM_exception_throw_adhoc(tc, "Cannot turn %d bit wide bigint into 64 bit integer", bits); | |
| + } | |
| + | |
| /* get number of digits of the lsb we have to read */ | |
| i = MIN(a->used,(int)((sizeof(MVMuint64)*CHAR_BIT+DIGIT_BIT-1)/DIGIT_BIT))-1; | |
| @@ -85,12 +90,12 @@ static MVMint64 get_int(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, vo | |
| if (MP_LT == mp_cmp_d(i, 0)) { | |
| MVMint64 ret; | |
| mp_neg(i, i); | |
| - ret = mp_get_int64(i); | |
| + ret = mp_get_int64(tc, i); | |
| mp_neg(i, i); | |
| return -ret; | |
| } | |
| else { | |
| - return mp_get_int64(i); | |
| + return mp_get_int64(tc, i); | |
| } | |
| } | |
| else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment