big_register{0,1,2}_get can now be inlined macros

This commit is contained in:
Juan Jose Garcia Ripoll 2009-08-28 19:27:55 +02:00
parent 3d778f4974
commit 1fb5504aaa
3 changed files with 12 additions and 7 deletions

View file

@ -26,10 +26,10 @@
* need big_set_ui() for some stupid code where the register is used
* uninitialized. */
#ifdef BIGNUM_REGISTER_SIZE
#undef BIGNUM_REGISTER_SIZE
#endif
#define BIGNUM_REGISTER_SIZE 64
#if 0
#undef big_register0_get
#undef big_register1_get
#undef big_register2_get
cl_object
big_register0_get()
@ -54,13 +54,14 @@ big_register2_get()
big_set_ui(x, 0);
return x;
}
#endif
void
big_register_free(cl_object x)
{
/* We only need to free the integer when it gets too large */
if (x->big.big_dim > BIGNUM_REGISTER_SIZE) {
mpz_realloc2(x->big.big_num, BIGNUM_REGISTER_SIZE * GMP_LIMB_BITS);
if (x->big.big_dim > 3 * ECL_BIG_REGISTER_SIZE) {
mpz_realloc2(x->big.big_num, ECL_BIG_REGISTER_SIZE * GMP_LIMB_BITS);
}
}

View file

@ -248,7 +248,7 @@ ecl_init_env(cl_env_ptr env)
int i;
for (i = 0; i < 3; i++) {
cl_object x = ecl_alloc_object(t_bignum);
big_init2(x, 32);
big_init2(x, ECL_BIG_REGISTER_SIZE);
env->big_register[i] = x;
}
}

View file

@ -13,6 +13,10 @@
See file '../Copyright' for full details.
*/
#define ECL_BIG_REGISTER_SIZE 32
#define big_register0_get() ecl_process_env()->big_register[0]
#define big_register1_get() ecl_process_env()->big_register[1]
#define big_register2_get() ecl_process_env()->big_register[2]
#ifdef WITH_GMP
#define big_init2(x,size) mpz_init2((x)->big.big_num,(size)*GMP_LIMB_BITS)
#define big_clear(x) mpz_clear((x)->big.big_num)