Skip to content

Instantly share code, notes, and snippets.

@timo
Created January 27, 2014 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timo/5804138fc21801a3498e to your computer and use it in GitHub Desktop.
Save timo/5804138fc21801a3498e to your computer and use it in GitHub Desktop.
(gdb) list
5 static mp_int mag_32bit_limit;
6
7 /* Forces a bigint to actually be a bigint, rather than a smallbigint. */
8 inline void force_bigint(void *data) {
9 mp_int *i = &((MVMP6bigintBody *)data)->i;
10 if (IS_SBI(data)) {
11 printf("making a big integer in force_bigint: %d\n", VALUE_SBI(data));
12 MVMint64 value = VALUE_SBI(data);
13 mp_init(i);
14 mp_zero(i);
(gdb) si
0x00007ffff7c44250 10 if (IS_SBI(data)) {
(gdb)
22 printf("forcing a bigint into a bigint.\n");
(gdb) print *(MVMP6bigint *)data
$4 = {common = {header = {owner = 0, flags = 0, size = 56, forwarder = 0x0, sc = 0x0},
st = 0x7ffff7302738}, {body = {i = {used = 0, alloc = 0, sign = 0, dp = 0x1}}, smallbig = {
pad1 = 0, pad2 = 0, storage = 0, flag = 1}}}
(gdb)
#define MAKE_SBI(a) ((((MVMP6smallbigintBody *)a)->flag) = 1)
#define IS_SBI(a) ((long)(((MVMP6smallbigintBody *)a)->flag) == 1)
#define STORE_SBI(a, value) (((MVMP6smallbigintBody *)a)->storage = value)
#define VALUE_SBI(a) (((MVMP6smallbigintBody *)a)->storage)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment