error handling

This commit is contained in:
Vitor Santos Costa 2016-07-30 23:06:28 -05:00
parent 0dd8f62237
commit 7d44e3188b
3 changed files with 50 additions and 39 deletions

View File

@ -27,8 +27,8 @@ static char SccsId[] = "%W% %G%";
#include "Yap.h" #include "Yap.h"
#include "Yatom.h" #include "Yatom.h"
#include "yapio.h"
#include "clause.h" #include "clause.h"
#include "yapio.h"
#include <stdio.h> #include <stdio.h>
#include <wchar.h> #include <wchar.h>
#if HAVE_STRING_Hq #if HAVE_STRING_Hq
@ -40,7 +40,7 @@ static char SccsId[] = "%W% %G%";
uint64_t hash = 5381; uint64_t hash = 5381;
uint64_t c; uint64_t c;
while ((c = (uint64_t)(*CHP++)) != '\0') { while ((c = *CHP++) != '\0') {
/* hash = ((hash << 5) + hash) + c; hash * 33 + c */ /* hash = ((hash << 5) + hash) + c; hash * 33 + c */
hash = hash * (uint64_t)33 + c; hash = hash * (uint64_t)33 + c;
} }
@ -63,7 +63,6 @@ uint64_t WideHashFunction(wchar_t *CHP) {
return hash; return hash;
} }
/* this routine must be run at least having a read lock on ae */ /* this routine must be run at least having a read lock on ae */
static Prop static Prop
GetFunctorProp(AtomEntry *ae, GetFunctorProp(AtomEntry *ae,
@ -78,8 +77,7 @@ GetFunctorProp(AtomEntry *ae,
} }
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */ /* vsc: We must guarantee that IsVarTerm(functor) returns true! */
static inline Functor InlinedUnlockedMkFunctor(AtomEntry *ae, static inline Functor InlinedUnlockedMkFunctor(AtomEntry *ae, arity_t arity) {
arity_t arity) {
FunctorEntry *p; FunctorEntry *p;
Prop p0; Prop p0;
@ -174,7 +172,7 @@ static Atom
LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */ LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */
uint64_t hash; uint64_t hash;
const unsigned char *p; const unsigned char *p;
Atom a, na; Atom a, na = NIL;
AtomEntry *ae; AtomEntry *ae;
size_t sz = AtomHashTableSize; size_t sz = AtomHashTableSize;
@ -566,10 +564,8 @@ Yap_OpPropForModule(Atom a,
} }
OpEntry * OpEntry *
Yap_GetOpProp(Atom a, Yap_GetOpProp(Atom a, op_type type,
op_type type, Term cmod USES_REGS) { /* look property list of atom a for kind */
Term cmod
USES_REGS) { /* look property list of atom a for kind */
AtomEntry *ae = RepAtom(a); AtomEntry *ae = RepAtom(a);
PropEntry *pp; PropEntry *pp;
OpEntry *oinfo = NULL; OpEntry *oinfo = NULL;
@ -888,8 +884,7 @@ Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) {
return NIL; return NIL;
} }
INIT_LOCK(p->PELock); INIT_LOCK(p->PELock);
p->StatisticsForPred = NULL: p->StatisticsForPred = NULL : p->KindOfPE = PEProp;
p->KindOfPE = PEProp;
p->ArityOfPE = ap->ArityOfPE; p->ArityOfPE = ap->ArityOfPE;
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL; p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
p->cs.p_code.NOfClauses = 0; p->cs.p_code.NOfClauses = 0;

View File

@ -93,6 +93,10 @@ arrays. Memory mapped arrays are limited by available space in the file
system and in the virtual memory space. system and in the virtual memory space.
The following predicates manipulate arrays: The following predicates manipulate arrays:
*/ */
#include "Yap.h" #include "Yap.h"
@ -100,6 +104,11 @@ The following predicates manipulate arrays:
#include "clause.h" #include "clause.h"
#include "eval.h" #include "eval.h"
#include "heapgc.h" #include "heapgc.h"
#if HAVE_ERRNO_H
#include <errno.h>
#else
extern int errno;
#endif
#if HAVE_STRING_H #if HAVE_STRING_H
#include <string.h> #include <string.h>
#endif #endif

View File

@ -97,10 +97,10 @@ stored in the i.d.b.
*/ */
#include "Yap.h" #include "Yap.h"
#include "clause.h"
#include "yapio.h"
#include "attvar.h" #include "attvar.h"
#include "clause.h"
#include "heapgc.h" #include "heapgc.h"
#include "yapio.h"
#if HAVE_STRING_H #if HAVE_STRING_H
#include <string.h> #include <string.h>
#endif #endif
@ -714,13 +714,20 @@ loop:
switch ((CELL)f) { switch ((CELL)f) {
case (CELL)FunctorDBRef: { case (CELL)FunctorDBRef: {
DBRef dbentry; DBRef dbentry;
/* store now the correct entry */
dbentry = DBRefOfTerm(d0); dbentry = DBRefOfTerm(d0);
*StoPoint++ = d0; *StoPoint++ = d0;
dbg->lr--; dbg->lr--;
if (dbentry->Flags & LogUpdMask) { if (dbentry->Flags & LogUpdMask) {
LogUpdClause *cl = (LogUpdClause *)dbentry; LogUpdClause *cl = (LogUpdClause *)dbentry;
/* store now the correct entry */
#if DEBUG
if (GLOBAL_Option['i' - 'a' + 1]) {
Yap_DebugPlWriteln(d0);
fprintf(stderr, "+%p@%p %s\n", cl, cl->ClPred,
IndicatorOfPred(cl->ClPred));
}
#endif
cl->ClRefCount++; cl->ClRefCount++;
} else { } else {
dbentry->NOfRefsTo++; dbentry->NOfRefsTo++;