fix C major issues

- use delays to implement setup_call
- fix user_* flag
- error handling i CXX should b local
- fix mess on  how to call openQuert
- deter pt -> from a pointer to another one
- avoid text forms when you can use C: LOCLS to locals.h
- fux seto_call
- new gated call
- mem streams
This commit is contained in:
Vitor Santos Costa 2017-08-21 12:29:58 +01:00
parent f8f1d75ad6
commit 54234c7e1d
37 changed files with 1233 additions and 2579 deletions

View File

@ -127,12 +127,13 @@ Term Yap_RatTermToApplTerm(Term t) {
#endif
Term Yap_AllocExternalDataInStack(CELL tag, size_t bytes, CELL **pt) {
Term Yap_AllocExternalDataInStack(CELL tag, size_t bytes, void *pt) {
CACHE_REGS
Int nlimbs;
MP_INT *dst = (MP_INT *)(HR + 2);
CELL *ret = HR;
CELL **blobp;
nlimbs = ALIGN_BY_TYPE(bytes, CELL) / CellSize;
if (nlimbs > (ASP - ret) - 1024) {
return TermNil;
@ -144,13 +145,14 @@ Term Yap_AllocExternalDataInStack(CELL tag, size_t bytes, CELL **pt) {
HR = (CELL *)(dst + 1) + nlimbs;
HR[0] = EndSpecials;
HR++;
*pt = (CELL *)(dst + 1);
blobp = (CELL **)pt;
*blobp = (CELL *)(dst + 1);
return AbsAppl(ret);
}
int Yap_CleanOpaqueVariable(CELL d) {
CELL blob_info, blob_tag;
MP_INT *blobp;
CELL *pt = RepAppl(HeadOfTerm(d));
#ifdef DEBUG
/* sanity checking */

View File

@ -2134,6 +2134,13 @@ X_API int YAP_InitConsult(int mode, const char *filename, char *full,
return sno;
}
/// given a stream descriptor or stream alias (see open/3),
/// return YAP's internal handle.
X_API void *YAP_GetStreamFromId(int no)
{
return GLOBAL_Stream+no;
}
X_API FILE *YAP_TermToStream(Term t) {
BACKUP_MACHINE_REGS();
FILE *s;

203
C/exec.c
View File

@ -723,23 +723,19 @@ static void prune_inner_computation(choiceptr parent) {
Int oENV = LCL0 - ENV;
cut_pt = B;
while (cut_pt < parent) {
/* make sure we
e C-choicepoints */
if (POP_CHOICE_POINT(cut_pt->cp_b)) {
POP_EXECUTE();
}
while (cut_pt->cp_b < parent) {
cut_pt = cut_pt->cp_b;
}
#ifdef YAPOR
CUT_prune_to(cut_pt);
#endif
B = parent;
B = cut_pt;
Yap_TrimTrail();
LOCAL_AllowRestart = FALSE;
P = oP;
CP = oCP;
ENV = LCL0 - oENV;
B = parent;
}
/**
@ -781,7 +777,7 @@ static Int Yap_ignore(Term t USES_REGS) {
CP = oCP;
ENV = LCL0 - oENV;
YENV = LCL0 - oYENV;
B = (choiceptr)(LCL0-oB);
B = (choiceptr)(LCL0 - oB);
return false;
}
@ -819,43 +815,29 @@ static bool watch_cut(Term ext USES_REGS) {
// called after backtracking..
//
Term task = TailOfTerm(ext);
Term box = ArgOfTerm(1, task);
Term port = ArgOfTerm(2, task);
Term cleanup = ArgOfTerm(3, task);
Term cleaned = ArgOfTerm(6, task);
bool first = Deref(ArgOfTerm(5, task)) == MkIntTerm(0);
bool done = first && !IsVarTerm(Deref(ArgOfTerm(4, task)));
bool previous = !IsVarTerm(Deref(ArgOfTerm(6, task)));
if (done || previous)
bool complete = !IsVarTerm(Deref(ArgOfTerm(4, task)));
bool active = ArgOfTerm(5, task) == TermTrue;
if (complete) {
return true;
while (B->cp_ap->opc == FAIL_OPCODE)
B = B->cp_b;
}
CELL *port_pt = deref_ptr(RepAppl(task) + 2);
if (Yap_HasException()) {
Term e = Yap_GetException();
Term t;
if (first) {
if (active) {
t = Yap_MkApplTerm(FunctorException, 1, &e);
} else {
t = Yap_MkApplTerm(FunctorExternalException, 1, &e);
t = Yap_MkApplTerm(FunctorExternalException, 1, &e);
}
if (!Yap_unify(port, t))
return false;
port_pt[0] = t;
} else {
if (!Yap_unify(port, TermCut))
return false;
port_pt[0] = TermCut;
}
if (IsVarTerm(cleaned) && box != TermTrue)
{
*VarOfTerm(cleaned) = Deref(port);
}
else
{
return true;
}
Yap_ignore(cleanup);
CELL *complete_pt = deref_ptr(RepAppl(task) + 4);
complete_pt[0] = TermTrue;
if (Yap_RaiseException())
return false;
return true;
@ -876,58 +858,39 @@ static bool watch_retry(Term d0 USES_REGS) {
choiceptr B0 = (choiceptr)(LCL0 - d);
Term task = TailOfTerm(d0);
Term box = ArgOfTerm(1, task);
bool box = ArgOfTerm(1, task) == TermTrue;
Term cleanup = ArgOfTerm(3, task);
Term port = ArgOfTerm(2, task);
Term cleaned = ArgOfTerm(6, task);
bool first = Deref(ArgOfTerm(5, task)) == MkIntTerm(0);
bool done = first && !IsVarTerm(Deref(ArgOfTerm(4, task)));
bool previous = !IsVarTerm(Deref(ArgOfTerm(6, task)));
bool ex = false;
if (done || previous)
bool complete = !IsVarTerm(ArgOfTerm(4, task));
bool active = ArgOfTerm(5, task) == TermTrue;
if ( complete)
return true;
CELL *port_pt= deref_ptr(RepAppl(Deref(task))+ 2);
CELL *complete_pt= deref_ptr(RepAppl(Deref(task))+ 4);
Term t;
while (B->cp_ap->opc == FAIL_OPCODE)
B = B->cp_b;
if (Yap_HasException())
{
B = B->cp_b;
if (Yap_HasException()) {
Term e = Yap_GetException();
Term t;
ex = true;
if (first)
{
if (active) {
t = Yap_MkApplTerm(FunctorException, 1, &e);
}
else
{
} else {
t = Yap_MkApplTerm(FunctorExternalException, 1, &e);
}
if (!Yap_unify(port, t))
return false;
}
else if(B < B0)
{
if (box != TermTrue) {
return true;
}
if (!Yap_unify(port, TermRetry)) {
return false;
}
} else if (first) {
if (!Yap_unify(port, TermFail))
return false;
} else {
return true;
}
if (IsVarTerm(cleaned) && box != TermTrue) {
*VarOfTerm(cleaned) = Deref(port);
complete_pt[0] = t;
} else if (B >= B0) {
t = TermFail;
complete_pt[0] = t;
} else if (box) {
t = TermRetry;
} else {
return true;
}
port_pt[0] = t;
Yap_ignore(cleanup);
if (!ex && Yap_RaiseException())
if ( Yap_RaiseException())
return false;
return true;
}
@ -958,7 +921,7 @@ static Int setup_call_catcher_cleanup(USES_REGS1) {
}
if (!rc) {
complete_inner_computation(B0);
// We'll pass it through
// We'll pass it throughs
return false;
} else {
@ -971,52 +934,40 @@ static Int setup_call_catcher_cleanup(USES_REGS1) {
return rc;
}
static Int tag_cleanup(USES_REGS1)
{
static Int tag_cleanup(USES_REGS1) {
Int iB = LCL0 - (CELL *)B;
set_watch(iB, Deref(ARG2));
return Yap_unify(ARG1, MkIntegerTerm(iB));
}
static Int cleanup_on_exit(USES_REGS1)
{
static Int cleanup_on_exit(USES_REGS1) {
choiceptr B0 = (choiceptr)(LCL0 - IntegerOfTerm(Deref(ARG1)));
Term task = Deref(ARG2);
Term box = ArgOfTerm(1, task);
Term cleanup = ArgOfTerm(3, task);
Term catcher = ArgOfTerm(2, task);
Term tag = ArgOfTerm(4, task);
Term cleaned = ArgOfTerm(6, task);
while (B->cp_ap->opc == FAIL_OPCODE)
B = B->cp_b;
if (B < B0)
{
// non-deterministic
set_watch(LCL0 - (CELL *)B, task);
if (box == TermTrue)
{
if (!Yap_unify(catcher, TermAnswer))
return false;
B->cp_tr++;
Yap_ignore(cleanup);
B->cp_tr--;
}
choiceptr B0 = (choiceptr)(LCL0 - IntegerOfTerm(Deref(ARG1)));
Term task = Deref(ARG2);
bool box = ArgOfTerm(1, task) == TermTrue;
Term cleanup = ArgOfTerm(3, task);
Term catcher = ArgOfTerm(2, task);
Term complete = !IsVarTerm( ArgOfTerm(4, task));
while (B->cp_ap->opc == FAIL_OPCODE)
B = B->cp_b;
if (complete )
return true;
CELL *catcher_p = deref_ptr(RepAppl(Deref(task))+2);
if (B < B0)
{
// non-deterministic
set_watch(LCL0 - (CELL *)B, task);
catcher_p[0] = TermAnswer;
if (!box) {
return true;
}
if (!Yap_unify(catcher, TermExit))
return false;
if (IsVarTerm(tag))
*VarOfTerm(tag) = TermTrue;
if (IsVarTerm(cleaned) && box != TermTrue)
{
*VarOfTerm(cleaned) = TermExit;
}
else
{
return true;
}
Yap_ignore(cleanup);
} else {
catcher_p[0] = TermExit;
CELL *complete_p = deref_ptr(RepAppl(Deref(task))+4);
complete_p[0] = TermExit;
}
Yap_ignore(cleanup);
return true;
}
@ -1490,8 +1441,6 @@ static bool do_goal(yamop *CodeAdr, int arity, CELL *pt, bool top USES_REGS) {
// PredPropByFunc(Yap_MkFunctor(AtomCall, 1), 0))); /* A1 mishaps */
out = exec_absmi(top, YAP_EXEC_ABSMI PASS_REGS);
if (top)
Yap_flush();
// if (out) {
// out = Yap_GetFromSlot(sl);
// }
@ -1987,30 +1936,6 @@ static Int JumpToEnv() {
}
POP_FAIL(handler);
B = handler;
// Yap_CopyException(ref);
if (Yap_PredForChoicePt(B, NULL) == PredDollarCatch) {
/* can recover Heap thanks to copy term :-( */
/* B->cp_h = H; */
/* I could backtrack here, but it is easier to leave the unwinding
to the emulator */
// handler->cp_h = HR;
/* try to recover space */
/* can only do that when we recover space */
/* first, backtrack */
/* so that I recover memory execute op_fail */
// now put the ball in place
// Yap_CopyException(dbt);
Term t = Yap_GetException();
if (t == 0) {
return false;
} else if (IsVarTerm(t)) {
t = Yap_MkApplTerm(FunctorGVar, 1, &t);
}
Yap_unify(t, B->cp_a2);
B->cp_h = HR;
TR--;
}
P = FAILCODE;
return true;
}

View File

@ -186,25 +186,19 @@ static Term stream(Term inp) {
static bool set_error_stream(Term inp) {
if (IsVarTerm(inp))
return Yap_unify(inp, Yap_StreamUserName(LOCAL_c_error_stream));
LOCAL_c_error_stream = Yap_CheckStream(
inp, Output_Stream_f | Append_Stream_f | Socket_Stream_f, "yap_flag/3");
return true;
return Yap_SetErrorStream( inp );
}
static bool set_input_stream(Term inp) {
if (IsVarTerm(inp))
return Yap_unify(inp, Yap_StreamUserName(LOCAL_c_input_stream));
LOCAL_c_input_stream =
Yap_CheckStream(inp, Input_Stream_f | Socket_Stream_f, "yap_flag/3");
return true;
return Yap_SetInputStream( inp );
}
static bool set_output_stream(Term inp) {
if (IsVarTerm(inp))
return Yap_unify(inp, Yap_StreamUserName(LOCAL_c_output_stream));
LOCAL_c_output_stream = Yap_CheckStream(
inp, Output_Stream_f | Append_Stream_f | Socket_Stream_f, "yap_flag/3");
return true;
return Yap_SetOutputStream( inp );
}
static Term isground(Term inp) {

View File

@ -134,7 +134,7 @@ gc_growtrail(int committed, tr_fr_ptr begsTR, cont *old_cont_top0 USES_REGS)
#endif
/* could not find more trail */
save_machine_regs();
siglongjmp(*LOCAL_gc_restore, 2);
siglongjmp(LOCAL_gc_restore, 2);
}
}
@ -397,7 +397,7 @@ check_pr_trail( tr_fr_ptr rc USES_REGS)
if (!Yap_locked_growtrail(0, TRUE) || TRUE) {
/* could not find more trail */
save_machine_regs();
siglongjmp(*LOCAL_gc_restore, 2);
siglongjmp( LOCAL_gc_restore, 2);
}
rc = TR-n;
}
@ -525,7 +525,7 @@ pop_registers(Int num_regs, yamop *nextop USES_REGS)
/* error: we don't have enough room */
/* could not find more trail */
save_machine_regs();
siglongjmp(*LOCAL_gc_restore, 4);
siglongjmp(LOCAL_gc_restore, 4);
}
}
}
@ -1451,7 +1451,7 @@ mark_variable(CELL_PTR current USES_REGS)
/* error: we don't have enough room */
/* could not find more trail */
save_machine_regs();
siglongjmp(*LOCAL_gc_restore, 3);
siglongjmp(LOCAL_gc_restore, 3);
} else if (n > 0) {
CELL *ptr = LOCAL_extra_gc_cells;
@ -3931,8 +3931,6 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
int jmp_res;
sigjmp_buf jmp;
LOCAL_gc_restore = &jmp;
heap_cells = HR-H0;
gc_verbose = is_gc_verbose();
effectiveness = 0;

View File

@ -378,8 +378,8 @@ Term YAPListTerm::car()
else
{
Yap_Error(TYPE_ERROR_LIST, to, "");
throw YAPError();
return 0;
throw YAPError();
}
}
@ -408,10 +408,12 @@ YAPListTerm::YAPListTerm(YAPTerm ts[], arity_t n)
const char *YAPAtom::getName(void) { return Yap_AtomToUTF8Text(a, nullptr); }
void YAPQuery::openQuery(Term t, Term *ts)
void YAPQuery::openQuery(Term *ts)
{
CACHE_REGS
if (ts) {
if (ap == NULL || ap->OpcodeOfPred == UNDEF_OPCODE) {
ap = rewriteUndefQuery();
} else if (ts) {
arity_t arity = ap->ArityOfPE;
for (arity_t i = 0; i < arity; i++)
{
@ -423,6 +425,7 @@ void YAPQuery::openQuery(Term t, Term *ts)
bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[])
{
sigjmp_buf *oj = LOCAL_RestartEnv, buf;
try
{
CACHE_REGS
@ -432,7 +435,6 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[])
arity_t arity = ap.getArity();
bool result;
YAP_dogoalinfo q;
sigjmp_buf q_env;
for (arity_t i = 0; i < arity; i++)
XREGS[i + 1] = ts[i].term();
@ -445,16 +447,19 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[])
q.CurSlot = Yap_StartSlots();
q.p = P;
q.cp = CP;
// allow Prolog style exceotion handling
LOCAL_RestartEnv = &q_env;
if (sigsetjmp(q_env, false))
LOCAL_RestartEnv = &buf;
if (sigsetjmp(*LOCAL_RestartEnv, false))
{
return 0;
throw YAPError();
}
// don't forget, on success these bindings will still be there);
result = YAP_LeaveGoal(false, &q);
Yap_CloseHandles(q.CurSlot);
LOCAL_RestartEnv = oj;
RECOVER_MACHINE_REGS();
return result;
}
@ -463,19 +468,23 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[])
YAP_LeaveGoal(false, &q);
Yap_CloseHandles(q.CurSlot);
std::cerr << "Exception received by " << YAPApplTerm(ap.functor(), ts).text() << ".\n Forwarded...\n\n";
LOCAL_RestartEnv = oj;
return 0;
throw e;
}
}
bool YAPEngine::mgoal(Term t, Term tmod)
{
sigjmp_buf buf, *oldp = LOCAL_RestartEnv;
try
{
CACHE_REGS
BACKUP_MACHINE_REGS();
Term *ts = nullptr;
PredEntry *ap = Yap_get_pred(t, tmod, "C++");
if (ap == nullptr || ap->OpcodeOfPred == UNDEF_OPCODE)
{
ap = rewriteUndefEngineQuery(ap, t, tmod);
@ -503,15 +512,16 @@ bool YAPEngine::mgoal(Term t, Term tmod)
}
bool result;
sigjmp_buf q_env;
q.CurSlot = Yap_StartSlots();
q.p = P;
q.cp = CP;
// allow Prolog style exceotion handling
LOCAL_RestartEnv = &q_env;
if (sigsetjmp(q_env, false))
LOCAL_RestartEnv = &buf;
if (sigsetjmp(*LOCAL_RestartEnv, false))
{
throw YAPError();
return false;
return 0;
throw YAPError();
}
// don't forget, on success these guys may create slots
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
@ -519,6 +529,7 @@ bool YAPEngine::mgoal(Term t, Term tmod)
result = (bool)YAP_EnterGoal(ap, nullptr, &q);
{
YAP_LeaveGoal(false, &q);
LOCAL_RestartEnv = oldp;
RECOVER_MACHINE_REGS();
return result;
}
@ -527,6 +538,8 @@ bool YAPEngine::mgoal(Term t, Term tmod)
{
YAP_LeaveGoal(false, &q);
Yap_CloseHandles(q.CurSlot);
LOCAL_RestartEnv = oldp;
return 0;
throw e;
}
}
@ -549,7 +562,6 @@ Term YAPEngine::fun(Term t)
PredEntry *ap;
arity_t arity;
Functor f;
sigjmp_buf q_env;
Atom name;
if (IsApplTerm(t))
@ -595,9 +607,11 @@ Term YAPEngine::fun(Term t)
// make sure this is safe
yhandle_t o = Yap_InitHandle(XREGS[arity]);
// allow Prolog style exception handling
LOCAL_RestartEnv = &q_env;
if (sigsetjmp(q_env, false))
sigjmp_buf buf, *oldp = LOCAL_RestartEnv;
LOCAL_RestartEnv = &buf;
if (sigsetjmp(*LOCAL_RestartEnv, false))
{
return false;
throw YAPError();
}
// don't forget, on success these guys may create slots
@ -607,13 +621,15 @@ Term YAPEngine::fun(Term t)
#if DEBUG
fprintf(stderr,"function call failed:\n");
#endif
return 0;
LOCAL_RestartEnv = oldp;
return 0;
}
DBTerm *pt = Yap_StoreTermInDB(Yap_GetFromSlot(o), arity);
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %ld", o);
YAP_LeaveGoal(false, &q);
Yap_CloseHandles(q.CurSlot);
Term rc = Yap_PopTermFromDB(pt);
LOCAL_RestartEnv = oldp;
RECOVER_MACHINE_REGS();
return rc;
}
@ -644,7 +660,7 @@ YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm ts[])
goal = MkVarTerm();
nts = nullptr;
}
openQuery(goal, nts);
openQuery( nts);
names = YAPPairTerm( TermNil );
RECOVER_MACHINE_REGS();
}
@ -661,7 +677,7 @@ YAPQuery::YAPQuery(YAPFunctor f, YAPTerm ts[]) : YAPPredicate(f) {
nts = nullptr;
}
names = YAPPairTerm( TermNil );
openQuery(goal.term(), nts);
openQuery(term(), nts);
RECOVER_MACHINE_REGS();
}
#endif
@ -671,7 +687,7 @@ YAPQuery::YAPQuery(YAPTerm t) : YAPPredicate(t)
BACKUP_MACHINE_REGS();
CELL *nts;
Term tt = t.term();
goal = t;
goal = * new YAPTerm(tt);
if (IsApplTerm(tt)) {
Functor f = FunctorOfTerm(tt);
if (IsExtensionFunctor(f))
@ -682,7 +698,7 @@ YAPQuery::YAPQuery(YAPTerm t) : YAPPredicate(t)
} else {
nts = nullptr;
}
openQuery(tt, nts);
openQuery( nts);
names = YAPPairTerm( TermNil );
RECOVER_MACHINE_REGS();
}
@ -695,10 +711,10 @@ YAPQuery::YAPQuery(YAPPredicate p, YAPTerm ts[]) : YAPPredicate(p.ap) {
goal = YAPApplTerm(YAPFunctor(p.ap->FunctorOfPred), ts).term();
for (arity_t i =0; i < arity; i++)
XREGS[i+1]=ts[i].term();
openQuery(goal.term(), nullptr);
openQuery( nullptr);
} else {
goal = YAPAtomTerm((Atom)(p.ap->FunctorOfPred));
openQuery(goal.term(), nullptr);
openQuery(nullptr);
}
names = TermNil;
RECOVER_MACHINE_REGS();
@ -708,19 +724,18 @@ bool YAPQuery::next()
{
CACHE_REGS
bool result = false;
sigjmp_buf buf, *oldp = LOCAL_RestartEnv;
Term terr;
if (ap == NULL || ap->OpcodeOfPred == UNDEF_OPCODE) {
ap = rewriteUndefQuery();
}
LOCAL_RestartEnv = &q_env;
try
try
{
BACKUP_MACHINE_REGS();
if (!q_open)
return false;
if (sigsetjmp(q_env, false))
LOCAL_RestartEnv = &buf;
if (sigsetjmp(*LOCAL_RestartEnv, false))
{
throw YAPError();
//throw YAPError();
return false;
}
// don't forget, on success these guys may create slots
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
@ -748,6 +763,7 @@ bool YAPQuery::next()
{
if ((terr = Yap_GetException()))
{
LOCAL_RestartEnv = &buf;
throw YAPError();
}
}
@ -764,6 +780,7 @@ bool YAPQuery::next()
q_handles = Yap_StartSlots();
}
RECOVER_MACHINE_REGS();
LOCAL_RestartEnv = oldp;
return result;
}
catch (YAPError e)
@ -775,6 +792,7 @@ bool YAPQuery::next()
Yap_CloseHandles(q_handles);
q_open = false;
std::cerr << "Exception received by " << __func__ << "( " << YAPTerm(terr).text() << ").\n Forwarded...\n\n";
LOCAL_RestartEnv = oldp;
throw e;
}
}
@ -809,7 +827,7 @@ void YAPQuery::cut()
if (!q_open || q_state == 0)
return;
YAP_LeaveGoal(FALSE, &q_h);
q_open = 0;
q_open = false;
// LOCAL_execution = this;
RECOVER_MACHINE_REGS();
}
@ -908,6 +926,7 @@ void YAPEngine::doInit(YAP_file_type_t BootMode)
{
if ((BootMode = YAP_Init(&engine_args->init_args)) == YAP_FOUND_BOOT_ERROR)
{
return;
throw YAPError();
}
/* Begin preprocessor code */

View File

@ -59,13 +59,14 @@ class X_API YAPQuery : public YAPPredicate
};
void openQuery(Term t, Term *ts);
void openQuery( Term *ts);
PredEntry *rewriteUndefQuery();
public:
YAPQuery() {
openQuery(TermTrue, nullptr);
goal = TermTrue;
openQuery( nullptr);
};
/// main constructor, uses a predicate and an array of terms
///
@ -109,7 +110,7 @@ YAPQuery() {
}
}
names = YAPPairTerm(tnames);
openQuery(tgoal, qt);
openQuery(qt);
};
// inline YAPQuery() : YAPPredicate(s, tgoal, tnames)
// {

20
H/CMakeLists.txt Normal file
View File

@ -0,0 +1,20 @@
file( STRINGS locals.h tmp )
if (WITH_THREADS)
Foreach(i ${tmp})
string(REGEX REPLACE "^LOCAL[^(]*[(][^,]+,[^_a-zA-Z0-9]*([_a-zA-Z0-9]+)[^_a-zA-Z0-9,]*,[^_a-zA-Z0-9]*([_a-zA-Z0-9]+)[^)]*.*$" "#define LOCAL_\\0 (Yap_regs.worker_local->\\1)\\n#define REMOTE_\\1(wid) (REMOTE(wid)->\\1)\\n" i2 ${i})
list( APPEND tmp2 ${i2} "\n")
endforeach()
else()
Foreach(i ${tmp})
string(REGEX REPLACE "^LOCAL[^(]*[(][ \t]*([^,]+)[ \t]*,[ \t]*([^),]+).*" "#define LOCAL_\\2 (Yap_local.\\2)\\n#define REMOTE_\\2(wid) (REMOTE(wid)->\\2)\\n" i2 ${i})
list( APPEND tmp2 ${i2} "\n")
endforeach()
endif()
file( WRITE ${CMAKE_TOP_BINARY_DIR}/dlocals.h ${tmp2})
install (FILES ${PL_SOURCES}
DESTINATION ${libpl}/pl
)

