fixes to reclaim space on error, allow compilation whitout GMP, and
improve docs. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1493 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
72214cb08c
commit
772a6ae805
16
C/arith2.c
16
C/arith2.c
|
@ -228,6 +228,10 @@ p_mod(Term t1, Term t2 E_ARGS)
|
||||||
RERROR();
|
RERROR();
|
||||||
}
|
}
|
||||||
case double_e:
|
case double_e:
|
||||||
|
#if USE_GMP
|
||||||
|
if (bt2 == big_int_e)
|
||||||
|
mpz_clear(v2.big);
|
||||||
|
#endif
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "mod/2");
|
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "mod/2");
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
RERROR();
|
RERROR();
|
||||||
|
@ -404,6 +408,10 @@ p_rem(Term t1, Term t2 E_ARGS)
|
||||||
RERROR();
|
RERROR();
|
||||||
}
|
}
|
||||||
case double_e:
|
case double_e:
|
||||||
|
#if USE_GMP
|
||||||
|
if (bt2 == big_int_e)
|
||||||
|
mpz_clear(v2.big);
|
||||||
|
#endif
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "mod/2");
|
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "mod/2");
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
RERROR();
|
RERROR();
|
||||||
|
@ -795,6 +803,10 @@ p_xor(Term t1, Term t2 E_ARGS)
|
||||||
RERROR();
|
RERROR();
|
||||||
}
|
}
|
||||||
case double_e:
|
case double_e:
|
||||||
|
#if USE_GMP
|
||||||
|
if (bt2 == big_int_e)
|
||||||
|
mpz_clear(v2.big);
|
||||||
|
#endif
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "#/2");
|
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "#/2");
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
RERROR();
|
RERROR();
|
||||||
|
@ -1394,6 +1406,10 @@ p_gcd(Term t1, Term t2 E_ARGS)
|
||||||
RERROR();
|
RERROR();
|
||||||
}
|
}
|
||||||
case double_e:
|
case double_e:
|
||||||
|
#if USE_GMP
|
||||||
|
if (bt2 == big_int_e)
|
||||||
|
mpz_clear(v2.big);
|
||||||
|
#endif
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "gcd/2");
|
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), "gcd/2");
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
RERROR();
|
RERROR();
|
||||||
|
|
|
@ -1214,9 +1214,9 @@ sll_ovflw(Int x,Int i)
|
||||||
inline static E_FUNC
|
inline static E_FUNC
|
||||||
do_sll(Int i, Int j E_ARGS)
|
do_sll(Int i, Int j E_ARGS)
|
||||||
{
|
{
|
||||||
|
#if USE_GMP
|
||||||
Int x = (8*sizeof(CELL)-2)-j;
|
Int x = (8*sizeof(CELL)-2)-j;
|
||||||
|
|
||||||
#if USE_GMP
|
|
||||||
if (x < 0||
|
if (x < 0||
|
||||||
sll_ovflw(x,i)) {
|
sll_ovflw(x,i)) {
|
||||||
MP_INT *new = TMP_BIG();
|
MP_INT *new = TMP_BIG();
|
||||||
|
@ -1226,11 +1226,7 @@ do_sll(Int i, Int j E_ARGS)
|
||||||
RBIG(new);
|
RBIG(new);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef BEAM
|
|
||||||
RINT(i << j);
|
RINT(i << j);
|
||||||
#else
|
|
||||||
RINT(i << j);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1517,8 +1513,10 @@ p_slr(Term t1, Term t2 E_ARGS)
|
||||||
RERROR();
|
RERROR();
|
||||||
}
|
}
|
||||||
case double_e:
|
case double_e:
|
||||||
|
#if USE_GMP
|
||||||
if (bt2 == big_int_e)
|
if (bt2 == big_int_e)
|
||||||
mpz_clear(v2.big);
|
mpz_clear(v2.big);
|
||||||
|
#endif
|
||||||
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), ">>/2");
|
Yap_Error(TYPE_ERROR_INTEGER, MkFloatTerm(v1.dbl), ">>/2");
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
RERROR();
|
RERROR();
|
||||||
|
|
|
@ -10738,6 +10738,7 @@ p_print_bignum(void)
|
||||||
YAP_BigNumOfTerm(YAP_ARG1, mz);
|
YAP_BigNumOfTerm(YAP_ARG1, mz);
|
||||||
gmp_printf("Shows up as %Zd\n", mz);
|
gmp_printf("Shows up as %Zd\n", mz);
|
||||||
mpz_clear(mz);
|
mpz_clear(mz);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
|
Reference in New Issue