change macros in misc/GLOBALS to GLOBAL_.

This commit is contained in:
Joao 2011-05-10 10:06:51 +01:00
parent bbf83cb34d
commit 676dd26c90
15 changed files with 120 additions and 120 deletions

View File

@ -7711,14 +7711,14 @@ Yap_absmi(int inp)
{ {
PredEntry *pt0; PredEntry *pt0;
#ifdef THREADS #ifdef THREADS
LOCK(Yap_ThreadHandlesLock); LOCK(GLOBAL_ThreadHandlesLock);
#endif #endif
pt0 = SpyCode; pt0 = SpyCode;
P_before_spy = PREG; P_before_spy = PREG;
PREG = pt0->CodeOfPred; PREG = pt0->CodeOfPred;
/* for profiler */ /* for profiler */
#ifdef THREADS #ifdef THREADS
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
#endif #endif
save_pc(); save_pc();
CACHE_A1(); CACHE_A1();

View File

@ -384,7 +384,7 @@ clean_atom_list(AtomHashEntry *HashPtr)
AtomEntry *at = RepAtom(atm); AtomEntry *at = RepAtom(atm);
if (AtomResetMark(at) || if (AtomResetMark(at) ||
at->PropsOfAE != NIL || at->PropsOfAE != NIL ||
(Yap_AGCHook != NULL && !Yap_AGCHook(atm))) { (GLOBAL_AGCHook != NULL && !GLOBAL_AGCHook(atm))) {
patm = &(at->NextOfAE); patm = &(at->NextOfAE);
atm = at->NextOfAE; atm = at->NextOfAE;
} else { } else {
@ -463,7 +463,7 @@ atom_gc(USES_REGS1)
mark_stacks(PASS_REGS1); mark_stacks(PASS_REGS1);
restore_codes(); restore_codes();
clean_atoms(); clean_atoms();
Yap_AGcLastCall = NOfAtoms; GLOBAL_AGcLastCall = NOfAtoms;
YAPLeaveCriticalSection(); YAPLeaveCriticalSection();
agc_time = Yap_cputime()-time_start; agc_time = Yap_cputime()-time_start;
tot_agc_time += agc_time; tot_agc_time += agc_time;
@ -511,7 +511,7 @@ p_agc_threshold(USES_REGS1)
{ {
Term t = Deref(ARG1); Term t = Deref(ARG1);
if (IsVarTerm(t)) { if (IsVarTerm(t)) {
return Yap_unify(ARG1, MkIntegerTerm(Yap_AGcThreshold)); return Yap_unify(ARG1, MkIntegerTerm(GLOBAL_AGcThreshold));
} else if (!IsIntegerTerm(t)) { } else if (!IsIntegerTerm(t)) {
Yap_Error(TYPE_ERROR_INTEGER,t,"prolog_flag/2 agc_margin"); Yap_Error(TYPE_ERROR_INTEGER,t,"prolog_flag/2 agc_margin");
return FALSE; 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"); Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t,"prolog_flag/2 agc_margin");
return FALSE; return FALSE;
} else { } else {
Yap_AGcThreshold = i; GLOBAL_AGcThreshold = i;
return TRUE; return TRUE;
} }
} }

View File

@ -703,8 +703,8 @@ AllocHeap(unsigned long int size)
UNLOCK(HeapTopLock); UNLOCK(HeapTopLock);
Yap_signal(YAP_CDOVF_SIGNAL); Yap_signal(YAP_CDOVF_SIGNAL);
} else { } else {
if (size > Yap_SizeOfOverflow) if (size > GLOBAL_SizeOfOverflow)
Yap_SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE); GLOBAL_SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE);
/* big allocations, the caller must handle the problem */ /* big allocations, the caller must handle the problem */
UNLOCK(HeapUsedLock); UNLOCK(HeapUsedLock);
UNLOCK(HeapTopLock); UNLOCK(HeapTopLock);

View File

@ -2781,9 +2781,9 @@ YAP_Init(YAP_init_args *yap_init)
LOCAL_ThreadHandle.ssize = Trail+Stack; LOCAL_ThreadHandle.ssize = Trail+Stack;
#endif #endif
#endif #endif
Yap_AllowGlobalExpansion = TRUE; GLOBAL_AllowGlobalExpansion = TRUE;
Yap_AllowLocalExpansion = TRUE; GLOBAL_AllowLocalExpansion = TRUE;
Yap_AllowTrailExpansion = TRUE; GLOBAL_AllowTrailExpansion = TRUE;
Yap_InitExStacks (Trail, Stack); Yap_InitExStacks (Trail, Stack);
if (yap_init->QuietMode) { if (yap_init->QuietMode) {
yap_flags[QUIET_MODE_FLAG] = TRUE; yap_flags[QUIET_MODE_FLAG] = TRUE;
@ -2849,19 +2849,19 @@ YAP_Init(YAP_init_args *yap_init)
} }
/* make sure we do this after restore */ /* make sure we do this after restore */
if (yap_init->MaxStackSize) { if (yap_init->MaxStackSize) {
Yap_AllowLocalExpansion = FALSE; GLOBAL_AllowLocalExpansion = FALSE;
} else { } else {
Yap_AllowLocalExpansion = TRUE; GLOBAL_AllowLocalExpansion = TRUE;
} }
if (yap_init->MaxGlobalSize) { if (yap_init->MaxGlobalSize) {
Yap_AllowGlobalExpansion = FALSE; GLOBAL_AllowGlobalExpansion = FALSE;
} else { } else {
Yap_AllowGlobalExpansion = TRUE; GLOBAL_AllowGlobalExpansion = TRUE;
} }
if (yap_init->MaxTrailSize) { if (yap_init->MaxTrailSize) {
Yap_AllowTrailExpansion = FALSE; GLOBAL_AllowTrailExpansion = FALSE;
} else { } else {
Yap_AllowTrailExpansion = TRUE; GLOBAL_AllowTrailExpansion = TRUE;
} }
if (yap_init->YapPrologRCFile) { if (yap_init->YapPrologRCFile) {
Yap_PutValue(AtomConsultOnBoot, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile))); Yap_PutValue(AtomConsultOnBoot, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile)));
@ -3029,7 +3029,7 @@ YAP_Reset(void)
} }
/* reinitialise the engine */ /* reinitialise the engine */
Yap_InitYaamRegs(); Yap_InitYaamRegs();
Yap_Initialised = TRUE; GLOBAL_Initialised = TRUE;
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return(TRUE); return(TRUE);
@ -3290,8 +3290,8 @@ YAP_AtomReleaseHold(Atom at)
X_API Agc_hook X_API Agc_hook
YAP_AGCRegisterHook(Agc_hook hook) YAP_AGCRegisterHook(Agc_hook hook)
{ {
Agc_hook old = Yap_AGCHook; Agc_hook old = GLOBAL_AGCHook;
Yap_AGCHook = hook; GLOBAL_AGCHook = hook;
return old; return old;
} }
@ -3527,9 +3527,9 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
return TRUE; return TRUE;
case YAPC_ENABLE_AGC: case YAPC_ENABLE_AGC:
if (val) { if (val) {
Yap_AGcThreshold = 10000; GLOBAL_AGcThreshold = 10000;
} else { } else {
Yap_AGcThreshold = 0; GLOBAL_AGcThreshold = 0;
} }
return TRUE; return TRUE;
default: default:

