32 bit support:

use uint64_t for predflags
define a type for arity
This commit is contained in:
Vitor Santos Costa 2015-01-06 17:47:58 +00:00
parent de9a1d7429
commit f22f337f67
12 changed files with 136 additions and 143 deletions

View File

@ -816,9 +816,6 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
p->cs.p_code.NOfClauses = 0;
p->PredFlags = 0L;
#if SIZEOF_INT_P==4
p->ExtraPredFlags = 0L;
#endif
p->src.OwnerFile = AtomNil;
p->OpcodeOfPred = UNDEF_OPCODE;
p->CodeOfPred = p->cs.p_code.TrueCodeOfPred = (yamop *)(&(p->OpcodeOfPred));
@ -964,9 +961,6 @@ Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod)
p->cs.p_code.FirstClause = p->cs.p_code.LastClause = NULL;
p->cs.p_code.NOfClauses = 0;
p->PredFlags = 0L;
#if SIZEOF_INT_P==4
p->ExtraPredFlags = 0L;
#endif
p->src.OwnerFile = AtomNil;
p->OpcodeOfPred = UNDEF_OPCODE;
p->cs.p_code.ExpandCode = EXPAND_OP_CODE;

View File

@ -2936,9 +2936,9 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
yamop *either_inst[MAX_DISJ_BRANCHES];
int either_cont = 0;
#endif /* YAPOR */
int log_update;
int dynamic;
int tabled;
bool log_update;
bool dynamic;
bool tabled;
int ystop_found = FALSE;
union clause_obj *cl_u;
yamop *code_p;

View File

