diff --git a/C/absmi.c b/C/absmi.c index 788b0466a..3efb4e562 100755 --- a/C/absmi.c +++ b/C/absmi.c @@ -725,7 +725,7 @@ Yap_absmi(int inp) /* the registers are all set up, let's swap */ #ifdef THREADS pthread_setspecific(Yap_yaamregs_key, (const void *)&absmi_regs); - MY_ThreadHandle.current_yaam_regs = &absmi_regs; + LOCAL_ThreadHandle.current_yaam_regs = &absmi_regs; regcache = &absmi_regs; #else Yap_regp = &absmi_regs; diff --git a/C/adtdefs.c b/C/adtdefs.c index 7c637dca0..cf7cea954 100755 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -840,8 +840,8 @@ Yap_NewThreadPred(PredEntry *ap USES_REGS) p->beamTable = NULL; #endif /* careful that they don't cross MkFunctor */ - p->NextOfPE = AbsPredProp(MY_ThreadHandle.local_preds); - MY_ThreadHandle.local_preds = p; + p->NextOfPE = AbsPredProp(LOCAL_ThreadHandle.local_preds); + LOCAL_ThreadHandle.local_preds = p; p->FunctorOfPred = ap->FunctorOfPred; #ifdef LOW_PROF if (ProfilerOn && diff --git a/C/alloc.c b/C/alloc.c index aedb1c4bc..ce8535979 100755 --- a/C/alloc.c +++ b/C/alloc.c @@ -364,7 +364,7 @@ InitExStacks(int Trail, int Stack) #ifdef THREADS if (worker_id) - Yap_GlobalBase = (ADDR)MY_ThreadHandle.stack_address; + Yap_GlobalBase = (ADDR)LOCAL_ThreadHandle.stack_address; #endif Yap_TrailTop = Yap_GlobalBase + pm; Yap_LocalBase = Yap_GlobalBase + sa; @@ -431,7 +431,7 @@ Yap_ExtendWorkSpace(Int s) if (nbp == NULL) return FALSE; #if defined(THREADS) - MY_ThreadHandle.stack_address = (char *)nbp; + LOCAL_ThreadHandle.stack_address = (char *)nbp; #endif Yap_GlobalBase = (char *)nbp; return TRUE; diff --git a/C/c_interface.c b/C/c_interface.c index 10ae27c25..e9187c511 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -2777,8 +2777,8 @@ YAP_Init(YAP_init_args *yap_init) } #if THREADS /* don't forget this is a thread */ - MY_ThreadHandle.stack_address = Yap_GlobalBase; - MY_ThreadHandle.ssize = Trail+Stack; + LOCAL_ThreadHandle.stack_address = Yap_GlobalBase; + LOCAL_ThreadHandle.ssize = Trail+Stack; #endif #endif Yap_AllowGlobalExpansion = TRUE; diff --git a/C/sysbits.c b/C/sysbits.c index 7489416b1..6a0f95aca 100755 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -334,8 +334,8 @@ bla bla #endif #if THREADS -#define StartOfTimes (*(MY_ThreadHandle.start_of_timesp)) -#define last_time (*(MY_ThreadHandle.last_timep)) +#define StartOfTimes (*(LOCAL_ThreadHandle.start_of_timesp)) +#define last_time (*(LOCAL_ThreadHandle.last_timep)) #else /* since the point YAP was started */ @@ -355,8 +355,8 @@ InitTime (void) struct rusage rusage; #if THREADS - MY_ThreadHandle.start_of_timesp = (struct timeval *)malloc(sizeof(struct timeval)); - MY_ThreadHandle.last_timep = (struct timeval *)malloc(sizeof(struct timeval)); + LOCAL_ThreadHandle.start_of_timesp = (struct timeval *)malloc(sizeof(struct timeval)); + LOCAL_ThreadHandle.last_timep = (struct timeval *)malloc(sizeof(struct timeval)); #endif getrusage(RUSAGE_SELF, &rusage); last_time.tv_sec = StartOfTimes.tv_sec = rusage.ru_utime.tv_sec; @@ -2760,14 +2760,14 @@ p_first_signal( USES_REGS1 ) { LOCK(LOCAL_SignalLock); #ifdef THREADS - pthread_mutex_lock(&(MY_ThreadHandle.tlock)); + pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock)); #endif /* always do wakeups first, because you don't want to keep the non-backtrackable variable bad */ if (LOCAL_ActiveSignals & YAP_WAKEUP_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_WAKEUP_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigWakeUp)); @@ -2775,7 +2775,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_ITI_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_ITI_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigIti)); @@ -2783,7 +2783,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_INT_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_INT_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigInt)); @@ -2791,7 +2791,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_USR2_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_USR2_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigUsr2)); @@ -2799,7 +2799,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_USR1_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_USR1_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigUsr1)); @@ -2807,7 +2807,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_PIPE_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_PIPE_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigPipe)); @@ -2815,7 +2815,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_HUP_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_HUP_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigHup)); @@ -2833,7 +2833,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_DELAY_CREEP_SIGNAL) { LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL|YAP_DELAY_CREEP_SIGNAL); #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigDelayCreep)); @@ -2841,7 +2841,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigCreep)); @@ -2849,7 +2849,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_TRACE_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_TRACE_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigTrace)); @@ -2857,7 +2857,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_DEBUG_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_DEBUG_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigDebug)); @@ -2865,7 +2865,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_BREAK_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_BREAK_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigBreak)); @@ -2873,7 +2873,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_STACK_DUMP_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_STACK_DUMP_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigStackDump)); @@ -2881,7 +2881,7 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_STATISTICS_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_STATISTICS_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomSigStatistics)); @@ -2889,13 +2889,13 @@ p_first_signal( USES_REGS1 ) if (LOCAL_ActiveSignals & YAP_FAIL_SIGNAL) { LOCAL_ActiveSignals &= ~YAP_FAIL_SIGNAL; #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return Yap_unify(ARG1, MkAtomTerm(AtomFail)); } #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif UNLOCK(LOCAL_SignalLock); return FALSE; @@ -2951,7 +2951,7 @@ p_continue_signals( USES_REGS1 ) Yap_signal(YAP_FAIL_SIGNAL); } #ifdef THREADS - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); #endif return TRUE; } diff --git a/C/threads.c b/C/threads.c index 0e7084f0a..f21a5ef8c 100755 --- a/C/threads.c +++ b/C/threads.c @@ -211,7 +211,7 @@ thread_run(void *widp) start_thread(myworker_id); regcache = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key)); do { - t = tgs[0] = Yap_PopTermFromDB(MY_ThreadHandle.tgoal); + t = tgs[0] = Yap_PopTermFromDB(LOCAL_ThreadHandle.tgoal); if (t == 0) { if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) { Yap_Error_TYPE = YAP_NO_ERROR; @@ -222,7 +222,7 @@ thread_run(void *widp) } } else { Yap_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growstack(MY_ThreadHandle.tgoal->NOfCells*CellSize)) { + if (!Yap_growstack(LOCAL_ThreadHandle.tgoal->NOfCells*CellSize)) { Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); thread_die(worker_id, FALSE); return NULL; @@ -231,7 +231,7 @@ thread_run(void *widp) } } while (t == 0); FOREIGN_ThreadHandle(myworker_id).tgoal = NULL; - tgs[1] = MY_ThreadHandle.tdetach; + tgs[1] = LOCAL_ThreadHandle.tdetach; tgoal = Yap_MkApplTerm(FunctorThreadRun, 2, tgs); Yap_RunTopGoal(tgoal); thread_die(worker_id, FALSE); @@ -343,15 +343,15 @@ p_thread_zombie_self( USES_REGS1 ) if (pthread_getspecific(Yap_yaamregs_key) == NULL) return Yap_unify(MkIntegerTerm(-1), ARG1); DEBUG_TLOCK_ACCESS(4, worker_id); - pthread_mutex_lock(&(MY_ThreadHandle.tlock)); + pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock)); if (LOCAL_ActiveSignals &= YAP_ITI_SIGNAL) { DEBUG_TLOCK_ACCESS(5, worker_id); - pthread_mutex_unlock(&(MY_ThreadHandle.tlock)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock)); return FALSE; } // fprintf(stderr," -- %d\n", worker_id); - MY_ThreadHandle.in_use = FALSE; - MY_ThreadHandle.zombie = TRUE; + LOCAL_ThreadHandle.in_use = FALSE; + LOCAL_ThreadHandle.zombie = TRUE; return Yap_unify(MkIntegerTerm(worker_id), ARG1); } @@ -361,7 +361,7 @@ p_thread_status_lock( USES_REGS1 ) /* make sure the lock is available */ if (pthread_getspecific(Yap_yaamregs_key) == NULL) return FALSE; - pthread_mutex_lock(&(MY_ThreadHandle.tlock_status)); + pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock_status)); return Yap_unify(MkIntegerTerm(worker_id), ARG1); } @@ -371,7 +371,7 @@ p_thread_status_unlock( USES_REGS1 ) /* make sure the lock is available */ if (pthread_getspecific(Yap_yaamregs_key) == NULL) return FALSE; - pthread_mutex_unlock(&(MY_ThreadHandle.tlock_status)); + pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock_status)); return Yap_unify(MkIntegerTerm(worker_id), ARG1); } @@ -538,8 +538,8 @@ p_thread_detach( USES_REGS1 ) static Int p_thread_detached( USES_REGS1 ) { - if (MY_ThreadHandle.tdetach) - return Yap_unify(ARG1,MY_ThreadHandle.tdetach); + if (LOCAL_ThreadHandle.tdetach) + return Yap_unify(ARG1,LOCAL_ThreadHandle.tdetach); else return FALSE; } @@ -766,13 +766,13 @@ p_thread_atexit( USES_REGS1 ) { /* '$thread_signal'(+P) */ Term t; - if (!MY_ThreadHandle.texit || - MY_ThreadHandle.texit->Entry == MkAtomTerm(AtomTrue)) { + if (!LOCAL_ThreadHandle.texit || + LOCAL_ThreadHandle.texit->Entry == MkAtomTerm(AtomTrue)) { return FALSE; } do { - t = Yap_PopTermFromDB(MY_ThreadHandle.texit); - MY_ThreadHandle.texit = NULL; + t = Yap_PopTermFromDB(LOCAL_ThreadHandle.texit); + LOCAL_ThreadHandle.texit = NULL; if (t == 0) { if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) { Yap_Error_TYPE = YAP_NO_ERROR; @@ -783,7 +783,7 @@ p_thread_atexit( USES_REGS1 ) } } else { Yap_Error_TYPE = YAP_NO_ERROR; - if (!Yap_growstack(MY_ThreadHandle.tgoal->NOfCells*CellSize)) { + if (!Yap_growstack(LOCAL_ThreadHandle.tgoal->NOfCells*CellSize)) { Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); thread_die(worker_id, FALSE); return FALSE; @@ -791,7 +791,7 @@ p_thread_atexit( USES_REGS1 ) } } } while (t == 0); - return Yap_unify(ARG1, t) && Yap_unify(ARG2, MY_ThreadHandle.texit_mod); + return Yap_unify(ARG1, t) && Yap_unify(ARG2, LOCAL_ThreadHandle.texit_mod); } @@ -866,7 +866,7 @@ p_thread_runtime( USES_REGS1 ) static Int p_thread_self_lock( USES_REGS1 ) { /* '$thread_unlock' */ - pthread_mutex_lock(&(MY_ThreadHandle.tlock)); + pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock)); return Yap_unify(ARG1,MkIntegerTerm(worker_id)); } diff --git a/C/tracer.c b/C/tracer.c index d09674ad0..527d540e6 100755 --- a/C/tracer.c +++ b/C/tracer.c @@ -164,7 +164,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) sc = Yap_heap_regs; vsc_count++; #ifdef THREADS - MY_ThreadHandle.thread_inst_count++; + LOCAL_ThreadHandle.thread_inst_count++; #endif #ifdef COMMENTED { choiceptr myB = B; diff --git a/H/Yatom.h b/H/Yatom.h index 95f7ca01f..03289ac25 100755 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -1493,7 +1493,7 @@ Yap_GetThreadPred(struct pred_entry *ap USES_REGS) { Functor f = ap->FunctorOfPred; Term mod = ap->ModuleOfPred; - Prop p0 = AbsPredProp(MY_ThreadHandle.local_preds); + Prop p0 = AbsPredProp(LOCAL_ThreadHandle.local_preds); while(p0) { PredEntry *ap = RepPredProp(p0); diff --git a/H/absmi.h b/H/absmi.h index a84f6c3a8..240602b70 100644 --- a/H/absmi.h +++ b/H/absmi.h @@ -192,7 +192,7 @@ restore_absmi_regs(REGSTORE * old_regs) memcpy(old_regs, Yap_regp, sizeof(REGSTORE)); #ifdef THREADS pthread_setspecific(Yap_yaamregs_key, (void *)old_regs); - MY_ThreadHandle.current_yaam_regs = old_regs; + LOCAL_ThreadHandle.current_yaam_regs = old_regs; #else Yap_regp = old_regs; #endif diff --git a/H/dlocals.h b/H/dlocals.h index 78a512226..186ccb1e6 100644 --- a/H/dlocals.h +++ b/H/dlocals.h @@ -125,8 +125,7 @@ #ifdef THREADS #define LOCAL_ThreadHandle LOCAL->thread_handle #define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle) -#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle) -#endif +#endif /* THREADS */ #if defined(YAPOR) || defined(TABLING) #define LOCAL_optyap_data LOCAL->optyap_data #endif /* YAPOR || TABLING */ diff --git a/H/hlocals.h b/H/hlocals.h index 9f05e2d8a..6c0f97432 100644 --- a/H/hlocals.h +++ b/H/hlocals.h @@ -127,8 +127,7 @@ typedef struct worker_local { #ifdef THREADS struct thandle thread_handle; #define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle) -#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle) -#endif +#endif /* THREADS */ #if defined(YAPOR) || defined(TABLING) struct local_optyap_data optyap_data; #endif /* YAPOR || TABLING */ diff --git a/H/ilocals.h b/H/ilocals.h index 626feb69c..0c02c9859 100644 --- a/H/ilocals.h +++ b/H/ilocals.h @@ -5,128 +5,127 @@ static void InitWorker(int wid) { - FOREIGN(wid)->c_input_stream = 0; - FOREIGN(wid)->c_output_stream = 1; - FOREIGN(wid)->c_error_stream = 2; + REMOTE(wid)->c_input_stream = 0; + REMOTE(wid)->c_output_stream = 1; + REMOTE(wid)->c_error_stream = 2; - FOREIGN(wid)->rinfo.old_ASP = NULL; - FOREIGN(wid)->rinfo.old_LCL0 = NULL; - FOREIGN(wid)->rinfo.old_TR = NULL; - FOREIGN(wid)->rinfo.old_GlobalBase = NULL; - FOREIGN(wid)->rinfo.old_H = NULL; - FOREIGN(wid)->rinfo.old_H0 = NULL; - FOREIGN(wid)->rinfo.old_TrailBase = NULL; - FOREIGN(wid)->rinfo.old_TrailTop = NULL; - FOREIGN(wid)->rinfo.old_HeapBase = NULL; - FOREIGN(wid)->rinfo.old_HeapTop = NULL; - FOREIGN(wid)->rinfo.cl_diff = 0L; - FOREIGN(wid)->rinfo.g_diff = 0L; - FOREIGN(wid)->rinfo.h_diff = 0L; - FOREIGN(wid)->rinfo.g_diff0 = 0L; - FOREIGN(wid)->rinfo.g_split = NULL; - FOREIGN(wid)->rinfo.l_diff = 0L; - FOREIGN(wid)->rinfo.tr_diff = 0L; - FOREIGN(wid)->rinfo.x_diff = 0L; - FOREIGN(wid)->rinfo.delay_diff = 0L; - FOREIGN(wid)->rinfo.base_diff = 0L; - FOREIGN(wid)->call_counters.reductions = 0L; - FOREIGN(wid)->call_counters.reductions_retries = 0L; - FOREIGN(wid)->call_counters.retries = 0L; - FOREIGN(wid)->call_counters.reductions_on = 0L; - FOREIGN(wid)->call_counters.reductions_retries_on = 0L; - FOREIGN(wid)->call_counters.retries_on = 0L; - FOREIGN(wid)->interrupts_disabled = FALSE; + REMOTE(wid)->rinfo.old_ASP = NULL; + REMOTE(wid)->rinfo.old_LCL0 = NULL; + REMOTE(wid)->rinfo.old_TR = NULL; + REMOTE(wid)->rinfo.old_GlobalBase = NULL; + REMOTE(wid)->rinfo.old_H = NULL; + REMOTE(wid)->rinfo.old_H0 = NULL; + REMOTE(wid)->rinfo.old_TrailBase = NULL; + REMOTE(wid)->rinfo.old_TrailTop = NULL; + REMOTE(wid)->rinfo.old_HeapBase = NULL; + REMOTE(wid)->rinfo.old_HeapTop = NULL; + REMOTE(wid)->rinfo.cl_diff = 0L; + REMOTE(wid)->rinfo.g_diff = 0L; + REMOTE(wid)->rinfo.h_diff = 0L; + REMOTE(wid)->rinfo.g_diff0 = 0L; + REMOTE(wid)->rinfo.g_split = NULL; + REMOTE(wid)->rinfo.l_diff = 0L; + REMOTE(wid)->rinfo.tr_diff = 0L; + REMOTE(wid)->rinfo.x_diff = 0L; + REMOTE(wid)->rinfo.delay_diff = 0L; + REMOTE(wid)->rinfo.base_diff = 0L; + REMOTE(wid)->call_counters.reductions = 0L; + REMOTE(wid)->call_counters.reductions_retries = 0L; + REMOTE(wid)->call_counters.retries = 0L; + REMOTE(wid)->call_counters.reductions_on = 0L; + REMOTE(wid)->call_counters.reductions_retries_on = 0L; + REMOTE(wid)->call_counters.retries_on = 0L; + REMOTE(wid)->interrupts_disabled = FALSE; - FOREIGN(wid)->consultsp = NULL; + REMOTE(wid)->consultsp = NULL; - FOREIGN(wid)->consultbase = NULL; + REMOTE(wid)->consultbase = NULL; - FOREIGN(wid)->consultlow = NULL; + REMOTE(wid)->consultlow = NULL; - FOREIGN(wid)->global_arena = 0L; - FOREIGN(wid)->global_arena_overflows = 0L; - FOREIGN(wid)->arena_overflows = 0L; - FOREIGN(wid)->depth_arenas = 0; - FOREIGN(wid)->arith_error = FALSE; - FOREIGN(wid)->last_asserted_pred = NULL; - FOREIGN(wid)->debug_on = FALSE; - FOREIGN(wid)->scanner_stack = NULL; - FOREIGN(wid)->scanner_extra_blocks = NULL; - FOREIGN(wid)->ball_term = NULL; - FOREIGN(wid)->active_signals = 0L; - FOREIGN(wid)->i_pred_arity = 0L; - FOREIGN(wid)->prof_end = NULL; - FOREIGN(wid)->uncaught_throw = FALSE; - FOREIGN(wid)->doing_undefp = FALSE; - FOREIGN(wid)->start_line = 0L; + REMOTE(wid)->global_arena = 0L; + REMOTE(wid)->global_arena_overflows = 0L; + REMOTE(wid)->arena_overflows = 0L; + REMOTE(wid)->depth_arenas = 0; + REMOTE(wid)->arith_error = FALSE; + REMOTE(wid)->last_asserted_pred = NULL; + REMOTE(wid)->debug_on = FALSE; + REMOTE(wid)->scanner_stack = NULL; + REMOTE(wid)->scanner_extra_blocks = NULL; + REMOTE(wid)->ball_term = NULL; + REMOTE(wid)->active_signals = 0L; + REMOTE(wid)->i_pred_arity = 0L; + REMOTE(wid)->prof_end = NULL; + REMOTE(wid)->uncaught_throw = FALSE; + REMOTE(wid)->doing_undefp = FALSE; + REMOTE(wid)->start_line = 0L; InitScratchPad(wid); #ifdef COROUTINING - FOREIGN(wid)->woken_goals = 0L; - FOREIGN(wid)->atts_mutable_list = 0L; + REMOTE(wid)->woken_goals = 0L; + REMOTE(wid)->atts_mutable_list = 0L; #endif - FOREIGN(wid)->gc_generation = 0L; - FOREIGN(wid)->gc_phase = 0L; - FOREIGN(wid)->gc_current_phase = 0L; - FOREIGN(wid)->gc_calls = 0L; - FOREIGN(wid)->tot_gc_time = 0L; - FOREIGN(wid)->tot_gc_recovered = 0L; - FOREIGN(wid)->last_gc_time = 0L; - FOREIGN(wid)->last_ss_time = 0L; + REMOTE(wid)->gc_generation = 0L; + REMOTE(wid)->gc_phase = 0L; + REMOTE(wid)->gc_current_phase = 0L; + REMOTE(wid)->gc_calls = 0L; + REMOTE(wid)->tot_gc_time = 0L; + REMOTE(wid)->tot_gc_recovered = 0L; + REMOTE(wid)->last_gc_time = 0L; + REMOTE(wid)->last_ss_time = 0L; #if LOW_LEVEL_TRACER - FOREIGN(wid)->total_cps = 0; + REMOTE(wid)->total_cps = 0; #endif - FOREIGN(wid)->consult_level_ = 0; + REMOTE(wid)->consult_level_ = 0; #if defined(YAPOR) || defined(THREADS) - INIT_LOCK(FOREIGN(wid)->signal_lock); + INIT_LOCK(REMOTE(wid)->signal_lock); #endif - FOREIGN(wid)->tot_marked = 0L; - FOREIGN(wid)->tot_oldies = 0L; - FOREIGN(wid)->wl_current_B = NULL; - FOREIGN(wid)->wl_prev_HB = NULL; - FOREIGN(wid)->hgen = NULL; - FOREIGN(wid)->ip_top = NULL; + REMOTE(wid)->tot_marked = 0L; + REMOTE(wid)->tot_oldies = 0L; + REMOTE(wid)->wl_current_B = NULL; + REMOTE(wid)->wl_prev_HB = NULL; + REMOTE(wid)->hgen = NULL; + REMOTE(wid)->ip_top = NULL; #if defined(GC_NO_TAGS) - FOREIGN(wid)->b_p = NULL; + REMOTE(wid)->b_p = NULL; #endif - FOREIGN(wid)->wl_sTR = NULL; - FOREIGN(wid)->wl_sTR0 = NULL; - FOREIGN(wid)->new_tr = NULL; - FOREIGN(wid)->conttop0 = NULL; - FOREIGN(wid)->conttop = NULL; - FOREIGN(wid)->disc_trail_entries = 0; + REMOTE(wid)->wl_sTR = NULL; + REMOTE(wid)->wl_sTR0 = NULL; + REMOTE(wid)->new_tr = NULL; + REMOTE(wid)->conttop0 = NULL; + REMOTE(wid)->conttop = NULL; + REMOTE(wid)->disc_trail_entries = 0; - FOREIGN(wid)->Gc_ma_h_top = NULL; - FOREIGN(wid)->Gc_ma_h_list = NULL; - FOREIGN(wid)->Gc_timestamp = 0L; - FOREIGN(wid)->DB_vec = NULL; - FOREIGN(wid)->DB_vec0 = NULL; - FOREIGN(wid)->DB_root = NULL; - FOREIGN(wid)->DB_nil = NULL; + REMOTE(wid)->Gc_ma_h_top = NULL; + REMOTE(wid)->Gc_ma_h_list = NULL; + REMOTE(wid)->Gc_timestamp = 0L; + REMOTE(wid)->DB_vec = NULL; + REMOTE(wid)->DB_vec0 = NULL; + REMOTE(wid)->DB_root = NULL; + REMOTE(wid)->DB_nil = NULL; - FOREIGN(wid)->dynamic_arrays = NULL; - FOREIGN(wid)->static_arrays = NULL; - FOREIGN(wid)->global_variables = NULL; - FOREIGN(wid)->allow_restart = FALSE; + REMOTE(wid)->dynamic_arrays = NULL; + REMOTE(wid)->static_arrays = NULL; + REMOTE(wid)->global_variables = NULL; + REMOTE(wid)->allow_restart = FALSE; - FOREIGN(wid)->cmem_first_block = NULL; - FOREIGN(wid)->cmem_first_block_sz = 0L; + REMOTE(wid)->cmem_first_block = NULL; + REMOTE(wid)->cmem_first_block_sz = 0L; - FOREIGN(wid)->label_first_array = NULL; - FOREIGN(wid)->label_first_array_sz = 0L; + REMOTE(wid)->label_first_array = NULL; + REMOTE(wid)->label_first_array_sz = 0L; - FOREIGN(wid)->Yap_ld_ = Yap_InitThreadIO(wid); - FOREIGN(wid)->_execution = NULL; + REMOTE(wid)->Yap_ld_ = Yap_InitThreadIO(wid); + REMOTE(wid)->_execution = NULL; #ifdef THREADS InitThreadHandle(wid); #define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle) -#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle) -#endif +#endif /* THREADS */ #if defined(YAPOR) || defined(TABLING) Yap_init_local_optyap_data(wid); #endif /* YAPOR || TABLING */ diff --git a/H/rlocals.h b/H/rlocals.h index e09c45504..17b66ff28 100644 --- a/H/rlocals.h +++ b/H/rlocals.h @@ -46,7 +46,7 @@ static void RestoreWorker(int wid USES_REGS) { - FOREIGN(wid)->global_arena = TermToGlobalOrAtomAdjust(FOREIGN(wid)->global_arena); + REMOTE(wid)->global_arena = TermToGlobalOrAtomAdjust(REMOTE(wid)->global_arena); @@ -64,12 +64,12 @@ static void RestoreWorker(int wid USES_REGS) { #ifdef COROUTINING - FOREIGN(wid)->woken_goals = TermToGlobalAdjust(FOREIGN(wid)->woken_goals); - FOREIGN(wid)->atts_mutable_list = TermToGlobalAdjust(FOREIGN(wid)->atts_mutable_list); + REMOTE(wid)->woken_goals = TermToGlobalAdjust(REMOTE(wid)->woken_goals); + REMOTE(wid)->atts_mutable_list = TermToGlobalAdjust(REMOTE(wid)->atts_mutable_list); #endif - FOREIGN(wid)->gc_generation = TermToGlobalAdjust(FOREIGN(wid)->gc_generation); - FOREIGN(wid)->gc_phase = TermToGlobalAdjust(FOREIGN(wid)->gc_phase); + REMOTE(wid)->gc_generation = TermToGlobalAdjust(REMOTE(wid)->gc_generation); + REMOTE(wid)->gc_phase = TermToGlobalAdjust(REMOTE(wid)->gc_phase); @@ -81,7 +81,7 @@ static void RestoreWorker(int wid USES_REGS) { #endif #if defined(YAPOR) || defined(THREADS) - REINIT_LOCK(FOREIGN(wid)->signal_lock); + REINIT_LOCK(REMOTE(wid)->signal_lock); #endif @@ -109,9 +109,9 @@ static void RestoreWorker(int wid USES_REGS) { - FOREIGN(wid)->dynamic_arrays = PtoArrayEAdjust(FOREIGN(wid)->dynamic_arrays); - FOREIGN(wid)->static_arrays = PtoArraySAdjust(FOREIGN(wid)->static_arrays); - FOREIGN(wid)->global_variables = PtoGlobalEAdjust(FOREIGN(wid)->global_variables); + REMOTE(wid)->dynamic_arrays = PtoArrayEAdjust(REMOTE(wid)->dynamic_arrays); + REMOTE(wid)->static_arrays = PtoArraySAdjust(REMOTE(wid)->static_arrays); + REMOTE(wid)->global_variables = PtoGlobalEAdjust(REMOTE(wid)->global_variables); @@ -125,8 +125,7 @@ static void RestoreWorker(int wid USES_REGS) { #ifdef THREADS #define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle) -#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle) -#endif +#endif /* THREADS */ #if defined(YAPOR) || defined(TABLING) #endif /* YAPOR || TABLING */ diff --git a/misc/LOCALS b/misc/LOCALS index 17f76f465..2f1885335 100644 --- a/misc/LOCALS +++ b/misc/LOCALS @@ -140,8 +140,7 @@ struct open_query_struct* _execution LOCAL_execution =NULL #ifdef THREADS struct thandle thread_handle LOCAL_ThreadHandle InitThreadHandle(wid) #define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle) -#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle) -#endif +#endif /* THREADS */ #if defined(YAPOR) || defined(TABLING) struct local_optyap_data optyap_data LOCAL_optyap_data Yap_init_local_optyap_data(wid) diff --git a/misc/buildheap b/misc/buildheap index 7d5cd893b..dbda2258e 100644 --- a/misc/buildheap +++ b/misc/buildheap @@ -122,13 +122,13 @@ fetch_name(Global) :- Global = "LOCAL->". fetch_name(Global) :- globals(worker_init), !, - Global = "FOREIGN(wid)->". + Global = "REMOTE(wid)->". fetch_name(Global) :- Global = "Yap_heap_regs->". fetch_name(Global,RField,_) :- globals(worker_init), !, - append("FOREIGN(wid)->",RField,Global). + append("REMOTE(wid)->",RField,Global). fetch_name(Global,_,Global). % handle *field[4]