View File

@ -212,8 +212,8 @@ yapsbrk(long size)
UNLOCK(HeapTopLock); UNLOCK(HeapTopLock);
Yap_signal(YAP_CDOVF_SIGNAL); Yap_signal(YAP_CDOVF_SIGNAL);
} else { } else {
if (size > Yap_SizeOfOverflow) if (size > GLOBAL_SizeOfOverflow)
Yap_SizeOfOverflow = size; GLOBAL_SizeOfOverflow = size;
/* big allocations, the caller must handle the problem */ /* big allocations, the caller must handle the problem */
UNLOCK(HeapUsedLock); UNLOCK(HeapUsedLock);
UNLOCK(HeapTopLock); UNLOCK(HeapTopLock);

View File

@ -903,12 +903,12 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
Yap_PrologMode |= GrowStackMode; Yap_PrologMode |= GrowStackMode;
start_growth_time = Yap_cputime(); start_growth_time = Yap_cputime();
if (do_grow) { if (do_grow) {
if (!Yap_AllowGlobalExpansion) { if (!GLOBAL_AllowGlobalExpansion) {
Yap_ErrorMessage = "Global Stack crashed against Local Stack"; Yap_ErrorMessage = "Global Stack crashed against Local Stack";
LeaveGrowMode(GrowStackMode); LeaveGrowMode(GrowStackMode);
return 0; return 0;
} }
if (!Yap_AllowGlobalExpansion || !Yap_ExtendWorkSpace(size)) { if (!GLOBAL_AllowGlobalExpansion || !Yap_ExtendWorkSpace(size)) {
/* always fails when using malloc */ /* always fails when using malloc */
Yap_ErrorMessage = NULL; Yap_ErrorMessage = NULL;
size += AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap); size += AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap);
@ -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"); Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running");
return FALSE; return FALSE;
#endif #endif
if (Yap_SizeOfOverflow > sz) { if (GLOBAL_SizeOfOverflow > sz) {
if (size < YAP_ALLOC_SIZE) if (size < YAP_ALLOC_SIZE)
size = YAP_ALLOC_SIZE; size = YAP_ALLOC_SIZE;
sz = AdjustPageSize(Yap_SizeOfOverflow); sz = AdjustPageSize(GLOBAL_SizeOfOverflow);
} }
while(sz >= sizeof(CELL) * K16 && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep PASS_REGS)) { while(sz >= sizeof(CELL) * K16 && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep PASS_REGS)) {
size = size/2; size = size/2;
@ -1401,7 +1401,7 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
if (NOfAtoms > 2*AtomHashTableSize) { if (NOfAtoms > 2*AtomHashTableSize) {
UInt n = NOfAtoms; UInt n = NOfAtoms;
if (Yap_AGcThreshold) if (GLOBAL_AGcThreshold)
Yap_atom_gc( PASS_REGS1 ); Yap_atom_gc( PASS_REGS1 );
/* check if we have a significant improvement from agc */ /* check if we have a significant improvement from agc */
if (n > NOfAtoms+ NOfAtoms/10 || if (n > NOfAtoms+ NOfAtoms/10 ||
@ -1447,7 +1447,7 @@ Yap_growglobal(CELL **ptr)
return(FALSE); return(FALSE);
} }
#elif defined(THREADS) #elif defined(THREADS)
if (Yap_NOfThreads != 1) { if (GLOBAL_NOfThreads != 1) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running"); Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
return(FALSE); return(FALSE);
} }
@ -1493,7 +1493,7 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
long size = size0; long size = size0;
ADDR old_Yap_GlobalBase = Yap_GlobalBase; ADDR old_Yap_GlobalBase = Yap_GlobalBase;
if (!Yap_AllowGlobalExpansion) { if (!GLOBAL_AllowGlobalExpansion) {
Yap_ErrorMessage = "Database crashed against stacks"; Yap_ErrorMessage = "Database crashed against stacks";
return FALSE; return FALSE;
} }
@ -1703,7 +1703,7 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
fprintf(Yap_stderr, "%% growing the trail %ld bytes\n", size); fprintf(Yap_stderr, "%% growing the trail %ld bytes\n", size);
} }
Yap_ErrorMessage = NULL; Yap_ErrorMessage = NULL;
if (!Yap_AllowTrailExpansion) { if (!GLOBAL_AllowTrailExpansion) {
Yap_ErrorMessage = "Trail Overflow"; Yap_ErrorMessage = "Trail Overflow";
return FALSE; return FALSE;
} }

View File

@ -1447,17 +1447,17 @@ Yap_HaltRegisterHook (HaltHookFunc f, void * env)
return FALSE; return FALSE;
h->environment = env; h->environment = env;
h->hook = f; h->hook = f;
LOCK(Yap_BGL); LOCK(GLOBAL_BGL);
h->next = Yap_HaltHooks; h->next = GLOBAL_HaltHooks;
Yap_HaltHooks = h; GLOBAL_HaltHooks = h;
UNLOCK(Yap_BGL); UNLOCK(GLOBAL_BGL);
return TRUE; return TRUE;
} }
static void static void
run_halt_hooks(int code) run_halt_hooks(int code)
{ {
struct halt_hook *hooke = Yap_HaltHooks; struct halt_hook *hooke = GLOBAL_HaltHooks;
while (hooke) { while (hooke) {
hooke->hook(code, hooke->environment); hooke->hook(code, hooke->environment);

View File

@ -623,7 +623,7 @@ p_save2( USES_REGS1 )
} }
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef THREADS #ifdef THREADS
if (Yap_NOfThreads != 1) { if (GLOBAL_NOfThreads != 1) {
Yap_Error(SYSTEM_ERROR,TermNil, Yap_Error(SYSTEM_ERROR,TermNil,
"cannot perform save: more than a worker/thread running"); "cannot perform save: more than a worker/thread running");
return(FALSE); return(FALSE);
@ -1802,7 +1802,7 @@ p_restore( USES_REGS1 )
} }
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef THREADS #ifdef THREADS
if (Yap_NOfThreads != 1) { if (GLOBAL_NOfThreads != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running"); Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
return(FALSE); return(FALSE);
} }

View File

@ -3913,14 +3913,14 @@ p_system_mode( USES_REGS1 )
static Int static Int
p_lock_system( USES_REGS1 ) p_lock_system( USES_REGS1 )
{ {
LOCK(Yap_BGL); LOCK(GLOBAL_BGL);
return TRUE; return TRUE;
} }
static Int static Int
p_unlock_system( USES_REGS1 ) p_unlock_system( USES_REGS1 )
{ {
UNLOCK(Yap_BGL); UNLOCK(GLOBAL_BGL);
return TRUE; return TRUE;
} }

View File

@ -50,7 +50,7 @@ static int
allocate_new_tid(void) allocate_new_tid(void)
{ {
int new_worker_id = 0; int new_worker_id = 0;
LOCK(Yap_ThreadHandlesLock); LOCK(GLOBAL_ThreadHandlesLock);
while(new_worker_id < MAX_THREADS && while(new_worker_id < MAX_THREADS &&
Yap_local[new_worker_id] && Yap_local[new_worker_id] &&
(REMOTE_ThreadHandle(new_worker_id).in_use == TRUE || (REMOTE_ThreadHandle(new_worker_id).in_use == TRUE ||
@ -72,7 +72,7 @@ allocate_new_tid(void)
} else { } else {
new_worker_id = -1; new_worker_id = -1;
} }
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
return new_worker_id; return new_worker_id;
} }
@ -146,7 +146,7 @@ kill_thread_engine (int wid, int always_die)
free(REMOTE_ThreadHandle(wid).start_of_timesp); free(REMOTE_ThreadHandle(wid).start_of_timesp);
free(REMOTE_ThreadHandle(wid).last_timep); free(REMOTE_ThreadHandle(wid).last_timep);
Yap_FreeCodeSpace((ADDR)REMOTE_ThreadHandle(wid).texit); Yap_FreeCodeSpace((ADDR)REMOTE_ThreadHandle(wid).texit);
LOCK(Yap_ThreadHandlesLock); LOCK(GLOBAL_ThreadHandlesLock);
if (REMOTE_ThreadHandle(wid).tdetach == MkAtomTerm(AtomTrue) || if (REMOTE_ThreadHandle(wid).tdetach == MkAtomTerm(AtomTrue) ||
always_die) { always_die) {
REMOTE_ThreadHandle(wid).zombie = FALSE; REMOTE_ThreadHandle(wid).zombie = FALSE;
@ -154,7 +154,7 @@ kill_thread_engine (int wid, int always_die)
DEBUG_TLOCK_ACCESS(1, wid); DEBUG_TLOCK_ACCESS(1, wid);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock)); pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
} }
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
} }
static void static void
@ -162,7 +162,7 @@ thread_die(int wid, int always_die)
{ {
if (!always_die) { if (!always_die) {
/* called by thread itself */ /* called by thread itself */
Yap_ThreadsTotalTime += Yap_cputime(); GLOBAL_ThreadsTotalTime += Yap_cputime();
} }
kill_thread_engine(wid, always_die); kill_thread_engine(wid, always_die);
} }
@ -188,7 +188,7 @@ setup_engine(int myworker_id, int init_thread)
Yap_InitYaamRegs(); Yap_InitYaamRegs();
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace()); Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
/* I exist */ /* I exist */
Yap_NOfThreadsCreated++; GLOBAL_NOfThreadsCreated++;
DEBUG_TLOCK_ACCESS(2, myworker_id); DEBUG_TLOCK_ACCESS(2, myworker_id);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(myworker_id).tlock)); pthread_mutex_unlock(&(REMOTE_ThreadHandle(myworker_id).tlock));
} }
@ -481,17 +481,17 @@ p_thread_join( USES_REGS1 )
{ {
Int tid = IntegerOfTerm(Deref(ARG1)); Int tid = IntegerOfTerm(Deref(ARG1));
LOCK(Yap_ThreadHandlesLock); LOCK(GLOBAL_ThreadHandlesLock);
if (!REMOTE_ThreadHandle(tid).in_use && if (!REMOTE_ThreadHandle(tid).in_use &&
!REMOTE_ThreadHandle(tid).zombie) { !REMOTE_ThreadHandle(tid).zombie) {
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE; return FALSE;
} }
if (!REMOTE_ThreadHandle(tid).tdetach == MkAtomTerm(AtomTrue)) { if (!REMOTE_ThreadHandle(tid).tdetach == MkAtomTerm(AtomTrue)) {
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE; return FALSE;
} }
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
/* make sure this lock is accessible */ /* make sure this lock is accessible */
if (pthread_join(REMOTE_ThreadHandle(tid).pthread_handle, NULL) < 0) { if (pthread_join(REMOTE_ThreadHandle(tid).pthread_handle, NULL) < 0) {
/* ERROR */ /* ERROR */
@ -506,12 +506,12 @@ p_thread_destroy( USES_REGS1 )
{ {
Int tid = IntegerOfTerm(Deref(ARG1)); Int tid = IntegerOfTerm(Deref(ARG1));
LOCK(Yap_ThreadHandlesLock); LOCK(GLOBAL_ThreadHandlesLock);
REMOTE_ThreadHandle(tid).zombie = FALSE; REMOTE_ThreadHandle(tid).zombie = FALSE;
REMOTE_ThreadHandle(tid).in_use = FALSE; REMOTE_ThreadHandle(tid).in_use = FALSE;
DEBUG_TLOCK_ACCESS(32, tid); DEBUG_TLOCK_ACCESS(32, tid);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(tid).tlock)); pthread_mutex_unlock(&(REMOTE_ThreadHandle(tid).tlock));
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
return TRUE; return TRUE;
} }
@ -747,16 +747,16 @@ p_thread_stacks( USES_REGS1 )
Int tid = IntegerOfTerm(Deref(ARG1)); Int tid = IntegerOfTerm(Deref(ARG1));
Int status= TRUE; Int status= TRUE;
LOCK(Yap_ThreadHandlesLock); LOCK(GLOBAL_ThreadHandlesLock);
if (!REMOTE_ThreadHandle(tid).in_use && if (!REMOTE_ThreadHandle(tid).in_use &&
!REMOTE_ThreadHandle(tid).zombie) { !REMOTE_ThreadHandle(tid).zombie) {
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE; return FALSE;
} }
status &= Yap_unify(ARG2,MkIntegerTerm(REMOTE_ThreadHandle(tid).ssize)); status &= Yap_unify(ARG2,MkIntegerTerm(REMOTE_ThreadHandle(tid).ssize));
status &= Yap_unify(ARG3,MkIntegerTerm(REMOTE_ThreadHandle(tid).tsize)); status &= Yap_unify(ARG3,MkIntegerTerm(REMOTE_ThreadHandle(tid).tsize));
status &= Yap_unify(ARG4,MkIntegerTerm(REMOTE_ThreadHandle(tid).sysize)); status &= Yap_unify(ARG4,MkIntegerTerm(REMOTE_ThreadHandle(tid).sysize));
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
return status; return status;
} }
@ -828,13 +828,13 @@ static Int
p_nof_threads( USES_REGS1 ) p_nof_threads( USES_REGS1 )
{ /* '$nof_threads'(+P) */ { /* '$nof_threads'(+P) */
int i = 0, wid; int i = 0, wid;
LOCK(Yap_ThreadHandlesLock); LOCK(GLOBAL_ThreadHandlesLock);
for (wid = 0; wid < MAX_THREADS; wid++) { for (wid = 0; wid < MAX_THREADS; wid++) {
if (!Yap_local[wid]) break; if (!Yap_local[wid]) break;
if (REMOTE_ThreadHandle(wid).in_use) if (REMOTE_ThreadHandle(wid).in_use)
i++; i++;
} }
UNLOCK(Yap_ThreadHandlesLock); UNLOCK(GLOBAL_ThreadHandlesLock);
return Yap_unify(ARG1,MkIntegerTerm(i)); return Yap_unify(ARG1,MkIntegerTerm(i));
} }
@ -853,13 +853,13 @@ p_max_threads( USES_REGS1 )
static Int static Int
p_nof_threads_created( USES_REGS1 ) p_nof_threads_created( USES_REGS1 )
{ /* '$nof_threads'(+P) */ { /* '$nof_threads'(+P) */
return Yap_unify(ARG1,MkIntTerm(Yap_NOfThreadsCreated)); return Yap_unify(ARG1,MkIntTerm(GLOBAL_NOfThreadsCreated));
} }
static Int static Int
p_thread_runtime( USES_REGS1 ) p_thread_runtime( USES_REGS1 )
{ /* '$thread_runtime'(+P) */ { /* '$thread_runtime'(+P) */
return Yap_unify(ARG1,MkIntegerTerm(Yap_ThreadsTotalTime)); return Yap_unify(ARG1,MkIntegerTerm(GLOBAL_ThreadsTotalTime));
} }
static Int static Int

