2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: adtdefs.c *
|
|
|
|
* Last rev: *
|
|
|
|
* mods: *
|
|
|
|
* comments: abstract machine definitions *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
|
|
|
#ifdef SCCS
|
|
|
|
static char SccsId[] = "%W% %G%";
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ADTDEFS_C
|
|
|
|
|
2002-02-22 06:12:18 +00:00
|
|
|
#ifdef __SUNPRO_CC
|
|
|
|
#define inline
|
|
|
|
#endif
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#include "Yap.h"
|
|
|
|
#include "Yatom.h"
|
|
|
|
#include "yapio.h"
|
|
|
|
#include <stdio.h>
|
2006-11-27 17:42:03 +00:00
|
|
|
#include <wchar.h>
|
2001-04-09 20:54:03 +01:00
|
|
|
#if HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* this routine must be run at least having a read lock on ae */
|
|
|
|
static Prop
|
2015-10-22 00:25:11 +01:00
|
|
|
GetFunctorProp(AtomEntry *ae,
|
|
|
|
unsigned int arity) { /* look property list of atom a for kind */
|
2001-04-09 20:54:03 +01:00
|
|
|
FunctorEntry *pp;
|
|
|
|
|
2001-10-30 16:42:05 +00:00
|
|
|
pp = RepFunctorProp(ae->PropsOfAE);
|
2001-04-09 20:54:03 +01:00
|
|
|
while (!EndOfPAEntr(pp) &&
|
2015-10-22 00:25:11 +01:00
|
|
|
(!IsFunctorProperty(pp->KindOfPE) || pp->ArityOfFE != arity))
|
2001-04-09 20:54:03 +01:00
|
|
|
pp = RepFunctorProp(pp->NextOfPE);
|
|
|
|
return (AbsFunctorProp(pp));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
2015-10-22 00:25:11 +01:00
|
|
|
static inline Functor InlinedUnlockedMkFunctor(AtomEntry *ae,
|
|
|
|
unsigned int arity) {
|
2001-04-09 20:54:03 +01:00
|
|
|
FunctorEntry *p;
|
|
|
|
Prop p0;
|
|
|
|
|
|
|
|
p0 = GetFunctorProp(ae, arity);
|
|
|
|
if (p0 != NIL) {
|
2015-10-22 00:25:11 +01:00
|
|
|
return ((Functor)RepProp(p0));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
p = (FunctorEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
2007-04-18 07:30:41 +01:00
|
|
|
if (!p)
|
|
|
|
return NULL;
|
2001-04-09 20:54:03 +01:00
|
|
|
p->KindOfPE = FunctorProperty;
|
|
|
|
p->NameOfFE = AbsAtom(ae);
|
|
|
|
p->ArityOfFE = arity;
|
2001-10-03 14:39:16 +01:00
|
|
|
p->PropsOfFE = NIL;
|
|
|
|
INIT_RWLOCK(p->FRWLock);
|
2011-08-17 19:16:21 +01:00
|
|
|
/* respect the first property, in case this is a wide atom */
|
|
|
|
AddPropToAtom(ae, (PropEntry *)p);
|
2015-10-22 00:25:11 +01:00
|
|
|
return ((Functor)p);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Functor Yap_UnlockedMkFunctor(AtomEntry *ae, unsigned int arity) {
|
|
|
|
return (InlinedUnlockedMkFunctor(ae, arity));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
2015-10-22 00:25:11 +01:00
|
|
|
Functor Yap_MkFunctor(Atom ap, unsigned int arity) {
|
2001-04-09 20:54:03 +01:00
|
|
|
AtomEntry *ae = RepAtom(ap);
|
|
|
|
Functor f;
|
|
|
|
|
|
|
|
WRITE_LOCK(ae->ARWLock);
|
|
|
|
f = InlinedUnlockedMkFunctor(ae, arity);
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return (f);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vsc: We must guarantee that IsVarTerm(functor) returns true! */
|
2015-10-22 00:25:11 +01:00
|
|
|
void Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p) {
|
2001-04-09 20:54:03 +01:00
|
|
|
AtomEntry *ae = RepAtom(ap);
|
2015-10-22 00:25:11 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
WRITE_LOCK(ae->ARWLock);
|
|
|
|
p->KindOfPE = FunctorProperty;
|
|
|
|
p->NameOfFE = ap;
|
|
|
|
p->ArityOfFE = arity;
|
2011-08-17 19:16:21 +01:00
|
|
|
AddPropToAtom(ae, (PropEntry *)p);
|
2001-04-09 20:54:03 +01:00
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
inline static Atom SearchInInvisible(const unsigned char *atom) {
|
2001-04-09 20:54:03 +01:00
|
|
|
AtomEntry *chain;
|
|
|
|
|
|
|
|
READ_LOCK(INVISIBLECHAIN.AERWLock);
|
|
|
|
chain = RepAtom(INVISIBLECHAIN.Entry);
|
2015-09-21 23:05:36 +01:00
|
|
|
while (!EndOfPAEntr(chain) && strcmp((char *)chain->StrOfAE, (char *)atom)) {
|
2001-04-09 20:54:03 +01:00
|
|
|
chain = RepAtom(chain->NextOfAE);
|
|
|
|
}
|
|
|
|
READ_UNLOCK(INVISIBLECHAIN.AERWLock);
|
|
|
|
if (EndOfPAEntr(chain))
|
|
|
|
return (NIL);
|
|
|
|
else
|
2015-10-22 00:25:11 +01:00
|
|
|
return (AbsAtom(chain));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
static inline Atom SearchAtom(const unsigned char *p, Atom a) {
|
2001-04-09 20:54:03 +01:00
|
|
|
AtomEntry *ae;
|
|
|
|
|
|
|
|
/* search atom in chain */
|
|
|
|
while (a != NIL) {
|
|
|
|
ae = RepAtom(a);
|
2015-09-21 23:05:36 +01:00
|
|
|
if (strcmp((char *)ae->StrOfAE, (const char *)p) == 0) {
|
2015-10-22 00:25:11 +01:00
|
|
|
return (a);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
a = ae->NextOfAE;
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
return (NIL);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
static inline Atom SearchWideAtom(const wchar_t *p, Atom a) {
|
2006-11-27 17:42:03 +00:00
|
|
|
AtomEntry *ae;
|
|
|
|
|
|
|
|
/* search atom in chain */
|
|
|
|
while (a != NIL) {
|
|
|
|
ae = RepAtom(a);
|
|
|
|
if (wcscmp((wchar_t *)ae->StrOfAE, p) == 0) {
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
a = ae->NextOfAE;
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
return (NIL);
|
2006-11-27 17:42:03 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
static Atom
|
2015-10-22 00:25:11 +01:00
|
|
|
LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */
|
2013-11-07 23:50:04 +00:00
|
|
|
UInt hash;
|
2015-09-21 23:05:36 +01:00
|
|
|
const unsigned char *p;
|
2003-12-01 17:27:42 +00:00
|
|
|
Atom a, na;
|
2001-04-09 20:54:03 +01:00
|
|
|
AtomEntry *ae;
|
2015-10-22 00:25:11 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/* compute hash */
|
2015-07-23 00:59:07 +01:00
|
|
|
p = atom;
|
2003-10-28 01:16:03 +00:00
|
|
|
hash = HashFunction(p) % AtomHashTableSize;
|
2013-11-07 23:50:04 +00:00
|
|
|
|
2003-12-01 17:27:42 +00:00
|
|
|
/* we'll start by holding a read lock in order to avoid contention */
|
|
|
|
READ_LOCK(HashChain[hash].AERWLock);
|
2001-04-09 20:54:03 +01:00
|
|
|
a = HashChain[hash].Entry;
|
|
|
|
/* search atom in chain */
|
2015-07-23 00:59:07 +01:00
|
|
|
na = SearchAtom(atom, a);
|
2003-12-01 17:27:42 +00:00
|
|
|
if (na != NIL) {
|
|
|
|
READ_UNLOCK(HashChain[hash].AERWLock);
|
2015-10-22 00:25:11 +01:00
|
|
|
return (na);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2003-12-01 17:27:42 +00:00
|
|
|
READ_UNLOCK(HashChain[hash].AERWLock);
|
|
|
|
/* we need a write lock */
|
|
|
|
WRITE_LOCK(HashChain[hash].AERWLock);
|
2015-10-22 00:25:11 +01:00
|
|
|
/* concurrent version of Yap, need to take care */
|
2003-12-01 17:27:42 +00:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
|
|
|
if (a != HashChain[hash].Entry) {
|
|
|
|
a = HashChain[hash].Entry;
|
2015-07-23 00:59:07 +01:00
|
|
|
na = SearchAtom(atom, a);
|
2003-12-01 17:27:42 +00:00
|
|
|
if (na != NIL) {
|
|
|
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
2015-10-22 00:25:11 +01:00
|
|
|
return (na);
|
2003-12-01 17:27:42 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
/* add new atom to start of chain */
|
2015-10-22 00:25:11 +01:00
|
|
|
ae = (AtomEntry *)Yap_AllocAtomSpace((sizeof *ae) +
|
|
|
|
strlen((const char *)atom) + 1);
|
2005-04-27 21:09:26 +01:00
|
|
|
if (ae == NULL) {
|
|
|
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
2005-03-01 22:25:09 +00:00
|
|
|
return NIL;
|
2005-04-27 21:09:26 +01:00
|
|
|
}
|
|
|
|
NOfAtoms++;
|
2003-12-01 17:27:42 +00:00
|
|
|
na = AbsAtom(ae);
|
2001-10-30 16:42:05 +00:00
|
|
|
ae->PropsOfAE = NIL;
|
2015-09-21 23:05:36 +01:00
|
|
|
if (ae->UStrOfAE != atom)
|
|
|
|
strcpy((char *)ae->StrOfAE, (const char *)atom);
|
2003-12-01 17:27:42 +00:00
|
|
|
ae->NextOfAE = a;
|
|
|
|
HashChain[hash].Entry = na;
|
2001-04-09 20:54:03 +01:00
|
|
|
INIT_RWLOCK(ae->ARWLock);
|
|
|
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
2014-09-10 05:50:43 +01:00
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
if (NOfAtoms > 2 * AtomHashTableSize) {
|
2004-01-23 02:23:51 +00:00
|
|
|
Yap_signal(YAP_CDOVF_SIGNAL);
|
2003-10-28 01:16:03 +00:00
|
|
|
}
|
2003-12-01 17:27:42 +00:00
|
|
|
return na;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2006-11-27 17:42:03 +00:00
|
|
|
static Atom
|
2015-10-22 00:25:11 +01:00
|
|
|
LookupWideAtom(const wchar_t *atom) { /* lookup atom in atom table */
|
2006-11-27 17:42:03 +00:00
|
|
|
CELL hash;
|
|
|
|
wchar_t *p;
|
|
|
|
Atom a, na;
|
|
|
|
AtomEntry *ae;
|
|
|
|
UInt sz;
|
|
|
|
WideAtomEntry *wae;
|
|
|
|
|
|
|
|
/* compute hash */
|
2014-05-25 20:44:57 +01:00
|
|
|
p = (wchar_t *)atom;
|
2006-11-27 17:42:03 +00:00
|
|
|
hash = WideHashFunction(p) % WideAtomHashTableSize;
|
|
|
|
/* we'll start by holding a read lock in order to avoid contention */
|
|
|
|
READ_LOCK(WideHashChain[hash].AERWLock);
|
|
|
|
a = WideHashChain[hash].Entry;
|
|
|
|
/* search atom in chain */
|
|
|
|
na = SearchWideAtom(atom, a);
|
|
|
|
if (na != NIL) {
|
|
|
|
READ_UNLOCK(WideHashChain[hash].AERWLock);
|
2015-10-22 00:25:11 +01:00
|
|
|
return (na);
|
2006-11-27 17:42:03 +00:00
|
|
|
}
|
|
|
|
READ_UNLOCK(WideHashChain[hash].AERWLock);
|
|
|
|
/* we need a write lock */
|
|
|
|
WRITE_LOCK(WideHashChain[hash].AERWLock);
|
2015-10-22 00:25:11 +01:00
|
|
|
/* concurrent version of Yap, need to take care */
|
2006-11-27 17:42:03 +00:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
|
|
|
if (a != WideHashChain[hash].Entry) {
|
|
|
|
a = WideHashChain[hash].Entry;
|
2006-11-28 00:51:59 +00:00
|
|
|
na = SearchWideAtom(atom, a);
|
2006-11-27 17:42:03 +00:00
|
|
|
if (na != NIL) {
|
|
|
|
WRITE_UNLOCK(WideHashChain[hash].AERWLock);
|
|
|
|
return na;
|
|
|
|
}
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
#endif
|
2006-11-27 17:42:03 +00:00
|
|
|
/* add new atom to start of chain */
|
|
|
|
sz = wcslen(atom);
|
2015-10-22 00:25:11 +01:00
|
|
|
ae = (AtomEntry *)Yap_AllocAtomSpace((size_t)(((AtomEntry *)NULL) + 1) +
|
|
|
|
sizeof(wchar_t) * (sz + 1));
|
2006-11-27 17:42:03 +00:00
|
|
|
if (ae == NULL) {
|
|
|
|
WRITE_UNLOCK(WideHashChain[hash].AERWLock);
|
|
|
|
return NIL;
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
wae = (WideAtomEntry *)Yap_AllocAtomSpace(sizeof(WideAtomEntry));
|
2012-10-16 08:43:29 +01:00
|
|
|
if (wae == NULL) {
|
|
|
|
WRITE_UNLOCK(WideHashChain[hash].AERWLock);
|
|
|
|
return NIL;
|
|
|
|
}
|
2006-11-27 17:42:03 +00:00
|
|
|
na = AbsAtom(ae);
|
|
|
|
ae->PropsOfAE = AbsWideAtomProp(wae);
|
|
|
|
wae->NextOfPE = NIL;
|
|
|
|
wae->KindOfPE = WideAtomProperty;
|
|
|
|
wae->SizeOfAtom = sz;
|
2013-01-09 09:21:07 +00:00
|
|
|
if (ae->WStrOfAE != atom)
|
|
|
|
wcscpy(ae->WStrOfAE, atom);
|
2006-11-27 17:42:03 +00:00
|
|
|
NOfAtoms++;
|
|
|
|
ae->NextOfAE = a;
|
|
|
|
WideHashChain[hash].Entry = na;
|
|
|
|
INIT_RWLOCK(ae->ARWLock);
|
|
|
|
WRITE_UNLOCK(WideHashChain[hash].AERWLock);
|
2014-09-10 05:50:43 +01:00
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
if (NOfWideAtoms > 2 * WideAtomHashTableSize) {
|
2006-11-27 17:42:03 +00:00
|
|
|
Yap_signal(YAP_CDOVF_SIGNAL);
|
|
|
|
}
|
|
|
|
return na;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Atom Yap_LookupMaybeWideAtom(
|
|
|
|
const wchar_t *atom) { /* lookup atom in atom table */
|
2014-05-25 20:44:57 +01:00
|
|
|
wchar_t *p = (wchar_t *)atom, c;
|
2008-03-27 00:41:33 +00:00
|
|
|
size_t len = 0;
|
2015-09-21 23:05:36 +01:00
|
|
|
unsigned char *ptr, *ptr0;
|
2008-03-27 00:41:33 +00:00
|
|
|
Atom at;
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
while ((c = *p++)) {
|
|
|
|
if (c > 255)
|
|
|
|
return LookupWideAtom(atom);
|
2008-03-27 00:41:33 +00:00
|
|
|
len++;
|
|
|
|
}
|
|
|
|
/* not really a wide atom */
|
2014-05-25 20:44:57 +01:00
|
|
|
p = (wchar_t *)atom;
|
2015-10-22 00:25:11 +01:00
|
|
|
ptr0 = ptr = Yap_AllocCodeSpace(len + 1);
|
2008-03-27 00:41:33 +00:00
|
|
|
if (!ptr)
|
|
|
|
return NIL;
|
2015-10-22 00:25:11 +01:00
|
|
|
while ((*ptr++ = *p++))
|
|
|
|
;
|
2008-03-27 00:41:33 +00:00
|
|
|
at = LookupAtom(ptr0);
|
|
|
|
Yap_FreeCodeSpace(ptr0);
|
|
|
|
return at;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Atom Yap_LookupMaybeWideAtomWithLength(
|
|
|
|
const wchar_t *atom, size_t len0) { /* lookup atom in atom table */
|
2010-05-06 10:58:25 +01:00
|
|
|
Atom at;
|
|
|
|
int wide = FALSE;
|
2014-04-23 22:41:12 +01:00
|
|
|
size_t i = 0;
|
2014-03-18 15:40:50 +00:00
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
while (i < len0) {
|
2014-03-18 15:40:50 +00:00
|
|
|
// primary support for atoms with null chars
|
|
|
|
wchar_t c = atom[i];
|
|
|
|
if (c > 255) {
|
|
|
|
wide = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
if (c == '\0') {
|
2014-03-18 15:40:50 +00:00
|
|
|
len0 = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
2010-05-06 10:58:25 +01:00
|
|
|
}
|
2013-12-15 10:27:33 +00:00
|
|
|
if (wide) {
|
|
|
|
wchar_t *ptr0;
|
2014-03-18 15:40:50 +00:00
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
ptr0 = (wchar_t *)Yap_AllocCodeSpace(sizeof(wchar_t) * (len0 + 1));
|
2013-12-15 10:27:33 +00:00
|
|
|
if (!ptr0)
|
2010-05-06 10:58:25 +01:00
|
|
|
return NIL;
|
2015-10-22 00:25:11 +01:00
|
|
|
memcpy(ptr0, atom, len0 * sizeof(wchar_t));
|
2013-12-15 10:27:33 +00:00
|
|
|
ptr0[len0] = '\0';
|
2010-05-06 10:58:25 +01:00
|
|
|
at = LookupWideAtom(ptr0);
|
2010-05-06 12:19:51 +01:00
|
|
|
Yap_FreeCodeSpace((char *)ptr0);
|
2010-05-06 10:58:25 +01:00
|
|
|
return at;
|
|
|
|
} else {
|
2015-09-21 23:05:36 +01:00
|
|
|
unsigned char *ptr0;
|
2014-03-18 15:40:50 +00:00
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
ptr0 = Yap_AllocCodeSpace((len0 + 1));
|
2013-12-15 10:27:33 +00:00
|
|
|
if (!ptr0)
|
2010-05-06 10:58:25 +01:00
|
|
|
return NIL;
|
2015-10-22 00:25:11 +01:00
|
|
|
for (i = 0; i < len0; i++)
|
2014-03-18 15:40:50 +00:00
|
|
|
ptr0[i] = atom[i];
|
2013-12-15 10:27:33 +00:00
|
|
|
ptr0[len0] = '\0';
|
2010-05-06 10:58:25 +01:00
|
|
|
at = LookupAtom(ptr0);
|
|
|
|
Yap_FreeCodeSpace(ptr0);
|
|
|
|
return at;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Atom Yap_LookupAtomWithLength(const char *atom,
|
|
|
|
size_t len0) { /* lookup atom in atom table */
|
2013-12-02 14:49:41 +00:00
|
|
|
Atom at;
|
2015-09-21 23:05:36 +01:00
|
|
|
unsigned char *ptr;
|
2013-12-02 14:49:41 +00:00
|
|
|
|
|
|
|
/* not really a wide atom */
|
2015-10-22 00:25:11 +01:00
|
|
|
ptr = Yap_AllocCodeSpace(len0 + 1);
|
2013-12-02 14:49:41 +00:00
|
|
|
if (!ptr)
|
|
|
|
return NIL;
|
2014-03-18 15:40:50 +00:00
|
|
|
memcpy(ptr, atom, len0);
|
|
|
|
ptr[len0] = '\0';
|
|
|
|
at = LookupAtom(ptr);
|
|
|
|
Yap_FreeCodeSpace(ptr);
|
2013-12-02 14:49:41 +00:00
|
|
|
return at;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Atom Yap_LookupAtom(const char *atom) { /* lookup atom in atom table */
|
2015-09-21 23:05:36 +01:00
|
|
|
return LookupAtom((const unsigned char *)atom);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Atom Yap_ULookupAtom(
|
|
|
|
const unsigned char *atom) { /* lookup atom in atom table */
|
2005-03-01 22:25:09 +00:00
|
|
|
return LookupAtom(atom);
|
2002-11-11 17:38:10 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Atom Yap_LookupWideAtom(const wchar_t *atom) { /* lookup atom in atom table */
|
2006-11-27 17:42:03 +00:00
|
|
|
return LookupWideAtom(atom);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Atom Yap_FullLookupAtom(const char *atom) { /* lookup atom in atom table */
|
2001-04-09 20:54:03 +01:00
|
|
|
Atom t;
|
|
|
|
|
2015-09-21 23:05:36 +01:00
|
|
|
if ((t = SearchInInvisible((const unsigned char *)atom)) != NIL) {
|
2001-04-09 20:54:03 +01:00
|
|
|
return (t);
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
return (LookupAtom((const unsigned char *)atom));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
void Yap_LookupAtomWithAddress(const char *atom,
|
|
|
|
AtomEntry *ae) { /* lookup atom in atom table */
|
2001-04-09 20:54:03 +01:00
|
|
|
register CELL hash;
|
2015-09-21 23:05:36 +01:00
|
|
|
register const unsigned char *p;
|
2001-04-09 20:54:03 +01:00
|
|
|
Atom a;
|
|
|
|
|
|
|
|
/* compute hash */
|
2015-09-21 23:05:36 +01:00
|
|
|
p = (const unsigned char *)atom;
|
2003-10-28 01:16:03 +00:00
|
|
|
hash = HashFunction(p) % AtomHashTableSize;
|
2015-10-22 00:25:11 +01:00
|
|
|
/* ask for a WRITE lock because it is highly unlikely we shall find anything
|
|
|
|
*/
|
2001-04-09 20:54:03 +01:00
|
|
|
WRITE_LOCK(HashChain[hash].AERWLock);
|
|
|
|
a = HashChain[hash].Entry;
|
|
|
|
/* search atom in chain */
|
|
|
|
if (SearchAtom(p, a) != NIL) {
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil,
|
|
|
|
"repeated initialization for atom %s", ae);
|
2001-04-09 20:54:03 +01:00
|
|
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* add new atom to start of chain */
|
2005-10-28 18:38:50 +01:00
|
|
|
NOfAtoms++;
|
2001-04-09 20:54:03 +01:00
|
|
|
ae->NextOfAE = a;
|
|
|
|
HashChain[hash].Entry = AbsAtom(ae);
|
2001-10-30 16:42:05 +00:00
|
|
|
ae->PropsOfAE = NIL;
|
2015-09-21 23:05:36 +01:00
|
|
|
strcpy((char *)ae->StrOfAE, (char *)atom);
|
2001-04-09 20:54:03 +01:00
|
|
|
INIT_RWLOCK(ae->ARWLock);
|
|
|
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
void Yap_ReleaseAtom(Atom atom) { /* Releases an atom from the hash chain */
|
2001-04-09 20:54:03 +01:00
|
|
|
register Int hash;
|
2015-09-21 23:05:36 +01:00
|
|
|
register const unsigned char *p;
|
2001-04-09 20:54:03 +01:00
|
|
|
AtomEntry *inChain;
|
|
|
|
AtomEntry *ap = RepAtom(atom);
|
2015-09-21 23:05:36 +01:00
|
|
|
char unsigned *name = ap->UStrOfAE;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* compute hash */
|
2015-07-23 00:59:07 +01:00
|
|
|
p = name;
|
2003-10-28 01:16:03 +00:00
|
|
|
hash = HashFunction(p) % AtomHashTableSize;
|
2001-04-09 20:54:03 +01:00
|
|
|
WRITE_LOCK(HashChain[hash].AERWLock);
|
|
|
|
if (HashChain[hash].Entry == atom) {
|
2003-10-28 01:16:03 +00:00
|
|
|
NOfAtoms--;
|
2001-04-09 20:54:03 +01:00
|
|
|
HashChain[hash].Entry = ap->NextOfAE;
|
|
|
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* else */
|
|
|
|
inChain = RepAtom(HashChain[hash].Entry);
|
|
|
|
while (inChain->NextOfAE != atom)
|
|
|
|
inChain = RepAtom(inChain->NextOfAE);
|
|
|
|
WRITE_LOCK(inChain->ARWLock);
|
|
|
|
inChain->NextOfAE = ap->NextOfAE;
|
|
|
|
WRITE_UNLOCK(inChain->ARWLock);
|
|
|
|
WRITE_UNLOCK(HashChain[hash].AERWLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Prop
|
2015-10-22 00:25:11 +01:00
|
|
|
GetAPropHavingLock(AtomEntry *ae,
|
|
|
|
PropFlags kind) { /* look property list of atom a for kind */
|
2001-04-09 20:54:03 +01:00
|
|
|
PropEntry *pp;
|
|
|
|
|
2001-10-30 16:42:05 +00:00
|
|
|
pp = RepProp(ae->PropsOfAE);
|
2001-04-09 20:54:03 +01:00
|
|
|
while (!EndOfPAEntr(pp) && pp->KindOfPE != kind)
|
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
return (AbsProp(pp));
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetAPropHavingLock(
|
|
|
|
AtomEntry *ae, PropFlags kind) { /* look property list of atom a for kind */
|
|
|
|
return GetAPropHavingLock(ae, kind);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2002-11-11 17:38:10 +00:00
|
|
|
static Prop
|
2015-10-22 00:25:11 +01:00
|
|
|
GetAProp(Atom a, PropFlags kind) { /* look property list of atom a for kind */
|
2001-04-09 20:54:03 +01:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
Prop out;
|
|
|
|
|
|
|
|
READ_LOCK(ae->ARWLock);
|
2002-11-11 17:38:10 +00:00
|
|
|
out = GetAPropHavingLock(ae, kind);
|
2001-04-09 20:54:03 +01:00
|
|
|
READ_UNLOCK(ae->ARWLock);
|
|
|
|
return (out);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetAProp(Atom a,
|
|
|
|
PropFlags kind) { /* look property list of atom a for kind */
|
|
|
|
return GetAProp(a, kind);
|
2002-11-11 17:38:10 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
OpEntry *Yap_GetOpPropForAModuleHavingALock(
|
|
|
|
Atom a, Term mod) { /* look property list of atom a for kind */
|
2009-11-20 00:33:14 +00:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
PropEntry *pp;
|
|
|
|
|
|
|
|
pp = RepProp(ae->PropsOfAE);
|
|
|
|
while (!EndOfPAEntr(pp) &&
|
2015-10-22 00:25:11 +01:00
|
|
|
(pp->KindOfPE != OpProperty || ((OpEntry *)pp)->OpModule != mod))
|
2009-11-20 00:33:14 +00:00
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
if (EndOfPAEntr(pp)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return (OpEntry *)pp;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
int Yap_HasOp(Atom a) { /* look property list of atom a for kind */
|
2005-10-21 17:09:03 +01:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
PropEntry *pp;
|
|
|
|
|
2009-11-20 00:33:14 +00:00
|
|
|
READ_LOCK(ae->ARWLock);
|
|
|
|
pp = RepProp(ae->PropsOfAE);
|
2015-10-22 00:25:11 +01:00
|
|
|
while (!EndOfPAEntr(pp) && (pp->KindOfPE != OpProperty))
|
2009-11-20 00:33:14 +00:00
|
|
|
pp = RepProp(pp->NextOfPE);
|
2009-12-17 18:11:02 +00:00
|
|
|
READ_UNLOCK(ae->ARWLock);
|
2009-11-20 00:33:14 +00:00
|
|
|
if (EndOfPAEntr(pp)) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-28 01:23:14 +01:00
|
|
|
OpEntry *
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_OpPropForModule(Atom a,
|
|
|
|
Term mod) { /* look property list of atom a for kind */
|
2011-08-28 01:23:14 +01:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
PropEntry *pp;
|
2011-08-31 21:54:52 +01:00
|
|
|
OpEntry *info = NULL;
|
2011-08-28 01:23:14 +01:00
|
|
|
|
|
|
|
if (mod == TermProlog)
|
|
|
|
mod = PROLOG_MODULE;
|
|
|
|
WRITE_LOCK(ae->ARWLock);
|
|
|
|
pp = RepProp(ae->PropsOfAE);
|
|
|
|
while (!EndOfPAEntr(pp)) {
|
2015-10-22 00:25:11 +01:00
|
|
|
if (pp->KindOfPE == OpProperty) {
|
2011-08-28 01:23:14 +01:00
|
|
|
info = (OpEntry *)pp;
|
2011-08-31 21:54:52 +01:00
|
|
|
if (info->OpModule == mod) {
|
2015-10-22 00:25:11 +01:00
|
|
|
WRITE_LOCK(info->OpRWLock);
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return info;
|
2011-08-31 21:54:52 +01:00
|
|
|
}
|
2011-08-28 01:23:14 +01:00
|
|
|
}
|
2011-08-31 21:54:52 +01:00
|
|
|
pp = pp->NextOfPE;
|
2011-08-28 01:23:14 +01:00
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry));
|
2011-08-31 21:54:52 +01:00
|
|
|
info->KindOfPE = Ord(OpProperty);
|
|
|
|
info->OpModule = mod;
|
|
|
|
info->OpName = a;
|
|
|
|
LOCK(OpListLock);
|
|
|
|
info->OpNext = OpList;
|
|
|
|
OpList = info;
|
|
|
|
UNLOCK(OpListLock);
|
|
|
|
AddPropToAtom(ae, (PropEntry *)info);
|
|
|
|
INIT_RWLOCK(info->OpRWLock);
|
|
|
|
WRITE_LOCK(info->OpRWLock);
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
info->Prefix = info->Infix = info->Posfix = 0;
|
|
|
|
return info;
|
2011-08-28 01:23:14 +01:00
|
|
|
}
|
|
|
|
|
2009-11-20 00:33:14 +00:00
|
|
|
OpEntry *
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_GetOpProp(Atom a,
|
|
|
|
op_type type
|
|
|
|
USES_REGS) { /* look property list of atom a for kind */
|
2009-11-20 00:33:14 +00:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
PropEntry *pp;
|
2011-08-18 13:01:48 +01:00
|
|
|
OpEntry *oinfo = NULL;
|
2009-11-20 00:33:14 +00:00
|
|
|
|
2005-10-21 17:09:03 +01:00
|
|
|
READ_LOCK(ae->ARWLock);
|
|
|
|
pp = RepProp(ae->PropsOfAE);
|
2011-06-14 08:55:44 +01:00
|
|
|
while (!EndOfPAEntr(pp)) {
|
|
|
|
OpEntry *info = NULL;
|
2015-10-22 00:25:11 +01:00
|
|
|
if (pp->KindOfPE != OpProperty) {
|
2009-11-20 00:33:14 +00:00
|
|
|
pp = RepProp(pp->NextOfPE);
|
2011-06-14 08:55:44 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
info = (OpEntry *)pp;
|
2015-10-22 00:25:11 +01:00
|
|
|
if (info->OpModule != CurrentModule && info->OpModule != PROLOG_MODULE) {
|
2011-06-14 08:55:44 +01:00
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (type == INFIX_OP) {
|
|
|
|
if (!info->Infix) {
|
2015-10-22 00:25:11 +01:00
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
continue;
|
2011-06-14 08:55:44 +01:00
|
|
|
}
|
|
|
|
} else if (type == POSFIX_OP) {
|
|
|
|
if (!info->Posfix) {
|
2015-10-22 00:25:11 +01:00
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
continue;
|
2011-06-14 08:55:44 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!info->Prefix) {
|
2015-10-22 00:25:11 +01:00
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
continue;
|
2011-06-14 08:55:44 +01:00
|
|
|
}
|
2009-11-20 00:33:14 +00:00
|
|
|
}
|
2011-08-18 13:01:48 +01:00
|
|
|
/* if it is not the latest module */
|
|
|
|
if (info->OpModule == PROLOG_MODULE) {
|
|
|
|
/* cannot commit now */
|
|
|
|
oinfo = info;
|
|
|
|
pp = RepProp(pp->NextOfPE);
|
|
|
|
} else {
|
|
|
|
READ_LOCK(info->OpRWLock);
|
|
|
|
READ_UNLOCK(ae->ARWLock);
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (oinfo) {
|
|
|
|
READ_LOCK(oinfo->OpRWLock);
|
2009-11-20 00:33:14 +00:00
|
|
|
READ_UNLOCK(ae->ARWLock);
|
2011-08-18 13:01:48 +01:00
|
|
|
return oinfo;
|
2009-11-20 00:33:14 +00:00
|
|
|
}
|
2011-06-14 08:55:44 +01:00
|
|
|
READ_UNLOCK(ae->ARWLock);
|
|
|
|
return NULL;
|
2005-10-21 17:09:03 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod)
|
2001-10-30 16:42:05 +00:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
|
|
|
|
p0 = ae->PropsOfAE;
|
|
|
|
while (p0) {
|
|
|
|
PredEntry *pe = RepPredProp(p0);
|
2015-10-22 00:25:11 +01:00
|
|
|
if (pe->KindOfPE == PEProp &&
|
|
|
|
(pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) {
|
|
|
|
return (p0);
|
2004-02-11 16:09:15 +00:00
|
|
|
#if THREADS
|
|
|
|
/* Thread Local Predicates */
|
|
|
|
if (pe->PredFlags & ThreadLocalPredFlag) {
|
2015-10-22 00:25:11 +01:00
|
|
|
return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS));
|
2004-02-11 16:09:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
2001-10-30 16:42:05 +00:00
|
|
|
}
|
|
|
|
p0 = pe->NextOfPE;
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
return (NIL);
|
2001-10-30 16:42:05 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetPredPropByAtom(Atom at, Term cur_mod)
|
2001-10-30 16:42:05 +00:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
AtomEntry *ae = RepAtom(at);
|
|
|
|
|
|
|
|
READ_LOCK(ae->ARWLock);
|
|
|
|
p0 = GetPredPropByAtomHavingLock(ae, cur_mod);
|
|
|
|
READ_UNLOCK(ae->ARWLock);
|
2015-10-22 00:25:11 +01:00
|
|
|
return (p0);
|
2001-10-30 16:42:05 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
inline static Prop GetPredPropByAtomHavingLockInThisModule(AtomEntry *ae,
|
|
|
|
Term cur_mod)
|
2003-08-25 19:42:35 +01:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
|
|
|
|
p0 = ae->PropsOfAE;
|
|
|
|
while (p0) {
|
|
|
|
PredEntry *pe = RepPredProp(p0);
|
2015-10-22 00:25:11 +01:00
|
|
|
if (pe->KindOfPE == PEProp && pe->ModuleOfPred == cur_mod) {
|
2004-02-11 16:09:15 +00:00
|
|
|
#if THREADS
|
|
|
|
/* Thread Local Predicates */
|
|
|
|
if (pe->PredFlags & ThreadLocalPredFlag) {
|
2015-10-22 00:25:11 +01:00
|
|
|
return AbsPredProp(Yap_GetThreadPred(pe INIT_REGS));
|
2004-02-11 16:09:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
2015-10-22 00:25:11 +01:00
|
|
|
return (p0);
|
2003-08-25 19:42:35 +01:00
|
|
|
}
|
|
|
|
p0 = pe->NextOfPE;
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
return (NIL);
|
2003-08-25 19:42:35 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod)
|
2003-08-25 19:42:35 +01:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
AtomEntry *ae = RepAtom(at);
|
|
|
|
|
|
|
|
READ_LOCK(ae->ARWLock);
|
|
|
|
p0 = GetPredPropByAtomHavingLockInThisModule(ae, cur_mod);
|
|
|
|
READ_UNLOCK(ae->ARWLock);
|
2015-10-22 00:25:11 +01:00
|
|
|
return (p0);
|
2003-08-25 19:42:35 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetPredPropByFunc(Functor f, Term cur_mod)
|
|
|
|
/* get predicate entry for ap/arity; */
|
2001-10-03 14:39:16 +01:00
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
|
2014-06-11 19:44:01 +01:00
|
|
|
FUNC_READ_LOCK(f);
|
2007-11-01 10:01:35 +00:00
|
|
|
|
2001-11-15 00:01:43 +00:00
|
|
|
p0 = GetPredPropByFuncHavingLock(f, cur_mod);
|
2014-06-11 19:44:01 +01:00
|
|
|
FUNC_READ_UNLOCK(f);
|
2001-04-09 20:54:03 +01:00
|
|
|
return (p0);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod)
|
|
|
|
/* get predicate entry for ap/arity; */
|
2003-08-25 19:42:35 +01:00
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
|
2014-06-11 19:44:01 +01:00
|
|
|
FUNC_READ_LOCK(f);
|
2007-09-29 00:18:17 +01:00
|
|
|
p0 = GetPredPropByFuncHavingLock(f, cur_mod);
|
2014-06-11 19:44:01 +01:00
|
|
|
FUNC_READ_UNLOCK(f);
|
2003-08-25 19:42:35 +01:00
|
|
|
return (p0);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod)
|
|
|
|
/* get predicate entry for ap/arity; */
|
2001-04-09 20:54:03 +01:00
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
AtomEntry *ae = RepAtom(ap);
|
2001-10-03 14:39:16 +01:00
|
|
|
Functor f;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2001-10-30 16:42:05 +00:00
|
|
|
if (arity == 0) {
|
2001-11-15 00:01:43 +00:00
|
|
|
GetPredPropByAtomHavingLock(ae, mod);
|
2001-10-30 16:42:05 +00:00
|
|
|
}
|
2001-10-03 14:39:16 +01:00
|
|
|
f = InlinedUnlockedMkFunctor(ae, arity);
|
2014-06-11 19:44:01 +01:00
|
|
|
FUNC_READ_LOCK(f);
|
2001-11-15 00:01:43 +00:00
|
|
|
p0 = GetPredPropByFuncHavingLock(f, mod);
|
2014-06-11 19:44:01 +01:00
|
|
|
FUNC_READ_UNLOCK(f);
|
2001-04-09 20:54:03 +01:00
|
|
|
return (p0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get expression entry for at/arity; */
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetExpProp(Atom at, unsigned int arity) {
|
2001-04-09 20:54:03 +01:00
|
|
|
Prop p0;
|
|
|
|
AtomEntry *ae = RepAtom(at);
|
|
|
|
ExpEntry *p;
|
|
|
|
|
|
|
|
READ_LOCK(ae->ARWLock);
|
2001-10-30 16:42:05 +00:00
|
|
|
p = RepExpProp(p0 = ae->PropsOfAE);
|
2001-04-09 20:54:03 +01:00
|
|
|
while (p0 && (p->KindOfPE != ExpProperty || p->ArityOfEE != arity))
|
|
|
|
p = RepExpProp(p0 = p->NextOfPE);
|
|
|
|
READ_UNLOCK(ae->ARWLock);
|
|
|
|
return (p0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get expression entry for at/arity, at is already locked; */
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity) {
|
2001-04-09 20:54:03 +01:00
|
|
|
Prop p0;
|
|
|
|
ExpEntry *p;
|
|
|
|
|
2001-10-30 16:42:05 +00:00
|
|
|
p = RepExpProp(p0 = ae->PropsOfAE);
|
2001-04-09 20:54:03 +01:00
|
|
|
while (p0 && (p->KindOfPE != ExpProperty || p->ArityOfEE != arity))
|
|
|
|
p = RepExpProp(p0 = p->NextOfPE);
|
2006-11-27 17:42:03 +00:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
return (p0);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
static int ExpandPredHash(void) {
|
|
|
|
UInt new_size = PredHashTableSize + PredHashIncrement;
|
2007-09-29 00:18:17 +01:00
|
|
|
PredEntry **oldp = PredHash;
|
2015-10-22 00:25:11 +01:00
|
|
|
PredEntry **np =
|
|
|
|
(PredEntry **)Yap_AllocAtomSpace(sizeof(PredEntry **) * new_size);
|
2007-09-29 00:18:17 +01:00
|
|
|
UInt i;
|
|
|
|
|
|
|
|
if (!np) {
|
2007-11-06 17:02:13 +00:00
|
|
|
return FALSE;
|
2007-09-29 00:18:17 +01:00
|
|
|
}
|
|
|
|
for (i = 0; i < new_size; i++) {
|
|
|
|
np[i] = NULL;
|
|
|
|
}
|
|
|
|
for (i = 0; i < PredHashTableSize; i++) {
|
|
|
|
PredEntry *p = PredHash[i];
|
|
|
|
|
|
|
|
while (p) {
|
2015-04-19 04:13:12 +01:00
|
|
|
PredEntry *nextp = p->NextPredOfHash;
|
2007-09-29 00:18:17 +01:00
|
|
|
UInt hsh = PRED_HASH(p->FunctorOfPred, p->ModuleOfPred, new_size);
|
2015-04-19 04:13:12 +01:00
|
|
|
p->NextPredOfHash = np[hsh];
|
2007-09-29 00:18:17 +01:00
|
|
|
np[hsh] = p;
|
2015-04-19 04:13:12 +01:00
|
|
|
p = nextp;
|
2007-09-29 00:18:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
PredHashTableSize = new_size;
|
|
|
|
PredHash = np;
|
|
|
|
Yap_FreeAtomSpace((ADDR)oldp);
|
2007-11-06 17:02:13 +00:00
|
|
|
return TRUE;
|
2007-09-29 00:18:17 +01:00
|
|
|
}
|
|
|
|
|
2003-12-01 17:27:42 +00:00
|
|
|
/* fe is supposed to be locked */
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
|
|
|
|
CACHE_REGS
|
|
|
|
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
2001-11-15 00:01:43 +00:00
|
|
|
|
2007-11-06 17:02:13 +00:00
|
|
|
if (p == NULL) {
|
2014-06-14 10:27:39 +01:00
|
|
|
WRITE_UNLOCK(fe->FRWLock);
|
2007-11-06 17:02:13 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-11-16 14:58:41 +00:00
|
|
|
if (cur_mod == TermProlog)
|
|
|
|
p->ModuleOfPred = 0L;
|
|
|
|
else
|
|
|
|
p->ModuleOfPred = cur_mod;
|
2015-10-22 00:25:11 +01:00
|
|
|
// TRUE_FUNC_WRITE_LOCK(fe);
|
2014-06-17 15:06:23 +01:00
|
|
|
#if DEBUG_NEW_FUNCTOR
|
|
|
|
if (!strcmp(fe->NameOfFE->StrOfAE, "library_directory"))
|
|
|
|
jmp_deb(1);
|
|
|
|
#endif
|
2004-02-05 16:57:02 +00:00
|
|
|
INIT_LOCK(p->PELock);
|
2001-04-09 20:54:03 +01:00
|
|
|
p->KindOfPE = PEProp;
|
2001-10-03 14:39:16 +01:00
|
|
|
p->ArityOfPE = fe->ArityOfFE;
|
2002-12-27 16:53:09 +00:00
|
|
|
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
|
2003-04-30 18:46:05 +01:00
|
|
|
p->cs.p_code.NOfClauses = 0;
|
2001-04-09 20:54:03 +01:00
|
|
|
p->PredFlags = 0L;
|
2015-06-18 00:11:02 +01:00
|
|
|
p->src.OwnerFile = LOCAL_SourceFileName;
|
2001-04-09 20:54:03 +01:00
|
|
|
p->OpcodeOfPred = UNDEF_OPCODE;
|
2015-10-22 00:25:11 +01:00
|
|
|
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
|
|
|
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;
|
|
|
|
p->TimeStampOfPred = 0L;
|
|
|
|
p->LastCallOfPred = LUCALL_ASSERT;
|
2004-02-12 12:37:12 +00:00
|
|
|
if (cur_mod == TermProlog)
|
2004-06-05 04:37:01 +01:00
|
|
|
p->ModuleOfPred = 0L;
|
2004-02-12 12:37:12 +00:00
|
|
|
else
|
|
|
|
p->ModuleOfPred = cur_mod;
|
|
|
|
Yap_NewModulePred(cur_mod, p);
|
2015-10-22 00:25:11 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef TABLING
|
|
|
|
p->TableOfPred = NULL;
|
|
|
|
#endif /* TABLING */
|
2005-09-08 23:06:45 +01:00
|
|
|
#ifdef BEAM
|
|
|
|
p->beamTable = NULL;
|
2015-10-22 00:25:11 +01:00
|
|
|
#endif /* BEAM */
|
2001-04-09 20:54:03 +01:00
|
|
|
/* careful that they don't cross MkFunctor */
|
2004-12-05 05:01:45 +00:00
|
|
|
if (PRED_GOAL_EXPANSION_FUNC) {
|
|
|
|
if (fe->PropsOfFE &&
|
2015-10-22 00:25:11 +01:00
|
|
|
(RepPredProp(fe->PropsOfFE)->PredFlags & GoalExPredFlag)) {
|
2004-12-05 05:01:45 +00:00
|
|
|
p->PredFlags |= GoalExPredFlag;
|
|
|
|
}
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
2014-11-25 12:03:48 +00:00
|
|
|
p->PredFlags |= NoTracePredFlag;
|
2013-12-12 14:24:40 +00:00
|
|
|
}
|
2007-09-29 00:18:17 +01:00
|
|
|
p->FunctorOfPred = fe;
|
2014-06-11 19:44:01 +01:00
|
|
|
if (fe->PropsOfFE) {
|
|
|
|
UInt hsh = PRED_HASH(fe, cur_mod, PredHashTableSize);
|
|
|
|
|
|
|
|
WRITE_LOCK(PredHashRWLock);
|
2015-10-22 00:25:11 +01:00
|
|
|
if (10 * (PredsInHashTable + 1) > 6 * PredHashTableSize) {
|
2014-06-11 19:44:01 +01:00
|
|
|
if (!ExpandPredHash()) {
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_FreeCodeSpace((ADDR)p);
|
|
|
|
WRITE_UNLOCK(PredHashRWLock);
|
|
|
|
FUNC_WRITE_UNLOCK(fe);
|
|
|
|
return NULL;
|
2014-06-11 19:44:01 +01:00
|
|
|
}
|
|
|
|
/* retry hashing */
|
|
|
|
hsh = PRED_HASH(fe, cur_mod, PredHashTableSize);
|
|
|
|
}
|
|
|
|
PredsInHashTable++;
|
|
|
|
if (p->ModuleOfPred == 0L) {
|
|
|
|
PredEntry *pe = RepPredProp(fe->PropsOfFE);
|
|
|
|
|
|
|
|
hsh = PRED_HASH(fe, pe->ModuleOfPred, PredHashTableSize);
|
|
|
|
/* should be the first one */
|
2015-04-19 04:13:12 +01:00
|
|
|
pe->NextPredOfHash = PredHash[hsh];
|
2014-06-11 19:44:01 +01:00
|
|
|
PredHash[hsh] = pe;
|
|
|
|
fe->PropsOfFE = AbsPredProp(p);
|
2015-04-19 04:13:12 +01:00
|
|
|
p->NextOfPE = AbsPredProp(pe);
|
2014-06-11 19:44:01 +01:00
|
|
|
} else {
|
2015-04-19 04:13:12 +01:00
|
|
|
p->NextPredOfHash = PredHash[hsh];
|
2014-06-11 19:44:01 +01:00
|
|
|
PredHash[hsh] = p;
|
2015-04-19 04:13:12 +01:00
|
|
|
p->NextOfPE = fe->PropsOfFE->NextOfPE;
|
|
|
|
fe->PropsOfFE->NextOfPE = AbsPredProp(p);
|
2014-06-11 19:44:01 +01:00
|
|
|
}
|
|
|
|
WRITE_UNLOCK(PredHashRWLock);
|
|
|
|
} else {
|
|
|
|
fe->PropsOfFE = AbsPredProp(p);
|
|
|
|
p->NextOfPE = NIL;
|
|
|
|
}
|
2014-06-12 01:25:50 +01:00
|
|
|
FUNC_WRITE_UNLOCK(fe);
|
2012-12-20 21:33:20 +00:00
|
|
|
{
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p,
|
|
|
|
GPROF_NEW_PRED_FUNC);
|
|
|
|
if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) {
|
|
|
|
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode),
|
|
|
|
&(p->cs.p_code.ExpandCode) + 1, p,
|
|
|
|
GPROF_NEW_PRED_FUNC);
|
2012-12-20 21:33:20 +00:00
|
|
|
}
|
2007-02-18 00:26:36 +00:00
|
|
|
}
|
2007-09-29 00:18:17 +01:00
|
|
|
return AbsPredProp(p);
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2004-02-05 16:57:02 +00:00
|
|
|
#if THREADS
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) {
|
|
|
|
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
2004-02-05 16:57:02 +00:00
|
|
|
|
2008-10-07 23:52:26 +01:00
|
|
|
if (p == NULL) {
|
2008-10-08 13:15:09 +01:00
|
|
|
return NIL;
|
2008-10-07 23:52:26 +01:00
|
|
|
}
|
2004-02-05 16:57:02 +00:00
|
|
|
INIT_LOCK(p->PELock);
|
|
|
|
p->KindOfPE = PEProp;
|
|
|
|
p->ArityOfPE = ap->ArityOfPE;
|
|
|
|
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
|
|
|
|
p->cs.p_code.NOfClauses = 0;
|
2015-10-22 00:25:11 +01:00
|
|
|
p->PredFlags = ap->PredFlags & ~(IndexedPredFlag | SpiedPredFlag);
|
|
|
|
#if SIZEOF_INT_P == 4
|
2013-12-12 14:24:40 +00:00
|
|
|
p->ExtraPredFlags = 0L;
|
|
|
|
#endif
|
2004-02-05 16:57:02 +00:00
|
|
|
p->src.OwnerFile = ap->src.OwnerFile;
|
2014-04-24 11:40:35 +01:00
|
|
|
p->OpcodeOfPred = FAIL_OPCODE;
|
2015-10-22 00:25:11 +01:00
|
|
|
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
|
|
|
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;
|
2004-02-05 16:57:02 +00:00
|
|
|
p->ModuleOfPred = ap->ModuleOfPred;
|
|
|
|
p->NextPredOfModule = NULL;
|
2015-10-22 00:25:11 +01:00
|
|
|
p->TimeStampOfPred = 0L;
|
|
|
|
p->LastCallOfPred = LUCALL_ASSERT;
|
2004-02-05 16:57:02 +00:00
|
|
|
#ifdef TABLING
|
|
|
|
p->TableOfPred = NULL;
|
|
|
|
#endif /* TABLING */
|
2005-09-08 23:06:45 +01:00
|
|
|
#ifdef BEAM
|
|
|
|
p->beamTable = NULL;
|
2015-10-22 00:25:11 +01:00
|
|
|
#endif
|
2004-02-05 16:57:02 +00:00
|
|
|
/* careful that they don't cross MkFunctor */
|
2011-05-09 19:55:06 +01:00
|
|
|
p->NextOfPE = AbsPredProp(LOCAL_ThreadHandle.local_preds);
|
|
|
|
LOCAL_ThreadHandle.local_preds = p;
|
2004-02-05 16:57:02 +00:00
|
|
|
p->FunctorOfPred = ap->FunctorOfPred;
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p,
|
|
|
|
GPROF_NEW_PRED_THREAD);
|
2015-06-18 00:05:49 +01:00
|
|
|
if (falseGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
2015-10-22 00:25:11 +01:00
|
|
|
p->PredFlags |= (NoSpyPredFlag | NoTracePredFlag);
|
2013-12-12 14:24:40 +00:00
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) {
|
|
|
|
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode),
|
|
|
|
&(p->cs.p_code.ExpandCode) + 1, p,
|
|
|
|
GPROF_NEW_PRED_THREAD);
|
2012-03-09 11:46:34 +00:00
|
|
|
}
|
2004-02-05 16:57:02 +00:00
|
|
|
return AbsPredProp(p);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
|
|
|
|
Prop p0;
|
|
|
|
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
|
2001-11-15 00:01:43 +00:00
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
/* Printf("entering %s:%s/0\n", RepAtom(AtomOfTerm(cur_mod))->StrOfAE,
|
|
|
|
* ae->StrOfAE); */
|
2001-10-30 16:42:05 +00:00
|
|
|
|
2008-10-08 13:15:09 +01:00
|
|
|
if (p == NULL) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return NIL;
|
|
|
|
}
|
2004-02-05 16:57:02 +00:00
|
|
|
INIT_LOCK(p->PELock);
|
2001-10-30 16:42:05 +00:00
|
|
|
p->KindOfPE = PEProp;
|
|
|
|
p->ArityOfPE = 0;
|
2002-12-27 16:53:09 +00:00
|
|
|
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
|
2003-04-30 18:46:05 +01:00
|
|
|
p->cs.p_code.NOfClauses = 0;
|
2001-10-30 16:42:05 +00:00
|
|
|
p->PredFlags = 0L;
|
2003-08-25 19:42:35 +01:00
|
|
|
p->src.OwnerFile = AtomNil;
|
2001-10-30 16:42:05 +00:00
|
|
|
p->OpcodeOfPred = UNDEF_OPCODE;
|
2015-10-22 00:25:11 +01:00
|
|
|
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;
|
|
|
|
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
|
2004-02-12 12:37:12 +00:00
|
|
|
if (cur_mod == TermProlog)
|
|
|
|
p->ModuleOfPred = 0;
|
|
|
|
else
|
|
|
|
p->ModuleOfPred = cur_mod;
|
|
|
|
Yap_NewModulePred(cur_mod, p);
|
2015-10-22 00:25:11 +01:00
|
|
|
p->TimeStampOfPred = 0L;
|
|
|
|
p->LastCallOfPred = LUCALL_ASSERT;
|
2001-10-30 16:42:05 +00:00
|
|
|
#ifdef TABLING
|
|
|
|
p->TableOfPred = NULL;
|
|
|
|
#endif /* TABLING */
|
2005-09-08 23:06:45 +01:00
|
|
|
#ifdef BEAM
|
|
|
|
p->beamTable = NULL;
|
2015-10-22 00:25:11 +01:00
|
|
|
#endif
|
2001-10-30 16:42:05 +00:00
|
|
|
/* careful that they don't cross MkFunctor */
|
2004-12-05 05:01:45 +00:00
|
|
|
if (PRED_GOAL_EXPANSION_FUNC) {
|
|
|
|
Prop p1 = ae->PropsOfAE;
|
|
|
|
|
|
|
|
while (p1) {
|
|
|
|
PredEntry *pe = RepPredProp(p1);
|
|
|
|
|
|
|
|
if (pe->KindOfPE == PEProp) {
|
2015-10-22 00:25:11 +01:00
|
|
|
if (pe->PredFlags & GoalExPredFlag) {
|
|
|
|
p->PredFlags |= GoalExPredFlag;
|
|
|
|
}
|
|
|
|
break;
|
2004-12-05 05:01:45 +00:00
|
|
|
}
|
|
|
|
p1 = pe->NextOfPE;
|
|
|
|
}
|
|
|
|
}
|
2011-08-17 19:16:21 +01:00
|
|
|
AddPropToAtom(ae, (PropEntry *)p);
|
|
|
|
p0 = AbsPredProp(p);
|
2001-10-30 16:42:05 +00:00
|
|
|
p->FunctorOfPred = (Functor)AbsAtom(ae);
|
2015-10-22 00:25:11 +01:00
|
|
|
if (!trueGlobalPrologFlag(DEBUG_INFO_FLAG)) {
|
|
|
|
p->PredFlags |= (NoTracePredFlag | NoSpyPredFlag);
|
2013-12-12 14:24:40 +00:00
|
|
|
}
|
2001-10-30 16:42:05 +00:00
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
2012-12-20 21:33:20 +00:00
|
|
|
{
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred) + 1, p,
|
|
|
|
GPROF_NEW_PRED_ATOM);
|
|
|
|
if (!(p->PredFlags & (CPredFlag | AsmPredFlag))) {
|
|
|
|
Yap_inform_profiler_of_clause(&(p->cs.p_code.ExpandCode),
|
|
|
|
&(p->cs.p_code.ExpandCode) + 1, p,
|
|
|
|
GPROF_NEW_PRED_ATOM);
|
2012-12-20 21:33:20 +00:00
|
|
|
}
|
2012-03-09 11:46:34 +00:00
|
|
|
}
|
2004-12-05 05:01:45 +00:00
|
|
|
return p0;
|
2001-10-30 16:42:05 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
|
2004-02-11 01:20:56 +00:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
2007-09-29 00:18:17 +01:00
|
|
|
PredEntry *p;
|
2004-02-11 01:20:56 +00:00
|
|
|
|
2014-06-11 19:44:01 +01:00
|
|
|
FUNC_WRITE_LOCK(f);
|
2015-10-22 00:25:11 +01:00
|
|
|
if (!(p = RepPredProp(f->PropsOfFE)))
|
|
|
|
return Yap_NewPredPropByFunctor(f, cur_mod);
|
2007-09-29 00:18:17 +01:00
|
|
|
|
|
|
|
if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) {
|
2011-09-07 21:04:42 +01:00
|
|
|
/* don't match multi-files */
|
2015-10-22 00:25:11 +01:00
|
|
|
if (!(p->PredFlags & MultiFileFlag) || p->ModuleOfPred || !cur_mod ||
|
|
|
|
cur_mod == TermProlog) {
|
2014-06-11 19:44:01 +01:00
|
|
|
FUNC_WRITE_UNLOCK(f);
|
2011-09-07 21:04:42 +01:00
|
|
|
return AbsPredProp(p);
|
|
|
|
}
|
2007-09-29 00:18:17 +01:00
|
|
|
}
|
|
|
|
if (p->NextOfPE) {
|
2015-10-22 00:25:11 +01:00
|
|
|
UInt hash = PRED_HASH(f, cur_mod, PredHashTableSize);
|
2007-09-29 00:18:17 +01:00
|
|
|
READ_LOCK(PredHashRWLock);
|
|
|
|
p = PredHash[hash];
|
2015-10-22 00:25:11 +01:00
|
|
|
|
2007-09-29 00:18:17 +01:00
|
|
|
while (p) {
|
2015-10-22 00:25:11 +01:00
|
|
|
if (p->FunctorOfPred == f && p->ModuleOfPred == cur_mod) {
|
|
|
|
READ_UNLOCK(PredHashRWLock);
|
|
|
|
FUNC_WRITE_UNLOCK(f);
|
|
|
|
return AbsPredProp(p);
|
|
|
|
}
|
2015-04-19 04:13:12 +01:00
|
|
|
p = p->NextPredOfHash;
|
2004-02-11 01:20:56 +00:00
|
|
|
}
|
2007-09-29 00:18:17 +01:00
|
|
|
READ_UNLOCK(PredHashRWLock);
|
2004-02-11 01:20:56 +00:00
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
return Yap_NewPredPropByFunctor(f, cur_mod);
|
2004-02-11 01:20:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Prop Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
|
2004-02-11 01:20:56 +00:00
|
|
|
/* get predicate entry for ap/arity; create it if neccessary. */
|
|
|
|
{
|
|
|
|
Prop p0;
|
|
|
|
AtomEntry *ae = RepAtom(at);
|
|
|
|
|
|
|
|
WRITE_LOCK(ae->ARWLock);
|
|
|
|
p0 = ae->PropsOfAE;
|
|
|
|
while (p0) {
|
|
|
|
PredEntry *pe = RepPredProp(p0);
|
2015-10-22 00:25:11 +01:00
|
|
|
if (pe->KindOfPE == PEProp &&
|
|
|
|
(pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) {
|
2011-09-07 21:04:42 +01:00
|
|
|
/* don't match multi-files */
|
2015-10-22 00:25:11 +01:00
|
|
|
if (!(pe->PredFlags & MultiFileFlag) || pe->ModuleOfPred || !cur_mod ||
|
|
|
|
cur_mod == TermProlog) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return (p0);
|
2011-09-07 21:04:42 +01:00
|
|
|
}
|
2004-02-11 01:20:56 +00:00
|
|
|
}
|
|
|
|
p0 = pe->NextOfPE;
|
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
return Yap_NewPredPropByAtom(ae, cur_mod);
|
2004-02-11 01:20:56 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Term Yap_GetValue(Atom a) {
|
2001-04-09 20:54:03 +01:00
|
|
|
Prop p0 = GetAProp(a, ValProperty);
|
|
|
|
Term out;
|
|
|
|
|
|
|
|
if (p0 == NIL)
|
|
|
|
return (TermNil);
|
|
|
|
READ_LOCK(RepValProp(p0)->VRWLock);
|
|
|
|
out = RepValProp(p0)->ValueOfVE;
|
2002-02-27 01:20:18 +00:00
|
|
|
if (IsApplTerm(out)) {
|
|
|
|
Functor f = FunctorOfTerm(out);
|
|
|
|
if (f == FunctorDouble) {
|
2013-03-26 20:01:52 +00:00
|
|
|
CACHE_REGS
|
2002-02-27 01:20:18 +00:00
|
|
|
out = MkFloatTerm(FloatOfTerm(out));
|
|
|
|
} else if (f == FunctorLongInt) {
|
2013-03-26 20:01:52 +00:00
|
|
|
CACHE_REGS
|
2002-02-27 01:20:18 +00:00
|
|
|
out = MkLongIntTerm(LongIntOfTerm(out));
|
2013-12-02 14:49:41 +00:00
|
|
|
} else if (f == FunctorString) {
|
|
|
|
CACHE_REGS
|
|
|
|
out = MkStringTerm(StringOfTerm(out));
|
2002-02-27 01:20:18 +00:00
|
|
|
}
|
|
|
|
#ifdef USE_GMP
|
|
|
|
else {
|
2006-01-18 15:34:54 +00:00
|
|
|
out = Yap_MkBigIntTerm(Yap_BigIntOfTerm(out));
|
2002-02-27 01:20:18 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
READ_UNLOCK(RepValProp(p0)->VRWLock);
|
|
|
|
return (out);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
void Yap_PutValue(Atom a, Term v) {
|
2001-04-09 20:54:03 +01:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
Prop p0;
|
|
|
|
ValEntry *p;
|
2002-02-27 01:11:51 +00:00
|
|
|
Term t0;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
WRITE_LOCK(ae->ARWLock);
|
2001-10-30 16:42:05 +00:00
|
|
|
p0 = GetAPropHavingLock(ae, ValProperty);
|
2001-04-09 20:54:03 +01:00
|
|
|
if (p0 != NIL) {
|
|
|
|
p = RepValProp(p0);
|
|
|
|
WRITE_LOCK(p->VRWLock);
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
} else {
|
2015-10-22 00:25:11 +01:00
|
|
|
p = (ValEntry *)Yap_AllocAtomSpace(sizeof(ValEntry));
|
2008-10-07 23:52:26 +01:00
|
|
|
if (p == NULL) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return;
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
p->KindOfPE = ValProperty;
|
2002-02-27 01:11:51 +00:00
|
|
|
p->ValueOfVE = TermNil;
|
2011-08-17 22:35:29 +01:00
|
|
|
AddPropToAtom(RepAtom(a), (PropEntry *)p);
|
2001-04-09 20:54:03 +01:00
|
|
|
/* take care that the lock for the property will be inited even
|
|
|
|
if someone else searches for the property */
|
|
|
|
INIT_RWLOCK(p->VRWLock);
|
|
|
|
WRITE_LOCK(p->VRWLock);
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
}
|
2002-02-27 01:11:51 +00:00
|
|
|
t0 = p->ValueOfVE;
|
2001-04-09 20:54:03 +01:00
|
|
|
if (IsFloatTerm(v)) {
|
|
|
|
/* store a float in code space, so that we can access the property */
|
|
|
|
union {
|
|
|
|
Float f;
|
|
|
|
CELL ar[sizeof(Float) / sizeof(CELL)];
|
|
|
|
} un;
|
|
|
|
CELL *pt, *iptr;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
un.f = FloatOfTerm(v);
|
2002-02-27 01:11:51 +00:00
|
|
|
if (IsFloatTerm(t0)) {
|
|
|
|
pt = RepAppl(t0);
|
|
|
|
} else {
|
|
|
|
if (IsApplTerm(t0)) {
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_FreeCodeSpace((char *)(RepAppl(t0)));
|
2002-02-27 01:11:51 +00:00
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
pt = (CELL *)Yap_AllocAtomSpace(sizeof(CELL) *
|
|
|
|
(1 + 2 * sizeof(Float) / sizeof(CELL)));
|
2008-10-07 23:52:26 +01:00
|
|
|
if (pt == NULL) {
|
2015-10-22 00:25:11 +01:00
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return;
|
2008-10-07 23:52:26 +01:00
|
|
|
}
|
2002-02-27 01:11:51 +00:00
|
|
|
p->ValueOfVE = AbsAppl(pt);
|
|
|
|
pt[0] = (CELL)FunctorDouble;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
iptr = pt + 1;
|
2001-04-09 20:54:03 +01:00
|
|
|
for (i = 0; i < sizeof(Float) / sizeof(CELL); i++) {
|
2002-02-27 01:11:51 +00:00
|
|
|
*iptr++ = (CELL)un.ar[i];
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
} else if (IsLongIntTerm(v)) {
|
|
|
|
CELL *pt;
|
|
|
|
Int val = LongIntOfTerm(v);
|
2002-02-27 01:11:51 +00:00
|
|
|
|
|
|
|
if (IsLongIntTerm(t0)) {
|
|
|
|
pt = RepAppl(t0);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2002-02-27 01:11:51 +00:00
|
|
|
if (IsApplTerm(t0)) {
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_FreeCodeSpace((char *)(RepAppl(t0)));
|
2002-02-27 01:11:51 +00:00
|
|
|
}
|
2015-10-22 00:25:11 +01:00
|
|
|
pt = (CELL *)Yap_AllocAtomSpace(2 * sizeof(CELL));
|
2008-10-07 23:52:26 +01:00
|
|
|
if (pt == NULL) {
|
2015-10-22 00:25:11 +01:00
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return;
|
2008-10-07 23:52:26 +01:00
|
|
|
}
|
2002-02-27 01:11:51 +00:00
|
|
|
p->ValueOfVE = AbsAppl(pt);
|
|
|
|
pt[0] = (CELL)FunctorLongInt;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2002-02-27 01:11:51 +00:00
|
|
|
pt[1] = (CELL)val;
|
|
|
|
#ifdef USE_GMP
|
|
|
|
} else if (IsBigIntTerm(v)) {
|
|
|
|
CELL *ap = RepAppl(v);
|
2015-10-22 00:25:11 +01:00
|
|
|
Int sz = sizeof(MP_INT) + sizeof(CELL) +
|
|
|
|
(((MP_INT *)(ap + 1))->_mp_alloc * sizeof(mp_limb_t));
|
|
|
|
CELL *pt = (CELL *)Yap_AllocAtomSpace(sz);
|
2008-10-07 23:52:26 +01:00
|
|
|
|
|
|
|
if (pt == NULL) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return;
|
|
|
|
}
|
2002-02-27 01:11:51 +00:00
|
|
|
if (IsApplTerm(t0)) {
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_FreeCodeSpace((char *)RepAppl(t0));
|
2002-02-27 01:11:51 +00:00
|
|
|
}
|
|
|
|
memcpy((void *)pt, (void *)ap, sz);
|
2001-04-09 20:54:03 +01:00
|
|
|
p->ValueOfVE = AbsAppl(pt);
|
2002-02-27 01:11:51 +00:00
|
|
|
#endif
|
2013-12-02 14:49:41 +00:00
|
|
|
} else if (IsStringTerm(v)) {
|
|
|
|
CELL *ap = RepAppl(v);
|
2015-10-22 00:25:11 +01:00
|
|
|
Int sz = sizeof(CELL) * (3 + ap[1]);
|
|
|
|
CELL *pt = (CELL *)Yap_AllocAtomSpace(sz);
|
2013-12-02 14:49:41 +00:00
|
|
|
|
|
|
|
if (pt == NULL) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (IsApplTerm(t0)) {
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_FreeCodeSpace((char *)RepAppl(t0));
|
2013-12-02 14:49:41 +00:00
|
|
|
}
|
|
|
|
memcpy((void *)pt, (void *)ap, sz);
|
|
|
|
p->ValueOfVE = AbsAppl(pt);
|
2001-04-09 20:54:03 +01:00
|
|
|
} else {
|
2002-02-27 01:11:51 +00:00
|
|
|
if (IsApplTerm(t0)) {
|
2001-04-09 20:54:03 +01:00
|
|
|
/* recover space */
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_FreeCodeSpace((char *)(RepAppl(p->ValueOfVE)));
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
p->ValueOfVE = v;
|
|
|
|
}
|
|
|
|
WRITE_UNLOCK(p->VRWLock);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i) {
|
2013-10-04 13:22:00 +01:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
Prop p0;
|
|
|
|
TranslationEntry *p;
|
|
|
|
|
|
|
|
WRITE_LOCK(ae->ARWLock);
|
|
|
|
p0 = GetAPropHavingLock(ae, TranslationProperty);
|
|
|
|
if (p0 == NIL) {
|
2015-10-22 00:25:11 +01:00
|
|
|
p = (TranslationEntry *)Yap_AllocAtomSpace(sizeof(TranslationEntry));
|
2013-10-04 13:22:00 +01:00
|
|
|
if (p == NULL) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
2014-11-25 16:41:53 +00:00
|
|
|
return false;
|
2013-10-04 13:22:00 +01:00
|
|
|
}
|
|
|
|
p->KindOfPE = TranslationProperty;
|
|
|
|
p->Translation = i;
|
2015-08-07 22:57:53 +01:00
|
|
|
p->arity = arity;
|
2013-10-04 13:22:00 +01:00
|
|
|
AddPropToAtom(RepAtom(a), (PropEntry *)p);
|
|
|
|
}
|
|
|
|
/* take care that the lock for the property will be inited even
|
|
|
|
if someone else searches for the property */
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
2014-11-25 16:41:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
bool Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i) {
|
2015-08-07 22:57:53 +01:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
Prop p0;
|
|
|
|
TranslationEntry *p;
|
|
|
|
|
|
|
|
WRITE_LOCK(ae->ARWLock);
|
|
|
|
p0 = GetAPropHavingLock(ae, TranslationProperty);
|
|
|
|
if (p0 == NIL) {
|
2015-10-22 00:25:11 +01:00
|
|
|
p = (TranslationEntry *)Yap_AllocAtomSpace(sizeof(TranslationEntry));
|
2015-08-07 22:57:53 +01:00
|
|
|
if (p == NULL) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
p->KindOfPE = TranslationProperty;
|
|
|
|
p->Translation = i;
|
|
|
|
p->arity = arity;
|
2015-10-22 00:25:11 +01:00
|
|
|
AddPropToAtom(RepAtom(a), (PropEntry *)p);
|
2015-08-07 22:57:53 +01:00
|
|
|
}
|
|
|
|
/* take care that the lock for the property will be inited even
|
|
|
|
if someone else searches for the property */
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
bool Yap_PutAtomMutex(Atom a, void *i) {
|
2014-11-25 16:41:53 +00:00
|
|
|
AtomEntry *ae = RepAtom(a);
|
|
|
|
Prop p0;
|
|
|
|
MutexEntry *p;
|
|
|
|
|
|
|
|
WRITE_LOCK(ae->ARWLock);
|
|
|
|
p0 = GetAPropHavingLock(ae, MutexProperty);
|
|
|
|
if (p0 == NIL) {
|
2015-10-22 00:25:11 +01:00
|
|
|
p = (MutexEntry *)Yap_AllocAtomSpace(sizeof(MutexEntry));
|
2014-11-25 16:41:53 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
p->KindOfPE = MutexProperty;
|
|
|
|
p->Mutex = i;
|
|
|
|
AddPropToAtom(RepAtom(a), (PropEntry *)p);
|
|
|
|
}
|
|
|
|
/* take care that the lock for the property will be inited even
|
|
|
|
if someone else searches for the property */
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return true;
|
2013-10-04 13:22:00 +01:00
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Term Yap_ArrayToList(register Term *tp, size_t nof) {
|
2011-03-07 16:02:55 +00:00
|
|
|
CACHE_REGS
|
2001-04-09 20:54:03 +01:00
|
|
|
register Term *pt = tp + nof;
|
|
|
|
register Term t;
|
|
|
|
|
|
|
|
t = MkAtomTerm(AtomNil);
|
|
|
|
while (pt > tp) {
|
|
|
|
Term tm = *--pt;
|
2011-03-30 15:32:59 +01:00
|
|
|
#if YAPOR_SBA
|
2001-04-09 20:54:03 +01:00
|
|
|
if (tm == 0)
|
|
|
|
t = MkPairTerm((CELL)pt, t);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
t = MkPairTerm(tm, t);
|
|
|
|
}
|
|
|
|
return (t);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
int Yap_GetName(char *s, UInt max, Term t) {
|
2001-04-09 20:54:03 +01:00
|
|
|
register Term Head;
|
|
|
|
register Int i;
|
|
|
|
|
|
|
|
if (IsVarTerm(t) || !IsPairTerm(t))
|
2005-03-01 22:25:09 +00:00
|
|
|
return FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
while (IsPairTerm(t)) {
|
|
|
|
Head = HeadOfTerm(t);
|
|
|
|
if (!IsNumTerm(Head))
|
|
|
|
return (FALSE);
|
|
|
|
i = IntOfTerm(Head);
|
2006-11-27 17:42:03 +00:00
|
|
|
if (i < 0 || i > MAX_ISO_LATIN1)
|
|
|
|
return FALSE;
|
2001-04-09 20:54:03 +01:00
|
|
|
*s++ = i;
|
|
|
|
t = TailOfTerm(t);
|
2002-01-02 20:56:22 +00:00
|
|
|
if (--max == 0) {
|
2015-10-22 00:25:11 +01:00
|
|
|
Yap_Error(SYSTEM_ERROR_FATAL, t, "not enough space for GetName");
|
2002-01-02 20:56:22 +00:00
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
*s = '\0';
|
2005-03-01 22:25:09 +00:00
|
|
|
return TRUE;
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SFUNC
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
Term MkSFTerm(Functor f, int n, Term *a, empty_value) {
|
2001-04-09 20:54:03 +01:00
|
|
|
Term t, p = AbsAppl(H);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
*H++ = f;
|
|
|
|
RESET_VARIABLE(H);
|
|
|
|
++H;
|
|
|
|
for (i = 1; i <= n; ++i) {
|
|
|
|
t = Derefa(a++);
|
|
|
|
if (t != empty_value) {
|
|
|
|
*H++ = i;
|
|
|
|
*H++ = t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*H++ = 0;
|
|
|
|
return (p);
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
CELL *ArgsOfSFTerm(Term t) {
|
2001-04-09 20:54:03 +01:00
|
|
|
CELL *p = RepAppl(t) + 1;
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
while (*p != (CELL)p)
|
2001-04-09 20:54:03 +01:00
|
|
|
p = CellPtr(*p) + 1;
|
|
|
|
return (p + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2002-10-17 01:05:29 +01:00
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
static HoldEntry *InitAtomHold(void) {
|
2007-12-05 12:17:25 +00:00
|
|
|
HoldEntry *x = (HoldEntry *)Yap_AllocAtomSpace(sizeof(struct hold_entry));
|
2008-10-07 23:52:26 +01:00
|
|
|
if (x == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-12-05 12:17:25 +00:00
|
|
|
x->KindOfPE = HoldProperty;
|
|
|
|
x->NextOfPE = NIL;
|
2009-12-21 12:12:47 +00:00
|
|
|
x->RefsOfPE = 1;
|
2007-12-05 12:17:25 +00:00
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
int Yap_AtomIncreaseHold(Atom at) {
|
2007-12-05 12:17:25 +00:00
|
|
|
AtomEntry *ae = RepAtom(at);
|
2009-12-21 12:12:47 +00:00
|
|
|
HoldEntry *pp;
|
|
|
|
Prop *opp = &(ae->PropsOfAE);
|
2002-10-17 01:05:29 +01:00
|
|
|
|
2007-12-05 12:17:25 +00:00
|
|
|
WRITE_LOCK(ae->ARWLock);
|
2009-12-21 12:12:47 +00:00
|
|
|
pp = RepHoldProp(ae->PropsOfAE);
|
2015-10-22 00:25:11 +01:00
|
|
|
while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) {
|
2009-12-21 12:12:47 +00:00
|
|
|
opp = &(pp->NextOfPE);
|
|
|
|
pp = RepHoldProp(pp->NextOfPE);
|
2007-12-05 12:17:25 +00:00
|
|
|
}
|
|
|
|
if (!pp) {
|
2009-12-21 12:12:47 +00:00
|
|
|
HoldEntry *new = InitAtomHold();
|
|
|
|
if (!new) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
*opp = AbsHoldProp(new);
|
2007-12-05 12:17:25 +00:00
|
|
|
} else {
|
2009-12-21 12:12:47 +00:00
|
|
|
pp->RefsOfPE++;
|
2007-12-05 12:17:25 +00:00
|
|
|
}
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:25:11 +01:00
|
|
|
int Yap_AtomDecreaseHold(Atom at) {
|
2007-12-05 12:17:25 +00:00
|
|
|
AtomEntry *ae = RepAtom(at);
|
2009-12-21 12:12:47 +00:00
|
|
|
HoldEntry *pp;
|
|
|
|
Prop *opp = &(ae->PropsOfAE);
|
2007-12-05 12:17:25 +00:00
|
|
|
|
|
|
|
WRITE_LOCK(ae->ARWLock);
|
2009-12-21 12:12:47 +00:00
|
|
|
pp = RepHoldProp(ae->PropsOfAE);
|
2015-10-22 00:25:11 +01:00
|
|
|
while (!EndOfPAEntr(pp) && pp->KindOfPE != HoldProperty) {
|
2009-12-21 12:12:47 +00:00
|
|
|
opp = &(pp->NextOfPE);
|
|
|
|
pp = RepHoldProp(pp->NextOfPE);
|
|
|
|
}
|
|
|
|
if (!pp) {
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pp->RefsOfPE--;
|
|
|
|
if (!pp->RefsOfPE) {
|
|
|
|
*opp = pp->NextOfPE;
|
|
|
|
Yap_FreeCodeSpace((ADDR)pp);
|
2007-12-05 12:17:25 +00:00
|
|
|
}
|
|
|
|
WRITE_UNLOCK(ae->ARWLock);
|
2009-12-21 12:12:47 +00:00
|
|
|
return TRUE;
|
2007-12-05 12:17:25 +00:00
|
|
|
}
|