Branch: Tag:

2013-12-25

2013-12-25 23:07:28 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Bignums: Changed the API to get MP_INTs from svalues.

To get an MP_INT from an svalue it is now possible to
call mpz_from_svalue().

Also fixes bugs in get_auto_bignum_program{,_or_zero}(),
so that they actually work (previously they always
returned NULL due to the svalue auto_bignum_program
not being a function).

20:      PMOD_EXPORT struct program *get_auto_bignum_program(void)   { -  return program_from_function(&auto_bignum_program); +  return program_from_svalue(&auto_bignum_program);   }      PMOD_EXPORT struct program *get_auto_bignum_program_or_zero(void)   {    if (TYPEOF(auto_bignum_program) == PIKE_T_FREE)    return 0; -  return program_from_function(&auto_bignum_program); +  return program_from_svalue(&auto_bignum_program);   }      void exit_auto_bignum(void)
127:   PMOD_EXPORT int (*ulongest_from_bignum) (unsigned LONGEST *,    struct object *) = NULL;    - PMOD_EXPORT MP_INT *(*mpz_from_bignum)(struct object *, int) = NULL; + PMOD_EXPORT int (*mpz_from_svalue)(MP_INT *, struct svalue *) = NULL;   PMOD_EXPORT void (*push_bignum)(MP_INT *) = NULL;      PMOD_EXPORT void hook_in_gmp_funcs (
138:   #endif    void (*push_ulongest_val) (unsigned LONGEST),    int (*ulongest_from_bignum_val) (unsigned LONGEST *, struct object *), -  MP_INT *(*mpz_from_bignum_val)(struct object *, int), +  int (*mpz_from_svalue_val)(MP_INT *, struct svalue *),    void (*push_bignum_val)(MP_INT *))   {    /* Assigning the pointers above directly from the Gmp module doesn't
150:   #endif    push_ulongest = push_ulongest_val;    ulongest_from_bignum = ulongest_from_bignum_val; -  mpz_from_bignum = mpz_from_bignum_val; +  mpz_from_svalue = mpz_from_svalue_val;    push_bignum = push_bignum_val;   }