From e7ab7b4c8a6e38fe5aa1133f8e1ef1085f039edc Mon Sep 17 00:00:00 2001 From: vsc Date: Thu, 18 Dec 2003 17:23:22 +0000 Subject: [PATCH] fix non-tabling version fix compilation with THREADS git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@952 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/absmi.c | 18 +++++------------- C/amasm.c | 8 ++++---- C/cdmgr.c | 6 +++--- C/dbase.c | 4 ++-- C/exec.c | 2 +- C/heapgc.c | 6 +++--- C/index.c | 9 +++++++-- C/init.c | 2 +- 8 files changed, 26 insertions(+), 29 deletions(-) diff --git a/C/absmi.c b/C/absmi.c index 0063013c4..0f2b27f15 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -1129,7 +1129,7 @@ Yap_absmi(int inp) /* clear the entry from the trail */ TR = --(B->cp_tr); /* actually get rid of the code */ - if (cl->ref_count == 0 && cl->ClFlags & ErasedMask) { + if (cl->ClRefCount == 0 && cl->ClFlags & ErasedMask) { UNLOCK(cl->ClLock); /* I am the last one using this clause, hence I don't need a lock to dispose of it @@ -1208,7 +1208,6 @@ Yap_absmi(int inp) setregs(); #if defined(YAPOR) || defined(THREADS) - LOCK(cl->ClLock); /* always add an extra reference */ INC_CLREF_COUNT(cl); @@ -1253,7 +1252,6 @@ Yap_absmi(int inp) /* say that an environment is using this clause */ /* we have our own copy for the clause */ #if defined(YAPOR) || defined(THREADS) - LOCK(cl->ClLock); /* always add an extra reference */ INC_CLREF_COUNT(cl); @@ -1619,7 +1617,7 @@ Yap_absmi(int inp) int erase; LOCK(cl->ClLock); DEC_CLREF_COUNT(cl); - erase = (cl->ClFlags & ErasedMask) && (cl->ref_count == 0); + erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount); UNLOCK(cl->ClLock); if (erase) { saveregs(); @@ -1628,12 +1626,13 @@ Yap_absmi(int inp) hence we don't need to have a lock it */ Yap_ErLogUpdCl(cl); setregs(); + } } else { DynamicClause *cl = ClauseFlagsToDynamicClause(pt1); int erase; LOCK(cl->ClLock); DEC_CLREF_COUNT(cl); - erase = (cl->ClFlags & ErasedMask) && (cl->ref_count == 0); + erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount); UNLOCK(cl->ClLock); if (erase) { saveregs(); @@ -6359,17 +6358,10 @@ Yap_absmi(int inp) we do not lock access to the predicate, we must take extra care here */ - /* - Ideally, this code should only be executed by - dynamic procedures in YAPOR. Unfortunately, it also seems - to be executed when - running a procedure from within the file that defines it. - */ - /* THIS SHOULD BE AN ERROR !!!!! */ if (PredFromDefCode(PREG)->OpcodeOfPred != INDEX_OPCODE) { /* someone was here before we were */ Yap_Error(SYSTEM_ERROR,TermNil,"Bad locking"); - PREG = FAILCODE; + PREG = PredFromDefCode(PREG)->CodeOfPred; WRITE_UNLOCK(PredFromDefCode(PREG)->PRWLock); JMPNext(); } diff --git a/C/amasm.c b/C/amasm.c index 31fd97045..2a17e90cb 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -2067,8 +2067,8 @@ do_pass(void) cl_u->luc.ClExt = NULL; cl_u->luc.ClPrev = cl_u->luc.ClNext = NULL; #if defined(YAPOR) || defined(THREADS) - INIT_LOCK(cl_u.luc->ClLock); - INIT_CLREF_COUNT(cl_u.luc); + INIT_LOCK(cl_u->luc.ClLock); + INIT_CLREF_COUNT(&(cl_u->luc)); #endif } code_p = cl_u->luc.ClCode; @@ -2080,8 +2080,8 @@ do_pass(void) } cl_u->ic.ClRefCount = 0; #if defined(YAPOR) || defined(THREADS) - INIT_LOCK(cl_u.ic->ClLock); - INIT_CLREF_COUNT(cl_u.ic); + INIT_LOCK(cl_u->ic.ClLock); + INIT_CLREF_COUNT(&(cl_u->ic)); #endif } code_p = cl_u->ic.ClCode; diff --git a/C/cdmgr.c b/C/cdmgr.c index 1fb2a1ed0..fd5e9b136 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -3049,10 +3049,10 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya return FALSE; } rtn = MkDBRefTerm((DBRef)cl); -#if defined(OR) || defined(THREADS) +#if defined(YAPOR) || defined(THREADS) LOCK(cl->ClLock); TRAIL_CLREF(cl); /* So that fail will erase it */ - INC_DBREF_COUNT(cl); + INC_CLREF_COUNT(cl); UNLOCK(cl->ClLock); #else if (!(cl->ClFlags & InUseMask)) { @@ -3325,7 +3325,7 @@ p_nth_clause(void) #if defined(YAPOR) || defined(THREADS) LOCK(cl->ClLock); TRAIL_CLREF(cl); /* So that fail will erase it */ - INC_DBREF_COUNT(cl); + INC_CLREF_COUNT(cl); UNLOCK(cl->ClLock); #else if (!(cl->ClFlags & InUseMask)) { diff --git a/C/dbase.c b/C/dbase.c index 9f297a738..711dddfd4 100644 --- a/C/dbase.c +++ b/C/dbase.c @@ -2606,7 +2606,7 @@ new_lu_entry(Term t) WRITE_LOCK(RepAtom(at)->ARWLock); p0 = Yap_NewPredPropByAtom(at,2); } else { - WRITE_LOCK(f->FRWLock); + WRITE_LOCK(FunctorList->FRWLock); p0 = Yap_NewPredPropByFunctor(FunctorList,2); } pe = RepPredProp(p0); @@ -3729,7 +3729,7 @@ find_next_clause(DBRef ref0) LOCK(cl->ClLock); TRAIL_CLREF(cl); - INC_DBREF_COUNT(cl); + INC_CLREF_COUNT(cl); UNLOCK(cl->ClLock); } #else diff --git a/C/exec.c b/C/exec.c index e0f23c322..9b2f5d099 100644 --- a/C/exec.c +++ b/C/exec.c @@ -156,7 +156,7 @@ CallClause(PredEntry *pen, Int position) LOCK(cl->ClLock); TRAIL_CLREF(cl); - INC_DBREF_COUNT(cl); + INC_CLREF_COUNT(cl); UNLOCK(cl->ClLock); } #else diff --git a/C/heapgc.c b/C/heapgc.c index ba13cf1bf..792925a08 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -1949,7 +1949,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR) indx->ClFlags &= ~InUseMask; erase = (indx->ClFlags & ErasedMask) #if defined(YAPOR) || defined(THREADS) - && (indx->ref_count == 0) + && (indx->ClRefCount == 0) #endif ; if (erase) { @@ -1964,7 +1964,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR) cl->ClFlags &= ~InUseMask; erase = (cl->ClFlags & ErasedMask) #if defined(YAPOR) || defined(THREADS) - && (cl->ref_count == 0) + && (cl->ClRefCount == 0) #endif ; if (erase) { @@ -1980,7 +1980,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR) cl->ClFlags &= ~InUseMask; erase = (cl->ClFlags & ErasedMask) #if defined(YAPOR) || defined(THREADS) - && (cl->ref_count == 0) + && (cl->ClRefCount == 0) #endif ; if (erase) { diff --git a/C/index.c b/C/index.c index 35f88fc15..593faeb40 100644 --- a/C/index.c +++ b/C/index.c @@ -2351,10 +2351,13 @@ emit_optry(int var_group, int first, int clauses, int clleft, PredEntry *ap) return trust_op; } } else if (clleft == 0) { +#ifdef TABLING if (ap->PredFlags & TabledPredFlag && !first) { /* we never actually get to remove the last choice-point in this case */ return retry_op; - } else { + } else +#endif + { /* last group */ return try_op; } @@ -2862,6 +2865,7 @@ emit_protection_choicepoint(int first, int clleft, UInt nxtlbl, PredEntry *ap) /* !first */ if (clleft) { Yap_emit(retryme_op, nxtlbl, (clleft << 1)); +#ifdef TABLING } else if ((ap->PredFlags & TabledPredFlag)) { /* we cannot get rid of the choice-point for tabled predicates, all @@ -2870,6 +2874,7 @@ emit_protection_choicepoint(int first, int clleft, UInt nxtlbl, PredEntry *ap) */ Yap_emit(retryme_op, (CELL)TRUSTFAILCODE, 0); } else { +#endif Yap_emit(trustme_op, 0, 0); } } @@ -6203,7 +6208,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term t1, Term tb, Term tr, yam /* clear the entry from the trail */ TR = --(B->cp_tr); /* actually get rid of the code */ - if (cl->ref_count == 0 && cl->ClFlags & ErasedMask) { + if (cl->ClRefCount == 0 && cl->ClFlags & ErasedMask) { UNLOCK(cl->ClLock); /* I am the last one using this clause, hence I don't need a lock to dispose of it diff --git a/C/init.c b/C/init.c index 5e3b05e09..84ceb6c6f 100644 --- a/C/init.c +++ b/C/init.c @@ -1105,7 +1105,7 @@ Yap_InitStacks(int Heap, #endif /* PUSH_REGS */ #ifdef THREADS - regp->worker_id_ = 0; + Yap_regp->worker_id_ = 0; #endif /* Init signal handling and time */ /* also init memory page size, required by later functions */