Branch: Tag:

2013-12-24

2013-12-24 12:55:53 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Bignums: Added API for pushing bignums directly.

This simplifies code needing to handle bignums from external
sources (eg hogweed).

22: Inside #if defined(USE_GMP) || defined(USE_GMP2)
     #if defined(USE_GMP) || defined(USE_GMP2)    + #include "my_gmp.h" +    #include "interpret.h"   #include "svalue.h"   #include "stralloc.h"
38:   #include "operators.h"   #include "gc.h"    - #include "my_gmp.h" -  +    #include <limits.h>      #define sp Pike_sp
65:      static mpz_t mpz_int_type_min;    + static MP_INT *gmp_mpz_from_bignum(struct object *o, int inherit) + { +  if (!IS_MPZ_OBJ(o)) return NULL; +  return OBTOMPZ(o); + } +  + static void gmp_push_bignum(MP_INT *mpz) + { +  push_object(fast_clone_object(bignum_program)); +  mpz_set(OBTOMPZ(Pike_sp[-1].u.object), mpz); + } +    void mpzmod_reduce(struct object *o)   {    MP_INT *mpz = OBTOMPZ (o);
2254: Inside #if defined(USE_GMP) || defined(USE_GMP2) and #if defined(INT64)
  #ifdef INT64    NULL, NULL, NULL,   #endif -  NULL, NULL); +  NULL, NULL, NULL, NULL);   #endif   }   
2444:    MPZ_DEFS();       id=add_program_constant("bignum", bignum_program=end_program(), 0); +  bignum_program->id = PROG_GMP_BIGNUM_ID;    bignum_program->flags |=    PROGRAM_NO_WEAK_FREE |    PROGRAM_NO_EXPLICIT_DESTRUCT |
2473: Inside #if defined(INT64)
   gmp_push_int64, gmp_int64_from_bignum,    gmp_reduce_stack_top_bignum,   #endif -  gmp_push_ulongest, gmp_ulongest_from_bignum); +  gmp_push_ulongest, gmp_ulongest_from_bignum, +  gmp_mpz_from_bignum, gmp_push_bignum);      #if 0    /* magic /Hubbe