MaxOS fixes
Avoid a thread deadlock improvements to SWI predicates. make variables_in_term system builtin. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2304 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
14
C/absmi.c
14
C/absmi.c
@@ -10,8 +10,11 @@
|
||||
* *
|
||||
* File: absmi.c *
|
||||
* comments: Portable abstract machine interpreter *
|
||||
* Last rev: $Date: 2008-08-07 20:51:15 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2008-08-12 01:27:22 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.245 2008/08/07 20:51:15 vsc
|
||||
* more threadin fixes
|
||||
*
|
||||
* Revision 1.244 2008/08/06 23:05:49 vsc
|
||||
* fix debugging info
|
||||
*
|
||||
@@ -491,6 +494,15 @@
|
||||
#include "cut_c.h"
|
||||
#endif
|
||||
|
||||
#ifdef PUSH_X
|
||||
#else
|
||||
|
||||
/* keep X as a global variable */
|
||||
|
||||
Term Yap_XREGS[MaxTemps]; /* 29 */
|
||||
|
||||
#endif
|
||||
|
||||
inline static Functor
|
||||
AritFunctorOfTerm(Term t) {
|
||||
if (IsVarTerm(t)) {
|
||||
|
14
C/amasm.c
14
C/amasm.c
@@ -11,8 +11,11 @@
|
||||
* File: amasm.c *
|
||||
* comments: abstract machine assembler *
|
||||
* *
|
||||
* Last rev: $Date: 2008-08-07 20:51:16 $ *
|
||||
* Last rev: $Date: 2008-08-12 01:27:22 $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.103 2008/08/07 20:51:16 vsc
|
||||
* more threadin fixes
|
||||
*
|
||||
* Revision 1.102 2008/07/11 17:02:07 vsc
|
||||
* fixes by Bart and Tom: mostly libraries but nasty one in indexing
|
||||
* compilation.
|
||||
@@ -3119,7 +3122,8 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
#if defined(THREADS) || defined(YAPOR)
|
||||
else
|
||||
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag))
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
|
||||
!clinfo.alloc_found)
|
||||
code_p = a_e(_unlock_lu, code_p, pass_no);
|
||||
#endif
|
||||
code_p = a_pl(_procceed, cip->CurrentPred, code_p, pass_no);
|
||||
@@ -3218,7 +3222,8 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
#if defined(THREADS) || defined(YAPOR)
|
||||
else
|
||||
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag))
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
|
||||
!clinfo.alloc_found)
|
||||
code_p = a_e(_unlock_lu, code_p, pass_no);
|
||||
#endif
|
||||
code_p = a_pl(_procceed, cip->CurrentPred, code_p, pass_no);
|
||||
@@ -3229,7 +3234,8 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
case execute_op:
|
||||
#if defined(THREADS) || defined(YAPOR)
|
||||
if (cip->CurrentPred->PredFlags & LogUpdatePredFlag &&
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag))
|
||||
!(cip->CurrentPred->PredFlags & ThreadLocalPredFlag) &&
|
||||
!clinfo.alloc_found)
|
||||
code_p = a_e(_unlock_lu, code_p, pass_no);
|
||||
#endif
|
||||
code_p = a_p(_execute, &clinfo, code_p, pass_no, cip);
|
||||
|
47
C/arith1.c
47
C/arith1.c
@@ -1966,6 +1966,52 @@ p_sign(Term t E_ARGS)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
unary negation is \
|
||||
*/
|
||||
static E_FUNC
|
||||
p_random(Term t E_ARGS)
|
||||
{
|
||||
Functor f = AritFunctorOfTerm(t);
|
||||
union arith_ret v;
|
||||
blob_type bt;
|
||||
|
||||
switch (BlobOfFunctor(f)) {
|
||||
case long_int_e:
|
||||
RINT(Yap_random()*IntegerOfTerm(t));
|
||||
case double_e:
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t, "random(%f)", FloatOfTerm(t));
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t, "random(%f)", FloatOfTerm(t));
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#endif
|
||||
default:
|
||||
/* we've got a full term, need to evaluate it first */
|
||||
bt = Yap_Eval(t, &v);
|
||||
/* second case, no need no evaluation */
|
||||
switch (bt) {
|
||||
case long_int_e:
|
||||
RINT(Yap_random()*v.Int);
|
||||
case double_e:
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t, "random(%f)", v.dbl);
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#ifdef USE_GMP
|
||||
case big_int_e:
|
||||
Yap_Error(TYPE_ERROR_INTEGER, t, "random(%f)", FloatOfTerm(t));
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
#endif
|
||||
default:
|
||||
/* Yap_Error */
|
||||
RERROR();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static InitUnEntry InitUnTab[] = {
|
||||
{"+", p_uplus},
|
||||
{"-", p_uminus},
|
||||
@@ -1998,6 +2044,7 @@ static InitUnEntry InitUnTab[] = {
|
||||
{"float_integer_part", p_fintp},
|
||||
{"sign", p_sign},
|
||||
{"lgamma", p_lgamma},
|
||||
{"random", p_random},
|
||||
};
|
||||
|
||||
static Int
|
||||
|
@@ -897,6 +897,11 @@ p_thread_self(void)
|
||||
return Yap_unify(ARG1,MkIntTerm(0));
|
||||
}
|
||||
|
||||
p_thread_stacks(void)
|
||||
{ /* '$thread_runtime'(+P) */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_unlock(void)
|
||||
{ /* '$thread_runtime'(+P) */
|
||||
|
@@ -172,9 +172,9 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
|
||||
UNLOCK(entryref->lock);
|
||||
}
|
||||
*ptf++ = d0; /* you can just copy other extensions. */
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
else if (!share) {
|
||||
if (!share) {
|
||||
UInt sz;
|
||||
|
||||
*ptf++ = AbsAppl(H); /* you can just copy other extensions. */
|
||||
@@ -2105,9 +2105,9 @@ void Yap_InitUtilCPreds(void)
|
||||
Yap_InitCPred("ground", 1, p_ground, SafePredFlag);
|
||||
Yap_InitCPred("$variables_in_term", 3, p_variables_in_term, HiddenPredFlag);
|
||||
Yap_InitCPred("$non_singletons_in_term", 3, p_non_singletons_in_term, SafePredFlag|HiddenPredFlag);
|
||||
CurrentModule = TERMS_MODULE;
|
||||
Yap_InitCPred("term_variables", 2, p_term_variables, 0);
|
||||
Yap_InitCPred("term_variables", 3, p_term_variables3, 0);
|
||||
CurrentModule = TERMS_MODULE;
|
||||
Yap_InitCPred("variable_in_term", 2, p_var_in_term, SafePredFlag);
|
||||
Yap_InitCPred("term_hash", 4, GvNTermHash, SafePredFlag);
|
||||
Yap_InitCPred("variant", 2, p_variant, 0);
|
||||
|
Reference in New Issue
Block a user