bignum should always reset pre_alloc_base and recover Heap space
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@158 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
8f72bc3c91
commit
cbd499b8df
@ -139,6 +139,7 @@ p_mod(Term t1, Term t2 E_ARGS)
|
|||||||
MP_INT *new = PreAllocBigNum();
|
MP_INT *new = PreAllocBigNum();
|
||||||
Int r = mpz_mod_ui(new, l1, i2);
|
Int r = mpz_mod_ui(new, l1, i2);
|
||||||
|
|
||||||
|
CleanBigNum();
|
||||||
RINT((mpz_sgn(l1) ? r : -r));
|
RINT((mpz_sgn(l1) ? r : -r));
|
||||||
} else if (i2 == 0) {
|
} else if (i2 == 0) {
|
||||||
goto zero_divisor;
|
goto zero_divisor;
|
||||||
@ -146,6 +147,7 @@ p_mod(Term t1, Term t2 E_ARGS)
|
|||||||
MP_INT *new = PreAllocBigNum();
|
MP_INT *new = PreAllocBigNum();
|
||||||
Int r = mpz_mod_ui(new, l1, -i2);
|
Int r = mpz_mod_ui(new, l1, -i2);
|
||||||
|
|
||||||
|
CleanBigNum();
|
||||||
RINT((mpz_sgn(l1) ? r : -r));
|
RINT((mpz_sgn(l1) ? r : -r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,6 +213,7 @@ p_mod(Term t1, Term t2 E_ARGS)
|
|||||||
MP_INT *new = PreAllocBigNum();
|
MP_INT *new = PreAllocBigNum();
|
||||||
Int r = mpz_mod_ui(new, v1.big, v2.Int);
|
Int r = mpz_mod_ui(new, v1.big, v2.Int);
|
||||||
|
|
||||||
|
CleanBigNum();
|
||||||
RINT((mpz_sgn(v1.big) ? r : -r));
|
RINT((mpz_sgn(v1.big) ? r : -r));
|
||||||
} else if (v2.Int == 0) {
|
} else if (v2.Int == 0) {
|
||||||
goto zero_divisor;
|
goto zero_divisor;
|
||||||
@ -218,6 +221,7 @@ p_mod(Term t1, Term t2 E_ARGS)
|
|||||||
MP_INT *new = PreAllocBigNum();
|
MP_INT *new = PreAllocBigNum();
|
||||||
Int r = mpz_mod_ui(new, v1.big, -v2.Int);
|
Int r = mpz_mod_ui(new, v1.big, -v2.Int);
|
||||||
|
|
||||||
|
CleanBigNum();
|
||||||
RINT((mpz_sgn(v1.big) ? r : -r));
|
RINT((mpz_sgn(v1.big) ? r : -r));
|
||||||
}
|
}
|
||||||
case double_e:
|
case double_e:
|
||||||
@ -267,6 +271,7 @@ fdiv_bigint(MP_INT *b1,MP_INT *b2)
|
|||||||
mpf_set_z(f2, b2);
|
mpf_set_z(f2, b2);
|
||||||
mpf_div(f1, f1, f2);
|
mpf_div(f1, f1, f2);
|
||||||
res = mpf_get_d(f1);
|
res = mpf_get_d(f1);
|
||||||
|
CleanBigNum();
|
||||||
return(res);
|
return(res);
|
||||||
} else {
|
} else {
|
||||||
return(f1/f2);
|
return(f1/f2);
|
||||||
@ -450,6 +455,7 @@ mpz_xor(MP_INT *new, MP_INT *r1, MP_INT *r2)
|
|||||||
mpz_com(n3, r2);
|
mpz_com(n3, r2);
|
||||||
mpz_and(n3, n3, new);
|
mpz_and(n3, n3, new);
|
||||||
mpz_ior(new, n2, n3);
|
mpz_ior(new, n2, n3);
|
||||||
|
CleanBigNum();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,6 +53,13 @@ PreAllocBigNum(void)
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CleanBigNum(void)
|
||||||
|
{
|
||||||
|
H = pre_alloc_base;
|
||||||
|
pre_alloc_base = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
MP_INT *
|
MP_INT *
|
||||||
InitBigNum(Int in)
|
InitBigNum(Int in)
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
|||||||
extern int gc_calls;
|
extern int gc_calls;
|
||||||
|
|
||||||
vsc_count++;
|
vsc_count++;
|
||||||
/* if (vsc_count < 2518) return; */
|
/* if (vsc_count < 24) return; */
|
||||||
/* if (vsc_count > 500000) exit(0); */
|
/* if (vsc_count > 500000) exit(0); */
|
||||||
/* if (gc_calls < 1) return;*/
|
/* if (gc_calls < 1) return;*/
|
||||||
YP_fprintf(YP_stderr,"%lu (%d)", vsc_count, CurrentModule);
|
YP_fprintf(YP_stderr,"%lu (%d)", vsc_count, CurrentModule);
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
<h2>Yap-4.3.20:</h2>
|
<h2>Yap-4.3.20:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>FIXED: always release stack after InitBigNum (report from
|
||||||
|
Nicos Angelopoulos).</li>
|
||||||
<li>FIXED: random would not load in windows (report from
|
<li>FIXED: random would not load in windows (report from
|
||||||
Henrik Boström).</li>
|
Henrik Boström).</li>
|
||||||
<li>FIXED: don't send warnings about repeated predicates from
|
<li>FIXED: don't send warnings about repeated predicates from
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* File: TermExt.h *
|
* File: TermExt.h *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Extensions to standard terms for YAP *
|
* comments: Extensions to standard terms for YAP *
|
||||||
* version: $Id: TermExt.h.m4,v 1.2 2001-06-06 10:38:10 stasinos Exp $ *
|
* version: $Id: TermExt.h.m4,v 1.3 2001-09-18 15:14:11 vsc Exp $ *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#if USE_OFFSETS
|
#if USE_OFFSETS
|
||||||
@ -160,10 +160,10 @@ Inline(IsLongIntTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == Functor
|
|||||||
|
|
||||||
|
|
||||||
MP_INT *STD_PROTO(PreAllocBigNum,(void));
|
MP_INT *STD_PROTO(PreAllocBigNum,(void));
|
||||||
void STD_PROTO(ClearAllocBigNum,(void));
|
|
||||||
MP_INT *STD_PROTO(InitBigNum,(Int));
|
MP_INT *STD_PROTO(InitBigNum,(Int));
|
||||||
Term STD_PROTO(MkBigIntTerm, (MP_INT *));
|
Term STD_PROTO(MkBigIntTerm, (MP_INT *));
|
||||||
MP_INT *STD_PROTO(BigIntOfTerm, (Term));
|
MP_INT *STD_PROTO(BigIntOfTerm, (Term));
|
||||||
|
void STD_PROTO(CleanBigNum,(void));
|
||||||
|
|
||||||
Inline(IsBigIntTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt)
|
Inline(IsBigIntTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user