aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/bigint.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-09 13:53:57 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-09 13:53:57 -0500
commitc2aa5e9486b88f24703b833a55c85e525acb50df (patch)
treee96a36d12d8c09f1635a0bb04929113174810504 /src/stdlib/bigint.h
parent75bb38a10c9fa069cfbc731a1f50e4f977447987 (diff)
Cut out a level of pointer indirection for integers by using underlying
struct
Diffstat (limited to 'src/stdlib/bigint.h')
-rw-r--r--src/stdlib/bigint.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/stdlib/bigint.h b/src/stdlib/bigint.h
index 558bc099..614e1501 100644
--- a/src/stdlib/bigint.h
+++ b/src/stdlib/bigint.h
@@ -34,13 +34,14 @@ bool Int$get_bit(Int_t x, Int_t bit_index);
#define SMALLEST_SMALL_INT -0x40000000
#define Int$from_mpz(mpz) \
- (mpz_cmpabs_ui(mpz, BIGGEST_SMALL_INT) <= 0 ? ((Int_t){.small = (mpz_get_si(mpz) << 2L) | 1L}) \
- : ((Int_t){.big = memcpy(new (mpz_t), &mpz, sizeof(mpz_t))}))
+ (mpz_cmpabs_ui(mpz, BIGGEST_SMALL_INT) <= 0 \
+ ? ((Int_t){.small = (mpz_get_si(mpz) << 2L) | 1L}) \
+ : ((Int_t){.big = memcpy(new (__mpz_struct), mpz, sizeof(__mpz_struct))}))
#define mpz_init_set_int(mpz, i) \
do { \
if likely ((i).small & 1L) mpz_init_set_si(mpz, (i).small >> 2L); \
- else mpz_init_set(mpz, *(i).big); \
+ else mpz_init_set(mpz, (i).big); \
} while (0)
#define I_small(i) ((Int_t){.small = (int64_t)((uint64_t)(i) << 2L) | 1L})