View File

@ -21,39 +21,39 @@
#define Yap_Initialised Yap_global->initialised #define GLOBAL_Initialised Yap_global->initialised
#define Yap_InitialisedFromPL Yap_global->initialised_from_pl #define GLOBAL_InitialisedFromPL Yap_global->initialised_from_pl
#define Yap_PL_Argc Yap_global->pl_argc #define GLOBAL_PL_Argc Yap_global->pl_argc
#define Yap_PL_Argv Yap_global->pl_argv #define GLOBAL_PL_Argv Yap_global->pl_argv
#define Yap_HaltHooks Yap_global->yap_halt_hook #define GLOBAL_HaltHooks Yap_global->yap_halt_hook
#define Yap_AllowLocalExpansion Yap_global->allow_local_expansion #define GLOBAL_AllowLocalExpansion Yap_global->allow_local_expansion
#define Yap_AllowGlobalExpansion Yap_global->allow_global_expansion #define GLOBAL_AllowGlobalExpansion Yap_global->allow_global_expansion
#define Yap_AllowTrailExpansion Yap_global->allow_trail_expansion #define GLOBAL_AllowTrailExpansion Yap_global->allow_trail_expansion
#define Yap_SizeOfOverflow Yap_global->size_of_overflow #define GLOBAL_SizeOfOverflow Yap_global->size_of_overflow
#define Yap_AGcLastCall Yap_global->agc_last_call #define GLOBAL_AGcLastCall Yap_global->agc_last_call
#define Yap_AGcThreshold Yap_global->agc_threshold #define GLOBAL_AGcThreshold Yap_global->agc_threshold
#define Yap_AGCHook Yap_global->agc_hook #define GLOBAL_AGCHook Yap_global->agc_hook
#if THREADS #if THREADS
#define Yap_NOfThreads Yap_global->n_of_threads #define GLOBAL_NOfThreads Yap_global->n_of_threads
#define Yap_NOfThreadsCreated Yap_global->n_of_threads_created #define GLOBAL_NOfThreadsCreated Yap_global->n_of_threads_created
#define Yap_ThreadsTotalTime Yap_global->threads_total_time #define GLOBAL_ThreadsTotalTime Yap_global->threads_total_time
#endif #endif
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
#define Yap_BGL Yap_global->bgl #define GLOBAL_BGL Yap_global->bgl
#endif #endif
#ifdef THREADS #ifdef THREADS
#define Yap_ThreadHandlesLock Yap_global->thread_handles_lock #define GLOBAL_ThreadHandlesLock Yap_global->thread_handles_lock
#endif #endif
#if defined(YAPOR) || defined(TABLING) #if defined(YAPOR) || defined(TABLING)
#define Yap_optyap_data Yap_global->optyap_data #define Yap_optyap_data Yap_global->optyap_data