323
H/LOCALS
View File

@ -1,323 +0,0 @@
// Stuff that must be considered local to a thread or worker
START_WORKER_LOCAL
// Streams
int c_input_stream =0
int c_output_stream =1
int c_error_stream =2
bool sockets_io =false
bool within_print_message =false
//
// Used by the prompts to check if they are after a newline, and then a
// prompt should be output, or if we are in the middle of a line.
//
bool newline =true
Atom AtPrompt =AtomNil
char Prompt[MAX_PROMPT+1] void
encoding_t encoding =Yap_DefaultEncoding()
bool quasi_quotations =false
UInt default_priority =1200
bool eot_before_eof =false
UInt max_depth =0
UInt max_list =0
UInt max_write_args =0
// Restore info
CELL* OldASP =NULL
CELL* OldLCL0 =NULL
tr_fr_ptr OldTR =NULL
CELL* OldGlobalBase =NULL
CELL* OldH =NULL
CELL* OldH0 =NULL
ADDR OldTrailBase =NULL
ADDR OldTrailTop =NULL
ADDR OldHeapBase =NULL
ADDR OldHeapTop =NULL
Int ClDiff =0L
Int GDiff =0L
Int HDiff =0L
Int GDiff0 =0L
CELL* GSplit =NULL
Int LDiff =0L
Int TrDiff =0L
Int XDiff =0L
Int DelayDiff =0L
Int BaseDiff =0L
// Reduction counters
YAP_ULONG_LONG ReductionsCounter =0L
YAP_ULONG_LONG PredEntriesCounter =0L
YAP_ULONG_LONG RetriesCounter =0L
int ReductionsCounterOn =0L
int PredEntriesCounterOn =0L
int RetriesCounterOn =0L
// support for consulting files
/* current consult stack */
union CONSULT_OBJ* ConsultSp =NULL
/* current maximum number of cells in consult stack */
UInt ConsultCapacity void
/* top of consult stack */
union CONSULT_OBJ* ConsultBase =NULL
/* low-water mark for consult */
union CONSULT_OBJ* ConsultLow =NULL
Term VarNames =((Term)0)
Atom SourceFileName =NULL
UInt SourceFileLineno =0
//global variables
Term GlobalArena =0L TermToGlobalOrAtomAdjust
UInt GlobalArenaOverflows =0L
Int ArenaOverflows =0L
Int DepthArenas =0
struct pred_entry* LastAssertedPred =NULL
struct pred_entry* TmpPred =NULL
char* ScannerStack =NULL
struct scanner_extra_alloc* ScannerExtraBlocks =NULL
/// worker control information
/// stack limit after which the stack is managed by C-code.
Int CBorder =0
/// max number of signals (uint64_t)
UInt MaxActiveSignals =64L
/// actual life signals
uint64_t Signals =0L
/// indexing help data?
UInt IPredArity =0L
yamop* ProfEnd =NULL
int DoingUndefp =FALSE
Int StartCharCount =0L
Int StartLineCount =0L
Int StartLinePos =0L
scratch_block ScratchPad InitScratchPad(wid)
#ifdef COROUTINING
Term WokenGoals =0L TermToGlobalAdjust
Term AttsMutableList =0L TermToGlobalAdjust
#endif
// gc_stuff
Term GcGeneration =0L TermToGlobalAdjust
Term GcPhase =0L TermToGlobalAdjust
UInt GcCurrentPhase =0L
UInt GcCalls =0L
Int TotGcTime =0L
YAP_ULONG_LONG TotGcRecovered =0L
Int LastGcTime =0L
Int LastSSTime =0L
CELL* OpenArray =NULL
/* in a single gc */
Int total_marked =0L
Int total_oldies =0L
struct choicept* current_B =NULL
CELL* prev_HB =NULL
CELL* HGEN =NULL
CELL** iptop =NULL
#if defined(GC_NO_TAGS)
char* bp =NULL
#endif
tr_fr_ptr sTR =NULL
tr_fr_ptr sTR0 =NULL
tr_fr_ptr new_TR =NULL
struct gc_mark_continuation* cont_top0 =NULL
struct gc_mark_continuation* cont_top =NULL
int discard_trail_entries =0
gc_ma_hash_entry gc_ma_hash_table[GC_MAVARS_HASH_SIZE] void
gc_ma_hash_entry* gc_ma_h_top =NULL
gc_ma_hash_entry* gc_ma_h_list =NULL
UInt gc_timestamp =0L
ADDR db_vec =NULL
ADDR db_vec0 =NULL
struct RB_red_blk_node* db_root =NULL
struct RB_red_blk_node* db_nil =NULL
sigjmp_buf* gc_restore void
CELL* extra_gc_cells void
CELL* extra_gc_cells_base void
CELL* extra_gc_cells_top void
UInt extra_gc_cells_size =256
struct array_entry* DynamicArrays =NULL PtoArrayEAdjust
struct static_array_entry* StaticArrays =NULL PtoArraySAdjust
struct global_entry* GlobalVariables =NULL PtoGlobalEAdjust
int AllowRestart =FALSE
// Thread Local Area for Fast Storage of Intermediate Compiled Code
struct mem_blk* CMemFirstBlock =NULL
UInt CMemFirstBlockSz =0L
// Variable used by the compiler to store number of permanent vars in a clause
int nperm =0
int jMP =0
// Thread Local Area for Labels
Int* LabelFirstArray =NULL
UInt LabelFirstArraySz =0L
// Thread Local Area for SWI-Prolog emulation routines.
// struct PL_local_data* PL_local_data_p =Yap_InitThreadIO(wid)
#ifdef THREADS
struct thandle ThreadHandle InitThreadHandle(wid)
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
struct local_optyap_data optyap_data Yap_init_local_optyap_data(wid)
UInt TabMode =0L
#endif /* YAPOR || TABLING */
int InterruptsDisabled =FALSE
struct open_query_struct* execution =NULL
#if LOW_LEVEL_TRACER
Int total_choicepoints =0
#endif
int consult_level =0
// Variables related to memory allocation
ADDR LocalBase void
ADDR GlobalBase void
ADDR TrailBase void
ADDR TrailTop void
/* error handling info, designed to be easy to pass to the foreign world */
yap_error_descriptor_t* ActiveError =calloc(sizeof(yap_error_descriptor_t),1)
/// pointer to an exception term, from throw
jmp_buf* IOBotch void
TokEntry* tokptr void
TokEntry* toktide void
VarEntry* VarTable void
VarEntry* AnonVarTable void
Term Comments void
CELL* CommentsTail void
CELL* CommentsNextChar void
wchar_t* CommentsBuff void
size_t CommentsBuffPos void
size_t CommentsBuffLim void
sigjmp_buf* RestartEnv void
char FileNameBuf[YAP_FILENAME_MAX+1] void
char FileNameBuf2[YAP_FILENAME_MAX+1] void
struct TextBuffer_manager* TextBuffer =Yap_InitTextAllocator()
// Prolog State
UInt BreakLevel =0
Int PrologMode =BootMode
int CritLocks =0
// Prolog execution and state flags
union flagTerm* Flags void
UInt flagCount void
//analyst.c
/* used to find out how many instructions of each kind are executed */
#ifdef ANALYST
YAP_ULONG_LONG opcount[_std_top+1] void
YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1] void
#endif /* ANALYST */
//dbase.c
struct db_globs* s_dbg void
//eval.c
Term mathtt void
char* mathstring =NULL
//grow.c
int heap_overflows =0
Int total_heap_overflow_time =0
int stack_overflows =0
Int total_stack_overflow_time =0
int delay_overflows =0
Int total_delay_overflow_time =0
int trail_overflows =0
Int total_trail_overflow_time =0
int atom_table_overflows =0
Int total_atom_table_overflow_time =0
//load_dyld
#ifdef LOAD_DYLD
int dl_errno =0
#endif
//tracer.c
#ifdef LOW_LEVEL_TRACER
int do_trace_primitives =TRUE
#endif
//quick loader
struct export_atom_hash_entry_struct *ExportAtomHashChain =NULL
UInt ExportAtomHashTableSize =0
UInt ExportAtomHashTableNum =0
struct export_functor_hash_entry_struct *ExportFunctorHashChain =NULL
UInt ExportFunctorHashTableSize =0
UInt ExportFunctorHashTableNum =0
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain =NULL
UInt ExportPredEntryHashTableSize =0
UInt ExportPredEntryHashTableNum =0
struct export_dbref_hash_entry_struct *ExportDBRefHashChain =NULL
UInt ExportDBRefHashTableSize =0
UInt ExportDBRefHashTableNum =0
struct import_atom_hash_entry_struct **ImportAtomHashChain =NULL
UInt ImportAtomHashTableSize =0
UInt ImportAtomHashTableNum =0
struct import_functor_hash_entry_struct **ImportFunctorHashChain =NULL
UInt ImportFunctorHashTableSize =0
UInt ImportFunctorHashTableNum =0
struct import_opcode_hash_entry_struct **ImportOPCODEHashChain =NULL
UInt ImportOPCODEHashTableSize =0
struct import_pred_entry_hash_entry_struct **ImportPredEntryHashChain =NULL
UInt ImportPredEntryHashTableSize =0
UInt ImportPredEntryHashTableNum =0
struct import_dbref_hash_entry_struct **ImportDBRefHashChain =NULL
UInt ImportDBRefHashTableSize =0
UInt ImportDBRefHashTableNum =0
yamop *ImportFAILCODE =NULL
// exo indexing
UInt ibnds[256] void
struct index_t* exo_it =NULL
CELL* exo_base =NULL
UInt exo_arity =0
UInt exo_arg =0
// atom completion
struct scan_atoms* search_atoms void
struct pred_entry* SearchPreds void
/// Slots Status
yhandle_t CurSlot =0
yhandle_t FrozenHandles =0
yhandle_t NSlots =0
CELL* SlotBase =InitHandles(wid)
// Mutexes
struct swi_mutex* Mutexes =NULL
Term SourceModule =0
Term Including =TermNil
size_t MAX_SIZE =1024L
/* last call to walltime. */
uint64_t LastWTime =0
void* shared =NULL
END_WORKER_LOCAL

View File

