pike.git / src / bignum.c

version» Context lines:

pike.git/src/bignum.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: bignum.c,v 1.33 2003/02/14 19:19:57 mast Exp $ + || $Id: bignum.c,v 1.34 2003/03/14 15:50:43 grubba Exp $   */      #include "global.h"      #ifdef AUTO_BIGNUM      #include "interpret.h"   #include "program.h"   #include "object.h"   #include "svalue.h"
pike.git/src/bignum.c:81:   }      PMOD_EXPORT int is_bignum_object_in_svalue(struct svalue *sv)   {    return sv->type == T_OBJECT && is_bignum_object(sv->u.object);   }      PMOD_EXPORT struct object *make_bignum_object(void)   {    convert_stack_top_to_bignum(); +  dmalloc_touch_svalue(sp-1);    return (--sp)->u.object;   }      PMOD_EXPORT struct object *bignum_from_svalue(struct svalue *s)   {    push_svalue(s);    convert_stack_top_to_bignum(); -  +  dmalloc_touch_svalue(sp-1);    return (--sp)->u.object;   }      PMOD_EXPORT struct pike_string *string_from_bignum(struct object *o, int base)   {    push_int(base);    safe_apply(o, "digits", 1);       if(sp[-1].type != T_STRING)    Pike_error("Gmp.mpz string conversion failed.\n");    -  +  dmalloc_touch_svalue(sp-1);    return (--sp)->u.string;   }      PMOD_EXPORT void convert_svalue_to_bignum(struct svalue *s)   {    push_svalue(s);    convert_stack_top_to_bignum();    free_svalue(s);    *s=sp[-1];    sp--;
pike.git/src/bignum.c:166:   PMOD_EXPORT int int64_from_bignum(INT64 *i, struct object *bignum)   {    int neg, pos, rshfun, andfun;       *i = 0;       push_int(0);    apply_low(bignum, FIND_LFUN(bignum->prog, LFUN_LT), 1);    if(sp[-1].type != T_INT)    Pike_error("Result from Gmp.bignum->`< not an integer.\n"); +  dmalloc_touch_svalue(sp-1);    neg = (--sp)->u.integer;       if(neg)    apply_low(bignum, FIND_LFUN(bignum->prog, LFUN_COMPL), 0);       rshfun = FIND_LFUN(bignum->prog, LFUN_RSH);    andfun = FIND_LFUN(bignum->prog, LFUN_AND);       ref_push_object(bignum);       for(pos = 0; sp[-1].type != T_INT; )    {    push_int(BIGNUM_INT64_MASK);    apply_low(sp[-2].u.object, andfun, 1);    if(sp[-1].type != T_INT)    Pike_error("Result from Gmp.bignum->`& not an integer.\n"); -  +  dmalloc_touch_svalue(sp-1);    *i |= (INT64)(--sp)->u.integer << (INT64)pos;    pos += BIGNUM_INT64_SHIFT;       push_int(BIGNUM_INT64_SHIFT);    apply_low(sp[-2].u.object, rshfun, 1);    stack_swap();    pop_stack();    }    -  +  dmalloc_touch_svalue(sp-1);    *i |= (INT64)(--sp)->u.integer << (INT64)pos;       if(neg)    *i = ~*i;       return 1; /* We may someday return 0 if the conversion fails. */   }   #endif /* INT64 */      #endif /* AUTO_BIGNUM */