View File

@ -21,39 +21,39 @@
static void InitGlobal(void) { static void InitGlobal(void) {
Yap_Initialised = FALSE; GLOBAL_Initialised = FALSE;
Yap_InitialisedFromPL = FALSE; GLOBAL_InitialisedFromPL = FALSE;
Yap_PL_Argc = 0; GLOBAL_PL_Argc = 0;
Yap_PL_Argv = NULL; GLOBAL_PL_Argv = NULL;
Yap_HaltHooks = NULL; GLOBAL_HaltHooks = NULL;
Yap_AllowLocalExpansion = TRUE; GLOBAL_AllowLocalExpansion = TRUE;
Yap_AllowGlobalExpansion = TRUE; GLOBAL_AllowGlobalExpansion = TRUE;
Yap_AllowTrailExpansion = TRUE; GLOBAL_AllowTrailExpansion = TRUE;
Yap_SizeOfOverflow = 0; GLOBAL_SizeOfOverflow = 0;
Yap_AGcLastCall = 0; GLOBAL_AGcLastCall = 0;
Yap_AGcThreshold = 10000; GLOBAL_AGcThreshold = 10000;
Yap_AGCHook = NULL; GLOBAL_AGCHook = NULL;
#if THREADS #if THREADS
Yap_NOfThreads = 1; GLOBAL_NOfThreads = 1;
Yap_NOfThreadsCreated = 1; GLOBAL_NOfThreadsCreated = 1;
Yap_ThreadsTotalTime = 0L; GLOBAL_ThreadsTotalTime = 0L;
#endif #endif
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_BGL); INIT_LOCK(GLOBAL_BGL);
#endif #endif
#ifdef THREADS #ifdef THREADS
INIT_LOCK(Yap_ThreadHandlesLock); INIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif #endif
#if defined(YAPOR) || defined(TABLING) #if defined(YAPOR) || defined(TABLING)

View File

@ -49,11 +49,11 @@ static void RestoreGlobal(void) {
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_BGL); REINIT_LOCK(GLOBAL_BGL);
#endif #endif
#ifdef THREADS #ifdef THREADS
REINIT_LOCK(Yap_ThreadHandlesLock); REINIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif #endif
#if defined(YAPOR) || defined(TABLING) #if defined(YAPOR) || defined(TABLING)

View File

@ -1988,22 +1988,22 @@ PL_initialise(int myargc, char **myargv)
init_args.SchedulerLoop = 10; init_args.SchedulerLoop = 10;
init_args.DelayedReleaseLoad = 3; init_args.DelayedReleaseLoad = 3;
Yap_PL_Argc = myargc; GLOBAL_PL_Argc = myargc;
Yap_PL_Argv = myargv; GLOBAL_PL_Argv = myargv;
Yap_InitialisedFromPL = TRUE; GLOBAL_InitialisedFromPL = TRUE;
return YAP_Init(&init_args) != YAP_BOOT_ERROR; return YAP_Init(&init_args) != YAP_BOOT_ERROR;
} }
X_API int X_API int
PL_is_initialised(int *argcp, char ***argvp) PL_is_initialised(int *argcp, char ***argvp)
{ {
if (Yap_InitialisedFromPL) { if (GLOBAL_InitialisedFromPL) {
if (argcp) if (argcp)
*argcp = Yap_PL_Argc; *argcp = GLOBAL_PL_Argc;
if (argvp) if (argvp)
*argvp = Yap_PL_Argv; *argvp = GLOBAL_PL_Argv;
} }
return Yap_InitialisedFromPL; return GLOBAL_InitialisedFromPL;
} }
X_API module_t X_API module_t

