Testing big ints

This commit is contained in:
Krzosa Karol
2022-06-06 17:00:01 +02:00
parent dc56bd54f3
commit 7173557d26
5 changed files with 19 additions and 6 deletions

View File

@@ -9,11 +9,13 @@ function void parsing_error(Token *token, const char *str, ...);
#define Set_BigInt_Allocator(x) BigInt_Allocator bigint_allocator(x)
struct BigInt_Allocator{
BigInt_Allocator(Allocator *allocator){bigint_allocator = allocator;}
~BigInt_Allocator(){bigint_allocator = 0;}
Allocator *old;
BigInt_Allocator(Allocator *allocator){old = bigint_allocator; bigint_allocator = allocator;}
~BigInt_Allocator(){bigint_allocator = old;}
};
#define malloc_arena(x) (bigint_allocation_count++, exp_alloc(bigint_allocator, x, AF_ZeroMemory))
#define count_bigint_alloc() (bigint_allocator != thread_ctx.scratch ? bigint_allocation_count++ : 0)
#define malloc_arena(x) (count_bigint_alloc(), exp_alloc(bigint_allocator, x, AF_ZeroMemory))
#define ALLOC_DIGITS(_digits) (uint64_t *)((_digits) ? malloc_arena(sizeof(uint64_t) * (_digits)) : NULL)
#define FATAL_ERROR(x) parsing_error(0, x)