/home/travis/build/MoarVM/MoarVM/src/6model/reprs/P6bigint.h
Line | Count | Source |
1 | | #include "tommath.h" |
2 | | |
3 | 2.69k | #define MVM_BIGINT_32_FLAG 0xFFFFFFFF |
4 | 2.33k | #define MVM_BIGINT_IS_BIG(body) ((body)->u.smallint.flag != 0xFFFFFFFF) |
5 | 1.37k | #define MVM_IS_32BIT_INT(i) ((long long)(i) >= -2147483648LL && (long long)(i) <= 2147483647LL) |
6 | | |
7 | | /* Representation used by big integers; inlined into P6bigint. We store any |
8 | | * values in 32-bit signed range without using the big integer library. */ |
9 | | struct MVMP6bigintBody { |
10 | | union { |
11 | | /* A 32-bit integer and a flag indicating this is not a pointer to a |
12 | | * big integer, but instead the 32-bit value should be read. Stored |
13 | | * so that the flag sets the lower bits of any 64-bit pointer, which |
14 | | * should never happen in a real pointer due to alignment. */ |
15 | | struct { |
16 | | #if defined(MVM_BIGENDIAN) && MVM_PTR_SIZE > 4 |
17 | | MVMint32 value; |
18 | | MVMuint32 flag; |
19 | | #else |
20 | | MVMuint32 flag; |
21 | | MVMint32 value; |
22 | | #endif |
23 | | } smallint; |
24 | | |
25 | | /* Pointer to a libtommath big integer. */ |
26 | | mp_int *bigint; |
27 | | } u; |
28 | | }; |
29 | | struct MVMP6bigint { |
30 | | MVMObject common; |
31 | | MVMP6bigintBody body; |
32 | | }; |
33 | | |
34 | | /* Function for REPR setup. */ |
35 | | const MVMREPROps * MVMP6bigint_initialize(MVMThreadContext *tc); |