From 43006aea94444d985ad58c30bb1c21adf1523ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Thu, 26 Dec 2013 00:07:28 +0100 Subject: [PATCH] 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). --- src/bignum.c | 10 +++++----- src/bignum.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bignum.c b/src/bignum.c index 7baecfd2b5..ad4b5282cb 100644 --- a/src/bignum.c +++ b/src/bignum.c @@ -20,14 +20,14 @@ PMOD_EXPORT struct svalue auto_bignum_program = SVALUE_INIT_FREE; 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,7 +127,7 @@ PMOD_EXPORT void (*push_ulongest) (unsigned LONGEST) = NULL; 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,7 +138,7 @@ PMOD_EXPORT void hook_in_gmp_funcs ( #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,6 +150,6 @@ PMOD_EXPORT void hook_in_gmp_funcs ( #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; } diff --git a/src/bignum.h b/src/bignum.h index 55d6f3fe65..981b310571 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -269,7 +269,7 @@ PMOD_EXPORT extern int (*ulongest_from_bignum) (unsigned LONGEST *i, #define MP_INT void #endif -PMOD_EXPORT extern MP_INT *(*mpz_from_bignum)(struct object *, int); +PMOD_EXPORT extern int (*mpz_from_svalue)(MP_INT *, struct svalue *); PMOD_EXPORT extern void (*push_bignum)(MP_INT *); PMOD_EXPORT void hook_in_gmp_funcs ( @@ -280,7 +280,7 @@ PMOD_EXPORT void hook_in_gmp_funcs ( #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 *)); /* Prototypes end here */ -- GitLab