change macros GLOBAL to Yap
This commit is contained in:
@@ -7687,14 +7687,14 @@ Yap_absmi(int inp)
|
||||
{
|
||||
PredEntry *pt0;
|
||||
#ifdef THREADS
|
||||
LOCK(ThreadHandlesLock);
|
||||
LOCK(Yap_ThreadHandlesLock);
|
||||
#endif
|
||||
pt0 = SpyCode;
|
||||
P_before_spy = PREG;
|
||||
PREG = pt0->CodeOfPred;
|
||||
/* for profiler */
|
||||
#ifdef THREADS
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
#endif
|
||||
save_pc();
|
||||
CACHE_A1();
|
||||
|
8
C/agc.c
8
C/agc.c
@@ -384,7 +384,7 @@ clean_atom_list(AtomHashEntry *HashPtr)
|
||||
AtomEntry *at = RepAtom(atm);
|
||||
if (AtomResetMark(at) ||
|
||||
at->PropsOfAE != NIL ||
|
||||
(AGCHook != NULL && !AGCHook(atm))) {
|
||||
(Yap_AGCHook != NULL && !Yap_AGCHook(atm))) {
|
||||
patm = &(at->NextOfAE);
|
||||
atm = at->NextOfAE;
|
||||
} else {
|
||||
@@ -463,7 +463,7 @@ atom_gc(USES_REGS1)
|
||||
mark_stacks(PASS_REGS1);
|
||||
restore_codes();
|
||||
clean_atoms();
|
||||
AGcLastCall = NOfAtoms;
|
||||
Yap_AGcLastCall = NOfAtoms;
|
||||
YAPLeaveCriticalSection();
|
||||
agc_time = Yap_cputime()-time_start;
|
||||
tot_agc_time += agc_time;
|
||||
@@ -511,7 +511,7 @@ p_agc_threshold(USES_REGS1)
|
||||
{
|
||||
Term t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
return Yap_unify(ARG1, MkIntegerTerm(AGcThreshold));
|
||||
return Yap_unify(ARG1, MkIntegerTerm(Yap_AGcThreshold));
|
||||
} else if (!IsIntegerTerm(t)) {
|
||||
Yap_Error(TYPE_ERROR_INTEGER,t,"prolog_flag/2 agc_margin");
|
||||
return FALSE;
|
||||
@@ -521,7 +521,7 @@ p_agc_threshold(USES_REGS1)
|
||||
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t,"prolog_flag/2 agc_margin");
|
||||
return FALSE;
|
||||
} else {
|
||||
AGcThreshold = i;
|
||||
Yap_AGcThreshold = i;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@@ -704,8 +704,8 @@ AllocHeap(unsigned long int size)
|
||||
UNLOCK(HeapTopLock);
|
||||
Yap_signal(YAP_CDOVF_SIGNAL);
|
||||
} else {
|
||||
if (size > SizeOfOverflow)
|
||||
SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE);
|
||||
if (size > Yap_SizeOfOverflow)
|
||||
Yap_SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE);
|
||||
/* big allocations, the caller must handle the problem */
|
||||
UNLOCK(HeapUsedLock);
|
||||
UNLOCK(HeapTopLock);
|
||||
|
@@ -2828,7 +2828,7 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
#ifdef TABLING
|
||||
/* make sure we initialise this field */
|
||||
GLOBAL_root_dep_fr = NULL;
|
||||
Yap_root_dep_fr = NULL;
|
||||
#endif
|
||||
make_root_frames();
|
||||
#ifdef YAPOR
|
||||
@@ -3300,8 +3300,8 @@ YAP_AtomReleaseHold(Atom at)
|
||||
X_API Agc_hook
|
||||
YAP_AGCRegisterHook(Agc_hook hook)
|
||||
{
|
||||
Agc_hook old = AGCHook;
|
||||
AGCHook = hook;
|
||||
Agc_hook old = Yap_AGCHook;
|
||||
Yap_AGCHook = hook;
|
||||
return old;
|
||||
}
|
||||
|
||||
@@ -3537,9 +3537,9 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
|
||||
return TRUE;
|
||||
case YAPC_ENABLE_AGC:
|
||||
if (val) {
|
||||
AGcThreshold = 10000;
|
||||
Yap_AGcThreshold = 10000;
|
||||
} else {
|
||||
AGcThreshold = 0;
|
||||
Yap_AGcThreshold = 0;
|
||||
}
|
||||
return TRUE;
|
||||
default:
|
||||
|
@@ -212,8 +212,8 @@ yapsbrk(long size)
|
||||
UNLOCK(HeapTopLock);
|
||||
Yap_signal(YAP_CDOVF_SIGNAL);
|
||||
} else {
|
||||
if (size > SizeOfOverflow)
|
||||
SizeOfOverflow = size;
|
||||
if (size > Yap_SizeOfOverflow)
|
||||
Yap_SizeOfOverflow = size;
|
||||
/* big allocations, the caller must handle the problem */
|
||||
UNLOCK(HeapUsedLock);
|
||||
UNLOCK(HeapTopLock);
|
||||
|
10
C/grow.c
10
C/grow.c
@@ -1256,10 +1256,10 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
|
||||
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running");
|
||||
return FALSE;
|
||||
#endif
|
||||
if (SizeOfOverflow > sz) {
|
||||
if (Yap_SizeOfOverflow > sz) {
|
||||
if (size < YAP_ALLOC_SIZE)
|
||||
size = YAP_ALLOC_SIZE;
|
||||
sz = AdjustPageSize(SizeOfOverflow);
|
||||
sz = AdjustPageSize(Yap_SizeOfOverflow);
|
||||
}
|
||||
while(sz >= sizeof(CELL) * K16 && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep PASS_REGS)) {
|
||||
size = size/2;
|
||||
@@ -1401,7 +1401,7 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
|
||||
|
||||
if (NOfAtoms > 2*AtomHashTableSize) {
|
||||
UInt n = NOfAtoms;
|
||||
if (AGcThreshold)
|
||||
if (Yap_AGcThreshold)
|
||||
Yap_atom_gc( PASS_REGS1 );
|
||||
/* check if we have a significant improvement from agc */
|
||||
if (n > NOfAtoms+ NOfAtoms/10 ||
|
||||
@@ -1442,12 +1442,12 @@ Yap_growglobal(CELL **ptr)
|
||||
unsigned long sz = sizeof(CELL) * K16;
|
||||
|
||||
#if defined(YAPOR) && !defined(THREADS)
|
||||
if (number_workers != 1) {
|
||||
if (Yap_number_workers != 1) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#elif defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
if (Yap_NOfThreads != 1) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
|
4
C/init.c
4
C/init.c
@@ -1392,10 +1392,10 @@ Yap_HaltRegisterHook (HaltHookFunc f, void * env)
|
||||
return FALSE;
|
||||
h->environment = env;
|
||||
h->hook = f;
|
||||
LOCK(BGL);
|
||||
LOCK(Yap_BGL);
|
||||
h->next = Yap_HaltHooks;
|
||||
Yap_HaltHooks = h;
|
||||
UNLOCK(BGL);
|
||||
UNLOCK(Yap_BGL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
8
C/save.c
8
C/save.c
@@ -614,13 +614,13 @@ p_save2( USES_REGS1 )
|
||||
|
||||
Term t;
|
||||
#if defined(YAPOR) && !defined(THREADS)
|
||||
if (number_workers != 1) {
|
||||
if (Yap_number_workers != 1) {
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,
|
||||
"cannot perform save: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#elif defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
if (Yap_NOfThreads != 1) {
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,
|
||||
"cannot perform save: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
@@ -1792,12 +1792,12 @@ p_restore( USES_REGS1 )
|
||||
|
||||
Term t1 = Deref(ARG1);
|
||||
#if defined(YAPOR) && !defined(THREADS)
|
||||
if (number_workers != 1) {
|
||||
if (Yap_number_workers != 1) {
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
#elif defined(THREADS)
|
||||
if (NOfThreads != 1) {
|
||||
if (Yap_NOfThreads != 1) {
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
|
||||
return(FALSE);
|
||||
}
|
||||
|
18
C/stdpreds.c
18
C/stdpreds.c
@@ -3832,49 +3832,49 @@ p_set_yap_flags( USES_REGS1 )
|
||||
#ifdef TABLING
|
||||
case TABLING_MODE_FLAG:
|
||||
if (value == 0) { /* default */
|
||||
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
|
||||
tab_ent_ptr tab_ent = Yap_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
TabEnt_mode(tab_ent) = TabEnt_flags(tab_ent);
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
yap_flags[TABLING_MODE_FLAG] = 0;
|
||||
} else if (value == 1) { /* batched */
|
||||
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
|
||||
tab_ent_ptr tab_ent = Yap_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
SetMode_Batched(TabEnt_mode(tab_ent));
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
SetMode_Batched(yap_flags[TABLING_MODE_FLAG]);
|
||||
} else if (value == 2) { /* local */
|
||||
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
|
||||
tab_ent_ptr tab_ent = Yap_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
SetMode_Local(TabEnt_mode(tab_ent));
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
SetMode_Local(yap_flags[TABLING_MODE_FLAG]);
|
||||
} else if (value == 3) { /* exec_answers */
|
||||
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
|
||||
tab_ent_ptr tab_ent = Yap_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
SetMode_ExecAnswers(TabEnt_mode(tab_ent));
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
SetMode_ExecAnswers(yap_flags[TABLING_MODE_FLAG]);
|
||||
} else if (value == 4) { /* load_answers */
|
||||
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
|
||||
tab_ent_ptr tab_ent = Yap_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
SetMode_LoadAnswers(TabEnt_mode(tab_ent));
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
SetMode_LoadAnswers(yap_flags[TABLING_MODE_FLAG]);
|
||||
} else if (value == 5) { /* local_trie */
|
||||
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
|
||||
tab_ent_ptr tab_ent = Yap_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
SetMode_LocalTrie(TabEnt_mode(tab_ent));
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
SetMode_LocalTrie(yap_flags[TABLING_MODE_FLAG]);
|
||||
} else if (value == 6) { /* global_trie */
|
||||
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
|
||||
tab_ent_ptr tab_ent = Yap_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
SetMode_GlobalTrie(TabEnt_mode(tab_ent));
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
@@ -3913,14 +3913,14 @@ p_system_mode( USES_REGS1 )
|
||||
static Int
|
||||
p_lock_system( USES_REGS1 )
|
||||
{
|
||||
LOCK(BGL);
|
||||
LOCK(Yap_BGL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_unlock_system( USES_REGS1 )
|
||||
{
|
||||
UNLOCK(BGL);
|
||||
UNLOCK(Yap_BGL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
38
C/threads.c
38
C/threads.c
@@ -51,7 +51,7 @@ static int
|
||||
allocate_new_tid(void)
|
||||
{
|
||||
int new_worker_id = 0;
|
||||
LOCK(ThreadHandlesLock);
|
||||
LOCK(Yap_ThreadHandlesLock);
|
||||
while(new_worker_id < MAX_THREADS &&
|
||||
Yap_WLocal[new_worker_id] &&
|
||||
(FOREIGN_ThreadHandle(new_worker_id).in_use == TRUE ||
|
||||
@@ -73,7 +73,7 @@ allocate_new_tid(void)
|
||||
} else {
|
||||
new_worker_id = -1;
|
||||
}
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
return new_worker_id;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ kill_thread_engine (int wid, int always_die)
|
||||
free(FOREIGN_ThreadHandle(wid).start_of_timesp);
|
||||
free(FOREIGN_ThreadHandle(wid).last_timep);
|
||||
Yap_FreeCodeSpace((ADDR)FOREIGN_ThreadHandle(wid).texit);
|
||||
LOCK(ThreadHandlesLock);
|
||||
LOCK(Yap_ThreadHandlesLock);
|
||||
if (FOREIGN_ThreadHandle(wid).tdetach == MkAtomTerm(AtomTrue) ||
|
||||
always_die) {
|
||||
FOREIGN_ThreadHandle(wid).zombie = FALSE;
|
||||
@@ -155,7 +155,7 @@ kill_thread_engine (int wid, int always_die)
|
||||
DEBUG_TLOCK_ACCESS(1, wid);
|
||||
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
|
||||
}
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -163,7 +163,7 @@ thread_die(int wid, int always_die)
|
||||
{
|
||||
if (!always_die) {
|
||||
/* called by thread itself */
|
||||
ThreadsTotalTime += Yap_cputime();
|
||||
Yap_ThreadsTotalTime += Yap_cputime();
|
||||
}
|
||||
kill_thread_engine(wid, always_die);
|
||||
}
|
||||
@@ -194,7 +194,7 @@ setup_engine(int myworker_id, int init_thread)
|
||||
#endif
|
||||
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
|
||||
/* I exist */
|
||||
NOfThreadsCreated++;
|
||||
Yap_NOfThreadsCreated++;
|
||||
DEBUG_TLOCK_ACCESS(2, myworker_id);
|
||||
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(myworker_id).tlock));
|
||||
}
|
||||
@@ -487,17 +487,17 @@ p_thread_join( USES_REGS1 )
|
||||
{
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
LOCK(ThreadHandlesLock);
|
||||
LOCK(Yap_ThreadHandlesLock);
|
||||
if (!FOREIGN_ThreadHandle(tid).in_use &&
|
||||
!FOREIGN_ThreadHandle(tid).zombie) {
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
return FALSE;
|
||||
}
|
||||
if (!FOREIGN_ThreadHandle(tid).tdetach == MkAtomTerm(AtomTrue)) {
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
return FALSE;
|
||||
}
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
/* make sure this lock is accessible */
|
||||
if (pthread_join(FOREIGN_ThreadHandle(tid).pthread_handle, NULL) < 0) {
|
||||
/* ERROR */
|
||||
@@ -512,12 +512,12 @@ p_thread_destroy( USES_REGS1 )
|
||||
{
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
LOCK(ThreadHandlesLock);
|
||||
LOCK(Yap_ThreadHandlesLock);
|
||||
FOREIGN_ThreadHandle(tid).zombie = FALSE;
|
||||
FOREIGN_ThreadHandle(tid).in_use = FALSE;
|
||||
DEBUG_TLOCK_ACCESS(32, tid);
|
||||
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(tid).tlock));
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -753,16 +753,16 @@ p_thread_stacks( USES_REGS1 )
|
||||
Int tid = IntegerOfTerm(Deref(ARG1));
|
||||
Int status= TRUE;
|
||||
|
||||
LOCK(ThreadHandlesLock);
|
||||
LOCK(Yap_ThreadHandlesLock);
|
||||
if (!FOREIGN_ThreadHandle(tid).in_use &&
|
||||
!FOREIGN_ThreadHandle(tid).zombie) {
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
return FALSE;
|
||||
}
|
||||
status &= Yap_unify(ARG2,MkIntegerTerm(FOREIGN_ThreadHandle(tid).ssize));
|
||||
status &= Yap_unify(ARG3,MkIntegerTerm(FOREIGN_ThreadHandle(tid).tsize));
|
||||
status &= Yap_unify(ARG4,MkIntegerTerm(FOREIGN_ThreadHandle(tid).sysize));
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -834,13 +834,13 @@ static Int
|
||||
p_nof_threads( USES_REGS1 )
|
||||
{ /* '$nof_threads'(+P) */
|
||||
int i = 0, wid;
|
||||
LOCK(ThreadHandlesLock);
|
||||
LOCK(Yap_ThreadHandlesLock);
|
||||
for (wid = 0; wid < MAX_THREADS; wid++) {
|
||||
if (!Yap_WLocal[wid]) break;
|
||||
if (FOREIGN_ThreadHandle(wid).in_use)
|
||||
i++;
|
||||
}
|
||||
UNLOCK(ThreadHandlesLock);
|
||||
UNLOCK(Yap_ThreadHandlesLock);
|
||||
return Yap_unify(ARG1,MkIntegerTerm(i));
|
||||
}
|
||||
|
||||
@@ -859,13 +859,13 @@ p_max_threads( USES_REGS1 )
|
||||
static Int
|
||||
p_nof_threads_created( USES_REGS1 )
|
||||
{ /* '$nof_threads'(+P) */
|
||||
return Yap_unify(ARG1,MkIntTerm(NOfThreadsCreated));
|
||||
return Yap_unify(ARG1,MkIntTerm(Yap_NOfThreadsCreated));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_thread_runtime( USES_REGS1 )
|
||||
{ /* '$thread_runtime'(+P) */
|
||||
return Yap_unify(ARG1,MkIntegerTerm(ThreadsTotalTime));
|
||||
return Yap_unify(ARG1,MkIntegerTerm(Yap_ThreadsTotalTime));
|
||||
}
|
||||
|
||||
static Int
|
||||
|
Reference in New Issue
Block a user