@ -515,7 +515,7 @@ static Int p_call_count_info( USES_REGS1 );
static Int p_call_count_set( USES_REGS1 );
static Int p_call_count_reset( USES_REGS1 );
static Int p_toggle_static_predicates_in_use( USES_REGS1 );
static Int PredForCode(yamop *, Atom *, UInt *, Term *);
static Int PredForCode(yamop *, Atom *, arity_t *, Term *);
static void kill_first_log_iblock(LogUpdIndex *, LogUpdIndex *, PredEntry *);
static LogUpdIndex *find_owner_log_index(LogUpdIndex *, yamop *);
static StaticIndex *find_owner_static_index(StaticIndex *, yamop *);
@ -672,7 +672,7 @@ static_in_use(PredEntry *p, int check_everything)
#if defined(YAPOR) || defined(THREADS)
return TRUE;
#else
CELL pflags = p->PredFlags;
pred_flags_t pflags = p->PredFlags;
if (pflags & (DynamicPredFlag|LogUpdatePredFlag)) {
return FALSE;
}
@ -2090,7 +2090,7 @@ addcl_permission_error(AtomEntry *ap, Int Arity, int in_use)
PredEntry * Yap_PredFromClause( Term t USES_REGS )
{
Term cmod = LOCAL_SourceModule;
UInt extra_arity = 0;
arity_t extra_arity = 0;
if (IsVarTerm( t )) return NULL;
while (IsApplTerm(t)) {
@ -2316,8 +2316,8 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
PredEntry *p;
int spy_flag = FALSE;
Atom at;
UInt Arity;
CELL pflags;
arity_t Arity;
pred_flags_t pflags;
Term tf;
@ -2339,7 +2339,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
PELOCK(20,p);
pflags = p->PredFlags;
/* we are redefining a prolog module predicate */
if (((p->PredFlags & SysExportPredFlag) == (UInt)0) &&
if (!(p->PredFlags & SysExportPredFlag) &&
(
(pflags & (UserCPredFlag|CArgsPredFlag|NumberDBPredFlag|AtomDBPredFlag|TestPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)) ||
(p->ModuleOfPred == PROLOG_MODULE &&
@ -2892,7 +2892,7 @@ p_set_no_trace( USES_REGS1 )
}
int
Yap_SetNoTrace(char *name, UInt arity, Term tmod)
Yap_SetNoTrace(char *name, arity_t arity, Term tmod)
{
PredEntry *pe;
@ -2915,7 +2915,7 @@ p_setspy( USES_REGS1 )
{ /* '$set_spy'(+Fun,+M) */
Atom at;
PredEntry *pred;
CELL fg;
pred_flags_t fg;
Term t, mod;
at = AtomSpy;
@ -3085,7 +3085,7 @@ static Int
p_new_multifile( USES_REGS1 )
{ /* '$new_multifile'(+N,+Ar,+Mod) */
Atom at;
int arity;
arity_t arity;
PredEntry *pe;
Term t = Deref(ARG1);
Term mod = Deref(ARG3);
@ -3126,7 +3126,7 @@ static Int
p_is_multifile( USES_REGS1 )
{ /* '$is_multifile'(+S,+Mod) */
PredEntry *pe;
Int out;
bool out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_multifile");
if (EndOfPAEntr(pe))
@ -3141,7 +3141,7 @@ static Int
p_new_discontiguous( USES_REGS1 )
{ /* '$new_discontiguous'(+N,+Ar,+Mod) */
Atom at;
int arity;
arity_t arity;
PredEntry *pe;
Term t = Deref(ARG1);
Term mod = Deref(ARG3);
@ -3177,7 +3177,7 @@ static Int
p_is_discontiguous( USES_REGS1 )
{ /* '$is_multifile'(+S,+Mod) */
PredEntry *pe;
Int out;
bool out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "discontiguous");
if (EndOfPAEntr(pe))
@ -3192,7 +3192,7 @@ static Int
p_is_thread_local( USES_REGS1 )
{ /* '$is_dynamic'(+P) */
PredEntry *pe;
Int out;
bool out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_log_updatable");
if (EndOfPAEntr(pe))
@ -3207,7 +3207,7 @@ static Int
p_is_log_updatable( USES_REGS1 )
{ /* '$is_dynamic'(+P) */
PredEntry *pe;
Int out;
bool out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_log_updatable");
if (EndOfPAEntr(pe))
@ -3222,7 +3222,7 @@ static Int
p_is_source( USES_REGS1 )
{ /* '$is_dynamic'(+P) */
PredEntry *pe;
Int out;
bool out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_source");
if (EndOfPAEntr(pe))
@ -3237,7 +3237,7 @@ static Int
p_is_exo( USES_REGS1 )
{ /* '$is_dynamic'(+P) */
PredEntry *pe;
Int out;
bool out;
MegaClause *mcl;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_exo");
@ -3322,7 +3322,7 @@ static Int
p_is_dynamic( USES_REGS1 )
{ /* '$is_dynamic'(+P) */
PredEntry *pe;
Int out;
bool out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_dynamic");
if (EndOfPAEntr(pe))
@ -3337,7 +3337,7 @@ static Int
p_is_metapredicate( USES_REGS1 )
{ /* '$is_metapredicate'(+P) */
PredEntry *pe;
Int out;
bool out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$is_meta");
if (EndOfPAEntr(pe))
@ -3354,7 +3354,7 @@ p_is_expandgoalormetapredicate( USES_REGS1 )
PredEntry *pe;
Term t = Deref(ARG1);
Term mod = Deref(ARG2);
Int out;
bool out;
if (PRED_GOAL_EXPANSION_ALL)
return TRUE;
@ -3415,7 +3415,7 @@ static Int
p_pred_exists( USES_REGS1 )
{ /* '$pred_exists'(+P,+M) */
PredEntry *pe;
Int out;
bool out;
pe = get_pred(Deref(ARG1), Deref(ARG2), "$exists");
if (EndOfPAEntr(pe))
@ -3914,7 +3914,7 @@ p_toggle_static_predicates_in_use( USES_REGS1 )
}
static void
clause_was_found(PredEntry *pp, Atom *pat, UInt *parity) {
clause_was_found(PredEntry *pp, Atom *pat, arity_t *parity) {
if (pp->ModuleOfPred == IDB_MODULE) {
if (pp->PredFlags & NumberDBPredFlag) {
*parity = 0;
@ -3937,7 +3937,7 @@ clause_was_found(PredEntry *pp, Atom *pat, UInt *parity) {
}
static void
code_in_pred_info(PredEntry *pp, Atom *pat, UInt *parity) {
code_in_pred_info(PredEntry *pp, Atom *pat, arity_t *parity) {
clause_was_found(pp, pat, parity);
}
@ -4086,7 +4086,7 @@ cl_code_in_pred(PredEntry *pp, yamop *codeptr, CODEADDR *startp, CODEADDR *endp)
}
static Int
code_in_pred(PredEntry *pp, Atom *pat, UInt *parity, yamop *codeptr) {
code_in_pred(PredEntry *pp, Atom *pat, arity_t *parity, yamop *codeptr) {
Int out;
// PELOCK(40,pp); this is deadlocking...
@ -4114,7 +4114,7 @@ code_in_pred(PredEntry *pp, Atom *pat, UInt *parity, yamop *codeptr) {
}
static Int
PredForCode(yamop *codeptr, Atom *pat, UInt *parity, Term *pmodule) {
PredForCode(yamop *codeptr, Atom *pat, arity_t *parity, Term *pmodule) {
Int found = 0;
ModEntry *me = CurrentModules;
@ -4136,7 +4136,7 @@ PredForCode(yamop *codeptr, Atom *pat, UInt *parity, Term *pmodule) {
}
Int
Yap_PredForCode(yamop *codeptr, find_pred_type where_from, Atom *pat, UInt *parity, Term *pmodule) {
Yap_PredForCode(yamop *codeptr, find_pred_type where_from, Atom *pat, arity_t *parity, Term *pmodule) {
PredEntry *p;
if (where_from == FIND_PRED_FROM_CP) {
@ -4352,7 +4352,7 @@ static Int
p_pred_for_code( USES_REGS1 ) {
yamop *codeptr;
Atom at;
UInt arity;
arity_t arity;
Term tmodule = TermProlog;
Int cl;
Term t = Deref(ARG1);
@ -4580,7 +4580,7 @@ p_parent_pred( USES_REGS1 )
/* This predicate is called from the debugger.
We assume a sequence of the form a -> b */
Atom at;
UInt arity;
arity_t arity;
Term module;
if (!PredForCode(P_before_spy, &at, &arity, &module)) {
return(Yap_unify(ARG1, MkIntTerm(0)) &&
@ -4895,7 +4895,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
}
if (pe->ArityOfPE) {
Functor f = FunctorOfTerm(th);
UInt arity = ArityOfFunctor(f), i;
arity_t arity = ArityOfFunctor(f), i;
CELL *pt = RepAppl(th)+1;
for (i=0; i<arity; i++) {
@ -5043,7 +5043,7 @@ fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term
}
if (pe->ArityOfPE) {
Functor f = FunctorOfTerm(th);
UInt arity = ArityOfFunctor(f), i;
arity_t arity = ArityOfFunctor(f), i;
CELL *pt = RepAppl(th)+1;
for (i=0; i<arity; i++) {
@ -5207,7 +5207,7 @@ Yap_UpdateTimestamps(PredEntry *ap)
yamop *cl0 = NEXTOP(PredLogUpdClause0->CodeOfPred,Otapl);
yamop *cl = NEXTOP(PredLogUpdClause->CodeOfPred,Otapl);
yamop *cle = NEXTOP(PredLogUpdClauseErase->CodeOfPred,Otapl);
UInt ar = ap->ArityOfPE;
arity_t ar = ap->ArityOfPE;
UInt *arp, *top, *base;
LogUpdClause *lcl;
@ -5358,7 +5358,7 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
}
if (pe->ArityOfPE) {
Functor f = FunctorOfTerm(th);
UInt arity = ArityOfFunctor(f), i;
arity_t arity = ArityOfFunctor(f), i;
CELL *pt = RepAppl(th)+1;
for (i=0; i<arity; i++) {
@ -5386,7 +5386,7 @@ fetch_next_static_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr
if (pe->ArityOfPE) {
Functor f = FunctorOfTerm(th);
UInt arity = ArityOfFunctor(f), i;
arity_t arity = ArityOfFunctor(f), i;
CELL *pt = RepAppl(th)+1;
for (i=0; i<arity; i++) {
@ -5793,7 +5793,7 @@ static Term
BuildActivePred(PredEntry *ap, CELL *vect)
{
CACHE_REGS
UInt i;
arity_t i;
if (!ap->ArityOfPE) {
return MkVarTerm();
@ -5814,7 +5814,7 @@ BuildActivePred(PredEntry *ap, CELL *vect)
static int
UnifyPredInfo(PredEntry *pe, int start_arg USES_REGS) {
UInt arity = pe->ArityOfPE;
arity_t arity = pe->ArityOfPE;
Term tmod, tname;
if (pe->ModuleOfPred != IDB_MODULE) {
@ -6073,7 +6073,7 @@ p_choicepoint_info( USES_REGS1 )
static UInt
compute_dbcl_size(UInt arity)
compute_dbcl_size(arity_t arity)
{
UInt sz;
switch(arity) {
@ -6103,7 +6103,7 @@ compute_dbcl_size(UInt arity)
t = Deref(V); if(IsVarTerm(t) || !(IsAtomOrIntTerm(t))) Yap_Error(TYPE_ERROR_ATOM, t0, "load_db");
static int
store_dbcl_size(yamop *pc, UInt arity, Term t0, PredEntry *pe)
store_dbcl_size(yamop *pc, arity_t arity, Term t0, PredEntry *pe)
{
Term t;
CELL *tp = RepAppl(t0)+1;
@ -6170,7 +6170,7 @@ store_dbcl_size(yamop *pc, UInt arity, Term t0, PredEntry *pe)
break;
default:
{
UInt i;
arity_t i;
for (i = 0; i< arity; i++) {
pc->opc = Yap_opcode(_get_atom);
#if PRECOMPUTE_REGADDRESS
@ -6197,7 +6197,7 @@ p_dbload_get_space( USES_REGS1 )
Term t = Deref(ARG1);
Term mod = Deref(ARG2);
Term tn = Deref(ARG3);
UInt arity;
arity_t arity;
Prop pe;
PredEntry *ap;
UInt sz;
@ -6344,7 +6344,7 @@ p_instance_property( USES_REGS1 )
t[1] = MkAtomTerm((Atom)ap->FunctorOfPred);
} else {
Functor nf = ap->FunctorOfPred;
UInt arity = ArityOfFunctor(nf);
arity_t arity = ArityOfFunctor(nf);
Atom name = NameOfFunctor(nf);
t[0] = MkAtomTerm(name);
@ -6388,7 +6388,7 @@ p_instance_property( USES_REGS1 )
return FALSE;
} else {
Functor nf = ap->FunctorOfPred;
UInt arity = ArityOfFunctor(nf);
arity_t arity = ArityOfFunctor(nf);
Atom name = NameOfFunctor(nf);
Term t[2];
@ -6437,7 +6437,7 @@ p_instance_property( USES_REGS1 )
t[1] = MkAtomTerm((Atom)ap->FunctorOfPred);
} else {
Functor nf = ap->FunctorOfPred;
UInt arity = ArityOfFunctor(nf);
arity_t arity = ArityOfFunctor(nf);
Atom name = NameOfFunctor(nf);
t[0] = MkAtomTerm(name);
@ -6473,7 +6473,7 @@ static Int
p_nth_instance( USES_REGS1 )
{
PredEntry *pe;
UInt pred_arity;
arity_t pred_arity;
Functor pred_f;
Term pred_module;
Term t4 = Deref(ARG4);
@ -6507,7 +6507,7 @@ p_nth_instance( USES_REGS1 )
return Yap_db_nth_recorded( pe, Count PASS_REGS );
} else {
Int CurSlot, sl4;
UInt i;
arity_t i;
void *cl0;
if (!pe)

View File

@ -698,7 +698,7 @@ recover_from_failed_susp_on_cls(struct intermediates *cint, UInt sz)
just follow the code through. */
struct PSEUDO *cpc = cint->CodeStart;
OPCODE ecls = Yap_opcode(_expand_clauses);
UInt log_upd_pred = cint->CurrentPred->PredFlags & LogUpdatePredFlag;
pred_flags_t log_upd_pred = cint->CurrentPred->PredFlags & LogUpdatePredFlag;
while (cpc) {
switch(cpc->op) {
@ -2714,7 +2714,8 @@ do_compound_index(ClauseDef *min0, ClauseDef* max0, Term* sreg, struct intermedi
CELL *top0 = top;
ClauseDef *min, *max;
PredEntry *ap = cint->CurrentPred;
int found_index = FALSE, lu_pred = ap->PredFlags & LogUpdatePredFlag;
int found_index = FALSE;
pred_flags_t lu_pred = ap->PredFlags & LogUpdatePredFlag;
UInt old_last_depth, old_last_depth_size;
newlabp = & ret_lab;
@ -6257,7 +6258,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
#if defined(YAPOR) || defined(THREADS)
yamop **jlbl = NULL;
#endif
int lu_pred = ap->PredFlags & LogUpdatePredFlag;
pred_flags_t lu_pred = ap->PredFlags & LogUpdatePredFlag;
int unbounded = TRUE;
if (ap->ModuleOfPred != IDB_MODULE) {

View File

@ -488,7 +488,7 @@ update_flags_from_prolog(UInt flags, PredEntry *pe)
}
void
Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, UInt flags)
Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, pred_flags_t flags)
{
CACHE_REGS
Atom atom = NIL;
@ -592,7 +592,7 @@ Yap_InitCPred(const char *Name, UInt Arity, CPredicate code, UInt flags)
}
void
Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, UInt flags)
Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, pred_flags_t flags)
{
CACHE_REGS
Atom atom = NIL;
@ -670,7 +670,7 @@ Yap_InitCmpPred(const char *Name, UInt Arity, CmpPredicate cmp_code, UInt flags)
}
void
Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, UInt flags)
Yap_InitAsmPred(const char *Name, UInt Arity, int code, CPredicate def, pred_flags_t flags)
{
CACHE_REGS
Atom atom = NIL;
@ -810,21 +810,21 @@ CleanBack(PredEntry *pe, CPredicate Start, CPredicate Cont, CPredicate Cut)
void
Yap_InitCPredBack(const char *Name, UInt Arity,
unsigned int Extra, CPredicate Start,
CPredicate Cont, UInt flags){
CPredicate Cont, pred_flags_t flags){
Yap_InitCPredBack_(Name,Arity,Extra,Start,Cont,NULL,flags);
}
void
Yap_InitCPredBackCut(const char *Name, UInt Arity,
unsigned int Extra, CPredicate Start,
CPredicate Cont,CPredicate Cut, UInt flags){
CPredicate Cont,CPredicate Cut, pred_flags_t flags){
Yap_InitCPredBack_(Name,Arity,Extra,Start,Cont,Cut,flags);
}
void
Yap_InitCPredBack_(const char *Name, UInt Arity,
unsigned int Extra, CPredicate Start,
CPredicate Cont, CPredicate Cut, UInt flags)
CPredicate Cont, CPredicate Cut, pred_flags_t flags)
{
CACHE_REGS
PredEntry *pe = NULL;

View File

@ -693,6 +693,14 @@ read_tag(IOSTREAM *stream)
return ch;
}
static UInt
read_predFlags(IOSTREAM *stream)
{
pred_flags_t v;
read_bytes(stream, &v, sizeof(pred_flags_t));
return v;
}
static bool
checkChars(IOSTREAM *stream, char s[])
{
@ -998,17 +1006,11 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
static void
read_pred(IOSTREAM *stream, Term mod) {
UInt flags;
#if SIZEOF_INT_P==4
UInt eflags;
#endif
UInt nclauses, fl1;
PredEntry *ap;
ap = LookupPredEntry((PredEntry *)read_UInt(stream));
flags = read_UInt(stream);
#if SIZEOF_INT_P==4
eflags = read_UInt(stream);
#endif
flags = read_predFlags(stream);
nclauses = read_UInt(stream);
if (ap->PredFlags & IndexedPredFlag) {
Yap_RemoveIndexation(ap);
@ -1017,16 +1019,9 @@ read_pred(IOSTREAM *stream, Term mod) {
// printf(" %s/%ld\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE);
//else if (ap->ModuleOfPred != IDB_MODULE)
// printf(" %s/%ld\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE);
#if SIZEOF_INT_P==4
fl1 = flags & ((UInt)STATIC_PRED_FLAGS);
ap->PredFlags &= ~((UInt)STATIC_PRED_FLAGS);
ap->PredFlags |= fl1;
ap->ExtraPredFlags = eflags;
#else
fl1 = flags & ((UInt)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
ap->PredFlags &= ~((UInt)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
ap->PredFlags |= fl1;
#endif
if (flags & NumberDBPredFlag) {
ap->src.IndxId = read_UInt(stream);
} else {

View File

@ -555,6 +555,12 @@ static size_t save_tag(IOSTREAM *stream, qlf_tag_t tag)
return save_byte(stream, tag);
}
static size_t save_predFlags(IOSTREAM *stream, pred_flags_t predFlags)
{
pred_flags_t v = predFlags;
return save_bytes(stream, &v, sizeof(pred_flags_t));
}
static int
SaveHash(IOSTREAM *stream)
{
@ -688,10 +694,7 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) {
static size_t
save_pred(IOSTREAM *stream, PredEntry *ap) {
CHECK(save_UInt(stream, (UInt)ap));
CHECK(save_UInt(stream, ap->PredFlags));
#if SIZEOF_INT_P==4
CHECK(save_UInt(stream, ap->ExtraPredFlags));
#endif
CHECK(save_predFlags(stream, ap->PredFlags));
CHECK(save_UInt(stream, ap->cs.p_code.NOfClauses));
CHECK(save_UInt(stream, ap->src.IndxId));
CHECK(save_UInt(stream, ap->TimeStampOfPred));

View File

@ -1162,7 +1162,7 @@ static Int init_current_atom_op(
static Int p_flags(USES_REGS1) { /* $flags(+Functor,+Mod,?OldFlags,?NewFlags) */
PredEntry *pe;
Int newFl;
pred_flags_t newFl;
Term t1 = Deref(ARG1);
Term mod = Deref(ARG2);
@ -1215,7 +1215,7 @@ static Int p_flags(USES_REGS1) { /* $flags(+Functor,+Mod,?OldFlags,?NewFlags) */
}
} else
newFl = IntegerOfTerm(ARG4);
pe->PredFlags = (CELL)newFl;
pe->PredFlags = newFl;
UNLOCK(pe->PELock);
return TRUE;
}

View File

@ -1,6 +1,8 @@
#define YAP_CPP_INTERFACE 1
//! @{
/**
*
* @defgroup yap-cplus-interface An object oriented interface for YAP.
@ -13,8 +15,6 @@
* with the swig interface language generator. It uses ideas from the old YAP
* interface and from the SWI foreign language interface.
*
* @{
*
*/
#include <stdlib.h>

View File

@ -250,12 +250,6 @@ void Yap_DebugEndline(void);
int Yap_DebugGetc(void);
#endif
int Yap_IsOpType(char *);
void Yap_InitCPred(const char *, UInt, CPredicate, UInt);
void Yap_InitAsmPred(const char *, UInt, int, CPredicate, UInt);
void Yap_InitCmpPred(const char *, UInt, CmpPredicate, UInt);
void Yap_InitCPredBack(const char *, UInt, unsigned int, CPredicate,CPredicate,UInt);
void Yap_InitCPredBackCut(const char *, UInt, unsigned int, CPredicate,CPredicate,CPredicate,UInt);
void Yap_InitCPredBack_(const char *, UInt, unsigned int, CPredicate,CPredicate,CPredicate,UInt);
void Yap_InitWorkspace(UInt,UInt,UInt,UInt,UInt,int,int,int);
#ifdef YAPOR
@ -425,15 +419,16 @@ size_t Yap_ExportTerm(Term, char *, size_t, UInt);
size_t Yap_SizeOfExportedTerm(char *);
Term Yap_ImportTerm(char *);
int Yap_IsListTerm(Term);
int Yap_IsListOrPartialListTerm(Term);
Term Yap_CopyTermNoShare(Term);
int Yap_SizeGroundTerm(Term, int);
int Yap_IsGroundTerm(Term);
int Yap_IsAcyclicTerm(Term);
void Yap_InitUtilCPreds(void);
int Yap_IsListOrPartialListTerm(Term);
Term Yap_CopyTermNoShare(Term);
int Yap_SizeGroundTerm(Term, int);
int Yap_IsGroundTerm(Term);
int Yap_IsAcyclicTerm(Term);
void Yap_InitUtilCPreds(void);
Int Yap_TermHash(Term, Int, Int, int);
Int Yap_NumberVars(Term, Int, int);
Term Yap_TermVariables( Term t, UInt arity USES_REGS );
int Yap_IsListOrPartialListTerm( UInt arity USES_REGS );
Term Yap_UnNumberTerm(Term, int);
Int Yap_SkipList(Term *, Term **);
/* yap.c */

View File

@ -638,11 +638,8 @@ IsValProperty (int flags)
return (PropFlags) ((flags == ValProperty));
}
#if SIZEOF_INT_P==4
#define EXTRA_FLAG_BASE 0
#else
#define EXTRA_FLAG_BASE 33
#endif
typedef uint64_t pred_flags_t;
/* predicate property entry structure */
/* AsmPreds are things like var, nonvar, atom ...which are implemented
@ -654,51 +651,51 @@ IsValProperty (int flags)
don't forget to also add in qly.h
*/
#define DiscontiguousPredFlag ((uint64_t)0x1000000000) /* predicates whose clauses may be all-over the place.. */
#define SysExportPredFlag ((uint64_t)0x800000000)
#define DiscontiguousPredFlag ((pred_flags_t)0x1000000000) /* predicates whose clauses may be all-over the place.. */
#define SysExportPredFlag ((pred_flags_t)0x800000000)
/* reuse export list to prolog module. */
#define NoTracePredFlag ((uint64_t)0x400000000) /* cannot trace this predicate */
#define NoSpyPredFlag ((uint64_t)0x200000000) /* cannot spy this predicate */
#define QuasiQuotationPredFlag ((uint64_t)0x100000000) /* SWI-like quasi quotations */
#define MegaClausePredFlag ((uint64_t)0x80000000) /* predicate is implemented as a mega-clause */
#define ThreadLocalPredFlag ((uint64_t)0x40000000) /* local to a thread */
#define MultiFileFlag ((uint64_t)0x20000000) /* is multi-file */
#define UserCPredFlag ((uint64_t)0x10000000) /* CPred defined by the user */
#define LogUpdatePredFlag ((uint64_t)0x08000000) /* dynamic predicate with log. upd. sem. */
#define InUsePredFlag ((uint64_t)0x04000000) /* count calls to pred */
#define CountPredFlag ((uint64_t)0x02000000) /* count calls to pred */
#define HiddenPredFlag ((uint64_t)0x01000000) /* invisible predicate */
#define CArgsPredFlag ((uint64_t)0x00800000) /* SWI-like C-interface pred. */
#define SourcePredFlag ((uint64_t)0x00400000) /* static predicate with source declaration */
#define MetaPredFlag ((uint64_t)0x00200000) /* predicate subject to a meta declaration */
#define SyncPredFlag ((uint64_t)0x00100000) /* has to synch before it can execute */
#define NumberDBPredFlag ((uint64_t)0x00080000) /* entry for a number key */
#define AtomDBPredFlag ((uint64_t)0x00040000) /* entry for an atom key */
#define GoalExPredFlag ((uint64_t)0x00020000) /* predicate that is called by goal_expand */
#define TestPredFlag ((uint64_t)0x00010000) /* is a test (optim. comit) */
#define AsmPredFlag ((uint64_t)0x00008000) /* inline */
#define StandardPredFlag ((uint64_t)0x00004000) /* system predicate */
#define DynamicPredFlag ((uint64_t)0x00002000) /* dynamic predicate */
#define CPredFlag ((uint64_t)0x00001000) /* written in C */
#define SafePredFlag ((uint64_t)0x00000800) /* does not alter arguments */
#define CompiledPredFlag ((uint64_t)0x00000400) /* is static */
#define IndexedPredFlag ((uint64_t)0x00000200) /* has indexing code */
#define SpiedPredFlag ((uint64_t)0x00000100) /* is a spy point */
#define BinaryPredFlag ((uint64_t)0x00000080) /* test predicate */
#define TabledPredFlag ((uint64_t)0x00000040) /* is tabled */
#define SequentialPredFlag ((uint64_t)0x00000020) /* may not create parallel choice points! */
#define ProfiledPredFlag ((uint64_t)0x00000010) /* pred is being profiled */
#define BackCPredFlag ((uint64_t)0x00000008) /* Myddas Imported pred */
#define ModuleTransparentPredFlag ((uint64_t)0x00000004) /* ModuleTransparent pred */
#define SWIEnvPredFlag ((uint64_t)0x00000002) /* new SWI interface */
#define UDIPredFlag ((uint64_t)0x00000001) /* User Defined Indexing */
#define NoTracePredFlag ((pred_flags_t)0x400000000) /* cannot trace this predicate */
#define NoSpyPredFlag ((pred_flags_t)0x200000000) /* cannot spy this predicate */
#define QuasiQuotationPredFlag ((pred_flags_t)0x100000000) /* SWI-like quasi quotations */
#define MegaClausePredFlag ((pred_flags_t)0x80000000) /* predicate is implemented as a mega-clause */
#define ThreadLocalPredFlag ((pred_flags_t)0x40000000) /* local to a thread */
#define MultiFileFlag ((pred_flags_t)0x20000000) /* is multi-file */
#define UserCPredFlag ((pred_flags_t)0x10000000) /* CPred defined by the user */
#define LogUpdatePredFlag ((pred_flags_t)0x08000000) /* dynamic predicate with log. upd. sem. */
#define InUsePredFlag ((pred_flags_t)0x04000000) /* count calls to pred */
#define CountPredFlag ((pred_flags_t)0x02000000) /* count calls to pred */
#define HiddenPredFlag ((pred_flags_t)0x01000000) /* invisible predicate */
#define CArgsPredFlag ((pred_flags_t)0x00800000) /* SWI-like C-interface pred. */
#define SourcePredFlag ((pred_flags_t)0x00400000) /* static predicate with source declaration */
#define MetaPredFlag ((pred_flags_t)0x00200000) /* predicate subject to a meta declaration */
#define SyncPredFlag ((pred_flags_t)0x00100000) /* has to synch before it can execute */
#define NumberDBPredFlag ((pred_flags_t)0x00080000) /* entry for a number key */
#define AtomDBPredFlag ((pred_flags_t)0x00040000) /* entry for an atom key */
#define GoalExPredFlag ((pred_flags_t)0x00020000) /* predicate that is called by goal_expand */
#define TestPredFlag ((pred_flags_t)0x00010000) /* is a test (optim. comit) */
#define AsmPredFlag ((pred_flags_t)0x00008000) /* inline */
#define StandardPredFlag ((pred_flags_t)0x00004000) /* system predicate */
#define DynamicPredFlag ((pred_flags_t)0x00002000) /* dynamic predicate */
#define CPredFlag ((pred_flags_t)0x00001000) /* written in C */
#define SafePredFlag ((pred_flags_t)0x00000800) /* does not alter arguments */
#define CompiledPredFlag ((pred_flags_t)0x00000400) /* is static */
#define IndexedPredFlag ((pred_flags_t)0x00000200) /* has indexing code */
#define SpiedPredFlag ((pred_flags_t)0x00000100) /* is a spy point */
#define BinaryPredFlag ((pred_flags_t)0x00000080) /* test predicate */
#define TabledPredFlag ((pred_flags_t)0x00000040) /* is tabled */
#define SequentialPredFlag ((pred_flags_t)0x00000020) /* may not create parallel choice points! */
#define ProfiledPredFlag ((pred_flags_t)0x00000010) /* pred is being profiled */
#define BackCPredFlag ((pred_flags_t)0x00000008) /* Myddas Imported pred */
#define ModuleTransparentPredFlag ((pred_flags_t)0x00000004) /* ModuleTransparent pred */
#define SWIEnvPredFlag ((pred_flags_t)0x00000002) /* new SWI interface */
#define UDIPredFlag ((pred_flags_t)0x00000001) /* User Defined Indexing */
/* profile data */
typedef struct
{
uint64_t NOfEntries; /* nbr of times head unification succeeded */
uint64_t NOfHeadSuccesses; /* nbr of times head unification succeeded */
uint64_t NOfRetries; /* nbr of times a clause for the pred
UInt NOfEntries; /* nbr of times head unification succeeded */
UInt NOfHeadSuccesses; /* nbr of times head unification succeeded */
UInt NOfRetries; /* nbr of times a clause for the pred
was retried */
#if defined(YAPOR) || defined(THREADS)
lockvar lock; /* a simple lock to protect this entry */
@ -714,13 +711,13 @@ typedef enum {
#define TIMESTAMP_EOT ((UInt)(~0L))
#define TIMESTAMP_RESET (TIMESTAMP_EOT-1024)
typedef struct pred_entry
typedef struct pred_entry
{
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
struct yami *CodeOfPred;
OPCODE OpcodeOfPred; /* undefcode, indexcode, spycode, .... */
uint64_t PredFlags;
pred_flags_t PredFlags;
UInt ArityOfPE; /* arity of property */
union
{
@ -842,6 +839,14 @@ typedef enum
/* other flags belong to DB */
} dbentry_flags;
/* predicate initialization */
void Yap_InitCPred(const char *, UInt, CPredicate, pred_flags_t);
void Yap_InitAsmPred(const char *, UInt, int, CPredicate, pred_flags_t);
void Yap_InitCmpPred(const char *, UInt, CmpPredicate, pred_flags_t);
void Yap_InitCPredBack(const char *, UInt, unsigned int, CPredicate,CPredicate,pred_flags_t);
void Yap_InitCPredBackCut(const char *, UInt, unsigned int, CPredicate,CPredicate,CPredicate,pred_flags_t);
void Yap_InitCPredBack_(const char *, UInt, unsigned int, CPredicate,CPredicate,CPredicate,pred_flags_t);
/* *********************** DBrefs **************************************/
typedef struct DB_TERM

View File

@ -1335,7 +1335,7 @@ restore_static_array(StaticArrayEntry *ae USES_REGS)
static void
CleanCode(PredEntry *pp USES_REGS)
{
CELL flag;
pred_flags_t flag;
/* Init takes care of the first 2 cases */