|
From: Vitor S. C. <vs...@us...> - 2008-08-12 02:08:53
|
Update of /cvsroot/yap/C In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21137/C Modified Files: absmi.c amasm.c arith1.c threads.c utilpreds.c Log Message: MaxOS fixes Avoid a thread deadlock improvements to SWI predicates. make variables_in_term system builtin. Index: absmi.c =================================================================== RCS file: /cvsroot/yap/C/absmi.c,v retrieving revision 1.245 retrieving revision 1.246 diff -u -r1.245 -r1.246 --- absmi.c 7 Aug 2008 20:51:15 -0000 1.245 +++ absmi.c 12 Aug 2008 01:27:22 -0000 1.246 @@ -12,6 +12,12 @@ * comments: Portable abstract machine interpreter * * Last rev: $Date$,$Author$ * * $Log$ +* Revision 1.246 2008/08/12 01:27:22 vsc +* MaxOS fixes +* Avoid a thread deadlock +* improvements to SWI predicates. +* make variables_in_term system builtin. +* * Revision 1.245 2008/08/07 20:51:15 vsc * more threadin fixes * @@ -494,6 +500,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)) { Index: amasm.c =================================================================== RCS file: /cvsroot/yap/C/amasm.c,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- amasm.c 7 Aug 2008 20:51:16 -0000 1.103 +++ amasm.c 12 Aug 2008 01:27:22 -0000 1.104 @@ -13,6 +13,12 @@ * * * Last rev: $Date$ * * $Log$ +* Revision 1.104 2008/08/12 01:27:22 vsc +* MaxOS fixes +* Avoid a thread deadlock +* improvements to SWI predicates. +* make variables_in_term system builtin. +* * Revision 1.103 2008/08/07 20:51:16 vsc * more threadin fixes * @@ -3122,7 +3128,8 @@ #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); @@ -3221,7 +3228,8 @@ #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); @@ -3232,7 +3240,8 @@ 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); Index: arith1.c =================================================================== RCS file: /cvsroot/yap/C/arith1.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- arith1.c 13 May 2008 10:37:27 -0000 1.32 +++ arith1.c 12 Aug 2008 01:27:22 -0000 1.33 @@ -1966,6 +1966,52 @@ } } +/* + 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 @@ {"float_integer_part", p_fintp}, {"sign", p_sign}, {"lgamma", p_lgamma}, + {"random", p_random}, }; static Int Index: threads.c =================================================================== RCS file: /cvsroot/yap/C/threads.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- threads.c 8 Aug 2008 16:05:10 -0000 1.46 +++ threads.c 12 Aug 2008 01:27:22 -0000 1.47 @@ -897,6 +897,11 @@ return Yap_unify(ARG1,MkIntTerm(0)); } +p_thread_stacks(void) +{ /* '$thread_runtime'(+P) */ + return FALSE; +} + static Int p_thread_unlock(void) { /* '$thread_runtime'(+P) */ Index: utilpreds.c =================================================================== RCS file: /cvsroot/yap/C/utilpreds.c,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- utilpreds.c 6 Aug 2008 17:32:20 -0000 1.64 +++ utilpreds.c 12 Aug 2008 01:27:22 -0000 1.65 @@ -172,9 +172,9 @@ 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 @@ 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); |