@ -176,8 +176,6 @@ typedef struct various_codes {
#include "hlocals.h"
#include "dlocals.h"

View File

@ -1,3 +1,4 @@
/*************************************************************************
* *
* YAP Prolog *

View File

@ -107,7 +107,7 @@ extern int Yap_IsStringTerm(Term);
extern int Yap_IsWideStringTerm(Term);
extern Term Yap_RatTermToApplTerm(Term);
extern void Yap_InitBigNums(void);
extern Term Yap_AllocExternalDataInStack(CELL, size_t, CELL **);
extern Term Yap_AllocExternalDataInStack(CELL, size_t, void *);
extern int Yap_CleanOpaqueVariable(Term t);
extern CELL *Yap_HeapStoreOpaqueTerm(Term t);
extern size_t Yap_OpaqueTermToString(Term t, char *str, size_t max);
@ -395,6 +395,10 @@ extern void Yap_InitCPreds(void);
extern void Yap_show_statistics(void);
extern int Yap_IsOpMaxPrio(Atom);
extern bool Yap_SetInputStream( Term sd );
extern bool Yap_SetOutputStream( Term sd );
extern bool Yap_SetErrorStream( Term sd );
/* sysbits.c */
extern size_t Yap_InitPageSize(void);
extern bool Yap_set_fpu_exceptions(Term);
@ -499,7 +503,7 @@ extern void Yap_init_optyap_preds(void);
/* pl-file.c */
// struct PL_local_data *Yap_InitThreadIO(int wid);
extern void Yap_flush(void);
extern void Yap_flush_all(void);
extern X_API YAP_opaque_tag_t
YAP_NewOpaqueType(struct YAP_opaque_handler_struct *f);

View File

@ -1,29 +1,28 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: amiops.h *
* Last rev: *
* mods: *
* comments: Basic abstract machine operations, such as *
* dereferencing, binding, trailing, and unification. *
* *
*************************************************************************/
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: amiops.h *
* Last rev: *
* mods: *
* comments: Basic abstract machine operations, such as *
* dereferencing, binding, trailing, and unification. *
* *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
static char SccsId[] = "%W% %G%";
#endif /* SCCS */
#include "inline-only.h"
#define IsArrayReference(a) ((a)->array_access_func == FunctorArrayAccess)
#define IsArrayReference(a) ((a)->array_access_func == FunctorArrayAccess)
/* dereferencing macros */
@ -36,72 +35,105 @@ Dereferencing macros
/* For DEREFD, D has both the input and the exit argument */
/* A is only used locally */
#define profiled_deref_head_TEST(D,Label) \
if (IsVarTerm(D)) { \
if (!strcmp(#D, "d0")) { EMIT_CONDITIONAL_SUCCESS("IsVarTerm(d0)"); } \
else if (!strcmp(#D, "d1")) { EMIT_CONDITIONAL_SUCCESS("IsVarTerm(d1)"); } \
goto Label; \
} \
if (!strcmp(#D, "d0")) { EMIT_CONDITIONAL_FAIL("IsVarTerm(d0)"); } \
else if (!strcmp(#D, "d1")) { EMIT_CONDITIONAL_FAIL("IsVarTerm(d1)"); }
#define profiled_deref_head_TEST(D, Label) \
if (IsVarTerm(D)) { \
if (!strcmp(#D, "d0")) { \
EMIT_CONDITIONAL_SUCCESS("IsVarTerm(d0)"); \
} else if (!strcmp(#D, "d1")) { \
EMIT_CONDITIONAL_SUCCESS("IsVarTerm(d1)"); \
} \
goto Label; \
} \
if (!strcmp(#D, "d0")) { \
EMIT_CONDITIONAL_FAIL("IsVarTerm(d0)"); \
} else if (!strcmp(#D, "d1")) { \
EMIT_CONDITIONAL_FAIL("IsVarTerm(d1)"); \
}
#define deref_head(D,Label) if (IsVarTerm(D)) goto Label
#define deref_head(D, Label) \
if (IsVarTerm(D)) \
goto Label
#define profiled_deref_body(D,A,LabelUnk,LabelNonVar) \
do { \
if(!IsVarTerm(D)) goto LabelNonVar; \
LabelUnk: \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
if (!strcmp(#D, "d0") && !strcmp(#A, "pt0")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT0); } \
else if (!strcmp(#D, "d0") && !strcmp(#A, "pt1")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT1); } \
else if (!strcmp(#D, "d0") && !strcmp(#A, "S_SREG")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0S_SREG); } \
else if (!strcmp(#D, "d1") && !strcmp(#A, "pt0")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT0); } \
else if (!strcmp(#D, "d1") && !strcmp(#A, "pt1")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT1); } \
} while (Unsigned(A) != (D));
#define deref_body(D,A,LabelUnk,LabelNonVar) \
do { \
if(!IsVarTerm(D)) goto LabelNonVar; \
LabelUnk: \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
} while (Unsigned(A) != (D))
#define do_derefa(D,A,LabelUnk,LabelDone) \
(D) = *(CELL *)(A); \
if (IsNonVarTerm(D)) goto LabelDone; \
goto LabelUnk; \
do { \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
if(!IsVarTerm(D)) goto LabelDone; \
LabelUnk: ; \
} while (Unsigned(A) != (D));\
LabelDone:
#define profiled_derefa_body(D,A,LabelUnk,LabelNonVar) \
do { \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
if (!strcmp(#D, "d0") && !strcmp(#A, "pt0")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT0); } \
else if (!strcmp(#D, "d0") && !strcmp(#A, "pt1")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT1); } \
else if (!strcmp(#D, "d0") && !strcmp(#A, "S_SREG")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0S_SREG); } \
else if (!strcmp(#D, "d1") && !strcmp(#A, "pt0")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT0); } \
else if (!strcmp(#D, "d1") && !strcmp(#A, "pt1")) { EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT1); } \
if(!IsVarTerm(D)) goto LabelNonVar; \
LabelUnk: ; \
#define profiled_deref_body(D, A, LabelUnk, LabelNonVar) \
do { \
if (!IsVarTerm(D)) \
goto LabelNonVar; \
LabelUnk: \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
if (!strcmp(#D, "d0") && !strcmp(#A, "pt0")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT0); \
} else if (!strcmp(#D, "d0") && !strcmp(#A, "pt1")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT1); \
} else if (!strcmp(#D, "d0") && !strcmp(#A, "S_SREG")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0S_SREG); \
} else if (!strcmp(#D, "d1") && !strcmp(#A, "pt0")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT0); \
} else if (!strcmp(#D, "d1") && !strcmp(#A, "pt1")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT1); \
} \
} while (Unsigned(A) != (D));
#define deref_body(D, A, LabelUnk, LabelNonVar) \
do { \
if (!IsVarTerm(D)) \
goto LabelNonVar; \
LabelUnk: \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
} while (Unsigned(A) != (D))
#define derefa_body(D,A,LabelUnk,LabelNonVar) \
do { \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
if(!IsVarTerm(D)) goto LabelNonVar; \
LabelUnk: ; \
} while (Unsigned(A) != (D))
#define deref_body(D, A, LabelUnk, LabelNonVar) \
do { \
if (!IsVarTerm(D)) \
goto LabelNonVar; \
LabelUnk: \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
} while (Unsigned(A) != (D))
#define do_derefa(D, A, LabelUnk, LabelDone) \
(D) = *(CELL *)(A); \
if (IsNonVarTerm(D)) \
goto LabelDone; \
goto LabelUnk; \
do { \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
if (!IsVarTerm(D)) \
goto LabelDone; \
LabelUnk:; \
} while (Unsigned(A) != (D)); \
LabelDone:
#define profiled_derefa_body(D, A, LabelUnk, LabelNonVar) \
do { \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
if (!strcmp(#D, "d0") && !strcmp(#A, "pt0")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT0); \
} else if (!strcmp(#D, "d0") && !strcmp(#A, "pt1")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0PT1); \
} else if (!strcmp(#D, "d0") && !strcmp(#A, "S_SREG")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D0S_SREG); \
} else if (!strcmp(#D, "d1") && !strcmp(#A, "pt0")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT0); \
} else if (!strcmp(#D, "d1") && !strcmp(#A, "pt1")) { \
EMIT_SIMPLE_BLOCK_TEST(YAAM_DEREF_BODY_D1PT1); \
} \
if (!IsVarTerm(D)) \
goto LabelNonVar; \
LabelUnk:; \
} while (Unsigned(A) != (D));
#define derefa_body(D, A, LabelUnk, LabelNonVar) \
do { \
(A) = (CELL *)(D); \
(D) = *(CELL *)(D); \
if (!IsVarTerm(D)) \
goto LabelNonVar; \
LabelUnk:; \
} while (Unsigned(A) != (D))
#if UNIQUE_TAG_FOR_PAIRS
@ -109,21 +141,39 @@ LabelUnk: \
speed up detection of dereferenced pairs, but will be slow
for the other cases.
The only instruction where this seems useful is
The only instruction where this seems useful is
switch_list_nl
*/
#define deref_list_head(D,Label) if (!IsPairTerm(D)) goto Label
#define deref_list_head(D, Label) \
if (!IsPairTerm(D)) \
goto Label
#define deref_list_body(D,A,LabelList,LabelNonVar) \
do { \
if (!IsVarTerm(D)) goto LabelNonVar; \
(A) = (CELL *)(D); \
(D) = *(A); \
if (Unsigned(A) == (D)) break; \
if (IsPairTerm(D)) goto LabelList; \
} while (TRUE);
#define deref_list_body(D, A, LabelList, LabelNonVar) \
do { \
if (!IsVarTerm(D)) \
goto LabelNonVar; \
(A) = (CELL *)(D); \
(D) = *(A); \
if (Unsigned(A) == (D)) \
break; \
if (IsPairTerm(D)) \
goto LabelList; \
} while (TRUE);
INLINE_ONLY inline EXTERN CELL *deref_ptr(CELL *A);
INLINE_ONLY inline EXTERN CELL *deref_ptr(CELL *A) {
Term D = *A;
do {
if (!IsVarTerm(D))
return A;
(A) = (CELL *)(D);
(D) = *(A);
if (Unsigned(A) == (D))
return A;
} while (TRUE);
}
#endif /* UNIQUE_TAG_FOR_PAIRS */
/************************************************************
@ -134,123 +184,148 @@ A contains the address of the variable that is to be trailed
*************************************************************/
#define RESET_VARIABLE(V) (*(CELL *)(V) = Unsigned(V))
#define RESET_VARIABLE(V) (*(CELL *)(V) = Unsigned(V))
#ifdef TABLING
#define DO_TRAIL(TERM, VAL) \
{ \
tr_fr_ptr r; \
r = TR; \
TR = r + 1; \
TrailTerm(r) = (Term) (TERM); \
TrailVal(r) = (CELL) (VAL); \
}
#define DO_TRAIL(TERM, VAL) \
{ \
tr_fr_ptr r; \
r = TR; \
TR = r + 1; \
TrailTerm(r) = (Term)(TERM); \
TrailVal(r) = (CELL)(VAL); \
}
#ifdef BFZ_TRAIL_SCHEME
#define TRAIL(TERM, VAL) \
if (OUTSIDE(HBREG,TERM,B) || \
((TERM) > (CELL *)B_FZ)) \
DO_TRAIL(TERM, VAL)
#define TRAIL(TERM, VAL) \
if (OUTSIDE(HBREG, TERM, B) || ((TERM) > (CELL *)B_FZ)) \
DO_TRAIL(TERM, VAL)
#define TRAIL_LOCAL(TERM, VAL) \
if ((TERM) > (CELL *)B || (TERM) > (CELL *)B_FZ) \
DO_TRAIL(TERM, VAL)
#define TRAIL_LOCAL(TERM, VAL) \
if ((TERM) > (CELL *)B || (TERM) > (CELL *)B_FZ) \
DO_TRAIL(TERM, VAL)
#else /* BBREG_TRAIL_SCHEME */
#define TRAIL(TERM, VAL) \
if (OUTSIDE(HBREG,TERM,BBREG)) \
DO_TRAIL(TERM, VAL)
#define TRAIL_LOCAL(TERM, VAL) \
if ((TERM) > (CELL *)BBREG) DO_TRAIL(TERM, VAL)
#define TRAIL(TERM, VAL) \
if (OUTSIDE(HBREG, TERM, BBREG)) \
DO_TRAIL(TERM, VAL)
#define TRAIL_LOCAL(TERM, VAL) \
if ((TERM) > (CELL *)BBREG) \
DO_TRAIL(TERM, VAL)
#endif /* TRAIL_SCHEME */
/* ------------------------------------------------------ */
#define TRAIL_GLOBAL(TERM, VAL) \
if ((TERM) < HBREG) DO_TRAIL(TERM, VAL)
#define TRAIL_GLOBAL(TERM, VAL) \
if ((TERM) < HBREG) \
DO_TRAIL(TERM, VAL)
#define DO_MATRAIL(TERM, OLDVAL, NEWVAL) \
{ \
register tr_fr_ptr r = TR; \
TR = r + 2; \
TrailVal(r) = (OLDVAL); \
TrailTerm(r) = TrailTerm(r+1) = AbsAppl((CELL *)(TERM)); \
TrailVal(r+1) = (NEWVAL); \
}
#define DO_MATRAIL(TERM, OLDVAL, NEWVAL) \
{ \
register tr_fr_ptr r = TR; \
TR = r + 2; \
TrailVal(r) = (OLDVAL); \
TrailTerm(r) = TrailTerm(r + 1) = AbsAppl((CELL *)(TERM)); \
TrailVal(r + 1) = (NEWVAL); \
}
#define MATRAIL(TERM, OVAL, VAL) \
if (OUTSIDE(HBREG,TERM,B)) \
DO_MATRAIL(TERM, OVAL, VAL)
#define MATRAIL(TERM, OVAL, VAL) \
if (OUTSIDE(HBREG, TERM, B)) \
DO_MATRAIL(TERM, OVAL, VAL)
#else /* TABLING */
#if defined(i386) && !defined(TERM_EXTENSIONS)
#define DO_TRAIL(A,D) \
{ \
tr_fr_ptr r; \
r = TR; \
TR = r+1; \
TrailTerm(r) = (CELL)(A); \
}
#define DO_TRAIL(A, D) \
{ \
tr_fr_ptr r; \
r = TR; \
TR = r + 1; \
TrailTerm(r) = (CELL)(A); \
}
#define TRAIL(A,D) if (OUTSIDE(HBREG,A,B)) \
DO_TRAIL(A,D);
#define TRAIL(A, D) \
if (OUTSIDE(HBREG, A, B)) \
DO_TRAIL(A, D);
#define TRAIL_GLOBAL(A,D) if ((A) < HBREG) DO_TRAIL(A,D);
#define TRAIL_LOCAL(A,D) if ((A) > (CELL *)B) DO_TRAIL(A,D);
#define TRAIL_GLOBAL(A, D) \
if ((A) < HBREG) \
DO_TRAIL(A, D);
#define TRAIL_LOCAL(A, D) \
if ((A) > (CELL *)B) \
DO_TRAIL(A, D);
#elif defined(__alpha) && !defined(TERM_EXTENSIONS)
/* alpha machines have a move conditional instruction, which avoids a
branch when jumping */
#define TRAIL(A,D) TrailTerm(TR) = (CELL)(A); \
if (OUTSIDE(HBREG,A,B)) \
TR++
#define TRAIL(A, D) \
TrailTerm(TR) = (CELL)(A); \
if (OUTSIDE(HBREG, A, B)) \
TR++
#define TRAIL(A,D) TrailTerm(TR) = (CELL)(A); \
if (!OUTSIDE(HBREG,A,B)) \
GONext();
#define TRAIL(A, D) \
TrailTerm(TR) = (CELL)(A); \
if (!OUTSIDE(HBREG, A, B)) \
GONext();
#define TRAIL_GLOBAL(A,D) TR[0] = (CELL)(A); if ((A) < HBREG) TR++
#define TRAIL_GLOBAL(A, D) \
TR[0] = (CELL)(A); \
if ((A) < HBREG) \
TR++
#define TRAIL_LOCAL(A,D) TR[0] = (CELL)(A); if ((A) > ((CELL *)(B))) TR++
#define TRAIL_LOCAL(A, D) \
TR[0] = (CELL)(A); \
if ((A) > ((CELL *)(B))) \
TR++
#elif !defined(TERM_EXTENSIONS)
#define DO_TRAIL(A,D) TrailTerm(TR++) = (CELL)(A)
#define DO_TRAIL(A, D) TrailTerm(TR++) = (CELL)(A)
#define TRAIL(A,D) if (OUTSIDE(HBREG,A,B)) \
DO_TRAIL(A,D)
#define TRAIL(A, D) \
if (OUTSIDE(HBREG, A, B)) \
DO_TRAIL(A, D)
#define TRAIL_AND_JUMP(A,D) if (IN_BETWEEN(HBREG,A,B)) GONext(); \
DO_TRAIL(A,D)
#define TRAIL_AND_JUMP(A, D) \
if (IN_BETWEEN(HBREG, A, B)) \
GONext(); \
DO_TRAIL(A, D)
#define TRAIL_GLOBAL(A,D) if ((A) < HBREG) DO_TRAIL(A,D)
#define TRAIL_GLOBAL(A, D) \
if ((A) < HBREG) \
DO_TRAIL(A, D)
#define TRAIL_LOCAL(A,D) if ((A) > ((CELL *)B)) DO_TRAIL(A,D)
#define TRAIL_LOCAL(A, D) \
if ((A) > ((CELL *)B)) \
DO_TRAIL(A, D)
#else
#define DO_TRAIL(A,D) TrailTerm(TR++) = (CELL)(A)
#define DO_TRAIL(A, D) TrailTerm(TR++) = (CELL)(A)
#define TRAIL(A,D) if (OUTSIDE(HBREG,A,B)) \
DO_TRAIL(A,D)
#define TRAIL(A, D) \
if (OUTSIDE(HBREG, A, B)) \
DO_TRAIL(A, D)
#define TrailAndJump(A,D) if (IN_BETWEEN(HBREG,A,B)) \
#define TrailAndJump(A, D) \
if (IN_BETWEEN(HBREG, A, B)) \
GONext();
#define TRAIL_GLOBAL(A,D) if ((A) < HBREG) DO_TRAIL(A,D)
#define TRAIL_GLOBAL(A, D) \
if ((A) < HBREG) \
DO_TRAIL(A, D)
#define TRAIL_LOCAL(A,D) if ((A) > ((CELL *)B)) DO_TRAIL(A,D)
#define TRAIL_LOCAL(A, D) \
if ((A) > ((CELL *)B)) \
DO_TRAIL(A, D)
#endif
@ -260,43 +335,85 @@ Binding Macros for Multiple Assignment Variables.
************************************************************/
#define DO_MATRAIL(VP, OLDV, D) \
{ TrailTerm(TR+1) = OLDV; \
TrailTerm(TR) = TrailTerm(TR+2) = AbsAppl(VP); \
TR += 3; \
}
#define DO_MATRAIL(VP, OLDV, D) \
{ \
TrailTerm(TR + 1) = OLDV; \
TrailTerm(TR) = TrailTerm(TR + 2) = AbsAppl(VP); \
TR += 3; \
}
#define MATRAIL(VP,OLDV,D) if (OUTSIDE(HBREG,VP,B)) \
DO_MATRAIL(VP, OLDV, D)
#define MATRAIL(VP, OLDV, D) \
if (OUTSIDE(HBREG, VP, B)) \
DO_MATRAIL(VP, OLDV, D)
#endif /* TABLING */
#define REF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->Flags)))
#define CLREF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->ClFlags)))
#define REF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->Flags)))
#define CLREF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->ClFlags)))
#if FROZEN_STACKS
#define TRAIL_REF(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = REF_TO_TRENTRY(REF)
#define TRAIL_CLREF(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = CLREF_TO_TRENTRY(REF)
#define TRAIL_LINK(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = AbsPair((CELL *)(REF))
#define TRAIL_REF(REF) \
RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = REF_TO_TRENTRY(REF)
#define TRAIL_CLREF(REF) \
RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = CLREF_TO_TRENTRY(REF)
#define TRAIL_LINK(REF) \
RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = AbsPair((CELL *)(REF))
#else
#define TRAIL_REF(REF) TrailTerm(TR++) = REF_TO_TRENTRY(REF)
#define TRAIL_CLREF(REF) TrailTerm(TR++) = CLREF_TO_TRENTRY(REF)
#define TRAIL_LINK(REF) TrailTerm(TR++) = AbsPair((CELL *)(REF))
#define TRAIL_REF(REF) TrailTerm(TR++) = REF_TO_TRENTRY(REF)
#define TRAIL_CLREF(REF) TrailTerm(TR++) = CLREF_TO_TRENTRY(REF)
#define TRAIL_LINK(REF) TrailTerm(TR++) = AbsPair((CELL *)(REF))
#endif
#define TRAIL_FRAME(FR) DO_TRAIL(AbsPair((CELL *)(LOCAL_TrailBase)), FR)
#define TRAIL_FRAME(FR) DO_TRAIL(AbsPair((CELL *)(LOCAL_TrailBase)), FR)
extern void Yap_WakeUp(CELL *v);
extern void Yap_WakeUp(CELL *v);
#define Bind_Local(A,D) { TRAIL_LOCAL(A,D); *(A) = (D); }
#define Bind_Global(A,D) { *(A) = (D); if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); }
#define YapBind(A,D) { *(A) = (D); if (A < HR) { if (__builtin_expect(GlobalIsAttVar(A),0)) Yap_WakeUp(A); else TRAIL_GLOBAL(A,D); } else { TRAIL_LOCAL(A,D); } }
#define Bind_NonAtt(A,D) { *(A) = (D); TRAIL(A,D); }
#define Bind_Global_NonAtt(A,D) { *(A) = (D); TRAIL_GLOBAL(A,D); }
#define Bind_and_Trail(A,D) { *(A) = (D); DO_TRAIL(A, D); }
#define Bind_Local(A, D) \
{ \
TRAIL_LOCAL(A, D); \
*(A) = (D); \
}
#define Bind_Global(A, D) \
{ \
*(A) = (D); \
if (__builtin_expect(GlobalIsAttVar(A), 0)) \
Yap_WakeUp(A); \
else \
TRAIL_GLOBAL(A, D); \
}
#define YapBind(A, D) \
{ \
*(A) = (D); \
if (A < HR) { \
if (__builtin_expect(GlobalIsAttVar(A), 0)) \
Yap_WakeUp(A); \
else \
TRAIL_GLOBAL(A, D); \
} else { \
TRAIL_LOCAL(A, D); \
} \
}
#define Bind_NonAtt(A, D) \
{ \
*(A) = (D); \
TRAIL(A, D); \
}
#define Bind_Global_NonAtt(A, D) \
{ \
*(A) = (D); \
TRAIL_GLOBAL(A, D); \
}
#define Bind_and_Trail(A, D) \
{ \
*(A) = (D); \
DO_TRAIL(A, D); \
}
// #define Bind(A,D) YapBind(A,D) conflicts with Windows headers
#define MaBind(VP,D) { MATRAIL((VP),*(VP),(D)); *(VP) = (D); }
#define MaBind(VP, D) \
{ \
MATRAIL((VP), *(VP), (D)); \
*(VP) = (D); \
}
/************************************************************
@ -306,10 +423,9 @@ Unification Routines
INLINE_ONLY inline EXTERN void reset_trail(tr_fr_ptr TR0);
INLINE_ONLY inline EXTERN void
reset_trail(tr_fr_ptr TR0) {
INLINE_ONLY inline EXTERN void reset_trail(tr_fr_ptr TR0) {
CACHE_REGS
while(TR != TR0) {
while (TR != TR0) {
CELL d1;
--TR;
d1 = TrailTerm(TR);
@ -321,14 +437,14 @@ reset_trail(tr_fr_ptr TR0) {
#ifdef MULTI_ASSIGNMENT_VARIABLES
} else {
CELL *pt = RepAppl(d1);
/* AbsAppl means */
/* multi-assignment variable */
/* so the next cell is the old value */
/* AbsAppl means */
/* multi-assignment variable */
/* so the next cell is the old value */
#ifdef FROZEN_STACKS
pt[0] = TrailVal(TR-1);
pt[0] = TrailVal(TR - 1);
TR -= 1;
#else
pt[0] = TrailTerm(TR-1);
pt[0] = TrailTerm(TR - 1);
TR -= 2;
#endif /* FROZEN_STACKS */
}
@ -338,34 +454,34 @@ reset_trail(tr_fr_ptr TR0) {
INLINE_ONLY inline EXTERN void reset_attvars(CELL *dvarsmin, CELL *dvarsmax);
INLINE_ONLY inline EXTERN void
reset_attvars(CELL *dvarsmin, CELL *dvarsmax) {
INLINE_ONLY inline EXTERN void reset_attvars(CELL *dvarsmin, CELL *dvarsmax) {
if (dvarsmin) {
dvarsmin += 1;
do {
CELL *newv;
newv = CellPtr(*dvarsmin);
RESET_VARIABLE(dvarsmin+1);
RESET_VARIABLE(dvarsmin + 1);
if (IsUnboundVar(dvarsmin))
break;
break;
RESET_VARIABLE(dvarsmin);
dvarsmin = newv;
} while (TRUE);
}
}
INLINE_ONLY inline EXTERN void close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax);
INLINE_ONLY inline EXTERN void close_attvar_chain(CELL *dvarsmin,
CELL *dvarsmax);
INLINE_ONLY inline EXTERN void
close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
INLINE_ONLY inline EXTERN void close_attvar_chain(CELL *dvarsmin,
CELL *dvarsmax) {
CACHE_REGS
if (dvarsmin) {
dvarsmin += 1;
do {
CELL *newv;
YapBind(dvarsmin+1, dvarsmin[1]);
YapBind(dvarsmin + 1, dvarsmin[1]);
if (IsUnboundVar(dvarsmin))
break;
break;
newv = CellPtr(*dvarsmin);
RESET_VARIABLE(dvarsmin);
dvarsmin = newv;
@ -373,16 +489,13 @@ close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
}
}
INLINE_ONLY EXTERN inline
bool Yap_unify(Term t0, Term t1);
INLINE_ONLY EXTERN inline bool Yap_unify(Term t0, Term t1);
INLINE_ONLY EXTERN inline
bool Yap_unify(Term t0, Term t1)
{
INLINE_ONLY EXTERN inline bool Yap_unify(Term t0, Term t1) {
CACHE_REGS
tr_fr_ptr TR0 = TR;
if (Yap_IUnify(t0,t1)) {
if (Yap_IUnify(t0, t1)) {
return true;
} else {
reset_trail(TR0);
@ -390,64 +503,58 @@ bool Yap_unify(Term t0, Term t1)
}
}
INLINE_ONLY EXTERN inline Int Yap_unify_constant(Term a, Term cons);
INLINE_ONLY EXTERN inline Int Yap_unify_constant(Term a, Term cons);
INLINE_ONLY EXTERN inline Int
Yap_unify_constant(Term a, Term cons)
{
INLINE_ONLY EXTERN inline Int Yap_unify_constant(Term a, Term cons) {
CACHE_REGS
CELL *pt;
deref_head(a,unify_cons_unk);
unify_cons_nonvar:
{
if (a == cons) return(TRUE);
else if (IsApplTerm(a)) {
Functor f;
if (!IsApplTerm(cons))
return(FALSE);
f = FunctorOfTerm(a);
if (f != FunctorOfTerm(cons))
return(FALSE);
if (IsExtensionFunctor(f)) {
switch((CELL)f) {
case db_ref_e:
return(a == cons);
case long_int_e:
{
CELL d0 = RepAppl(a)[1];
CELL d1 = RepAppl(cons)[1];
return d0 == d1;
}
case double_e:
{
Float d0 = FloatOfTerm(a);
Float d1 = FloatOfTerm(cons);
return d0 == d1;
}
case big_int_e:
#ifdef USE_GMP
return (Yap_gmp_tcmp_big_big(a, cons) == 0);
#endif /* USE_GMP */
default:
return FALSE;
}
deref_head(a, unify_cons_unk);
unify_cons_nonvar : {
if (a == cons)
return (TRUE);
else if (IsApplTerm(a)) {
Functor f;
if (!IsApplTerm(cons))
return (FALSE);
f = FunctorOfTerm(a);
if (f != FunctorOfTerm(cons))
return (FALSE);
if (IsExtensionFunctor(f)) {
switch ((CELL)f) {
case db_ref_e:
return (a == cons);
case long_int_e: {
CELL d0 = RepAppl(a)[1];
CELL d1 = RepAppl(cons)[1];
return d0 == d1;
}
} else
return FALSE;
}
deref_body(a,pt,unify_cons_unk,unify_cons_nonvar);
YapBind(pt,cons);
return(TRUE);
case double_e: {
Float d0 = FloatOfTerm(a);
Float d1 = FloatOfTerm(cons);
return d0 == d1;
}
case big_int_e:
#ifdef USE_GMP
return (Yap_gmp_tcmp_big_big(a, cons) == 0);
#endif /* USE_GMP */
default:
return FALSE;
}
}
} else
return FALSE;
}
deref_body(a, pt, unify_cons_unk, unify_cons_nonvar);
YapBind(pt, cons);
return (TRUE);
}
#define EQ_OK_IN_CMP 1
#define LT_OK_IN_CMP 2
#define GT_OK_IN_CMP 4
static inline int
do_cut(int i) {
static inline int do_cut(int i) {
CACHE_REGS
if (POP_CHOICE_POINT(B->cp_b)) {
cut_c_pop();
@ -460,4 +567,3 @@ do_cut(int i) {
#define cut_succeed() return do_cut(TRUE)
#define cut_fail() return do_cut(FALSE)

View File

@ -1,478 +0,0 @@
/* This file, dlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update H/LOCALS instead */
#define LOCAL_c_input_stream LOCAL->c_input_stream_
#define REMOTE_c_input_stream(wid) REMOTE(wid)->c_input_stream_
#define LOCAL_c_output_stream LOCAL->c_output_stream_
#define REMOTE_c_output_stream(wid) REMOTE(wid)->c_output_stream_
#define LOCAL_c_error_stream LOCAL->c_error_stream_
#define REMOTE_c_error_stream(wid) REMOTE(wid)->c_error_stream_
#define LOCAL_sockets_io LOCAL->sockets_io_
#define REMOTE_sockets_io(wid) REMOTE(wid)->sockets_io_
#define LOCAL_within_print_message LOCAL->within_print_message_
#define REMOTE_within_print_message(wid) REMOTE(wid)->within_print_message_
#define LOCAL_newline LOCAL->newline_
#define REMOTE_newline(wid) REMOTE(wid)->newline_
#define LOCAL_AtPrompt LOCAL->AtPrompt_
#define REMOTE_AtPrompt(wid) REMOTE(wid)->AtPrompt_
#define LOCAL_Prompt LOCAL->Prompt_
#define REMOTE_Prompt(wid) REMOTE(wid)->Prompt_
#define LOCAL_encoding LOCAL->encoding_
#define REMOTE_encoding(wid) REMOTE(wid)->encoding_
#define LOCAL_quasi_quotations LOCAL->quasi_quotations_
#define REMOTE_quasi_quotations(wid) REMOTE(wid)->quasi_quotations_
#define LOCAL_default_priority LOCAL->default_priority_
#define REMOTE_default_priority(wid) REMOTE(wid)->default_priority_
#define LOCAL_eot_before_eof LOCAL->eot_before_eof_
#define REMOTE_eot_before_eof(wid) REMOTE(wid)->eot_before_eof_
#define LOCAL_max_depth LOCAL->max_depth_
#define REMOTE_max_depth(wid) REMOTE(wid)->max_depth_
#define LOCAL_max_list LOCAL->max_list_
#define REMOTE_max_list(wid) REMOTE(wid)->max_list_
#define LOCAL_max_write_args LOCAL->max_write_args_
#define REMOTE_max_write_args(wid) REMOTE(wid)->max_write_args_
#define LOCAL_OldASP LOCAL->OldASP_
#define REMOTE_OldASP(wid) REMOTE(wid)->OldASP_
#define LOCAL_OldLCL0 LOCAL->OldLCL0_
#define REMOTE_OldLCL0(wid) REMOTE(wid)->OldLCL0_
#define LOCAL_OldTR LOCAL->OldTR_
#define REMOTE_OldTR(wid) REMOTE(wid)->OldTR_
#define LOCAL_OldGlobalBase LOCAL->OldGlobalBase_
#define REMOTE_OldGlobalBase(wid) REMOTE(wid)->OldGlobalBase_
#define LOCAL_OldH LOCAL->OldH_
#define REMOTE_OldH(wid) REMOTE(wid)->OldH_
#define LOCAL_OldH0 LOCAL->OldH0_
#define REMOTE_OldH0(wid) REMOTE(wid)->OldH0_
#define LOCAL_OldTrailBase LOCAL->OldTrailBase_
#define REMOTE_OldTrailBase(wid) REMOTE(wid)->OldTrailBase_
#define LOCAL_OldTrailTop LOCAL->OldTrailTop_
#define REMOTE_OldTrailTop(wid) REMOTE(wid)->OldTrailTop_
#define LOCAL_OldHeapBase LOCAL->OldHeapBase_
#define REMOTE_OldHeapBase(wid) REMOTE(wid)->OldHeapBase_
#define LOCAL_OldHeapTop LOCAL->OldHeapTop_
#define REMOTE_OldHeapTop(wid) REMOTE(wid)->OldHeapTop_
#define LOCAL_ClDiff LOCAL->ClDiff_
#define REMOTE_ClDiff(wid) REMOTE(wid)->ClDiff_
#define LOCAL_GDiff LOCAL->GDiff_
#define REMOTE_GDiff(wid) REMOTE(wid)->GDiff_
#define LOCAL_HDiff LOCAL->HDiff_
#define REMOTE_HDiff(wid) REMOTE(wid)->HDiff_
#define LOCAL_GDiff0 LOCAL->GDiff0_
#define REMOTE_GDiff0(wid) REMOTE(wid)->GDiff0_
#define LOCAL_GSplit LOCAL->GSplit_
#define REMOTE_GSplit(wid) REMOTE(wid)->GSplit_
#define LOCAL_LDiff LOCAL->LDiff_
#define REMOTE_LDiff(wid) REMOTE(wid)->LDiff_
#define LOCAL_TrDiff LOCAL->TrDiff_
#define REMOTE_TrDiff(wid) REMOTE(wid)->TrDiff_
#define LOCAL_XDiff LOCAL->XDiff_
#define REMOTE_XDiff(wid) REMOTE(wid)->XDiff_
#define LOCAL_DelayDiff LOCAL->DelayDiff_
#define REMOTE_DelayDiff(wid) REMOTE(wid)->DelayDiff_
#define LOCAL_BaseDiff LOCAL->BaseDiff_
#define REMOTE_BaseDiff(wid) REMOTE(wid)->BaseDiff_
#define LOCAL_ReductionsCounter LOCAL->ReductionsCounter_
#define REMOTE_ReductionsCounter(wid) REMOTE(wid)->ReductionsCounter_
#define LOCAL_PredEntriesCounter LOCAL->PredEntriesCounter_
#define REMOTE_PredEntriesCounter(wid) REMOTE(wid)->PredEntriesCounter_
#define LOCAL_RetriesCounter LOCAL->RetriesCounter_
#define REMOTE_RetriesCounter(wid) REMOTE(wid)->RetriesCounter_
#define LOCAL_ReductionsCounterOn LOCAL->ReductionsCounterOn_
#define REMOTE_ReductionsCounterOn(wid) REMOTE(wid)->ReductionsCounterOn_
#define LOCAL_PredEntriesCounterOn LOCAL->PredEntriesCounterOn_
#define REMOTE_PredEntriesCounterOn(wid) REMOTE(wid)->PredEntriesCounterOn_
#define LOCAL_RetriesCounterOn LOCAL->RetriesCounterOn_
#define REMOTE_RetriesCounterOn(wid) REMOTE(wid)->RetriesCounterOn_
#define LOCAL_ConsultSp LOCAL->ConsultSp_
#define REMOTE_ConsultSp(wid) REMOTE(wid)->ConsultSp_
#define LOCAL_ConsultCapacity LOCAL->ConsultCapacity_
#define REMOTE_ConsultCapacity(wid) REMOTE(wid)->ConsultCapacity_
#define LOCAL_ConsultBase LOCAL->ConsultBase_
#define REMOTE_ConsultBase(wid) REMOTE(wid)->ConsultBase_
#define LOCAL_ConsultLow LOCAL->ConsultLow_
#define REMOTE_ConsultLow(wid) REMOTE(wid)->ConsultLow_
#define LOCAL_VarNames LOCAL->VarNames_
#define REMOTE_VarNames(wid) REMOTE(wid)->VarNames_
#define LOCAL_SourceFileName LOCAL->SourceFileName_
#define REMOTE_SourceFileName(wid) REMOTE(wid)->SourceFileName_
#define LOCAL_SourceFileLineno LOCAL->SourceFileLineno_
#define REMOTE_SourceFileLineno(wid) REMOTE(wid)->SourceFileLineno_
#define LOCAL_GlobalArena LOCAL->GlobalArena_
#define REMOTE_GlobalArena(wid) REMOTE(wid)->GlobalArena_
#define LOCAL_GlobalArenaOverflows LOCAL->GlobalArenaOverflows_
#define REMOTE_GlobalArenaOverflows(wid) REMOTE(wid)->GlobalArenaOverflows_
#define LOCAL_ArenaOverflows LOCAL->ArenaOverflows_
#define REMOTE_ArenaOverflows(wid) REMOTE(wid)->ArenaOverflows_
#define LOCAL_DepthArenas LOCAL->DepthArenas_
#define REMOTE_DepthArenas(wid) REMOTE(wid)->DepthArenas_
#define LOCAL_LastAssertedPred LOCAL->LastAssertedPred_
#define REMOTE_LastAssertedPred(wid) REMOTE(wid)->LastAssertedPred_
#define LOCAL_TmpPred LOCAL->TmpPred_
#define REMOTE_TmpPred(wid) REMOTE(wid)->TmpPred_
#define LOCAL_ScannerStack LOCAL->ScannerStack_
#define REMOTE_ScannerStack(wid) REMOTE(wid)->ScannerStack_
#define LOCAL_ScannerExtraBlocks LOCAL->ScannerExtraBlocks_
#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_
#define LOCAL_CBorder LOCAL->CBorder_
#define REMOTE_CBorder(wid) REMOTE(wid)->CBorder_
#define LOCAL_MaxActiveSignals LOCAL->MaxActiveSignals_
#define REMOTE_MaxActiveSignals(wid) REMOTE(wid)->MaxActiveSignals_
#define LOCAL_Signals LOCAL->Signals_
#define REMOTE_Signals(wid) REMOTE(wid)->Signals_
#define LOCAL_IPredArity LOCAL->IPredArity_
#define REMOTE_IPredArity(wid) REMOTE(wid)->IPredArity_
#define LOCAL_ProfEnd LOCAL->ProfEnd_
#define REMOTE_ProfEnd(wid) REMOTE(wid)->ProfEnd_
#define LOCAL_DoingUndefp LOCAL->DoingUndefp_
#define REMOTE_DoingUndefp(wid) REMOTE(wid)->DoingUndefp_
#define LOCAL_StartCharCount LOCAL->StartCharCount_
#define REMOTE_StartCharCount(wid) REMOTE(wid)->StartCharCount_
#define LOCAL_StartLineCount LOCAL->StartLineCount_
#define REMOTE_StartLineCount(wid) REMOTE(wid)->StartLineCount_
#define LOCAL_StartLinePos LOCAL->StartLinePos_
#define REMOTE_StartLinePos(wid) REMOTE(wid)->StartLinePos_
#define LOCAL_ScratchPad LOCAL->ScratchPad_
#define REMOTE_ScratchPad(wid) REMOTE(wid)->ScratchPad_
#ifdef COROUTINING
#define LOCAL_WokenGoals LOCAL->WokenGoals_
#define REMOTE_WokenGoals(wid) REMOTE(wid)->WokenGoals_
#define LOCAL_AttsMutableList LOCAL->AttsMutableList_
#define REMOTE_AttsMutableList(wid) REMOTE(wid)->AttsMutableList_
#endif
#define LOCAL_GcGeneration LOCAL->GcGeneration_
#define REMOTE_GcGeneration(wid) REMOTE(wid)->GcGeneration_
#define LOCAL_GcPhase LOCAL->GcPhase_
#define REMOTE_GcPhase(wid) REMOTE(wid)->GcPhase_
#define LOCAL_GcCurrentPhase LOCAL->GcCurrentPhase_
#define REMOTE_GcCurrentPhase(wid) REMOTE(wid)->GcCurrentPhase_
#define LOCAL_GcCalls LOCAL->GcCalls_
#define REMOTE_GcCalls(wid) REMOTE(wid)->GcCalls_
#define LOCAL_TotGcTime LOCAL->TotGcTime_
#define REMOTE_TotGcTime(wid) REMOTE(wid)->TotGcTime_
#define LOCAL_TotGcRecovered LOCAL->TotGcRecovered_
#define REMOTE_TotGcRecovered(wid) REMOTE(wid)->TotGcRecovered_
#define LOCAL_LastGcTime LOCAL->LastGcTime_
#define REMOTE_LastGcTime(wid) REMOTE(wid)->LastGcTime_
#define LOCAL_LastSSTime LOCAL->LastSSTime_
#define REMOTE_LastSSTime(wid) REMOTE(wid)->LastSSTime_
#define LOCAL_OpenArray LOCAL->OpenArray_
#define REMOTE_OpenArray(wid) REMOTE(wid)->OpenArray_
#define LOCAL_total_marked LOCAL->total_marked_
#define REMOTE_total_marked(wid) REMOTE(wid)->total_marked_
#define LOCAL_total_oldies LOCAL->total_oldies_
#define REMOTE_total_oldies(wid) REMOTE(wid)->total_oldies_
#define LOCAL_current_B LOCAL->current_B_
#define REMOTE_current_B(wid) REMOTE(wid)->current_B_
#define LOCAL_prev_HB LOCAL->prev_HB_
#define REMOTE_prev_HB(wid) REMOTE(wid)->prev_HB_
#define LOCAL_HGEN LOCAL->HGEN_
#define REMOTE_HGEN(wid) REMOTE(wid)->HGEN_
#define LOCAL_iptop LOCAL->iptop_
#define REMOTE_iptop(wid) REMOTE(wid)->iptop_
#if defined(GC_NO_TAGS)
#define LOCAL_bp LOCAL->bp_
#define REMOTE_bp(wid) REMOTE(wid)->bp_
#endif
#define LOCAL_sTR LOCAL->sTR_
#define REMOTE_sTR(wid) REMOTE(wid)->sTR_
#define LOCAL_sTR0 LOCAL->sTR0_
#define REMOTE_sTR0(wid) REMOTE(wid)->sTR0_
#define LOCAL_new_TR LOCAL->new_TR_
#define REMOTE_new_TR(wid) REMOTE(wid)->new_TR_
#define LOCAL_cont_top0 LOCAL->cont_top0_
#define REMOTE_cont_top0(wid) REMOTE(wid)->cont_top0_
#define LOCAL_cont_top LOCAL->cont_top_
#define REMOTE_cont_top(wid) REMOTE(wid)->cont_top_
#define LOCAL_discard_trail_entries LOCAL->discard_trail_entries_
#define REMOTE_discard_trail_entries(wid) REMOTE(wid)->discard_trail_entries_
#define LOCAL_gc_ma_hash_table LOCAL->gc_ma_hash_table_
#define REMOTE_gc_ma_hash_table(wid) REMOTE(wid)->gc_ma_hash_table_
#define LOCAL_gc_ma_h_top LOCAL->gc_ma_h_top_
#define REMOTE_gc_ma_h_top(wid) REMOTE(wid)->gc_ma_h_top_
#define LOCAL_gc_ma_h_list LOCAL->gc_ma_h_list_
#define REMOTE_gc_ma_h_list(wid) REMOTE(wid)->gc_ma_h_list_
#define LOCAL_gc_timestamp LOCAL->gc_timestamp_
#define REMOTE_gc_timestamp(wid) REMOTE(wid)->gc_timestamp_
#define LOCAL_db_vec LOCAL->db_vec_
#define REMOTE_db_vec(wid) REMOTE(wid)->db_vec_
#define LOCAL_db_vec0 LOCAL->db_vec0_
#define REMOTE_db_vec0(wid) REMOTE(wid)->db_vec0_
#define LOCAL_db_root LOCAL->db_root_
#define REMOTE_db_root(wid) REMOTE(wid)->db_root_
#define LOCAL_db_nil LOCAL->db_nil_
#define REMOTE_db_nil(wid) REMOTE(wid)->db_nil_
#define LOCAL_gc_restore LOCAL->gc_restore_
#define REMOTE_gc_restore(wid) REMOTE(wid)->gc_restore_
#define LOCAL_extra_gc_cells LOCAL->extra_gc_cells_
#define REMOTE_extra_gc_cells(wid) REMOTE(wid)->extra_gc_cells_
#define LOCAL_extra_gc_cells_base LOCAL->extra_gc_cells_base_
#define REMOTE_extra_gc_cells_base(wid) REMOTE(wid)->extra_gc_cells_base_
#define LOCAL_extra_gc_cells_top LOCAL->extra_gc_cells_top_
#define REMOTE_extra_gc_cells_top(wid) REMOTE(wid)->extra_gc_cells_top_
#define LOCAL_extra_gc_cells_size LOCAL->extra_gc_cells_size_
#define REMOTE_extra_gc_cells_size(wid) REMOTE(wid)->extra_gc_cells_size_
#define LOCAL_DynamicArrays LOCAL->DynamicArrays_
#define REMOTE_DynamicArrays(wid) REMOTE(wid)->DynamicArrays_
#define LOCAL_StaticArrays LOCAL->StaticArrays_
#define REMOTE_StaticArrays(wid) REMOTE(wid)->StaticArrays_
#define LOCAL_GlobalVariables LOCAL->GlobalVariables_
#define REMOTE_GlobalVariables(wid) REMOTE(wid)->GlobalVariables_
#define LOCAL_AllowRestart LOCAL->AllowRestart_
#define REMOTE_AllowRestart(wid) REMOTE(wid)->AllowRestart_
#define LOCAL_CMemFirstBlock LOCAL->CMemFirstBlock_
#define REMOTE_CMemFirstBlock(wid) REMOTE(wid)->CMemFirstBlock_
#define LOCAL_CMemFirstBlockSz LOCAL->CMemFirstBlockSz_
#define REMOTE_CMemFirstBlockSz(wid) REMOTE(wid)->CMemFirstBlockSz_
#define LOCAL_nperm LOCAL->nperm_
#define REMOTE_nperm(wid) REMOTE(wid)->nperm_
#define LOCAL_jMP LOCAL->jMP_
#define REMOTE_jMP(wid) REMOTE(wid)->jMP_
#define LOCAL_LabelFirstArray LOCAL->LabelFirstArray_
#define REMOTE_LabelFirstArray(wid) REMOTE(wid)->LabelFirstArray_
#define LOCAL_LabelFirstArraySz LOCAL->LabelFirstArraySz_
#define REMOTE_LabelFirstArraySz(wid) REMOTE(wid)->LabelFirstArraySz_
#ifdef THREADS
#define LOCAL_ThreadHandle LOCAL->ThreadHandle_
#define REMOTE_ThreadHandle(wid) REMOTE(wid)->ThreadHandle_
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
#define LOCAL_optyap_data LOCAL->optyap_data_
#define REMOTE_optyap_data(wid) REMOTE(wid)->optyap_data_
#define LOCAL_TabMode LOCAL->TabMode_
#define REMOTE_TabMode(wid) REMOTE(wid)->TabMode_
#endif /* YAPOR || TABLING */
#define LOCAL_InterruptsDisabled LOCAL->InterruptsDisabled_
#define REMOTE_InterruptsDisabled(wid) REMOTE(wid)->InterruptsDisabled_
#define LOCAL_execution LOCAL->execution_
#define REMOTE_execution(wid) REMOTE(wid)->execution_
#if LOW_LEVEL_TRACER
#define LOCAL_total_choicepoints LOCAL->total_choicepoints_
#define REMOTE_total_choicepoints(wid) REMOTE(wid)->total_choicepoints_
#endif
#define LOCAL_consult_level LOCAL->consult_level_
#define REMOTE_consult_level(wid) REMOTE(wid)->consult_level_
#define LOCAL_LocalBase LOCAL->LocalBase_
#define REMOTE_LocalBase(wid) REMOTE(wid)->LocalBase_
#define LOCAL_GlobalBase LOCAL->GlobalBase_
#define REMOTE_GlobalBase(wid) REMOTE(wid)->GlobalBase_
#define LOCAL_TrailBase LOCAL->TrailBase_
#define REMOTE_TrailBase(wid) REMOTE(wid)->TrailBase_
#define LOCAL_TrailTop LOCAL->TrailTop_
#define REMOTE_TrailTop(wid) REMOTE(wid)->TrailTop_
#define LOCAL_ActiveError LOCAL->ActiveError_
#define REMOTE_ActiveError(wid) REMOTE(wid)->ActiveError_
#define LOCAL_IOBotch LOCAL->IOBotch_
#define REMOTE_IOBotch(wid) REMOTE(wid)->IOBotch_
#define LOCAL_tokptr LOCAL->tokptr_
#define REMOTE_tokptr(wid) REMOTE(wid)->tokptr_
#define LOCAL_toktide LOCAL->toktide_
#define REMOTE_toktide(wid) REMOTE(wid)->toktide_
#define LOCAL_VarTable LOCAL->VarTable_
#define REMOTE_VarTable(wid) REMOTE(wid)->VarTable_
#define LOCAL_AnonVarTable LOCAL->AnonVarTable_
#define REMOTE_AnonVarTable(wid) REMOTE(wid)->AnonVarTable_
#define LOCAL_Comments LOCAL->Comments_
#define REMOTE_Comments(wid) REMOTE(wid)->Comments_
#define LOCAL_CommentsTail LOCAL->CommentsTail_
#define REMOTE_CommentsTail(wid) REMOTE(wid)->CommentsTail_
#define LOCAL_CommentsNextChar LOCAL->CommentsNextChar_
#define REMOTE_CommentsNextChar(wid) REMOTE(wid)->CommentsNextChar_
#define LOCAL_CommentsBuff LOCAL->CommentsBuff_
#define REMOTE_CommentsBuff(wid) REMOTE(wid)->CommentsBuff_
#define LOCAL_CommentsBuffPos LOCAL->CommentsBuffPos_
#define REMOTE_CommentsBuffPos(wid) REMOTE(wid)->CommentsBuffPos_
#define LOCAL_CommentsBuffLim LOCAL->CommentsBuffLim_
#define REMOTE_CommentsBuffLim(wid) REMOTE(wid)->CommentsBuffLim_
#define LOCAL_RestartEnv LOCAL->RestartEnv_
#define REMOTE_RestartEnv(wid) REMOTE(wid)->RestartEnv_
#define LOCAL_FileNameBuf LOCAL->FileNameBuf_
#define REMOTE_FileNameBuf(wid) REMOTE(wid)->FileNameBuf_
#define LOCAL_FileNameBuf2 LOCAL->FileNameBuf2_
#define REMOTE_FileNameBuf2(wid) REMOTE(wid)->FileNameBuf2_
#define LOCAL_TextBuffer LOCAL->TextBuffer_
#define REMOTE_TextBuffer(wid) REMOTE(wid)->TextBuffer_
#define LOCAL_BreakLevel LOCAL->BreakLevel_
#define REMOTE_BreakLevel(wid) REMOTE(wid)->BreakLevel_
#define LOCAL_PrologMode LOCAL->PrologMode_
#define REMOTE_PrologMode(wid) REMOTE(wid)->PrologMode_
#define LOCAL_CritLocks LOCAL->CritLocks_
#define REMOTE_CritLocks(wid) REMOTE(wid)->CritLocks_
#define LOCAL_Flags LOCAL->Flags_
#define REMOTE_Flags(wid) REMOTE(wid)->Flags_
#define LOCAL_flagCount LOCAL->flagCount_
#define REMOTE_flagCount(wid) REMOTE(wid)->flagCount_
#ifdef ANALYST
#define LOCAL_opcount LOCAL->opcount_
#define REMOTE_opcount(wid) REMOTE(wid)->opcount_
#define LOCAL_2opcount LOCAL->2opcount_
#define REMOTE_2opcount(wid) REMOTE(wid)->2opcount_
#endif /* ANALYST */
#define LOCAL_s_dbg LOCAL->s_dbg_
#define REMOTE_s_dbg(wid) REMOTE(wid)->s_dbg_
#define LOCAL_mathtt LOCAL->mathtt_
#define REMOTE_mathtt(wid) REMOTE(wid)->mathtt_
#define LOCAL_mathstring LOCAL->mathstring_
#define REMOTE_mathstring(wid) REMOTE(wid)->mathstring_
#define LOCAL_heap_overflows LOCAL->heap_overflows_
#define REMOTE_heap_overflows(wid) REMOTE(wid)->heap_overflows_
#define LOCAL_total_heap_overflow_time LOCAL->total_heap_overflow_time_
#define REMOTE_total_heap_overflow_time(wid) REMOTE(wid)->total_heap_overflow_time_
#define LOCAL_stack_overflows LOCAL->stack_overflows_
#define REMOTE_stack_overflows(wid) REMOTE(wid)->stack_overflows_
#define LOCAL_total_stack_overflow_time LOCAL->total_stack_overflow_time_
#define REMOTE_total_stack_overflow_time(wid) REMOTE(wid)->total_stack_overflow_time_
#define LOCAL_delay_overflows LOCAL->delay_overflows_
#define REMOTE_delay_overflows(wid) REMOTE(wid)->delay_overflows_
#define LOCAL_total_delay_overflow_time LOCAL->total_delay_overflow_time_
#define REMOTE_total_delay_overflow_time(wid) REMOTE(wid)->total_delay_overflow_time_
#define LOCAL_trail_overflows LOCAL->trail_overflows_
#define REMOTE_trail_overflows(wid) REMOTE(wid)->trail_overflows_
#define LOCAL_total_trail_overflow_time LOCAL->total_trail_overflow_time_
#define REMOTE_total_trail_overflow_time(wid) REMOTE(wid)->total_trail_overflow_time_
#define LOCAL_atom_table_overflows LOCAL->atom_table_overflows_
#define REMOTE_atom_table_overflows(wid) REMOTE(wid)->atom_table_overflows_
#define LOCAL_total_atom_table_overflow_time LOCAL->total_atom_table_overflow_time_
#define REMOTE_total_atom_table_overflow_time(wid) REMOTE(wid)->total_atom_table_overflow_time_
#ifdef LOAD_DYLD
#define LOCAL_dl_errno LOCAL->dl_errno_
#define REMOTE_dl_errno(wid) REMOTE(wid)->dl_errno_
#endif
#ifdef LOW_LEVEL_TRACER
#define LOCAL_do_trace_primitives LOCAL->do_trace_primitives_
#define REMOTE_do_trace_primitives(wid) REMOTE(wid)->do_trace_primitives_
#endif
#define LOCAL_ExportAtomHashChain LOCAL->ExportAtomHashChain_
#define REMOTE_ExportAtomHashChain(wid) REMOTE(wid)->ExportAtomHashChain_
#define LOCAL_ExportAtomHashTableSize LOCAL->ExportAtomHashTableSize_
#define REMOTE_ExportAtomHashTableSize(wid) REMOTE(wid)->ExportAtomHashTableSize_
#define LOCAL_ExportAtomHashTableNum LOCAL->ExportAtomHashTableNum_
#define REMOTE_ExportAtomHashTableNum(wid) REMOTE(wid)->ExportAtomHashTableNum_
#define LOCAL_ExportFunctorHashChain LOCAL->ExportFunctorHashChain_
#define REMOTE_ExportFunctorHashChain(wid) REMOTE(wid)->ExportFunctorHashChain_
#define LOCAL_ExportFunctorHashTableSize LOCAL->ExportFunctorHashTableSize_
#define REMOTE_ExportFunctorHashTableSize(wid) REMOTE(wid)->ExportFunctorHashTableSize_
#define LOCAL_ExportFunctorHashTableNum LOCAL->ExportFunctorHashTableNum_
#define REMOTE_ExportFunctorHashTableNum(wid) REMOTE(wid)->ExportFunctorHashTableNum_
#define LOCAL_ExportPredEntryHashChain LOCAL->ExportPredEntryHashChain_
#define REMOTE_ExportPredEntryHashChain(wid) REMOTE(wid)->ExportPredEntryHashChain_
#define LOCAL_ExportPredEntryHashTableSize LOCAL->ExportPredEntryHashTableSize_
#define REMOTE_ExportPredEntryHashTableSize(wid) REMOTE(wid)->ExportPredEntryHashTableSize_
#define LOCAL_ExportPredEntryHashTableNum LOCAL->ExportPredEntryHashTableNum_
#define REMOTE_ExportPredEntryHashTableNum(wid) REMOTE(wid)->ExportPredEntryHashTableNum_
#define LOCAL_ExportDBRefHashChain LOCAL->ExportDBRefHashChain_
#define REMOTE_ExportDBRefHashChain(wid) REMOTE(wid)->ExportDBRefHashChain_
#define LOCAL_ExportDBRefHashTableSize LOCAL->ExportDBRefHashTableSize_
#define REMOTE_ExportDBRefHashTableSize(wid) REMOTE(wid)->ExportDBRefHashTableSize_
#define LOCAL_ExportDBRefHashTableNum LOCAL->ExportDBRefHashTableNum_
#define REMOTE_ExportDBRefHashTableNum(wid) REMOTE(wid)->ExportDBRefHashTableNum_
#define LOCAL_ImportAtomHashChain LOCAL->ImportAtomHashChain_
#define REMOTE_ImportAtomHashChain(wid) REMOTE(wid)->ImportAtomHashChain_
#define LOCAL_ImportAtomHashTableSize LOCAL->ImportAtomHashTableSize_
#define REMOTE_ImportAtomHashTableSize(wid) REMOTE(wid)->ImportAtomHashTableSize_
#define LOCAL_ImportAtomHashTableNum LOCAL->ImportAtomHashTableNum_
#define REMOTE_ImportAtomHashTableNum(wid) REMOTE(wid)->ImportAtomHashTableNum_
#define LOCAL_ImportFunctorHashChain LOCAL->ImportFunctorHashChain_
#define REMOTE_ImportFunctorHashChain(wid) REMOTE(wid)->ImportFunctorHashChain_
#define LOCAL_ImportFunctorHashTableSize LOCAL->ImportFunctorHashTableSize_
#define REMOTE_ImportFunctorHashTableSize(wid) REMOTE(wid)->ImportFunctorHashTableSize_
#define LOCAL_ImportFunctorHashTableNum LOCAL->ImportFunctorHashTableNum_
#define REMOTE_ImportFunctorHashTableNum(wid) REMOTE(wid)->ImportFunctorHashTableNum_
#define LOCAL_ImportOPCODEHashChain LOCAL->ImportOPCODEHashChain_
#define REMOTE_ImportOPCODEHashChain(wid) REMOTE(wid)->ImportOPCODEHashChain_
#define LOCAL_ImportOPCODEHashTableSize LOCAL->ImportOPCODEHashTableSize_
#define REMOTE_ImportOPCODEHashTableSize(wid) REMOTE(wid)->ImportOPCODEHashTableSize_
#define LOCAL_ImportPredEntryHashChain LOCAL->ImportPredEntryHashChain_
#define REMOTE_ImportPredEntryHashChain(wid) REMOTE(wid)->ImportPredEntryHashChain_
#define LOCAL_ImportPredEntryHashTableSize LOCAL->ImportPredEntryHashTableSize_
#define REMOTE_ImportPredEntryHashTableSize(wid) REMOTE(wid)->ImportPredEntryHashTableSize_
#define LOCAL_ImportPredEntryHashTableNum LOCAL->ImportPredEntryHashTableNum_
#define REMOTE_ImportPredEntryHashTableNum(wid) REMOTE(wid)->ImportPredEntryHashTableNum_
#define LOCAL_ImportDBRefHashChain LOCAL->ImportDBRefHashChain_
#define REMOTE_ImportDBRefHashChain(wid) REMOTE(wid)->ImportDBRefHashChain_
#define LOCAL_ImportDBRefHashTableSize LOCAL->ImportDBRefHashTableSize_
#define REMOTE_ImportDBRefHashTableSize(wid) REMOTE(wid)->ImportDBRefHashTableSize_
#define LOCAL_ImportDBRefHashTableNum LOCAL->ImportDBRefHashTableNum_
#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_
#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
#define LOCAL_ibnds LOCAL->ibnds_
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
#define LOCAL_exo_it LOCAL->exo_it_
#define REMOTE_exo_it(wid) REMOTE(wid)->exo_it_
#define LOCAL_exo_base LOCAL->exo_base_
#define REMOTE_exo_base(wid) REMOTE(wid)->exo_base_
#define LOCAL_exo_arity LOCAL->exo_arity_
#define REMOTE_exo_arity(wid) REMOTE(wid)->exo_arity_
#define LOCAL_exo_arg LOCAL->exo_arg_
#define REMOTE_exo_arg(wid) REMOTE(wid)->exo_arg_
#define LOCAL_search_atoms LOCAL->search_atoms_
#define REMOTE_search_atoms(wid) REMOTE(wid)->search_atoms_
#define LOCAL_SearchPreds LOCAL->SearchPreds_
#define REMOTE_SearchPreds(wid) REMOTE(wid)->SearchPreds_
#define LOCAL_CurSlot LOCAL->CurSlot_
#define REMOTE_CurSlot(wid) REMOTE(wid)->CurSlot_
#define LOCAL_FrozenHandles LOCAL->FrozenHandles_
#define REMOTE_FrozenHandles(wid) REMOTE(wid)->FrozenHandles_
#define LOCAL_NSlots LOCAL->NSlots_
#define REMOTE_NSlots(wid) REMOTE(wid)->NSlots_
#define LOCAL_SlotBase LOCAL->SlotBase_
#define REMOTE_SlotBase(wid) REMOTE(wid)->SlotBase_
#define LOCAL_Mutexes LOCAL->Mutexes_
#define REMOTE_Mutexes(wid) REMOTE(wid)->Mutexes_
#define LOCAL_SourceModule LOCAL->SourceModule_
#define REMOTE_SourceModule(wid) REMOTE(wid)->SourceModule_
#define LOCAL_Including LOCAL->Including_
#define REMOTE_Including(wid) REMOTE(wid)->Including_
#define LOCAL_MAX_SIZE LOCAL->MAX_SIZE_
#define REMOTE_MAX_SIZE(wid) REMOTE(wid)->MAX_SIZE_
#define LOCAL_LastWTime LOCAL->LastWTime_
#define REMOTE_LastWTime(wid) REMOTE(wid)->LastWTime_
#define LOCAL_shared LOCAL->shared_
#define REMOTE_shared(wid) REMOTE(wid)->shared_

View File

@ -1,272 +1,24 @@
/* This file, hlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update H/LOCALS instead */
#ifndef DLOCALS_H
#define DLOCALS_H
// Stuff that must be considered local to a thread or worker
typedef struct worker_local {
// Streams
int c_input_stream_;
int c_output_stream_;
int c_error_stream_;
bool sockets_io_;
bool within_print_message_;
//
// Used by the prompts to check if they are after a newline, and then a
// prompt should be output, or if we are in the middle of a line.
//
bool newline_;
Atom AtPrompt_;
char Prompt_[MAX_PROMPT+1];
encoding_t encoding_;
bool quasi_quotations_;
UInt default_priority_;
bool eot_before_eof_;
UInt max_depth_;
UInt max_list_;
UInt max_write_args_;
// Restore info
CELL* OldASP_;
CELL* OldLCL0_;
tr_fr_ptr OldTR_;
CELL* OldGlobalBase_;
CELL* OldH_;
CELL* OldH0_;
ADDR OldTrailBase_;
ADDR OldTrailTop_;
ADDR OldHeapBase_;
ADDR OldHeapTop_;
Int ClDiff_;
Int GDiff_;
Int HDiff_;
Int GDiff0_;
CELL* GSplit_;
Int LDiff_;
Int TrDiff_;
Int XDiff_;
Int DelayDiff_;
Int BaseDiff_;
// Reduction counters
YAP_ULONG_LONG ReductionsCounter_;
YAP_ULONG_LONG PredEntriesCounter_;
YAP_ULONG_LONG RetriesCounter_;
int ReductionsCounterOn_;
int PredEntriesCounterOn_;
int RetriesCounterOn_;
// support for consulting files
/* current consult stack */
union CONSULT_OBJ* ConsultSp_;
/* current maximum number of cells in consult stack */
UInt ConsultCapacity_;
/* top of consult stack */
union CONSULT_OBJ* ConsultBase_;
/* low-water mark for consult */
union CONSULT_OBJ* ConsultLow_;
Term VarNames_;
Atom SourceFileName_;
UInt SourceFileLineno_;
//global variables
Term GlobalArena_;
UInt GlobalArenaOverflows_;
Int ArenaOverflows_;
Int DepthArenas_;
struct pred_entry* LastAssertedPred_;
struct pred_entry* TmpPred_;
char* ScannerStack_;
struct scanner_extra_alloc* ScannerExtraBlocks_;
/// worker control information
/// stack limit after which the stack is managed by C-code.
Int CBorder_;
/// max number of signals (uint64_t)
UInt MaxActiveSignals_;
/// actual life signals
uint64_t Signals_;
/// indexing help data?
UInt IPredArity_;
yamop* ProfEnd_;
int DoingUndefp_;
Int StartCharCount_;
Int StartLineCount_;
Int StartLinePos_;
scratch_block ScratchPad_;
#ifdef COROUTINING
Term WokenGoals_;
Term AttsMutableList_;
#endif
// gc_stuff
Term GcGeneration_;
Term GcPhase_;
UInt GcCurrentPhase_;
UInt GcCalls_;
Int TotGcTime_;
YAP_ULONG_LONG TotGcRecovered_;
Int LastGcTime_;
Int LastSSTime_;
CELL* OpenArray_;
/* in a single gc */
Int total_marked_;
Int total_oldies_;
struct choicept* current_B_;
CELL* prev_HB_;
CELL* HGEN_;
CELL** iptop_;
#if defined(GC_NO_TAGS)
char* bp_;
#endif
tr_fr_ptr sTR_;
tr_fr_ptr sTR0_;
tr_fr_ptr new_TR_;
struct gc_mark_continuation* cont_top0_;
struct gc_mark_continuation* cont_top_;
int discard_trail_entries_;
gc_ma_hash_entry gc_ma_hash_table_[GC_MAVARS_HASH_SIZE];
gc_ma_hash_entry* gc_ma_h_top_;
gc_ma_hash_entry* gc_ma_h_list_;
UInt gc_timestamp_;
ADDR db_vec_;
ADDR db_vec0_;
struct RB_red_blk_node* db_root_;
struct RB_red_blk_node* db_nil_;
sigjmp_buf* gc_restore_;
CELL* extra_gc_cells_;
CELL* extra_gc_cells_base_;
CELL* extra_gc_cells_top_;
UInt extra_gc_cells_size_;
struct array_entry* DynamicArrays_;
struct static_array_entry* StaticArrays_;
struct global_entry* GlobalVariables_;
int AllowRestart_;
// Thread Local Area for Fast Storage of Intermediate Compiled Code
struct mem_blk* CMemFirstBlock_;
UInt CMemFirstBlockSz_;
// Variable used by the compiler to store number of permanent vars in a clause
int nperm_;
int jMP_;
// Thread Local Area for Labels
Int* LabelFirstArray_;
UInt LabelFirstArraySz_;
// Thread Local Area for SWI-Prolog emulation routines.
// struct PL_local_data* PL_local_data_p =Yap_InitThreadIO(wid)
#ifdef THREADS
struct thandle ThreadHandle_;
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
struct local_optyap_data optyap_data_;
UInt TabMode_;
#endif /* YAPOR || TABLING */
int InterruptsDisabled_;
struct open_query_struct* execution_;
#if LOW_LEVEL_TRACER
Int total_choicepoints_;
#endif
int consult_level_;
// Variables related to memory allocation
ADDR LocalBase_;
ADDR GlobalBase_;
ADDR TrailBase_;
ADDR TrailTop_;
/* error handling info, designed to be easy to pass to the foreign world */
yap_error_descriptor_t* ActiveError_;
/// pointer to an exception term, from throw
jmp_buf* IOBotch_;
TokEntry* tokptr_;
TokEntry* toktide_;
VarEntry* VarTable_;
VarEntry* AnonVarTable_;
Term Comments_;
CELL* CommentsTail_;
CELL* CommentsNextChar_;
wchar_t* CommentsBuff_;
size_t CommentsBuffPos_;
size_t CommentsBuffLim_;
sigjmp_buf* RestartEnv_;
char FileNameBuf_[YAP_FILENAME_MAX+1];
char FileNameBuf2_[YAP_FILENAME_MAX+1];
struct TextBuffer_manager* TextBuffer_;
// Prolog State
UInt BreakLevel_;
Int PrologMode_;
int CritLocks_;
// Prolog execution and state flags
union flagTerm* Flags_;
UInt flagCount_;
//analyst.c
/* used to find out how many instructions of each kind are executed */
#ifdef ANALYST
YAP_ULONG_LONG opcount_[_std_top+1];
YAP_ULONG_LONG 2opcount[_std_top+1][_std_top+1]_;
#endif /* ANALYST */
//dbase.c
struct db_globs* s_dbg_;
//eval.c
Term mathtt_;
char* mathstring_;
//grow.c
int heap_overflows_;
Int total_heap_overflow_time_;
int stack_overflows_;
Int total_stack_overflow_time_;
int delay_overflows_;
Int total_delay_overflow_time_;
int trail_overflows_;
Int total_trail_overflow_time_;
int atom_table_overflows_;
Int total_atom_table_overflow_time_;
//load_dyld
#ifdef LOAD_DYLD
int dl_errno_;
#endif
//tracer.c
#ifdef LOW_LEVEL_TRACER
int do_trace_primitives_;
#endif
//quick loader
struct export_atom_hash_entry_struct *ExportAtomHashChain_;
UInt ExportAtomHashTableSize_;
UInt ExportAtomHashTableNum_;
struct export_functor_hash_entry_struct *ExportFunctorHashChain_;
UInt ExportFunctorHashTableSize_;
UInt ExportFunctorHashTableNum_;
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain_;
UInt ExportPredEntryHashTableSize_;
UInt ExportPredEntryHashTableNum_;
struct export_dbref_hash_entry_struct *ExportDBRefHashChain_;
UInt ExportDBRefHashTableSize_;
UInt ExportDBRefHashTableNum_;
struct import_atom_hash_entry_struct **ImportAtomHashChain_;
UInt ImportAtomHashTableSize_;
UInt ImportAtomHashTableNum_;
struct import_functor_hash_entry_struct **ImportFunctorHashChain_;
UInt ImportFunctorHashTableSize_;
UInt ImportFunctorHashTableNum_;
struct import_opcode_hash_entry_struct **ImportOPCODEHashChain_;
UInt ImportOPCODEHashTableSize_;
struct import_pred_entry_hash_entry_struct **ImportPredEntryHashChain_;
UInt ImportPredEntryHashTableSize_;
UInt ImportPredEntryHashTableNum_;
struct import_dbref_hash_entry_struct **ImportDBRefHashChain_;
UInt ImportDBRefHashTableSize_;
UInt ImportDBRefHashTableNum_;
yamop *ImportFAILCODE_;
// exo indexing
UInt ibnds_[256];
struct index_t* exo_it_;
CELL* exo_base_;
UInt exo_arity_;
UInt exo_arg_;
// atom completion
struct scan_atoms* search_atoms_;
struct pred_entry* SearchPreds_;
/// Slots Status
yhandle_t CurSlot_;
yhandle_t FrozenHandles_;
yhandle_t NSlots_;
CELL* SlotBase_;
// Mutexes
struct swi_mutex* Mutexes_;
Term SourceModule_;
Term Including_;
size_t MAX_SIZE_;
/* last call to walltime. */
uint64_t LastWTime_;
void* shared_;
#undef LOCAL
#undef LOCAL_INIT
#undef LOCAL_INITF
#undef LOCAL_INIT_RESTORE
#undef LOCAL_ARRAY
#undef LOCAL_ARRAY_ARRAY
#define LOCAL(TYPE, NAME) TYPE NAME
#define LOCAL_INIT(TYPE, NAME, INIT) TYPE NAME
#define LOCAL_INITF(TYPE, NAME, INIT) TYPE NAME
#define LOCAL_INIT_RESTORE(TYPE, NAME, INIT, RESTORE) TYPE NAME
#define LOCAL_ARRAY(TYPE, NAME, DIM1) TYPE NAME [ DIM1 ]
#define LOCAL_ARRAY_ARRAY(TYPE, NAME, DIM1, DIM2) TYPE NAME [ DIM1 ][ DIM2 ]
// Stuff that must be considered local to a thread or worker
typedef struct worker_local {
#include "locals.h"
} w_local;
#endif

View File

@ -1,272 +1,23 @@
/* This file, ilocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update H/LOCALS instead */
#ifndef ILOCALS_H
#define ILOCALS_H
#undef LOCAL
#undef LOCAL_INIT
#undef LOCAL_INITF
#undef LOCAL_INIT_RESTORE
#undef LOCAL_ARRAY
#undef LOCAL_ARRAY_ARRAY
static void InitWorker(int wid) {
#define LOCAL(TYPE, NAME)
#define LOCAL_INIT(TYPE, NAME, INIT) REMOTE_##NAME(wid) = INIT
#define LOCAL_INITF(TYPE, NAME, INIT) INIT
#define LOCAL_INIT_RESTORE(TYPE, NAME, INIT, RESTORE) REMOTE_##NAME(wid) = INIT
#define LOCAL_ARRAY(TYPE, NAME, INIT)
#define LOCAL_ARRAY_ARRAY(TYPE, NAME, DIM1, DIM2)
REMOTE_c_input_stream(wid) = 0;
REMOTE_c_output_stream(wid) = 1;
REMOTE_c_error_stream(wid) = 2;
REMOTE_sockets_io(wid) = false;
REMOTE_within_print_message(wid) = false;
static void InitWorker(int wid){
#include "locals.h"
} w_local;
REMOTE_newline(wid) = true;
REMOTE_AtPrompt(wid) = AtomNil;
REMOTE_encoding(wid) = Yap_DefaultEncoding();
REMOTE_quasi_quotations(wid) = false;
REMOTE_default_priority(wid) = 1200;
REMOTE_eot_before_eof(wid) = false;
REMOTE_max_depth(wid) = 0;
REMOTE_max_list(wid) = 0;
REMOTE_max_write_args(wid) = 0;
REMOTE_OldASP(wid) = NULL;
REMOTE_OldLCL0(wid) = NULL;
REMOTE_OldTR(wid) = NULL;
REMOTE_OldGlobalBase(wid) = NULL;
REMOTE_OldH(wid) = NULL;
REMOTE_OldH0(wid) = NULL;
REMOTE_OldTrailBase(wid) = NULL;
REMOTE_OldTrailTop(wid) = NULL;
REMOTE_OldHeapBase(wid) = NULL;
REMOTE_OldHeapTop(wid) = NULL;
REMOTE_ClDiff(wid) = 0L;
REMOTE_GDiff(wid) = 0L;
REMOTE_HDiff(wid) = 0L;
REMOTE_GDiff0(wid) = 0L;
REMOTE_GSplit(wid) = NULL;
REMOTE_LDiff(wid) = 0L;
REMOTE_TrDiff(wid) = 0L;
REMOTE_XDiff(wid) = 0L;
REMOTE_DelayDiff(wid) = 0L;
REMOTE_BaseDiff(wid) = 0L;
REMOTE_ReductionsCounter(wid) = 0L;
REMOTE_PredEntriesCounter(wid) = 0L;
REMOTE_RetriesCounter(wid) = 0L;
REMOTE_ReductionsCounterOn(wid) = 0L;
REMOTE_PredEntriesCounterOn(wid) = 0L;
REMOTE_RetriesCounterOn(wid) = 0L;
REMOTE_ConsultSp(wid) = NULL;
REMOTE_ConsultBase(wid) = NULL;
REMOTE_ConsultLow(wid) = NULL;
REMOTE_VarNames(wid) = ((Term)0);
REMOTE_SourceFileName(wid) = NULL;
REMOTE_SourceFileLineno(wid) = 0;
REMOTE_GlobalArena(wid) = 0L;
REMOTE_GlobalArenaOverflows(wid) = 0L;
REMOTE_ArenaOverflows(wid) = 0L;
REMOTE_DepthArenas(wid) = 0;
REMOTE_LastAssertedPred(wid) = NULL;
REMOTE_TmpPred(wid) = NULL;
REMOTE_ScannerStack(wid) = NULL;
REMOTE_ScannerExtraBlocks(wid) = NULL;
REMOTE_CBorder(wid) = 0;
REMOTE_MaxActiveSignals(wid) = 64L;
REMOTE_Signals(wid) = 0L;
REMOTE_IPredArity(wid) = 0L;
REMOTE_ProfEnd(wid) = NULL;
REMOTE_DoingUndefp(wid) = FALSE;
REMOTE_StartCharCount(wid) = 0L;
REMOTE_StartLineCount(wid) = 0L;
REMOTE_StartLinePos(wid) = 0L;
InitScratchPad(wid);
#ifdef COROUTINING
REMOTE_WokenGoals(wid) = 0L;
REMOTE_AttsMutableList(wid) = 0L;
#endif
REMOTE_GcGeneration(wid) = 0L;
REMOTE_GcPhase(wid) = 0L;
REMOTE_GcCurrentPhase(wid) = 0L;
REMOTE_GcCalls(wid) = 0L;
REMOTE_TotGcTime(wid) = 0L;
REMOTE_TotGcRecovered(wid) = 0L;
REMOTE_LastGcTime(wid) = 0L;
REMOTE_LastSSTime(wid) = 0L;
REMOTE_OpenArray(wid) = NULL;
REMOTE_total_marked(wid) = 0L;
REMOTE_total_oldies(wid) = 0L;
REMOTE_current_B(wid) = NULL;
REMOTE_prev_HB(wid) = NULL;
REMOTE_HGEN(wid) = NULL;
REMOTE_iptop(wid) = NULL;
#if defined(GC_NO_TAGS)
REMOTE_bp(wid) = NULL;
#endif
REMOTE_sTR(wid) = NULL;
REMOTE_sTR0(wid) = NULL;
REMOTE_new_TR(wid) = NULL;
REMOTE_cont_top0(wid) = NULL;
REMOTE_cont_top(wid) = NULL;
REMOTE_discard_trail_entries(wid) = 0;
REMOTE_gc_ma_h_top(wid) = NULL;
REMOTE_gc_ma_h_list(wid) = NULL;
REMOTE_gc_timestamp(wid) = 0L;
REMOTE_db_vec(wid) = NULL;
REMOTE_db_vec0(wid) = NULL;
REMOTE_db_root(wid) = NULL;
REMOTE_db_nil(wid) = NULL;
REMOTE_extra_gc_cells_size(wid) = 256;
REMOTE_DynamicArrays(wid) = NULL;
REMOTE_StaticArrays(wid) = NULL;
REMOTE_GlobalVariables(wid) = NULL;
REMOTE_AllowRestart(wid) = FALSE;
REMOTE_CMemFirstBlock(wid) = NULL;
REMOTE_CMemFirstBlockSz(wid) = 0L;
REMOTE_nperm(wid) = 0;
REMOTE_jMP(wid) = 0;
REMOTE_LabelFirstArray(wid) = NULL;
REMOTE_LabelFirstArraySz(wid) = 0L;
#ifdef THREADS
InitThreadHandle(wid);
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
Yap_init_local_optyap_data(wid);
REMOTE_TabMode(wid) = 0L;
#endif /* YAPOR || TABLING */
REMOTE_InterruptsDisabled(wid) = FALSE;
REMOTE_execution(wid) = NULL;
#if LOW_LEVEL_TRACER
REMOTE_total_choicepoints(wid) = 0;
#endif
REMOTE_consult_level(wid) = 0;
REMOTE_ActiveError(wid) = calloc(sizeof(yap_error_descriptor_t),1);
REMOTE_TextBuffer(wid) = Yap_InitTextAllocator();
REMOTE_BreakLevel(wid) = 0;
REMOTE_PrologMode(wid) = BootMode;
REMOTE_CritLocks(wid) = 0;
#ifdef ANALYST
#endif /* ANALYST */
REMOTE_mathstring(wid) = NULL;
REMOTE_heap_overflows(wid) = 0;
REMOTE_total_heap_overflow_time(wid) = 0;
REMOTE_stack_overflows(wid) = 0;
REMOTE_total_stack_overflow_time(wid) = 0;
REMOTE_delay_overflows(wid) = 0;
REMOTE_total_delay_overflow_time(wid) = 0;
REMOTE_trail_overflows(wid) = 0;
REMOTE_total_trail_overflow_time(wid) = 0;
REMOTE_atom_table_overflows(wid) = 0;
REMOTE_total_atom_table_overflow_time(wid) = 0;
#ifdef LOAD_DYLD
REMOTE_dl_errno(wid) = 0;
#endif
#ifdef LOW_LEVEL_TRACER
REMOTE_do_trace_primitives(wid) = TRUE;
#endif
REMOTE_ExportAtomHashChain(wid) = NULL;
REMOTE_ExportAtomHashTableSize(wid) = 0;
REMOTE_ExportAtomHashTableNum(wid) = 0;
REMOTE_ExportFunctorHashChain(wid) = NULL;
REMOTE_ExportFunctorHashTableSize(wid) = 0;
REMOTE_ExportFunctorHashTableNum(wid) = 0;
REMOTE_ExportPredEntryHashChain(wid) = NULL;
REMOTE_ExportPredEntryHashTableSize(wid) = 0;
REMOTE_ExportPredEntryHashTableNum(wid) = 0;
REMOTE_ExportDBRefHashChain(wid) = NULL;
REMOTE_ExportDBRefHashTableSize(wid) = 0;
REMOTE_ExportDBRefHashTableNum(wid) = 0;
REMOTE_ImportAtomHashChain(wid) = NULL;
REMOTE_ImportAtomHashTableSize(wid) = 0;
REMOTE_ImportAtomHashTableNum(wid) = 0;
REMOTE_ImportFunctorHashChain(wid) = NULL;
REMOTE_ImportFunctorHashTableSize(wid) = 0;
REMOTE_ImportFunctorHashTableNum(wid) = 0;
REMOTE_ImportOPCODEHashChain(wid) = NULL;
REMOTE_ImportOPCODEHashTableSize(wid) = 0;
REMOTE_ImportPredEntryHashChain(wid) = NULL;
REMOTE_ImportPredEntryHashTableSize(wid) = 0;
REMOTE_ImportPredEntryHashTableNum(wid) = 0;
REMOTE_ImportDBRefHashChain(wid) = NULL;
REMOTE_ImportDBRefHashTableSize(wid) = 0;
REMOTE_ImportDBRefHashTableNum(wid) = 0;
REMOTE_ImportFAILCODE(wid) = NULL;
REMOTE_exo_it(wid) = NULL;
REMOTE_exo_base(wid) = NULL;
REMOTE_exo_arity(wid) = 0;
REMOTE_exo_arg(wid) = 0;
REMOTE_CurSlot(wid) = 0;
REMOTE_FrozenHandles(wid) = 0;
REMOTE_NSlots(wid) = 0;
REMOTE_SlotBase(wid) = InitHandles(wid);
REMOTE_Mutexes(wid) = NULL;
REMOTE_SourceModule(wid) = 0;
REMOTE_Including(wid) = TermNil;
REMOTE_MAX_SIZE(wid) = 1024L;
REMOTE_LastWTime(wid) = 0;
REMOTE_shared(wid) = NULL;
}

View File

@ -1,272 +1,23 @@
/* This file, rlocals.h, was generated automatically by "yap -L misc/buildlocalglobal"
please do not update, update H/LOCALS instead */
#ifndef HLOCALS_H
#define HLOCALS_H
#undef LOCAL
#undef LOCAL_INIT
#undef LOCAL_INITF
#undef LOCAL_INIT_RESTORE
#undef LOCAL_ARRAY
#undef LOCAL_ARRAY_ARRAY
#define LOCAL(TYPE, NAME)
#define LOCAL_INIT(TYPE, NAME, INIT)
#define LOCAL_INITF(TYPE, NAME, INIT)
#define LOCAL_INIT_RESTORE(TYPE, NAME, INIT, RESTORE) REMOTE_##NAME(wid) = RESTORE( REMOTE_##NAME(wid) )
#define LOCAL_ARRAY(TYPE, NAME, INIT)
#define LOCAL_ARRAY_ARRAY(TYPE, NAME, DIM1, DIM2)
static void RestoreWorker(int wid USES_REGS) {
REMOTE_GlobalArena(wid) = TermToGlobalOrAtomAdjust(REMOTE_GlobalArena(wid));
#ifdef COROUTINING
REMOTE_WokenGoals(wid) = TermToGlobalAdjust(REMOTE_WokenGoals(wid));
REMOTE_AttsMutableList(wid) = TermToGlobalAdjust(REMOTE_AttsMutableList(wid));
#endif
REMOTE_GcGeneration(wid) = TermToGlobalAdjust(REMOTE_GcGeneration(wid));
REMOTE_GcPhase(wid) = TermToGlobalAdjust(REMOTE_GcPhase(wid));
#if defined(GC_NO_TAGS)
#endif
REMOTE_DynamicArrays(wid) = PtoArrayEAdjust(REMOTE_DynamicArrays(wid));
REMOTE_StaticArrays(wid) = PtoArraySAdjust(REMOTE_StaticArrays(wid));
REMOTE_GlobalVariables(wid) = PtoGlobalEAdjust(REMOTE_GlobalVariables(wid));
#ifdef THREADS
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
#if LOW_LEVEL_TRACER
#endif
#ifdef ANALYST
#endif /* ANALYST */
#ifdef LOAD_DYLD
#endif
#ifdef LOW_LEVEL_TRACER
#endif
#include "locals.h"
}
#endif

View File

@ -1,319 +1,318 @@
// Stuff that must be considered local to a thread or worker
// START_WORKER_LOCL
// Streams
LOCL(struct AliasDescS *, FileAliases, Yap_InitStandardAliases())
LOC(int, NOfFileAliases)
LOCL(int, SzOfFileAliases, void)
LOCL(int, c_input_stream, 0)
LOCL(int, c_output_stream, 1)
LOCL(int, c_error_stream, 2)
LOCL(bool, sockets_io, false)
LOCL(bool, within_print_message, false)
#ifndef LOCAL
#include "Yap.h"
#include "heap.h"
#define LOCAL(A, B) A B
#define LOCAL_INIT(A, B, C) \
A B; \
B = C
#define LOCAL_ARRAY(A, B, C) A B[C]
#define LOCAL_ARRAY_ARRAY(A, B, C,D) A B[C][D]
#define LOCAL_INIT(A, B, C, D) A B[C][D]
#define LOCAL_INITF(A, B, C) \
A B; \
C
#define LOCAL_INIT_RESTORE(A,B,C,D) A B; C; D;
#endif
LOCAL_INIT(int, c_input_stream, 0);
LOCAL_INIT(int, c_output_stream, 1);
LOCAL_INIT(int, c_error_stream, 2);
LOCAL_INIT(bool, sockets_io, false);
LOCAL_INIT(bool, within_print_message, false);
//
// Used by the prompts to check if they are after a newline, and then a
// prompt should be output, or if we are in the middle of a line.
//
LOCL(bool, newline, true)
LOCAL_INIT(bool, newline, true);
LOCL(Atom, AtPrompt, AtomNil)
LOCN(char, MAX_PROMPT + 1, Prompt)
LOCL(encoding_t, encoding, Yap_DefaultEncoding())
LOCL(bool, quasi_quotations, false)
LOCL(UInt, default_priority, 1200)
LOCL(bool, eot_before_eof, false)
LOCL(UInt, max_depth, 0)
LOCL(UInt, max_list, 0)
LOCL(UInt, max_write_args, 0)
LOCAL_INIT(Atom, AtPrompt, AtomNil);
LOCAL_ARRAY(char, Prompt, MAX_PROMPT + 1);
LOCAL_INITF(encoding_t, encoding, Yap_DefaultEncoding());
LOCAL_INIT(bool, quasi_quotations, false);
LOCAL_INIT(UInt, default_priority, 1200);
LOCAL_INIT(bool, eot_before_eof, false);
LOCAL_INIT(UInt, max_depth, 0);
LOCAL_INIT(UInt, max_list, 0);
LOCAL_INIT(UInt, max_write_args, 0);
// Restore info
LOCL(CELL *, OldASP, NULL)
LOCL(CELL *, OldLCL0, NULL)
LOCL(tr_fr_ptr, OldTR, NULL)
LOCL(CELL *, OldGlobalBase, NULL)
LOCL(CELL *, OldH, NULL)
LOCL(CELL *, OldH0, NULL)
LOCL(ADDR, OldTrailBase, NULL)
LOCL(ADDR, OldTrailTop, NULL)
LOCL(ADDR, OldHeapBase, NULL)
LOCL(ADDR, OldHeapTop, NULL)
LOCL(Int, ClDiff, 0L)
LOCL(Int, GDiff, 0L)
LOCL(Int, HDiff, 0L)
LOCL(Int, GDiff0, 0L)
LOCL(CELL *, GSplit, NULL)
LOCL(Int, LDiff, 0L)
LOCL(Int, TrDiff, 0L)
LOCL(Int, XDiff, 0L)
LOCL(Int, DelayDiff, 0L)
LOCL(Int, BaseDiff, 0L)
LOCAL_INIT(CELL *, OldASP, NULL);
LOCAL_INIT(CELL *, OldLCL0, NULL);
LOCAL_INIT(tr_fr_ptr, OldTR, NULL);
LOCAL_INIT(CELL *, OldGlobalBase, NULL);
LOCAL_INIT(CELL *, OldH, NULL);
LOCAL_INIT(CELL *, OldH0, NULL);
LOCAL_INIT(ADDR, OldTrailBase, NULL);
LOCAL_INIT(ADDR, OldTrailTop, NULL);
LOCAL_INIT(ADDR, OldHeapBase, NULL);
LOCAL_INIT(ADDR, OldHeapTop, NULL);
LOCAL_INIT(Int, ClDiff, 0L);
LOCAL_INIT(Int, GDiff, 0L);
LOCAL_INIT(Int, HDiff, 0L);
LOCAL_INIT(Int, GDiff0, 0L);
LOCAL_INIT(CELL *, GSplit, NULL);
LOCAL_INIT(Int, LDiff, 0L);
LOCAL_INIT(Int, TrDiff, 0L);
LOCAL_INIT(Int, XDiff, 0L);
LOCAL_INIT(Int, DelayDiff, 0L);
LOCAL_INIT(Int, BaseDiff, 0L);
// Reduction counters
LOCL(YAP_ULONG_LONG, ReductionsCounter, 0L)
LOCL(YAP_ULONG_LONG, PredEntriesCounter, 0L)
LOCL(YAP_ULONG_LONG, RetriesCounter, 0L)
LOCL(int, ReductionsCounterOn, 0L)
LOCL(int, PredEntriesCounterOn, 0L)
LOCL(int, RetriesCounterOn, 0L)
LOCAL_INIT(YAP_ULONG_LONG, ReductionsCounter, 0L);
LOCAL_INIT(YAP_ULONG_LONG, PredEntriesCounter, 0L);
LOCAL_INIT(YAP_ULONG_LONG, RetriesCounter, 0L);
LOCAL_INIT(int, ReductionsCounterOn, 0L);
LOCAL_INIT(int, PredEntriesCounterOn, 0L);
LOCAL_INIT(int, RetriesCounterOn, 0L);
// support for consulting files
/* current consult stack */
LOCL(union CONSULT_OBJ *, ConsultSp, NULL)
LOCAL_INIT(union CONSULT_OBJ *, ConsultSp, NULL);
/* current maximum number of cells in consult stack */
LOC(UInt, ConsultCapacity)
LOCAL(UInt, ConsultCapacity);
/* top of consult stack */
LOCL(union CONSULT_OBJ *, ConsultBase, NULL)
LOCAL_INIT(union CONSULT_OBJ *, ConsultBase, NULL);
/* low-water mark for consult */
LOCL(union CONSULT_OBJ *, ConsultLow, NULL)
LOCL(Term, VarNames, ((Term)0))
LOCL(Atom, SourceFileName, NULL)
LOCL(UInt, SourceFileLineno, 0)
LOCAL_INIT(union CONSULT_OBJ *, ConsultLow, NULL);
LOCAL_INIT(Term, VarNames, ((Term)0));
LOCAL_INIT(Atom, SourceFileName, NULL);
LOCAL_INIT(UInt, SourceFileLineno, 0);
// global variables
LOCLR(Term, GlobalArena, 0L, TermToGlobalOrAtomAdjust() )
LOCL(UInt, GlobalArenaOverflows, 0L)
LOCL(Int, ArenaOverflows, 0L)
LOCL(Int, DepthArenas, 0)
LOCAL_INIT_RESTORE(Term, GlobalArena, 0L, TermToGlobalOrAtomAdjust);
LOCAL_INIT(UInt, GlobalArenaOverflows, 0L);
LOCAL_INIT(Int, ArenaOverflows, 0L);
LOCAL_INIT(Int, DepthArenas, 0);
LOCAL_INIT(struct pred_entry *, LastAssertedPred, NULL);
LOCAL_INIT(struct pred_entry *, TmpPred, NULL);
LOCAL_INIT(char *, ScannerStack, NULL);
LOCAL_INIT(struct scanner_extra_alloc *, ScannerExtraBlocks, NULL);
LOCL(int, ArithError, FALSE)
LOCL(struct pred_entry *, LastAssertedPred, NULL)
LOCL(struct pred_entry *, TmpPred, NULL)
LOCL(char *, ScannerStack, NULL)
LOCL(struct scanner_extra_alloc *, ScannerExtraBlocks, NULL)
LOCLR(struct DB_TERM *, BallTerm, NULL, RestoreBallTerm(wid))
LOCL(UInt, MaxActiveSignals, 64L)
LOCL(uint64_t, Signals, 0L)
LOCL(UInt, IPredArity, 0L)
LOCL(yamop *, ProfEnd, NULL)
LOCL(int, UncaughtThrow, FALSE)
LOCL(int, DoingUndefp, FALSE)
LOCL(Int, StartCharCount, 0L)
LOCL(Int, StartLineCount, 0L)
LOCL(Int, StartLinePos, 0L)
LOCL(scratch_block, ScratchPad, InitScratchPad(wid))
/// worker control information
/// stack limit after which the stack is managed by C-code.
LOCAL_INIT(Int, CBorder, 0);
/// max number of signals (uint64_t);
LOCAL_INIT(UInt, MaxActiveSignals, 64L);
/// actual life signals
LOCAL_INIT(uint64_t, Signals, 0L);
/// indexing help data?
LOCAL_INIT(UInt, IPredArity, 0L);
LOCAL_INIT(yamop *, ProfEnd, NULL);
LOCAL_INIT(int, DoingUndefp, FALSE);
LOCAL_INIT(Int, StartCharCount, 0L);
LOCAL_INIT(Int, StartLineCount, 0L);
LOCAL_INIT(Int, StartLinePos, 0L);
LOCAL_INITF(scratch_block, ScratchPad, InitScratchPad(wid));
#ifdef COROUTINING
LOCLR(Term, WokenGoals, 0L, TermToGlobalAdjust() )
LOCLR(Term, AttsMutableList, 0L, TermToGlobalAdjust() )
LOCAL_INIT_RESTORE(Term, WokenGoals, 0L, TermToGlobalAdjust);
LOCAL_INIT_RESTORE(Term, AttsMutableList, 0L, TermToGlobalAdjust);
#endif
// gc_stuff
LOCLR(Term, GcGeneration, 0L, TermToGlobalAdjust() )
LOCLR(Term, GcPhase, 0L, TermToGlobalAdjust() )
LOCL(UInt, GcCurrentPhase, 0L)
LOCL(UInt, GcCalls, 0L)
LOCL(Int, TotGcTime, 0L)
LOCL(YAP_ULONG_LONG, TotGcRecovered, 0L)
LOCL(Int, LastGcTime, 0L)
LOCL(Int, LastSSTime, 0L)
LOCL(CELL *, OpenArray, NULL)
LOCAL_INIT_RESTORE(Term, GcGeneration, 0L, TermToGlobalAdjust);
LOCAL_INIT_RESTORE(Term, GcPhase, 0L, TermToGlobalAdjust);
LOCAL_INIT(UInt, GcCurrentPhase, 0L);
LOCAL_INIT(UInt, GcCalls, 0L);
LOCAL_INIT(Int, TotGcTime, 0L);
LOCAL_INIT(YAP_ULONG_LONG, TotGcRecovered, 0L);
LOCAL_INIT(Int, LastGcTime, 0L);
LOCAL_INIT(Int, LastSSTime, 0L);
LOCAL_INIT(CELL *, OpenArray, NULL);
/* in a single gc */
LOCL(Int, total_marked, 0L)
LOCL(Int, total_oldies, 0L)
LOCL(struct choicept *, current_B, NULL)
LOCL(CELL *, prev_HB, NULL)
LOCL(CELL *, HGEN, NULL)
LOCL(CELL **, iptop, NULL)
LOCAL_INIT(Int, total_marked, 0L);
LOCAL_INIT(Int, total_oldies, 0L);
LOCAL_INIT(struct choicept *, current_B, NULL);
LOCAL_INIT(CELL *, prev_HB, NULL);
LOCAL_INIT(CELL *, HGEN, NULL);
LOCAL_INIT(CELL **, iptop, NULL);
#if defined(GC_NO_TAGS)
LOCL(char *, bp, NULL)
LOCAL_INIT(char *, bp, NULL);
#endif
LOCL(tr_fr_ptr, sTR, NULL)
LOCL(tr_fr_ptr, sTR0, NULL)
LOCL(tr_fr_ptr, new_TR, NULL)
LOCL(struct gc_mark_continuation *, cont_top0, NULL)
LOCL(struct gc_mark_continuation *, cont_top, NULL)
LOCL(int, discard_trail_entries, 0)
LOCN(gc_ma_hash_entry, GC_MAVARS_HASH_SIZE, gc_ma_hash_table)
LOCL(gc_ma_hash_entry *, gc_ma_h_top, NULL)
LOCL(gc_ma_hash_entry *, gc_ma_h_list, NULL)
LOCL(UInt, gc_timestamp, 0L)
LOCL(ADDR, db_vec, NULL)
LOCL(ADDR, db_vec0, NULL)
LOCL(struct RB_red_blk_node *, db_root, NULL)
LOCL(struct RB_red_blk_node *, db_nil, NULL)
LOCAL_INIT(tr_fr_ptr, sTR, NULL);
LOCAL_INIT(tr_fr_ptr, sTR0, NULL);
LOCAL_INIT(tr_fr_ptr, new_TR, NULL);
LOCAL_INIT(struct gc_mark_continuation *, cont_top0, NULL);
LOCAL_INIT(struct gc_mark_continuation *, cont_top, NULL);
LOCAL_INIT(int, discard_trail_entries, 0);
LOCAL_ARRAY(gc_ma_hash_entry, gc_ma_hash_table, GC_MAVARS_HASH_SIZE);
LOCAL_INIT(gc_ma_hash_entry *, gc_ma_h_top, NULL);
LOCAL_INIT(gc_ma_hash_entry *, gc_ma_h_list, NULL);
LOCAL_INIT(UInt, gc_timestamp, 0L);
LOCAL_INIT(ADDR, db_vec, NULL);
LOCAL_INIT(ADDR, db_vec0, NULL);
LOCAL_INIT(struct RB_red_blk_node *, db_root, NULL);
LOCAL_INIT(struct RB_red_blk_node *, db_nil, NULL);
LOC(sigjmp_buf, gc_restore)
LOC(CELL *, extra_gc_cells)
LOC(CELL *, extra_gc_cells_base)
LOC(CELL *, extra_gc_cells_top)
LOCN(UInt, 256, extra_gc_cells_size)
LOCLR(struct array_entry *, DynamicArrays, NULL, PtoArrayEAdjust)
LOCLR(struct static_array_entry *, StaticArrays, NULL, PtoArraySAdjust)
LOCLR(struct global_entry *, GlobalVariables, NULL, PtoGlobalEAdjust)
LOCL(int, AllowRestart, FALSE)
LOCAL(sigjmp_buf , gc_restore);
LOCAL(CELL *, extra_gc_cells);
LOCAL(CELL *, extra_gc_cells_base);
LOCAL(CELL *, extra_gc_cells_top);
LOCAL_INIT(UInt, extra_gc_cells_size, 256);
LOCAL_INIT_RESTORE(struct array_entry *, DynamicArrays, NULL, PtoArrayEAdjust);
LOCAL_INIT_RESTORE(struct static_array_entry *, StaticArrays, NULL, PtoArraySAdjust);
LOCAL_INIT_RESTORE(struct global_entry *, GlobalVariables, NULL, PtoGlobalEAdjust);
LOCAL_INIT(int, AllowRestart, FALSE);
// Thread Local Area for Fast Storage of Intermediate Compiled Code
LOCL(struct mem_blk *, CMemFirstBlock, NULL)
LOCL(UInt, CMemFirstBlockSz, 0L)
LOCAL_INIT(struct mem_blk *, CMemFirstBlock, NULL);
LOCAL_INIT(UInt, CMemFirstBlockSz, 0L);
// Variable used by the compiler to store number of permanent vars in a clause
LOCL(int, nperm, 0L)
LOCAL_INIT(int, nperm, 0);
LOCAL_INIT(int, jMP, 0);
// Thread Local Area for Labels
LOCL(Int *, LabelFirstArray, NULL)
LOCL(UInt, LabelFirstArraySz, 0L)
LOCAL_INIT(Int *, LabelFirstArray, NULL);
LOCAL_INIT(UInt, LabelFirstArraySz, 0L);
// Thread Local Area for SWI-Prolog emulation routines.
// struct PL_local_data*, PL_local_data_p, Yap_InitThreadIO(wid)
// struct LOCAL_INIT( PL_local_data*, PL_local_data_p, Yap_InitThreadIO(wid));
#ifdef THREADS
LOCL(struct thandle, ThreadHandle, InitThreadHandle(wid))
LOCAL_INITF(struct thandle, ThreadHandle, InitThreadHandle(wid));
#endif /* THREADS */
#if defined(YAPOR) || defined(TABLING)
LOCL(struct local_optyap_data, optyap_data, Yap_init_local_optyap_data(wid))
LOCL(UInt, TabMode, 0L)
LOCAL_INITF(struct local_optyap_data, optyap_data,Yap_init_local_optyap_data(wid));
LOCAL_INIT(UInt, TabMode, 0L);
#endif /* YAPOR || TABLING */
LOCL(int, InterruptsDisabled, FALSE)
LOCAL_INIT(int, InterruptsDisabled, FALSE);
LOCL(struct open_query_struct *, execution, NULL)
LOCAL_INIT(struct open_query_struct *, execution, NULL);
#if LOW_LEVEL_TRACER
LOCL(Int, total_choicepoints, 0)
LOCAL_INIT(Int, total_choicepoints, 0);
#endif
LOCL(int, consult_level, 0)
LOCAL_INIT(int, consult_level, 0);
// Variables related to memory allocation
LOC(ADDR, LocalBase)
LOC(ADDR, GlobalBase)
LOC(ADDR, TrailBase)
LOC(ADDR, TrailTop)
LOC(char *, ErrorMessage)
LOC(Term, Error_Term)
LOC(yap_error_number, Error_TYPE)
LOC(const char *, Error_File)
LOC(const char *, Error_Function)
LOC(int, Error_Lineno)
LOC(size_t, Error_Size)
LOCN(char, MAX_ERROR_MSG_SIZE, ErrorSay)
LOC(jmp_buf, IOBotch)
LOC(TokEntry *, tokptr)
LOC(TokEntry *, toktide)
LOC(VarEntry *, VarTable)
LOC(VarEntry *, AnonVarTable)
LOC(Term, Comments)
LOC(CELL *, CommentsTail)
LOC(CELL *, CommentsNextChar)
LOC(wchar_t *, CommentsBuff)
LOC(size_t, CommentsBuffPos)
LOC(size_t, CommentsBuffLim)
LOC(sigjmp_buf, RestartEnv)
LOCN(char, YAP_FILENAME_MAX, FileNameBuf)
LOCN(char, YAP_FILENAME_MAX, FileNameBuf2)
LOCAL(ADDR, LocalBase);
LOCAL(ADDR, GlobalBase);
LOCAL(ADDR, TrailBase);
LOCAL(ADDR, TrailTop);
/* error handling info, designed to be easy to pass to the foreign world */
LOCAL_INIT(yap_error_descriptor_t *, ActiveError, calloc(sizeof(yap_error_descriptor_t), 1));
/// pointer to an exception term, from throw
LOCAL(jmp_buf, IOBotch);
/// tokenizer support (should be private to the tokenizer).
LOCAL(TokEntry *, tokptr);
LOCAL(TokEntry *, toktide);
LOCAL(VarEntry *, VarTable);
LOCAL(VarEntry *, AnonVarTable);
LOCAL(Term, Comments);
LOCAL(CELL *, CommentsTail);
LOCAL(CELL *, CommentsNextChar);
LOCAL(wchar_t *, CommentsBuff);
LOCAL(size_t, CommentsBuffPos);
LOCAL(size_t, CommentsBuffLim);
LOCAL_INIT(sigjmp_buf *, RestartEnv, NULL);
LOCAL_ARRAY(char, FileNameBuf, YAP_FILENAME_MAX + 1);
LOCAL_ARRAY(char, FileNameBuf2, YAP_FILENAME_MAX + 1);
LOCAL_INIT(struct TextBuffer_manager *, TextBuffer, Yap_InitTextAllocator());
// Prolog State
LOCL(UInt, BreakLevel, 0)
LOCL(Int, PrologMode, BootMode)
LOCL(int, CritLocks, 0)
LOCAL_INIT(UInt, BreakLevel, 0);
LOCAL_INIT(Int, PrologMode, BootMode);
LOCAL_INIT(int, CritLocks, 0);
// Prolog execution and state flags
LOC(union flagTerm *, Flags)
LOC(UInt, flagCount)
LOCAL(union flagTerm *, Flags);
LOCAL(UInt, flagCount);
// analyst.c
/* used to find out how many instructions of each kind are executed */
#ifdef ANALYST
LOC(YAP_ULONG_LONG, opcount[_std_top + 1])
LOC(YAP_ULONG_LONG, 2opcount [_std_top + 1][_std_top + 1])
LOCAL_ARRAY(YAP_ULONG_LONG, opcount, _std_top + 1);
LOCAL_ARRAY_ARRAY(YAP_ULONG_LONG, 2opcount, _std_top + 1, _std_top + 1);
#endif /* ANALYST */
// dbase.c
LOC(struct db_globs *, s_dbg)
LOCAL(struct db_globs *, s_dbg);
// eval.c
LOCL(yap_error_number, matherror, YAP_NO_ERROR)
LOCL(Term, mathtt, NULL)
LOCL(char *, mathstring, NULL)
LOCL(yap_error_number, CurrentError, YAP_NO_ERROR)
LOCAL(Term, mathtt);
LOCAL_INIT(char *, mathstring, NULL);
// grow.c
LOCL(int, heap_overflows, 0)
LOCL(Int, total_heap_overflow_time, 0)
LOCL(int, stack_overflows, 0)
LOCL(Int, total_stack_overflow_time, 0)
LOCL(int, delay_overflows, 0)
LOCL(Int, total_delay_overflow_time, 0)
LOCL(int, trail_overflows, 0)
LOCL(Int, total_trail_overflow_time, 0)
LOCL(int, atom_table_overflows, 0)
LOCL(Int, total_atom_table_overflow_time, 0)
LOCAL_INIT(int, heap_overflows, 0);
LOCAL_INIT(Int, total_heap_overflow_time, 0);
LOCAL_INIT(int, stack_overflows, 0);
LOCAL_INIT(Int, total_stack_overflow_time, 0);
LOCAL_INIT(int, delay_overflows, 0);
LOCAL_INIT(Int, total_delay_overflow_time, 0);
LOCAL_INIT(int, trail_overflows, 0);
LOCAL_INIT(Int, total_trail_overflow_time, 0);
LOCAL_INIT(int, atom_table_overflows, 0);
LOCAL_INIT(Int, total_atom_table_overflow_time, 0);
// load_dyld
#ifdef LOAD_DYLD
LOCL(int, dl_errno, 0)
LOCAL_INIT(int, dl_errno, 0);
#endif
// tracer.c
#ifdef LOW_LEVEL_TRACER
LOCL(int, do_trace_primitives, TRUE)
LOCAL_INIT(int, do_trace_primitives, TRUE);
#endif
// quick loader
LOCL(struct export_atom_hash_entry_struct *, ExportAtomHashChain, NULL)
LOCL(UInt, ExportAtomHashTableSize, 0)
LOCL(UInt, ExportAtomHashTableNum, 0)
LOCL(struct export_functor_hash_entry_struct *, ExportFunctorHashChain, NULL)
LOCL(UInt, ExportFunctorHashTableSize, 0)
LOCL(UInt, ExportFunctorHashTableNum, 0)
LOCL(struct export_pred_entry_hash_entry_struct *, ExportPredEntryHashChain,
NULL)
LOCL(UInt, ExportPredEntryHashTableSize, 0)
LOCL(UInt, ExportPredEntryHashTableNum, 0)
LOCL(struct export_dbref_hash_entry_struct *, ExportDBRefHashChain, NULL)
LOCL(UInt, ExportDBRefHashTableSize, 0)
LOCL(UInt, ExportDBRefHashTableNum, 0)
LOCL(struct import_atom_hash_entry_struct **, ImportAtomHashChain, NULL)
LOCL(UInt, ImportAtomHashTableSize, 0)
LOCL(UInt, ImportAtomHashTableNum, 0)
LOCL(struct import_functor_hash_entry_struct **, ImportFunctorHashChain, NULL)
LOCL(UInt, ImportFunctorHashTableSize, 0)
LOCL(UInt, ImportFunctorHashTableNum, 0)
LOCL(struct import_opcode_hash_entry_struct **, ImportOPCODEHashChain, NULL)
LOCL(UInt, ImportOPCODEHashTableSize, 0)
LOCL(struct import_pred_entry_hash_entry_struct **, ImportPredEntryHashChain,
NULL)
LOCL(UInt, ImportPredEntryHashTableSize, 0)
LOCL(UInt, ImportPredEntryHashTableNum, 0)
LOCL(struct import_dbref_hash_entry_struct **, ImportDBRefHashChain, NULL)
LOCL(UInt, ImportDBRefHashTableSize, 0)
LOCL(UInt, ImportDBRefHashTableNum, 0)
LOCL(yamop *, ImportFAILCODE, NULL)
#if __ANDROID__
// current virtual directory.
LOCL(struct AAssetManager *assetManager, GLOBAL_assetManager)
LOCL(char *, InAssetDir, NULL)
#endif
LOCAL_INIT(struct export_atom_hash_entry_struct *, ExportAtomHashChain, NULL);
LOCAL_INIT(UInt, ExportAtomHashTableSize, 0);
LOCAL_INIT(UInt, ExportAtomHashTableNum, 0);
LOCAL_INIT(struct export_functor_hash_entry_struct *, ExportFunctorHashChain,NULL);
LOCAL_INIT(UInt, ExportFunctorHashTableSize, 0);
LOCAL_INIT(UInt, ExportFunctorHashTableNum, 0);
LOCAL_INIT(struct export_pred_entry_hash_entry_struct *,ExportPredEntryHashChain, NULL);
LOCAL_INIT(UInt, ExportPredEntryHashTableSize, 0);
LOCAL_INIT(UInt, ExportPredEntryHashTableNum, 0);
LOCAL_INIT(struct export_dbref_hash_entry_struct *, ExportDBRefHashChain, NULL);
LOCAL_INIT(UInt, ExportDBRefHashTableSize, 0);
LOCAL_INIT(UInt, ExportDBRefHashTableNum, 0);
LOCAL_INIT(struct import_atom_hash_entry_struct **, ImportAtomHashChain, NULL);
LOCAL_INIT(UInt, ImportAtomHashTableSize, 0);
LOCAL_INIT(UInt, ImportAtomHashTableNum, 0);
LOCAL_INIT(struct import_functor_hash_entry_struct **, ImportFunctorHashChain, NULL);
LOCAL_INIT(UInt, ImportFunctorHashTableSize, 0);
LOCAL_INIT(UInt, ImportFunctorHashTableNum, 0);
LOCAL_INIT(struct import_opcode_hash_entry_struct **, ImportOPCODEHashChain, NULL);
LOCAL_INIT(UInt, ImportOPCODEHashTableSize, 0);
LOCAL_INIT(struct import_pred_entry_hash_entry_struct **, ImportPredEntryHashChain, NULL);
LOCAL_INIT(UInt, ImportPredEntryHashTableSize, 0);
LOCAL_INIT(UInt, ImportPredEntryHashTableNum, 0);
LOCAL_INIT(struct import_dbref_hash_entry_struct **, ImportDBRefHashChain, NULL);
LOCAL_INIT(UInt, ImportDBRefHashTableSize, 0);
LOCAL_INIT(UInt, ImportDBRefHashTableNum, 0);
LOCAL_INIT(yamop *, ImportFAILCODE, NULL);
// exo indexing
LOCN(UInt, 256, ibnds)
LOCL(struct index_t *, exo_it, NULL)
LOCL(CELL *, exo_base, NULL)
LOCL(UInt, exo_arity, 0)
LOCL(UInt, exo_arg, 0)
LOCAL_ARRAY(UInt, ibnds, 256);
LOCAL_INIT(struct index_t *, exo_it, NULL);
LOCAL_INIT(CELL *, exo_base, NULL);
LOCAL_INIT(UInt, exo_arity, 0);
LOCAL_INIT(UInt, exo_arg, 0);
// atom completion
LOC(struct scan_atoms *, search_atoms)
LOCAL(struct scan_atoms *, search_atoms);
LOCAL(struct pred_entry *, SearchPreds);
// Slots
LOCL(yhandle_t, CurSlot, 0)
LOCL(yhandle_t, NSlots, 0)
LOCL(CELL *, SlotBase, InitHandles(wid))
/// Slots Status
LOCAL_INIT(yhandle_t, CurSlot, 0);
LOCAL_INIT(yhandle_t, FrozenHandles, 0);
LOCAL_INIT(yhandle_t, NSlots, 0);
LOCAL_INIT(CELL *, SlotBase, InitHandles(wid));
// Mutexes
LOCL(struct swi_mutex *, Mutexes, NULL)
LOCAL_INIT(struct swi_mutex *, Mutexes, NULL);
LOCL(Term, SourceModule, 0)
LOCL(Term, Including, TermNil)
LOCAL_INIT(Term, SourceModule, 0);
LOCAL_INIT(Term, Including, TermNil);
LOCL(size_t, MAX_SIZE, 1024L)
LOCAL_INIT(size_t, MAX_SIZE, 1024L);
/* last call to walltime. */
LOCAL_INIT(uint64_t, LastWTime, 0);
LOCAL_INIT(void *, shared, NULL);

View File

@ -1,7 +1,7 @@
#ifdef FROZEN_STACKS
{
tr_fr_ptr pt0, pt1, pbase;
restart:
pbase = B->cp_tr;
pt0 = pt1 = TR - 1;
while (pt1 >= pbase) {
@ -33,8 +33,10 @@
Functor f = FunctorOfTerm(t);
if (f == FunctorBigInt) {
Int tag = Yap_blob_tag(t) - USER_BLOB_START;
RESET_VARIABLE(&TrailTerm(pt1));
RESET_VARIABLE(&TrailTerm(pt1));
RESET_VARIABLE(&TrailVal(pt1));
GLOBAL_OpaqueHandlers[tag].cut_handler(d1);
goto restart;
} else {
pt0--;
}

View File

@ -531,63 +531,63 @@ struct local_optyap_data {
#define LOCAL_ma_h_top (LOCAL_optyap_data.ma_h_top)
#define LOCAL_ma_hash_table (LOCAL_optyap_data.ma_hash_table)
#define REMOTE_pages_void(wid) (REMOTE(wid)->optyap_data_.pages.void_pages)
#define REMOTE_pages_tab_ent(wid) (REMOTE(wid)->optyap_data_.pages.table_entry_pages)
#define REMOTE_pages_sg_ent(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_entry_pages)
#define REMOTE_pages_sg_fr(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_frame_pages)
#define REMOTE_pages_dep_fr(wid) (REMOTE(wid)->optyap_data_.pages.dependency_frame_pages)
#define REMOTE_pages_sg_node(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_trie_node_pages)
#define REMOTE_pages_sg_hash(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_trie_hash_pages)
#define REMOTE_pages_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_node_pages)
#define REMOTE_pages_ans_hash(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_hash_pages)
#define REMOTE_pages_ans_ref_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_ref_node_pages)
#define REMOTE_pages_gt_node(wid) (REMOTE(wid)->optyap_data_.pages.global_trie_node_pages)
#define REMOTE_pages_gt_hash(wid) (REMOTE(wid)->optyap_data_.pages.global_trie_hash_pages)
#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.next_free_answer_trie_node)
#define REMOTE_lock(wid) (REMOTE(wid)->optyap_data_.lock)
#define REMOTE_load(wid) (REMOTE(wid)->optyap_data_.load)
#define REMOTE_pages_void(wid) (REMOTE(wid)->optyap_data.pages.void_pages)
#define REMOTE_pages_tab_ent(wid) (REMOTE(wid)->optyap_data.pages.table_entry_pages)
#define REMOTE_pages_sg_ent(wid) (REMOTE(wid)->optyap_data.pages.subgoal_entry_pages)
#define REMOTE_pages_sg_fr(wid) (REMOTE(wid)->optyap_data.pages.subgoal_frame_pages)
#define REMOTE_pages_dep_fr(wid) (REMOTE(wid)->optyap_data.pages.dependency_frame_pages)
#define REMOTE_pages_sg_node(wid) (REMOTE(wid)->optyap_data.pages.subgoal_trie_node_pages)
#define REMOTE_pages_sg_hash(wid) (REMOTE(wid)->optyap_data.pages.subgoal_trie_hash_pages)
#define REMOTE_pages_ans_node(wid) (REMOTE(wid)->optyap_data.pages.answer_trie_node_pages)
#define REMOTE_pages_ans_hash(wid) (REMOTE(wid)->optyap_data.pages.answer_trie_hash_pages)
#define REMOTE_pages_ans_ref_node(wid) (REMOTE(wid)->optyap_data.pages.answer_ref_node_pages)
#define REMOTE_pages_gt_node(wid) (REMOTE(wid)->optyap_data.pages.global_trie_node_pages)
#define REMOTE_pages_gt_hash(wid) (REMOTE(wid)->optyap_data.pages.global_trie_hash_pages)
#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data.pages.next_free_answer_trie_node)
#define REMOTE_lock(wid) (REMOTE(wid)->optyap_data.lock)
#define REMOTE_load(wid) (REMOTE(wid)->optyap_data.load)
#ifdef YAPOR_THREADS
#define REMOTE_top_cp(wid) offset_to_cptr(REMOTE(wid)->optyap_data_.top_choice_point_offset)
#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_offset = cptr_to_offset(bptr))
#define REMOTE_top_cp(wid) offset_to_cptr(REMOTE(wid)->optyap_data.top_choice_point_offset)
#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_offset = cptr_to_offset(bptr))
#else
#define REMOTE_top_cp(wid) (REMOTE(wid)->optyap_data_.top_choice_point)
#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point = (bptr))
#define REMOTE_top_cp(wid) (REMOTE(wid)->optyap_data.top_choice_point)
#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point = (bptr))
#endif /* YAPOR_THREADS */
#define REMOTE_top_or_fr(wid) (REMOTE(wid)->optyap_data_.top_or_frame)
#define REMOTE_top_or_fr(wid) (REMOTE(wid)->optyap_data.top_or_frame)
#ifdef YAPOR_THREADS
#define Get_REMOTE_prune_request(wid) offset_to_cptr_with_null(REMOTE(wid)->optyap_data_.prune_request_offset)
#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data_.prune_request_offset = cptr_to_offset_with_null(cp))
#define Get_REMOTE_prune_request(wid) offset_to_cptr_with_null(REMOTE(wid)->optyap_data.prune_request_offset)
#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data.prune_request_offset = cptr_to_offset_with_null(cp))
#else
#define REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data_.prune_request)
#define Get_REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data_.prune_request)
#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data_.prune_request = cp)
#define REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data.prune_request)
#define Get_REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data.prune_request)
#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data.prune_request = cp)
#endif /* YAPOR_THREADS */
#define REMOTE_share_request(wid) (REMOTE(wid)->optyap_data_.share_request)
#define REMOTE_reply_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.reply_signal)
#define REMOTE_p_fase_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.P_fase)
#define REMOTE_q_fase_signal(wid) (REMOTE(wid)->optyap_data_.share_signals.Q_fase)
#define REMOTE_lock_signals(wid) (REMOTE(wid)->optyap_data_.share_signals.lock)
#define REMOTE_start_global_copy(wid) (REMOTE(wid)->optyap_data_.global_copy.start)
#define REMOTE_end_global_copy(wid) (REMOTE(wid)->optyap_data_.global_copy.end)
#define REMOTE_start_local_copy(wid) (REMOTE(wid)->optyap_data_.local_copy.start)
#define REMOTE_end_local_copy(wid) (REMOTE(wid)->optyap_data_.local_copy.end)
#define REMOTE_start_trail_copy(wid) (REMOTE(wid)->optyap_data_.trail_copy.start)
#define REMOTE_end_trail_copy(wid) (REMOTE(wid)->optyap_data_.trail_copy.end)
#define REMOTE_top_sg_fr(wid) (REMOTE(wid)->optyap_data_.top_subgoal_frame)
#define REMOTE_top_dep_fr(wid) (REMOTE(wid)->optyap_data_.top_dependency_frame)
#define REMOTE_pruning_scope(wid) (REMOTE(wid)->optyap_data_.bottom_pruning_scope)
#define REMOTE_share_request(wid) (REMOTE(wid)->optyap_data.share_request)
#define REMOTE_reply_signal(wid) (REMOTE(wid)->optyap_data.share_signals.reply_signal)
#define REMOTE_p_fase_signal(wid) (REMOTE(wid)->optyap_data.share_signals.P_fase)
#define REMOTE_q_fase_signal(wid) (REMOTE(wid)->optyap_data.share_signals.Q_fase)
#define REMOTE_lock_signals(wid) (REMOTE(wid)->optyap_data.share_signals.lock)
#define REMOTE_start_global_copy(wid) (REMOTE(wid)->optyap_data.global_copy.start)
#define REMOTE_end_global_copy(wid) (REMOTE(wid)->optyap_data.global_copy.end)
#define REMOTE_start_local_copy(wid) (REMOTE(wid)->optyap_data.local_copy.start)
#define REMOTE_end_local_copy(wid) (REMOTE(wid)->optyap_data.local_copy.end)
#define REMOTE_start_trail_copy(wid) (REMOTE(wid)->optyap_data.trail_copy.start)
#define REMOTE_end_trail_copy(wid) (REMOTE(wid)->optyap_data.trail_copy.end)
#define REMOTE_top_sg_fr(wid) (REMOTE(wid)->optyap_data.top_subgoal_frame)
#define REMOTE_top_dep_fr(wid) (REMOTE(wid)->optyap_data.top_dependency_frame)
#define REMOTE_pruning_scope(wid) (REMOTE(wid)->optyap_data.bottom_pruning_scope)
#ifdef YAPOR_THREADS
#define REMOTE_top_cp_on_stack(wid) offset_to_cptr(REMOTE(wid)->optyap_data_.top_choice_point_on_stack_offset)
#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack_offset = cptr_to_offset(bptr))
#define REMOTE_top_cp_on_stack(wid) offset_to_cptr(REMOTE(wid)->optyap_data.top_choice_point_on_stack_offset)
#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_on_stack_offset = cptr_to_offset(bptr))
#else
#define REMOTE_top_cp_on_stack(wid) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack)
#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data_.top_choice_point_on_stack = (bptr))
#define REMOTE_top_cp_on_stack(wid) (REMOTE(wid)->optyap_data.top_choice_point_on_stack)
#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_on_stack = (bptr))
#endif /* YAPOR_THREADS */
#define REMOTE_top_susp_or_fr(wid) (REMOTE(wid)->optyap_data_.top_or_frame_with_suspensions)
#define REMOTE_thread_output(wid) (REMOTE(wid)->optyap_data_.thread_output)
#define REMOTE_ma_timestamp(wid) (REMOTE(wid)->optyap_data_.ma_timestamp)
#define REMOTE_ma_h_top(wid) (REMOTE(wid)->optyap_data_.ma_h_top)
#define REMOTE_ma_hash_table(wid) (REMOTE(wid)->optyap_data_.ma_hash_table)
#define REMOTE_top_susp_or_fr(wid) (REMOTE(wid)->optyap_data.top_or_frame_with_suspensions)
#define REMOTE_thread_output(wid) (REMOTE(wid)->optyap_data.thread_output)
#define REMOTE_ma_timestamp(wid) (REMOTE(wid)->optyap_data.ma_timestamp)
#define REMOTE_ma_h_top(wid) (REMOTE(wid)->optyap_data.ma_h_top)
#define REMOTE_ma_hash_table(wid) (REMOTE(wid)->optyap_data.ma_hash_table)
#ifdef YAPOR
#include "or.structs.h"

View File

@ -688,6 +688,8 @@ extern X_API YAP_Functor YAP_IntToFunctor(YAP_Int i);
extern X_API YAP_PredEntryPtr YAP_TopGoal(void);
extern X_API void *YAP_GetStreamFromId(int no);
#define YAP_InitCPred(N, A, F) YAP_UserCPredicate(N, F, A)
__END_DECLS

View File

@ -10,8 +10,6 @@
static char SccsId[] = "%W% %G%";
#endif
#ifndef YAPSTREAMS_H
#define YAPSTREAMS_H 1
@ -22,7 +20,6 @@ static char SccsId[] = "%W% %G%";
#include <sys/socket.h>
#endif
#define YAP_ERROR NIL
#define MaxStreams 64
@ -42,7 +39,6 @@ static char SccsId[] = "%W% %G%";
#define HAVE_SOCKET 1
#endif
//#include "Atoms.h"
//#include "Yap.h"
#include <stdlib.h>
@ -60,7 +56,6 @@ static char SccsId[] = "%W% %G%";
#include <wchar.h>
/************ SWI compatible support for unicode representations ************/
typedef struct yap_io_position {
int64_t byteno; /* byte-position in file */
@ -72,7 +67,7 @@ typedef struct yap_io_position {
#ifndef _PL_STREAM_H
typedef struct {
YAP_Atom file; /* current source file */
YAP_Atom file; /* current source file */
yapIOPOS position; /* Line, line pos, char and byte */
} yapSourceLocation;
#endif
@ -99,12 +94,12 @@ typedef struct read_data_t {
int magic; /* RD_MAGIC */
struct stream_desc *stream;
FILE *f; /* file. of known */
FILE *f; /* file. of known */
YAP_Term position; /* Line, line pos, char and byte */
void *posp; /* position pointer */
size_t posi; /* position number */
void *posp; /* position pointer */
size_t posi; /* position number */
YAP_Term subtpos; /* Report Subterm positions */
YAP_Term subtpos; /* Report Subterm positions */
bool cycles; /* Re-establish cycles */
yapSourceLocation start_of_term; /* Position of start of term */
struct mod_entry *module; /* Current source module */
@ -114,14 +109,14 @@ typedef struct read_data_t {
int *char_conversion_table; /* active conversion table */
YAP_Atom on_error; /* Handling of syntax errors */
YAP_Atom on_error; /* Handling of syntax errors */
int has_exception; /* exception is raised */
YAP_Term exception; /* raised exception */
YAP_Term variables; /* report variables */
YAP_Term singles; /* Report singleton variables */
YAP_Term varnames; /* Report variables+names */
int strictness; /* Strictness level */
int strictness; /* Strictness level */
#ifdef O_QUASIQUOTATIONS
YAP_Term quasi_quotations; /* User option quasi_quotations(QQ) */
@ -133,8 +128,7 @@ typedef struct read_data_t {
} read_data, *ReadData;
#if __APPLE__
#if __APPLE__ && !PY4YAP_H
#include "fmemopen.h"
#define HAVE_FMEMOPEN 1
#define HAVE_OPEN_MEMSTREAM 1
@ -162,8 +156,8 @@ FILE *open_memstream(char **buf, size_t *len);
#endif
typedef struct mem_desc {
char *buf; /* where the file is being read from/written to */
int src; /* where the space comes from, 0 code space, 1 malloc */
char *buf; /* where the file is being read from/written to */
int src; /* where the space comes from, 0 code space, 1 malloc */
YAP_Int max_size; /* maximum buffer size (may be changed dynamically) */
YAP_UInt pos; /* cursor */
volatile void *error_handler;
@ -171,16 +165,16 @@ typedef struct mem_desc {
#if HAVE_SOCKET
typedef enum { /* in YAP, sockets may be in one of 4 possible status */
new_socket,
server_socket,
client_socket,
server_session_socket,
closed_socket
new_socket,
server_socket,
client_socket,
server_session_socket,
closed_socket
} socket_info;
typedef enum { /* we accept two domains for the moment, IPV6 may follow */
af_inet, /* IPV4 */
af_unix /* or AF_FILE */
af_inet, /* IPV4 */
af_unix /* or AF_FILE */
} socket_domain;
#endif
@ -229,7 +223,7 @@ typedef struct stream_desc {
struct {
const unsigned char *buf, *ptr;
} irl;
void *private_data;
void *private_data;
} u;
YAP_Int charcount, linecount, linepos;
@ -247,42 +241,9 @@ void *private_data;
struct vfs *vfs; /** stream belongs to a space */
void *vfs_handle; /** direct handle to stream in that space. */
int (*stream_wgetc_for_read)(
int); /* function the stream uses for parser. It may be different
from above if the ISO character conversion is on */
int); /* function the stream uses for parser. It may be different
from above if the ISO character conversion is on */
encoding_t encoding; /** current encoding for stream */
} StreamDesc;
#endif

View File

@ -101,6 +101,8 @@ if (READLINE_LIBS)
endif (READLINE_LIBS)
add_subDIRECTORY ( H )
#bootstrap and saved state
add_subDIRECTORY ( pl )

View File

@ -227,7 +227,8 @@ Yap_SetAlias (Atom arg, int sno)
Int alno = aliasp-GLOBAL_FileAliases;
aliasp->alias_stream = sno;
if (!(GLOBAL_Stream[sno].status &
(Null_Stream_f|InMemory_Stream_f|Socket_Stream_f))) {
(Null_Stream_f|InMemory_Stream_f|Socket_Stream_f)) &&
!GLOBAL_Stream[sno].vfs) {
switch(alno) {
case 0:
Yap_stdin = GLOBAL_Stream[sno].file;

View File

@ -1165,7 +1165,7 @@ leaving the current stream position unaltered.
*/
void Yap_flush(void) { CACHE_REGS(void) flush_all_streams(PASS_REGS1); }
void Yap_flush_all(void) { CACHE_REGS(void) flush_all_streams(PASS_REGS1); }
void Yap_FlushStreams(void) { CACHE_REGS(void) flush_all_streams(PASS_REGS1); }

View File

@ -44,8 +44,8 @@ static int ConsolePutc(int, int);
bool Yap_DoPrompt(StreamDesc *s) {
if (s->status & Tty_Stream_f) {
if (GLOBAL_Stream[StdInStream].status & Tty_Stream_f &&
GLOBAL_Stream[StdErrStream].status & Tty_Stream_f) {
if (GLOBAL_Stream[LOCAL_c_input_stream].status & Tty_Stream_f &&
GLOBAL_Stream[LOCAL_c_error_stream].status & Tty_Stream_f) {
return LOCAL_newline;
}
}
@ -56,7 +56,7 @@ bool Yap_DoPrompt(StreamDesc *s) {
/* check if we read a newline or an EOF */
int console_post_process_read_char(int ch, StreamDesc *s) {
/* the character is also going to be output by the console handler */
console_count_output_char(ch, GLOBAL_Stream + StdErrStream);
console_count_output_char(ch, GLOBAL_Stream + LOCAL_c_error_stream);
if (ch == '\r') {
s->linepos = 0;
LOCAL_newline = true;
@ -146,7 +146,7 @@ restart:
GLOBAL_Stream[StdErrStream].stream_putc(StdErrStream, ch);
}
}
Yap_clearInput(StdErrStream);
Yap_clearInput(LOCAL_c_error_stream);
strncpy(LOCAL_Prompt, (char *)RepAtom(LOCAL_AtPrompt)->StrOfAE, MAX_PROMPT);
LOCAL_newline = FALSE;
}

View File

@ -34,16 +34,24 @@ static char SccsId[] = "%W% %G%";
const char *s;
int n;
if (sno != sno0) {
fflush(GLOBAL_Stream[sno].file);
n = ftell(GLOBAL_Stream[sno].file);
s = GLOBAL_Stream[sno].nbuf;
fwrite(s, n, 1, GLOBAL_Stream[sno0].file);
fflush(GLOBAL_Stream[sno].file);
n = ftell(GLOBAL_Stream[sno].file);
s = GLOBAL_Stream[sno].nbuf;
if (GLOBAL_Stream[sno0].vfs) {
int ch;
int (*f)() = GLOBAL_Stream[sno0].vfs->put_char;
while ((ch = *s++)) {
f(sno0, ch);
}
} else {
fwrite(s, n, 1, GLOBAL_Stream[sno0].file);
}
rewind(GLOBAL_Stream[sno].file);
fg->lstart = 0;
fg->phys_start = 0;
fg->gapi = 0;
}
fflush(GLOBAL_Stream[sno0].file);
Yap_flush(sno0);
return sno;
}
@ -97,7 +105,7 @@ static char SccsId[] = "%W% %G%";
};
rewind(GLOBAL_Stream[sno].file);
fflush(GLOBAL_Stream[sno0].file);
Yap_flush(sno0);
GLOBAL_Stream[sno].linecount = 1;
GLOBAL_Stream[sno].linepos += nchars;
GLOBAL_Stream[sno].charcount = 0;

View File

@ -526,7 +526,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
// stream is already locked.
Yap_plwrite(t, GLOBAL_Stream + sno, 0, Handle_vars_f | To_heap_f,
GLOBAL_MaxPriority);
Yap_CloseSlots(sl);
Yap_CloseSlots(sl);
break;
case 'c': {
Int nch, i;
@ -905,7 +905,7 @@ static Int doformat(volatile Term otail, volatile Term oargs,
fill_pads(sno, sno0, finfo.lstart + repeats, &finfo PASS_REGS);
break;
case 't': {
#if MAY_WRITE
#if MAY_WRITR
if (fflush(GLOBAL_Stream[sno].file) == 0) {
finfo.gap[finfo.gapi].phys = ftell(GLOBAL_Stream[sno].file);
}
@ -1130,9 +1130,7 @@ static Int format(Term tf, Term tas, Term tout USES_REGS) {
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
return false;
} else {
out = doformat(tf, tas, output_stream PASS_REGS);
UNLOCK(GLOBAL_Stream[output_stream].streamlock);
if (mem_stream) {

View File

@ -1,19 +1,19 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: iopreds.c *
* Last rev: 5/2/88 *
* mods: *
* comments: Input/Output C implemented predicates *
* *
*************************************************************************/
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: iopreds.c *
* Last rev: 5/2/88 *
* mods: *
* comments: Input/Output C implemented predicates *
* *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
#endif
@ -33,10 +33,10 @@ static char SccsId[] = "%W% %G%";
*/
#include "Yap.h"
#include "YapEval.h"
#include "YapHeap.h"
#include "YapText.h"
#include "Yatom.h"
#include "YapEval.h"
#include "yapio.h"
#include <stdlib.h>
#if HAVE_UNISTD_H
@ -246,13 +246,13 @@ static void unix_upd_stream_info(StreamDesc *s) {
void Yap_DefaultStreamOps(StreamDesc *st) {
CACHE_REGS
if (st->vfs) {
st->stream_wputc = st->vfs->put_char;
st->stream_wgetc = st->vfs->get_char;
st->stream_putc = st->vfs->put_char;
st->stream_wgetc = st->vfs->get_char;
return;
}
if (st->vfs) {
st->stream_wputc = st->vfs->put_char;
st->stream_wgetc = st->vfs->get_char;
st->stream_putc = st->vfs->put_char;
st->stream_wgetc = st->vfs->get_char;
return;
}
st->stream_wputc = put_wchar;
st->stream_wgetc = get_wchar_UTF8;
st->stream_putc = FilePutc;
@ -354,8 +354,7 @@ static void InitStdStreams(void) {
#if USE_READLINE
if (GLOBAL_Stream[StdInStream].status & Tty_Stream_f &&
GLOBAL_Stream[StdOutStream].status & Tty_Stream_f &&
GLOBAL_Stream[StdErrStream].status & Tty_Stream_f &&
! Yap_embedded) {
GLOBAL_Stream[StdErrStream].status & Tty_Stream_f && !Yap_embedded) {
Yap_InitReadline(TermTrue);
}
#endif
@ -1057,7 +1056,8 @@ static void check_bom(int sno, StreamDesc *st) {
}
bool Yap_initStream(int sno, FILE *fd, const char *name, Term file_name,
encoding_t encoding, stream_flags_t flags, Atom open_mode, void *vfs) {
encoding_t encoding, stream_flags_t flags, Atom open_mode,
void *vfs) {
StreamDesc *st = &GLOBAL_Stream[sno];
st->status = flags;
@ -1290,21 +1290,22 @@ do_open(Term file_name, Term t2,
if (st - GLOBAL_Stream < 3) {
flags |= RepError_Prolog_f;
}
struct vfs *vfsp = NULL;
struct vfs *vfsp = NULL;
if ((vfsp = vfs_owner(fname)) != NULL) {
st->u.private_data = vfsp->open(fname, io_mode);
st->u.private_data = vfsp->open(fname, io_mode);
fd = NULL;
if (st->u.private_data == NULL)
return (PlIOError(EXISTENCE_ERROR_SOURCE_SINK, file_name, "%s", fname));
st->vfs = vfsp;
} else if ((fd = fopen(fname, io_mode)) == NULL ||
(!(flags & Binary_Stream_f) && binary_file(fname))) {
(!(flags & Binary_Stream_f) && binary_file(fname))) {
strncpy(LOCAL_FileNameBuf, fname, MAXPATHLEN);
if (fname != fbuf)
freeBuffer((void *)fname);
fname = LOCAL_FileNameBuf;
UNLOCK(st->streamlock);
free(args);
if (errno == ENOENT && !strchr(io_mode,'r')) {
if (errno == ENOENT && !strchr(io_mode, 'r')) {
return (PlIOError(EXISTENCE_ERROR_SOURCE_SINK, file_name, "%s: %s", fname,
strerror(errno)));
} else {
@ -1319,7 +1320,8 @@ do_open(Term file_name, Term t2,
#endif
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s", fname);
flags &= ~(Free_Stream_f);
if (!Yap_initStream(sno, fd, fname, file_name, encoding, flags, open_mode, vfsp))
if (!Yap_initStream(sno, fd, fname, file_name, encoding, flags, open_mode,
vfsp))
return false;
if (open_mode == AtomWrite) {
if (needs_bom && !write_bom(sno, st))
@ -1848,24 +1850,24 @@ static Int get_abs_file_parameter(USES_REGS1) {
void Yap_InitPlIO(struct yap_boot_params *argi) {
Int i;
if (argi->inp >0 )
Yap_stdin = fdopen(argi->inp-1, "r");
if (argi->inp > 0)
Yap_stdin = fdopen(argi->inp - 1, "r");
else if (argi->inp)
Yap_stdin = NULL;
Yap_stdin = NULL;
else
Yap_stdin = stdin;
if (argi->out >0 )
Yap_stdout = fdopen(argi->out-1, "a");
if (argi->out > 0)
Yap_stdout = fdopen(argi->out - 1, "a");
else if (argi->out)
Yap_stdout = NULL;
Yap_stdout = NULL;
else
Yap_stdout = stdout;
if (argi->err >0 )
Yap_stderr = fdopen(argi->err-1, "a");
Yap_stdout = stdout;
if (argi->err > 0)
Yap_stderr = fdopen(argi->err - 1, "a");
else if (argi->out)
Yap_stdout = NULL;
else
Yap_stderr = stderr;
Yap_stdout = NULL;
else
Yap_stderr = stderr;
GLOBAL_Stream =
(StreamDesc *)Yap_AllocCodeSpace(sizeof(StreamDesc) * MaxStreams);
for (i = 0; i < MaxStreams; ++i) {

View File

@ -238,7 +238,80 @@ static Term add_priority(Term t, Term tail) {
}
}
/**
static Term scanToList(TokEntry *tok, TokEntry *errtok)
{
TokEntry *tok0 = tok;
CELL *Hi = HR;
Term tf = TermNil;
Term *tailp = &tf;
while (tok)
{
if (HR > ASP - 1024)
{
Int used = HR-Hi;
/* for some reason moving this earlier confuses gcc on solaris */
HR = Hi;
tok = tok0;
if (!Yap_gcl(used, 1, ENV, CP))
{
return 0;
}
continue;
}
if (tok == errtok && tok->Tok != Error_tok)
{
*tailp = MkPairTerm(MkAtomTerm(AtomError), TermNil);
tailp = RepPair(*tailp) + 1;
}
Term rep = Yap_tokRep(tok);
*tailp = MkPairTerm(rep, TermNil);
tailp = RepPair(*tailp) + 1;
if (tok->TokNext)
{
tok = tok->TokNext;
}
}
return tf;
}
/**
@pred scan_to_list( +Stream, -Tokens )
Generate a list of tokens from a scan of the (input) stream, Tokens are of the form:
+ `atom`(Atom)
+ `<QQ>`(Text)
+ `number`(Number)
+ `var`(VarName)
+ `string`(String)
+ 'EOF''
+ symbols, including `(`, `)`, `,`, `;`
*/
static Int scan_to_list(USE_ARGS1)
{
int inp_stream;
Term tpos, tout;
/* needs to change LOCAL_output_stream for write */
inp_stream = Yap_CheckTextStream(ARG1, Input_Stream_f, "read/3");
if (inp_stream == -1)
{
return false;
}
TokEntry *tok = Yap_tokenizer(GLOBAL_Stream + inp_stream, false, &tpos);
UNLOCK(GLOBAL_Stream[inp_stream].streamlock);
tout = scanToList(tok, NULL);
if (tout == 0)
return false;
Yap_clean_tokenizer(tok, LOCAL_VarTable, LOCAL_AnonVarTable);
return Yap_unify(ARG1, tout);
}
/**
* Syntax Error Handler
*
* @par tokptr: the sequence of tokens
@ -247,74 +320,83 @@ static Term add_priority(Term t, Term tail) {
* Implicit arguments:
* +
*/
static Term syntax_error(TokEntry *errtok, int sno, Term cmod) {
CACHE_REGS
Term startline, errline, endline;
Term tf[3];
Term tm;
Term *tailp = tf + 2;
CELL *Hi = HR;
TokEntry *tok = LOCAL_tokptr;
Int cline = tok->TokPos;
static Term syntax_error(TokEntry * errtok, int sno, Term cmod)
{
CACHE_REGS
Term startline, errline, endline;
Term tf[3];
Term tm;
Term *tailp = tf + 2;
CELL *Hi = HR;
TokEntry *tok = LOCAL_tokptr;
Int cline = tok->TokPos;
startline = MkIntegerTerm(cline);
endline = MkIntegerTerm(cline);
if (errtok != LOCAL_toktide) {
errtok = LOCAL_toktide;
}
LOCAL_Error_TYPE = YAP_NO_ERROR;
errline = MkIntegerTerm(errtok->TokPos);
if (LOCAL_ErrorMessage)
tm = MkStringTerm(LOCAL_ErrorMessage);
else
tm = MkStringTerm("syntax error");
while (tok) {
startline = MkIntegerTerm(cline);
endline = MkIntegerTerm(cline);
if (errtok != LOCAL_toktide)
{
errtok = LOCAL_toktide;
}
LOCAL_Error_TYPE = YAP_NO_ERROR;
errline = MkIntegerTerm(errtok->TokPos);
if (LOCAL_ErrorMessage)
tm = MkStringTerm(LOCAL_ErrorMessage);
else
tm = MkStringTerm("syntax error");
while (tok)
{
if (HR > ASP - 1024) {
errline = MkIntegerTerm(0);
endline = MkIntegerTerm(0);
/* for some reason moving this earlier confuses gcc on solaris */
HR = Hi;
break;
}
if (tok->TokPos != cline) {
*tailp = MkPairTerm(TermNewLine, TermNil);
tailp = RepPair(*tailp) + 1;
cline = tok->TokPos;
}
if (tok == errtok && tok->Tok != Error_tok) {
*tailp = MkPairTerm(MkAtomTerm(AtomError), TermNil);
tailp = RepPair(*tailp) + 1;
}
Term rep = Yap_tokRep(tok);
if (tok->TokNext) {
tok = tok->TokNext;
} else {
endline = MkIntegerTerm(tok->TokPos);
tok = NULL;
break;
}
*tailp = MkPairTerm(rep, TermNil);
tailp = RepPair(*tailp) + 1;
}
{
Term t[3];
t[0] = startline;
t[1] = errline;
t[2] = endline;
tf[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomBetween, 3), 3, t);
}
/* 0: strat, error, end line */
/*2 msg */
/* 1: file */
tf[1] = Yap_StreamUserName(sno);
clean_vars(LOCAL_VarTable);
clean_vars(LOCAL_AnonVarTable);
Term terr = Yap_MkApplTerm(FunctorInfo3, 3, tf);
Term tn[2];
tn[0] = Yap_MkApplTerm(FunctorShortSyntaxError, 1, &tm);
tn[1] = terr;
terr = Yap_MkApplTerm(FunctorError, 2, tn);
if (HR > ASP - 1024)
{
errline = MkIntegerTerm(0);
endline = MkIntegerTerm(0);
/* for some reason moving this earlier confuses gcc on solaris */
HR = Hi;
break;
}
if (tok->TokPos != cline)
{
*tailp = MkPairTerm(TermNewLine, TermNil);
tailp = RepPair(*tailp) + 1;
cline = tok->TokPos;
}
if (tok == errtok && tok->Tok != Error_tok)
{
*tailp = MkPairTerm(MkAtomTerm(AtomError), TermNil);
tailp = RepPair(*tailp) + 1;
}
Term rep = Yap_tokRep(tok);
if (tok->TokNext)
{
tok = tok->TokNext;
}
else
{
endline = MkIntegerTerm(tok->TokPos);
tok = NULL;
break;
}
*tailp = MkPairTerm(rep, TermNil);
tailp = RepPair(*tailp) + 1;
}
{
Term t[3];
t[0] = startline;
t[1] = errline;
t[2] = endline;
tf[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomBetween, 3), 3, t);
}
/* 0: strat, error, end line */
/*2 msg */
/* 1: file */
tf[1] = Yap_StreamUserName(sno);
clean_vars(LOCAL_VarTable);
clean_vars(LOCAL_AnonVarTable);
Term terr = Yap_MkApplTerm(FunctorInfo3, 3, tf);
Term tn[2];
tn[0] = Yap_MkApplTerm(FunctorShortSyntaxError, 1, &tm);
tn[1] = terr;
terr = Yap_MkApplTerm(FunctorError, 2, tn);
#if DEBUG
if (Yap_ExecutionMode == YAP_BOOT_MODE) {
fprintf(stderr, "SYNTAX ERROR while booting: ");
@ -500,40 +582,33 @@ static void reset_regs(TokEntry *tokstart, FEnv *fe) {
static Term get_variables(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
Term v;
jmp_buf j;
LOCAL_IOBotch = &j;
if (fe->vp) {
while (true) {
fe->old_H = HR;
if (setjmp(j) == 0) {
if (setjmp(LOCAL_IOBotch) == 0) {
if ((v = Yap_Variables(LOCAL_VarTable, TermNil))) {
fe->old_H = HR;
LOCAL_IOBotch = NULL;
return v;
return v;
}
} else {
reset_regs(tokstart, fe);
}
}
}
LOCAL_IOBotch = NULL;
return 0;
}
static Term get_varnames(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
Term v;
jmp_buf j;
LOCAL_IOBotch = &j;
if (fe->np) {
while (true) {
fe->old_H = HR;
if (setjmp(j) == 0) {
if (setjmp(LOCAL_IOBotch) == 0) {
if ((v = Yap_VarNames(LOCAL_VarTable, TermNil))) {
fe->old_H = HR;
LOCAL_IOBotch = NULL;
return v;
}
} else {
@ -541,22 +616,18 @@ static Term get_varnames(FEnv *fe, TokEntry *tokstart) {
}
}
}
LOCAL_IOBotch = NULL;
return 0;
}
static Term get_singletons(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
Term v;
jmp_buf j;
LOCAL_IOBotch = &j;
if (fe->sp) {
while (TRUE) {
fe->old_H = HR;
if (setjmp(j) == 0) {
if (setjmp(LOCAL_IOBotch) == 0) {
if ((v = Yap_Singletons(LOCAL_VarTable, TermNil))) {
LOCAL_IOBotch = NULL;
return v;
}
} else {
@ -564,7 +635,6 @@ static Term get_singletons(FEnv *fe, TokEntry *tokstart) {
}
}
}
LOCAL_IOBotch = NULL;
return 0;
}
@ -593,15 +663,12 @@ static void warn_singletons(FEnv *fe, TokEntry *tokstart) {
static Term get_stream_position(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
Term v;
jmp_buf j;
LOCAL_IOBotch = &j;
if (fe->tp) {
while (true) {
fe->old_H = HR;
if (setjmp(j) == 0) {
if (setjmp(LOCAL_IOBotch) == 0) {
if ((v = CurrentPositionToTerm())) {
LOCAL_IOBotch = NULL;
return v;
}
} else {
@ -609,7 +676,6 @@ static Term get_stream_position(FEnv *fe, TokEntry *tokstart) {
}
}
}
LOCAL_IOBotch = NULL;
return 0;
}
@ -1491,6 +1557,7 @@ void Yap_InitReadTPreds(void) {
Yap_InitCPred("read_term", 2, read_term2, SyncPredFlag);
Yap_InitCPred("read_term", 3, read_term, SyncPredFlag);
Yap_InitCPred("scan_to_list", 2, scan_to_list, SyncPredFlag);
Yap_InitCPred("read", 1, read1, SyncPredFlag);
Yap_InitCPred("read", 2, read2, SyncPredFlag);
Yap_InitCPred("read_clause", 2, read_clause2, SyncPredFlag);

View File

@ -158,6 +158,10 @@ int Yap_GetFreeStreamD(void) { return GetFreeStreamD(); }
{
if (!(GLOBAL_Stream[sno].status & Tty_Stream_f))
return true;
if (GLOBAL_Stream[sno].vfs) {
GLOBAL_Stream[sno].vfs->flush(sno);
return true;
}
#if USE_READLINE
if (GLOBAL_Stream[sno].status & Readline_Stream_f)
return Yap_readline_clear_pending_input (GLOBAL_Stream+sno);
@ -173,6 +177,18 @@ int Yap_GetFreeStreamD(void) { return GetFreeStreamD(); }
return false;
}
bool Yap_flush(int sno)
{
if (!(GLOBAL_Stream[sno].status & Tty_Stream_f))
return true;
if (GLOBAL_Stream[sno].vfs) {
GLOBAL_Stream[sno].vfs->flush(sno);
return true;
}
return fflush(GLOBAL_Stream[sno].file) == 0;
}
static Int clear_input( USES_REGS1 )
{
int sno = Yap_CheckStream(ARG1, Input_Stream_f | Socket_Stream_f,
@ -954,12 +970,16 @@ static void CloseStream(int sno) {
Yap_CloseMemoryStream(sno);
}
GLOBAL_Stream[sno].status = Free_Stream_f;
GLOBAL_Stream[sno].vfs = NULL;
GLOBAL_Stream[sno].file = NULL;
Yap_DeleteAliases(sno);
if (LOCAL_c_input_stream == sno) {
LOCAL_c_input_stream = StdInStream;
} else if (LOCAL_c_output_stream == sno) {
}
if (LOCAL_c_output_stream == sno) {
LOCAL_c_output_stream = StdOutStream;
} else if (LOCAL_c_error_stream == sno) {
}
if (LOCAL_c_error_stream == sno) {
LOCAL_c_error_stream = StdErrStream;
}
/* if (st->status == Socket_Stream_f|Input_Stream_f|Output_Stream_f) {
@ -974,12 +994,16 @@ void Yap_ReleaseStream(int sno) {
CACHE_REGS
GLOBAL_Stream[sno].status = Free_Stream_f;
GLOBAL_Stream[sno].user_name = 0;
GLOBAL_Stream[sno].vfs = NULL;
GLOBAL_Stream[sno].file = NULL;
Yap_DeleteAliases(sno);
if (LOCAL_c_input_stream == sno) {
LOCAL_c_input_stream = StdInStream;
} else if (LOCAL_c_output_stream == sno) {
}
if (LOCAL_c_output_stream == sno) {
LOCAL_c_output_stream = StdOutStream;
} else if (LOCAL_c_error_stream == sno) {
}
if (LOCAL_c_error_stream == sno) {
LOCAL_c_error_stream = StdErrStream;
}
/* if (st->status == Socket_Stream_f|Input_Stream_f|Output_Stream_f) {
@ -1003,6 +1027,18 @@ static Int current_input(USES_REGS1) { /* current_input(?Stream) */
}
}
bool Yap_SetInputStream( Term sd )
{
int sno = Yap_CheckStream(sd, Input_Stream_f, "set_input/1");
if (sno < 0)
return false;
LOCAL_c_input_stream = sno;
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_SetAlias(AtomUserIn, sno);
return true;
}
/** @pred set_input(+ _S_) is iso
* Set stream _S_ as the current input stream. Predicates like read/1
* and get/1 will start using stream _S_ by default.
@ -1012,12 +1048,7 @@ static Int current_input(USES_REGS1) { /* current_input(?Stream) */
*
*/
static Int set_input(USES_REGS1) { /* '$show_stream_position'(+Stream,Pos) */
int sno = Yap_CheckStream(ARG1, Input_Stream_f, "set_input/1");
if (sno < 0)
return false;
LOCAL_c_input_stream = sno;
UNLOCK(GLOBAL_Stream[sno].streamlock);
return true;
return Yap_SetInputStream( ARG1 );
}
static Int current_output(USES_REGS1) { /* current_output(?Stream) */
@ -1035,6 +1066,30 @@ static Int current_output(USES_REGS1) { /* current_output(?Stream) */
}
}
bool Yap_SetOutputStream( Term sd )
{
int sno =
Yap_CheckStream(sd, Output_Stream_f | Append_Stream_f, "set_output/2");
if (sno < 0)
return false;
LOCAL_c_output_stream = sno;
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_SetAlias(AtomUserOut, sno);
return true;
}
bool Yap_SetErrorStream( Term sd )
{
int sno =
Yap_CheckStream(sd, Output_Stream_f | Append_Stream_f, "set_error/2");
if (sno < 0)
return false;
LOCAL_c_error_stream = sno;
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_SetAlias(AtomUserErr, sno);
return true;
}
/** @pred set_input(+ _S_) is iso
* Set stream _S_ as the current input stream. Predicates like read/1
* and get/1 will start using stream _S_ by default.
@ -1044,13 +1099,7 @@ static Int current_output(USES_REGS1) { /* current_output(?Stream) */
*
*/
static Int set_output(USES_REGS1) { /* '$show_stream_position'(+Stream,Pos) */
int sno =
Yap_CheckStream(ARG1, Output_Stream_f | Append_Stream_f, "set_output/2");
if (sno < 0)
return false;
LOCAL_c_output_stream = sno;
UNLOCK(GLOBAL_Stream[sno].streamlock);
return true;
return Yap_SetOutputStream( ARG1);
}

View File

@ -126,6 +126,8 @@ extern void Yap_plwrite(Term t, struct stream_desc *mywrite, int max_depth,
extern int Yap_CheckSocketStream(Term stream, const char *error);
extern void Yap_init_socks(char *host, long interface_port);
extern bool Yap_flush(int sno);
extern uint64_t HashFunction(const unsigned char *);
extern uint64_t WideHashFunction(wchar_t *);

View File

@ -764,12 +764,12 @@ number of steps.
'$yes_no'(G,(?-)).
'$query'(G,V) :-
(
'$current_choice_point'(CP),
'$current_module'(M),
'$user_call'(G, M),
'$current_choice_point'(NCP),
'$delayed_goals'(G, V, NV, LGs, DCP),
'$write_answer'(NV, LGs, Written),
'$current_module'(M),
'$current_choice_point'(CP),
'$user_call'(G, M),
'$current_choice_point'(NCP),
'$delayed_goals'(G, V, Vs, LGs, DCP),
'$write_answer'(Vs, LGs, Written),
'$write_query_answer_true'(Written),
(
'$prompt_alternatives_on'(determinism), CP == NCP, DCP = 0
@ -801,6 +801,13 @@ number of steps.
'$add_env_and_fail' :- fail.
'$process_answer'(Vs, LGs, Bindings) :-
'$purge_dontcares'(Vs,IVs),
'$sort'(IVs, NVs),
'$prep_answer_var_by_var'(NVs, LAnsw, LGs),
'$name_vars_in_goals'(LAnsw, Vs, Bindings).
%
% *-> at this point would require compiler support, which does not exist.
%
@ -901,12 +908,12 @@ number of steps.
flush_output,
fail.
'$write_answer'(Vs, LBlk, FLAnsw) :-
'$purge_dontcares'(Vs,IVs),
'$sort'(IVs, NVs),
'$prep_answer_var_by_var'(NVs, LAnsw, LBlk),
'$name_vars_in_goals'(LAnsw, Vs, NLAnsw),
'$process_answer'(Vs, LBlk, NLAnsw),
'$write_vars_and_goals'(NLAnsw, first, FLAnsw).
write_query_answer( Bindings ) :-
'$write_vars_and_goals'(Bindings, first, _FLAnsw).
'$purge_dontcares'([],[]).
'$purge_dontcares'([Name=_|Vs],NVs) :-
atom_codes(Name, [C|_]), C is "_", !,
@ -1555,8 +1562,8 @@ catch(G, C, A) :-
true
).
'$catch'(_,C,A) :-
nonvar(C),
'$run_catch'(A, C).
'$get_exception'(C),
'$run_catch'(A, C).
% variable throws are user-handled.
'$run_catch'(G,E) :-
@ -1578,8 +1585,8 @@ catch(G, C, A) :-
functor( E, N, _),
'$hidden_atom'(N), !,
throw(E).
'$run_catch'(E, _Signal) :-
call(E).
'$run_catch'( Signal, _E) :-
call( Signal ).
%
% throw has to be *exactly* after system catch!

View File

@ -291,6 +291,15 @@ setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup) :-
'$setup_call_catcher_cleanup'(Setup),
call_cleanup(Goal, Catcher, Cleanup).
gated_call(Setup, Goal, Catcher, Cleanup) :-
Task0 = cleanup( true, Catcher, Cleanup, Tag, true, Done),
TaskF = cleanup( true, Catcher, Cleanup, Tag, false, Done),
'$setup_call_catcher_cleanup'(Setup),
'$tag_cleanup'(CP0, Task0),
call( Goal ),
'$cleanup_on_exit'(CP0, TaskF).
/** @pred call_with_args(+ _Name_,...,? _Ai_,...)
@ -442,6 +451,22 @@ version(T) :-
fail.
'$set_toplevel_hook'(_).
query_to_answer(G, V, Status, Bindings) :-
gated_call( true, (G,'$delayed_goals'(G, V, Vs, LGs, _DCP)), Status, '$answer'( Status, LGs, Vs, Bindings) ).
'$answer'( exit, LGs, Vs, Bindings) :-
!,
'$process_answer'(Vs, LGs, Bindings).
'$answer'( answer, LGs, Vs, Bindings) :-
!,
'$process_answer'(Vs, LGs, Bindings).
'$answer'(cut, _, _, _).
'$answer'(fail,_,_,_).
'$answer'(exception(E),_,_,_) :-
'$LoopError'(E,error).
'$answer'(external_exception(_),_,_,_).
%% @}
%% @{

View File

@ -614,7 +614,8 @@ current_predicate(A,T0) :-
Defines the relation: indicator _P_ refers to a currently defined system predicate.
*/
system_predicate(P0) :-
'$yap_strip_module'(P0, M, P),
'$yap_strip_module'(P0, M0, P),
( M= M0 ; M0 \= user, M = user ; M0 \= prolog, M = prolog ),
(
var(P)
->