View File

@ -19,44 +19,44 @@
START_GLOBAL_DATA START_GLOBAL_DATA
// initialization: tell whether the system has been initialised and by whom. // initialization: tell whether the system has been initialised and by whom.
int initialised Yap_Initialised =FALSE int initialised GLOBAL_Initialised =FALSE
int initialised_from_pl Yap_InitialisedFromPL =FALSE int initialised_from_pl GLOBAL_InitialisedFromPL =FALSE
int pl_argc Yap_PL_Argc =0 int pl_argc GLOBAL_PL_Argc =0
char **pl_argv Yap_PL_Argv =NULL char **pl_argv GLOBAL_PL_Argv =NULL
// halt hooks // halt hooks
struct halt_hook *yap_halt_hook Yap_HaltHooks =NULL struct halt_hook *yap_halt_hook GLOBAL_HaltHooks =NULL
// stack overflow expansion/gc control // stack overflow expansion/gc control
int allow_local_expansion Yap_AllowLocalExpansion =TRUE int allow_local_expansion GLOBAL_AllowLocalExpansion =TRUE
int allow_global_expansion Yap_AllowGlobalExpansion =TRUE int allow_global_expansion GLOBAL_AllowGlobalExpansion =TRUE
int allow_trail_expansion Yap_AllowTrailExpansion =TRUE int allow_trail_expansion GLOBAL_AllowTrailExpansion =TRUE
UInt size_of_overflow Yap_SizeOfOverflow =0 UInt size_of_overflow GLOBAL_SizeOfOverflow =0
// amount of space recovered in all garbage collections // amount of space recovered in all garbage collections
UInt agc_last_call Yap_AGcLastCall =0 UInt agc_last_call GLOBAL_AGcLastCall =0
// amount of space recovered in all garbage collections // amount of space recovered in all garbage collections
UInt agc_threshold Yap_AGcThreshold =10000 UInt agc_threshold GLOBAL_AGcThreshold =10000
Agc_hook agc_hook Yap_AGCHook =NULL Agc_hook agc_hook GLOBAL_AGCHook =NULL
/* multi-thread support */ /* multi-thread support */
#if THREADS #if THREADS
/* number of threads and processes in system */ /* number of threads and processes in system */
UInt n_of_threads Yap_NOfThreads =1 UInt n_of_threads GLOBAL_NOfThreads =1
/* number of threads created since start */ /* number of threads created since start */
UInt n_of_threads_created Yap_NOfThreadsCreated =1 UInt n_of_threads_created GLOBAL_NOfThreadsCreated =1
/* total run time for dead threads */ /* total run time for dead threads */
UInt threads_total_time Yap_ThreadsTotalTime =0L UInt threads_total_time GLOBAL_ThreadsTotalTime =0L
#endif #endif
// multi-thread/ORP support // multi-thread/ORP support
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
// protect long critical regions // protect long critical regions
lockvar bgl Yap_BGL MkLock lockvar bgl GLOBAL_BGL MkLock
#endif #endif
// Threads Array // Threads Array
#ifdef THREADS #ifdef THREADS
lockvar thread_handles_lock Yap_ThreadHandlesLock MkLock lockvar thread_handles_lock GLOBAL_ThreadHandlesLock MkLock
#endif #endif
#if defined(YAPOR) || defined(TABLING) #if defined(YAPOR) || defined(TABLING)