diff -ruN klic-3.003-2002-02-25a/include/klic/alloc.h klic-3.003-2002-02-25b/include/klic/alloc.h
--- klic-3.003-2002-02-25a/include/klic/alloc.h	Tue Feb 19 17:05:00 2002
+++ klic-3.003-2002-02-25b/include/klic/alloc.h	Mon Feb 25 13:58:17 2002
@@ -21,12 +21,12 @@
 
 #define heapalloc(s, words, maketype) \
 do{ \
-  heapbottom -= (words); \
-  (s) = maketype(heapbottom); \
+  set_heapbottom(heapbottom() - (words)); \
+  (s) = maketype(heapbottom()); \
 \
-  real_heaplimit -= (words); \
+  set_real_heaplimit(real_heaplimit() - (words)); \
   if(heaplimit != 0) \
-    heaplimit = (interrupt_off ? real_heaplimit : 0); \
+    heaplimit = (interrupt_off ? real_heaplimit() : 0); \
 }while(0)
 
 
diff -ruN klic-3.003-2002-02-25a/include/klic/control.h klic-3.003-2002-02-25b/include/klic/control.h
--- klic-3.003-2002-02-25a/include/klic/control.h	Sun Feb 24 13:08:08 2002
+++ klic-3.003-2002-02-25b/include/klic/control.h	Mon Feb 25 13:13:21 2002
@@ -58,7 +58,7 @@
 
 #define enqueue_at_lower_priority_no_check(x, q0, q)	\
 do{							\
-  long prio = current_prio - intval(x); \
+  long prio = current_prio() - intval(x); \
   _ENQUEUE_AT_PRIORITY_NO_CHECK(prio, q0, q); \
 }while(0)
 
diff -ruN klic-3.003-2002-02-25a/include/klic/g_basic.h klic-3.003-2002-02-25b/include/klic/g_basic.h
--- klic-3.003-2002-02-25a/include/klic/g_basic.h	Fri Feb 22 11:27:31 2002
+++ klic-3.003-2002-02-25b/include/klic/g_basic.h	Mon Feb 25 15:03:42 2002
@@ -72,8 +72,8 @@
  */
 #define G_HEAPALLOC_WITH_CHECK(from,size,type,res) \
 do{ \
-  if ((long) real_heaplimit <= (long) (heapp() + (size))) { \
-    this_more_space += (size); \
+  if ((long) real_heaplimit() <= (long) (heapp() + (size))) { \
+    add_this_more_space(size); \
     heaplimit = 0; \
     (res) = GENERIC_GCREQUEST; \
   } else { \
@@ -111,7 +111,7 @@
  */
 #define G_COPY_KL1_TERM_TO_NEWGEN(from,to) \
 do{ \
-  if ((g_sp) == gcmax) { \
+  if (g_sp == gcmax()) { \
     (g_sp) = make_larger_stack(g_sp); \
   } \
   if(isref(from)) { \
diff -ruN klic-3.003-2002-02-25a/include/klic/gb.h klic-3.003-2002-02-25b/include/klic/gb.h
--- klic-3.003-2002-02-25a/include/klic/gb.h	Sun Feb 17 14:34:36 2002
+++ klic-3.003-2002-02-25b/include/klic/gb.h	Mon Feb 25 13:13:48 2002
@@ -53,7 +53,7 @@
 
 
 #define gblt_current_prio(p, fail) \
-  ((p) = makeint(current_prio))
+  ((p) = makeint(current_prio()))
 
 #define gblt_wait( x, susp )
 
diff -ruN klic-3.003-2002-02-25a/include/klic/gc_macro.h klic-3.003-2002-02-25b/include/klic/gc_macro.h
--- klic-3.003-2002-02-25a/include/klic/gc_macro.h	Sun Feb 24 14:31:09 2002
+++ klic-3.003-2002-02-25b/include/klic/gc_macro.h	Mon Feb 25 14:58:03 2002
@@ -233,13 +233,13 @@
   *g_allocp = (q) GC_SELF->method_table; \
   (newobj) = (GC_OBJ_TYPE *) g_allocp; \
   g_allocp += size; \
-  if(g_allocp > real_heaplimit) fatal("not enough space collected"); \
+  if(g_allocp > real_heaplimit()) fatal("not enough space collected"); \
 }while(0)
 
 #define GC_RETURN_FROM_GC(newgobj) \
 do{ \
   assert(g_allocp == heapp()); \
-  gcsp  = g_sp; \
+  set_gcsp(g_sp); \
   return (q *) (newgobj); \
 }while(0)
 
diff -ruN klic-3.003-2002-02-25a/include/klic/gd_macro.h klic-3.003-2002-02-25b/include/klic/gd_macro.h
--- klic-3.003-2002-02-25a/include/klic/gd_macro.h	Sun Feb 24 17:04:08 2002
+++ klic-3.003-2002-02-25b/include/klic/gd_macro.h	Mon Feb 25 14:58:18 2002
@@ -152,7 +152,7 @@
     (newobj) = (GD_OBJ_TYPE *) g_allocp; \
     (newobj)->method_table = GD_SELF->method_table; \
     g_allocp += size; \
-    if((g_allocp) > real_heaplimit) fatal("not enough space collected"); \
+    if(g_allocp > real_heaplimit()) fatal("not enough space collected"); \
 }while(0)
 
 /***************************************************************************/
@@ -379,7 +379,7 @@
 
 #define GD_RETURN_FROM_GC(newgobj) \
 do{ \
-  gcsp = g_sp; \
+  set_gcsp(g_sp); \
   assert(g_allocp == heapp()); \
   return(((q *)(newgobj))); \
 }while(0)
diff -ruN klic-3.003-2002-02-25a/include/klic/gg_macro.h klic-3.003-2002-02-25b/include/klic/gg_macro.h
--- klic-3.003-2002-02-25a/include/klic/gg_macro.h	Mon Feb 25 11:00:16 2002
+++ klic-3.003-2002-02-25b/include/klic/gg_macro.h	Mon Feb 25 14:58:32 2002
@@ -107,7 +107,7 @@
 do{ \
   G_HEAPALLOC((new), (size), type); \
   assert(g_allocp >= heapp() + (size)); \
-  if((long)real_heaplimit <= (long)(g_allocp)) { \
+  if((long) real_heaplimit() <= (long) g_allocp) { \
     goto label; \
   } \
 }while(0)
@@ -221,12 +221,12 @@
     *g_allocp = (q) GG_SELF->method_table; \
     (newobj) = (GG_OBJ_TYPE *) g_allocp; \
     g_allocp += size; \
-    if(g_allocp > real_heaplimit) fatal("not enough space collected"); \
+    if(g_allocp > real_heaplimit()) fatal("not enough space collected"); \
 }while(0)
 
 #define GG_RETURN_FROM_GC(newgobj) \
 do{ \
-  gcsp  = g_sp; \
+  set_gcsp(g_sp); \
   assert(g_allocp == heapp()); \
   return(((q *)(newgobj))); \
 }while(0)
diff -ruN klic-3.003-2002-02-25a/include/klic/sighndl.h klic-3.003-2002-02-25b/include/klic/sighndl.h
--- klic-3.003-2002-02-25a/include/klic/sighndl.h	Wed Feb 20 16:08:39 2002
+++ klic-3.003-2002-02-25b/include/klic/sighndl.h	Mon Feb 25 13:01:05 2002
@@ -20,20 +20,15 @@
 #endif
 
 #define signal_flags		(klic_sgnl_flags->flags)
-#define signal_handlers		(klic_sgnl_flags->sgnl_handlers)
 #define signal_done		(klic_sgnl_flags->done)
 
 struct klic_sgnl_flags {
   volatile long flags[NSIG];
   int ((* volatile sgnl_handlers[NSIG])());
   volatile long done;
-} my_klic_sgnl_flags;
+};
 
-#ifdef SIGMAIN
-volatile struct klic_sgnl_flags* klic_sgnl_flags = &my_klic_sgnl_flags;
-#else
 extern volatile struct klic_sgnl_flags* klic_sgnl_flags;
-#endif
 
 /* runtime/signal.c */
 extern void klic_signal_handler(void);
diff -ruN klic-3.003-2002-02-25a/include/klic/struct.h klic-3.003-2002-02-25b/include/klic/struct.h
--- klic-3.003-2002-02-25a/include/klic/struct.h	Wed Feb 20 15:48:34 2002
+++ klic-3.003-2002-02-25b/include/klic/struct.h	Mon Feb 25 15:03:55 2002
@@ -185,21 +185,7 @@
 
 #define current_queue	(glbl->current_queue0)
 #define resumed_goals	(glbl->resumed_goals0)
-#define prioq		(glbl->prioq0)
-#define current_prio	(glbl->current_prio0)
-#define heaptop		(glbl->heaptop0)
 #define heaplimit	(glbl->heaplimit0)
-#define real_heaplimit	(glbl->real_heaplimit0)
-#define heapbottom	(glbl->heapbottom0)
-#define heapsize	(glbl->heapsize0)
-#define maxheapsize	(glbl->maxheapsize0)
-#define real_heapbytesize (glbl->real_heapbytesize0)
-#define incrementsize	(glbl->incrementsize0)
-#define maxactiveratio	(glbl->maxactiveratio0)
-#define this_more_space	(glbl->this_more_space0)
-#define gcstack		(glbl->gcstack0)
-#define gcsp		(glbl->gcsp0)
-#define gcmax		(glbl->gcmax0)
 #define interrupt_off   (glbl->interrupt_off0)
 #define command_argc	(glbl->command_argc0)
 #define command_argv	(glbl->command_argv0)
@@ -223,19 +209,7 @@
   q* volatile heaplimit0;	/* copy of real_heaplimit or 0 */
   struct goalrec* current_queue0; /* queue for current priority */
   struct goalrec* resumed_goals0; /* spontaneous goals during reduction */
-  unsigned long current_prio0;	/* current priority */
   /* The rest are not accessed as often */
-  struct prioqrec prioq0;	/* priority queue head */
-  q* heaptop0;			/* top of the current heap */
-  q* heapbottom0;		/* bottom of free area */
-  q* real_heaplimit0;		/* limit of normal heap use */
-  unsigned long heapsize0, maxheapsize0, incrementsize0;
-  unsigned long real_heapbytesize0;
-  double maxactiveratio0;
-  unsigned long this_more_space0; /* at least this # of words needed after GC */
-  q** gcstack0;
-  q** gcsp0;
-  q** gcmax0;
   volatile long interrupt_off0;
 
   struct {
@@ -313,14 +287,43 @@
 
 /* runtime/alloc.c */
 extern q* heapp(void);
+extern q* heaptop(void);
+extern q* heapbottom(void);
+extern q* real_heaplimit(void);
 extern q* new_space_top(void);
 extern q* old_space_top(void);
 extern unsigned long new_space_size(void);
 extern unsigned long old_space_size(void);
+extern unsigned long real_heapbytesize(void);
+extern unsigned long this_more_space(void);
 extern void set_heapp(q* p);
+extern void set_heaptop(q* p);
+extern void set_heapbottom(q* p);
+extern void set_real_heaplimit(q* p);
 extern void set_new_space_top(q* p);
 extern void set_old_space_top(q* p);
 extern void set_new_space_size(unsigned long size);
 extern void set_old_space_size(unsigned long size);
+extern void set_real_heapbytesize(unsigned long size);
+extern void add_this_more_space(unsigned long size);
+extern void reset_this_more_space(void);
+
+/* runtime/gc.c */
+extern q** gcsp(void);
+extern q** gcmax(void);
+extern void set_gcsp(q** pp);
+
+/* runtime/kmain.c */
+extern unsigned long heapsize(void);
+extern unsigned long maxheapsize(void);
+extern unsigned long incrementsize(void);
+extern double maxactiveratio(void);
+extern void double_heapsize(void);
+
+/* runtime/sched.c */
+extern struct prioqrec prioq(void);
+extern unsigned long current_prio(void);
+extern void set_current_prio(unsigned long prio);
+
 
 #endif /* _KLIC_STRUCT_H_ */
diff -ruN klic-3.003-2002-02-25a/runtime/alloc.c klic-3.003-2002-02-25b/runtime/alloc.c
--- klic-3.003-2002-02-25a/runtime/alloc.c	Tue Feb 19 17:05:19 2002
+++ klic-3.003-2002-02-25b/runtime/alloc.c	Mon Feb 25 14:46:44 2002
@@ -11,9 +11,14 @@
 #include <klic/primitives.h>  /* extern */
 
 static q* heapp0;  /* top of free area (when decached) */
+static q* heaptop0;  /* top of the current heap */
+static q* heapbottom0;  /* bottom of free area */
+static q* real_heaplimit0;  /* limit of normal heap use */
 static q* new_space_top0;
 static q* old_space_top0;
 static unsigned long new_space_size0, old_space_size0;
+static unsigned long real_heapbytesize0;
+static unsigned long this_more_space0; /* at least this # of words needed after GC */
 
 static gc_t* gc_hook_table0;
 static int gc_hooktab_size0;
@@ -22,17 +27,19 @@
 static int after_gc_hooktab_size0;
 static int num_after_gc_hooks0;
 
-extern q*
-heapp(void)
-{
-  return heapp0;
-}
-
-extern void
-set_heapp(q* p)
-{
-  heapp0 = p;
-}
+extern q* heapp(void){ return heapp0; }
+extern q* heaptop(void){ return heaptop0; }
+extern q* heapbottom(void){ return heapbottom0; }
+extern q* real_heaplimit(void){ return real_heaplimit0; }
+extern unsigned long real_heapbytesize(void){ return real_heapbytesize0; }
+extern unsigned long this_more_space(void){ return this_more_space0; }
+extern void set_heapp(q* p){ heapp0 = p; }
+extern void set_heaptop(q* p){ heaptop0 = p; }
+extern void set_heapbottom(q* p){ heapbottom0 = p; }
+extern void set_real_heaplimit(q* p){ real_heaplimit0 = p; }
+extern void set_real_heapbytesize(unsigned long size){ real_heapbytesize0 = size; }
+extern void reset_this_more_space(void){ this_more_space0 = 0; }
+extern void add_this_more_space(unsigned long size){ this_more_space0 += size; }
 
 extern q* new_space_top(void){ return new_space_top0; }
 extern q* old_space_top(void){ return old_space_top0; }
@@ -77,11 +84,13 @@
 reinit_alloc()
 {
   declare_globals;
-  heaplimit = real_heaplimit = new_space_top() + heapsize;
-  heapbottom = real_heaplimit+incrementsize;
-  set_heapp( heaptop = new_space_top() );
-  real_heapbytesize = (unsigned long) heapbottom - (unsigned long) heaptop;
-  this_more_space = 0;
+  set_real_heaplimit(new_space_top() + heapsize());
+  heaplimit = real_heaplimit();
+  set_heapbottom(real_heaplimit() + incrementsize());
+  set_heaptop(new_space_top());
+  set_heapp(new_space_top());
+  set_real_heapbytesize((unsigned long) heapbottom() - (unsigned long) heaptop());
+  reset_this_more_space();
   gc_hooktab_size0 = 32;
   num_gc_hooks0 = 0;
   gc_hook_table0 = (gc_t*) malloc_check(gc_hooktab_size0*sizeof(gc_t*));
@@ -96,11 +105,11 @@
   declare_globals;
   unsigned long bytesize;
 
-  if(heapsize != 0  && incrementsize != 0) {
-    bytesize = (heapsize + incrementsize)*sizeof(q);
+  if(heapsize() != 0  && incrementsize() != 0) {
+    bytesize = (heapsize() + incrementsize()) * sizeof(q);
   } else {
     fatalf("Invalid memory size specification: heap = %d, incremental = %d",
-	    heapsize, incrementsize);
+	    heapsize(), incrementsize());
   }
   set_new_space_size(bytesize);
   set_old_space_size(bytesize);
diff -ruN klic-3.003-2002-02-25a/runtime/bodyblt.kl1 klic-3.003-2002-02-25b/runtime/bodyblt.kl1
--- klic-3.003-2002-02-25a/runtime/bodyblt.kl1	Fri Feb 22 22:27:35 2002
+++ klic-3.003-2002-02-25b/runtime/bodyblt.kl1	Mon Feb 25 14:17:46 2002
@@ -47,7 +47,7 @@
 
 report_measure(X) :- inline:"
   measure(after);
-  klic_fprintf(stdout, \"heap size = %%d words\\n\", heapsize);
+  klic_fprintf(stdout, \"heap size = %%d words\\n\", heapsize());
   {
 #ifdef GETRUSAGE
     long u_usec = diff_usec(ru_utime);
diff -ruN klic-3.003-2002-02-25a/runtime/cntlmsg.c klic-3.003-2002-02-25b/runtime/cntlmsg.c
--- klic-3.003-2002-02-25a/runtime/cntlmsg.c	Mon Feb 25 10:47:17 2002
+++ klic-3.003-2002-02-25b/runtime/cntlmsg.c	Mon Feb 25 14:17:56 2002
@@ -469,7 +469,7 @@
   arity = (unsigned short int)(pred_of_goal->arity); 
   newgoal = (struct goalrec *)allocp;
   allocp = allocp+arity+2;
-  /* if(allocp >= real_heaplimit){
+  /* if(allocp >= real_heaplimit()){
    *   fatal("Bad estimation of decodeing, heap exausted");
    * }
    */
@@ -480,7 +480,7 @@
     newgoal->args[i-1] = pop_decode_stack();
   }  
 
-  if(prio == current_prio){
+  if(prio == current_prio()){
     resume_same_prio(newgoal); 
   } else {
     (void) enqueue_goal(NULL, prio, newgoal, glbl);    
@@ -510,7 +510,7 @@
       encode_data(buffer, goal->args[i], eager_transfer_level);
   }
 
-  PUT4_BUFFER(buffer, decode_throw_goal, send_wtc, (long)current_prio,
+  PUT4_BUFFER(buffer, decode_throw_goal, send_wtc, (long) current_prio(),
 	      goal->pred);
   return(wtc);
 }
@@ -632,7 +632,7 @@
       ptr += strlen(ptr);
   
       if (!IS_SHOEN_NODE(my_node)) {
-	  sprintf(ptr, " heap size = %d words\n", heapsize);
+	  sprintf(ptr, " heap size = %d words\n", heapsize());
 	  ptr += strlen(ptr);
       }
       sprintf(ptr, " %ld ms total; %ld user; %ld system\n",
diff -ruN klic-3.003-2002-02-25a/runtime/datamsg.c klic-3.003-2002-02-25b/runtime/datamsg.c
--- klic-3.003-2002-02-25a/runtime/datamsg.c	Mon Feb 25 10:48:23 2002
+++ klic-3.003-2002-02-25b/runtime/datamsg.c	Mon Feb 25 14:47:52 2002
@@ -139,10 +139,10 @@
 
   p_funct = (q) GET_BUFFER(inbuf);
 
-  if ( real_heaplimit - allocp  <  arityof(p_funct) + 1 ) {
+  if ( real_heaplimit() - allocp  <  arityof(p_funct) + 1 ) {
     inbuf->rd_index -= 2;
     heaplimit = 0;
-    this_more_space += arityof(p_funct)+1;
+    add_this_more_space(arityof(p_funct) + 1);
     return allocp;
   }
 
@@ -192,7 +192,7 @@
     }
     break;
   case CONS:
-    if ((q*)data < heaptop || heaptop+heapsize+incrementsize <= (q*)data) {
+    if ((q*)data < heaptop() || heaptop()+heapsize()+incrementsize() <= (q*)data) {
       goto Const_case;
     } else if (depth == 0) {
       goto Make_exref;
@@ -206,7 +206,7 @@
     }
     break;
   case FUNCTOR:
-    if ((q*)data < heaptop || heaptop+heapsize+incrementsize <= (q*)data) {
+    if ((q*)data < heaptop() || heaptop()+heapsize()+incrementsize() <= (q*)data) {
       goto Const_case;
     } else {
       q f = functor_of(data);
diff -ruN klic-3.003-2002-02-25a/runtime/export_table.c klic-3.003-2002-02-25b/runtime/export_table.c
--- klic-3.003-2002-02-25a/runtime/export_table.c	Tue Feb 19 15:19:57 2002
+++ klic-3.003-2002-02-25b/runtime/export_table.c	Mon Feb 25 14:58:49 2002
@@ -165,7 +165,7 @@
   j = 0;
   for(i=0; i<current_exp_size; i++){
     if(exp_table[i].data != (q) UNUSED_EXPREC){
-      newdata = general_gc(&(exp_table[i].data), gcsp);
+      newdata = general_gc(&(exp_table[i].data), gcsp());
       exp_table[i].data = newdata;
       j++;
     }
diff -ruN klic-3.003-2002-02-25a/runtime/faisus.c klic-3.003-2002-02-25b/runtime/faisus.c
--- klic-3.003-2002-02-25a/runtime/faisus.c	Mon Feb 18 15:19:42 2002
+++ klic-3.003-2002-02-25b/runtime/faisus.c	Mon Feb 25 13:14:54 2002
@@ -83,7 +83,7 @@
   declare_globals;
   int suspended = 0;
 
-  goal->next = (struct goalrec*) makeint(current_prio);
+  goal->next = (struct goalrec*) makeint(current_prio());
   if (derefone(reason) == reason) {
     /* no goals suspended yet on this variable */
     struct susprec* susp;
@@ -147,7 +147,7 @@
 
 	allocnewsusp(newvar, susp);
 	susp->u.first_hook.u.g = goal;
-	newgp->next = (struct goalrec*) makeint(current_prio);
+	newgp->next = (struct goalrec*) makeint(current_prio());
 	newgp->pred = &predicate_unify__term__dcode_xunify__goal_2;
 	newgp->args[0] = reason;
 	newgp->args[1] = newvar;
@@ -227,7 +227,7 @@
     }
 #endif /* DEBUGLIB */
 
-    goal->next = (struct goalrec*) makeint(current_prio);
+    goal->next = (struct goalrec*) makeint(current_prio());
     {
       int redo_request = 0;
       do {
diff -ruN klic-3.003-2002-02-25a/runtime/gc.c klic-3.003-2002-02-25b/runtime/gc.c
--- klic-3.003-2002-02-25a/runtime/gc.c	Wed Feb 20 15:43:24 2002
+++ klic-3.003-2002-02-25b/runtime/gc.c	Mon Feb 25 15:06:29 2002
@@ -44,9 +44,16 @@
 
 extern struct goalrec goal_queue_tail;
 
+static q** gcstack;
+static q** gcsp0;
+static q** gcmax0;
 static unsigned long gcstack_size;
 static unsigned long copied_susp;
 
+extern q** gcsp(void){ return gcsp0; }
+extern q** gcmax(void){ return gcmax0; }
+extern void set_gcsp(q** pp){ gcsp0 = pp; }
+
 static struct goalrec* collect_garbage(struct goalrec* qp);
 
 static Inline void
@@ -77,9 +84,8 @@
  gc_again:
   if( make_heap_larger ){
     q* new_old_space_top;
-    heapsize *= 2;
-    if( heapsize > maxheapsize ) heapsize = maxheapsize;
-    bytesize = (heapsize+incrementsize) * sizeof(q);
+    double_heapsize();
+    bytesize = (heapsize() + incrementsize()) * sizeof(q);
     new_old_space_top = (q*) malloc(bytesize);
     if( new_old_space_top != NULL ){
       new_new_space_top = (q*) malloc(bytesize);
@@ -96,7 +102,7 @@
     }
   }else if( lastgc_dangerous ){
     fatalf("Maximum heap size specified (%u words) has been used up",
-	   maxheapsize);
+	   maxheapsize());
   }
   flip_spaces();
   copied_susp = 0;		/* for perpetual suspension detection */
@@ -107,13 +113,13 @@
     set_old_space_size(bytesize);
   }
   make_heap_larger =
-    (heapp()-new_space_top()+this_more_space > heapsize*maxactiveratio &&
-     heapsize < maxheapsize);
-  lastgc_dangerous = (real_heaplimit < heapp()+this_more_space);
+    (heapp()-new_space_top()+this_more_space() > heapsize()*maxactiveratio() &&
+     heapsize() < maxheapsize());
+  lastgc_dangerous = (real_heaplimit() < heapp()+this_more_space());
   if( lastgc_dangerous ){
     goto gc_again;
   }
-  this_more_space = 0;
+  reset_this_more_space();
   gctimes++;
 #ifdef SHM
   if( F_shm_gc ) qp = shm_gc(qp);
@@ -142,7 +148,7 @@
   newstack = (q**) realloc_check((void*) gcstack, gcstack_size*sizeof(q*));
   sp = newstack + (sp - gcstack);
   gcstack = newstack;
-  gcmax = newstack + gcstack_size;
+  gcmax0 = newstack + gcstack_size;
   return sp;
 }
 
@@ -172,7 +178,7 @@
 do{							\
   if( (sp) == max ){					\
     (sp) = make_larger_stack(sp);			\
-    max = gcmax;					\
+    max = gcmax0;					\
   }							\
   *(sp)++ = (addr);					\
 }while(0)
@@ -291,7 +297,7 @@
 		  /* not yet copied */
 		  struct generator_object* newobj =
 		    (struct generator_object*) generic_gc(oldobj, hp, sp);
-		  sp = gcsp;
+		  sp = gcsp0;
 		  hp = heapp();
 		  oldobj->method_table =
 		    (struct generator_object_method_table*) makefunctor(newobj);
@@ -333,7 +339,7 @@
 			struct consumer_object* newobj =
 			  (struct consumer_object*)
 			    generic_gc(untag_consumer_hook(u.o), hp, sp);
-			sp = gcsp;
+			sp = gcsp0;
 			hp = heapp();
 			untag_consumer_hook(u.o)->method_table =
 			  (struct consumer_object_method_table*)
@@ -429,7 +435,7 @@
 	    struct data_object* oldobj = (struct data_object*) functorp(obj);
 	    q* newobj;
 	    newobj = generic_gc(oldobj, hp, sp);
-	    sp = gcsp;
+	    sp = gcsp0;
 	    hp = heapp();
 	    *addr = functor_of(obj) = makefunctor(newobj);
 	  }else{
@@ -452,7 +458,7 @@
       break;
     }
   }
-  gcsp = sp;
+  set_gcsp(sp);
   set_heapp(hp);
 }
 
@@ -488,9 +494,9 @@
     }
 #endif
     hp = heapp();
-    copy_one_goal(qp, gcsp, gcmax, 0);
+    copy_one_goal(qp, gcsp0, gcmax0, 0);
     set_heapp(hp);
-    copy_terms(gcsp, gcmax);
+    copy_terms(gcsp0, gcmax0);
     qp->next = last;
     last = qp;
   }
@@ -504,7 +510,7 @@
   declare_globals;
   int k;
   unsigned long nsize, osize;
-  struct prioqrec* pq = prioq.next;
+  struct prioqrec* pq = prioq().next;
 
 #ifdef DIST
   if( node_wtc == 0 ){
@@ -516,8 +522,8 @@
     /* allocate GC stack on first GC */
     gcstack_size = GCSTACKSIZE;
     gcstack = (q**) malloc_check(gcstack_size*sizeof(q*));
-    gcsp = gcstack;
-    gcmax = gcstack+gcstack_size;
+    set_gcsp(gcstack);
+    gcmax0 = gcstack + gcstack_size;
 #ifdef SHM
     shm_gcstack_size = GCSTACKSIZE;
     shm_gcstack = (q**) malloc(shm_gcstack_size*sizeof(q*));
@@ -567,11 +573,12 @@
   }
 #endif /* SHM */
 
-  set_heapp(heaptop = new_space_top());
-  real_heapbytesize = new_space_size();
-  real_heaplimit = heapp() + heapsize;
-  heaplimit = (interrupt_off ? real_heaplimit : 0);
-  heapbottom = real_heaplimit + incrementsize;
+  set_heaptop(new_space_top());
+  set_heapp(new_space_top());
+  set_real_heapbytesize(new_space_size());
+  set_real_heaplimit(heapp() + heapsize());
+  heaplimit = (interrupt_off ? real_heaplimit() : 0);
+  set_heapbottom(real_heaplimit() + incrementsize());
 
   for( k=0; k<num_gc_hooks(); k++ ){
     ((gc_t) gc_hook_table(k))();
@@ -591,8 +598,8 @@
       switch( ptagof(sptr->localA) ){
       case CONS:
       case FUNCTOR:  /* generator hook but anybody reqested */
-        push_gc_stack((q*) &sptr->localA, gcsp, gcmax);
-	copy_terms(gcsp, gcmax);
+        push_gc_stack((q*) &sptr->localA, gcsp0, gcmax0);
+	copy_terms(gcsp0, gcmax0);
         push_shm_stack(&sptr->globalA, shm_sp, shm_gcmax);
         break;
       case ATOMIC: /* genarator object (distributed interface) */
@@ -605,11 +612,11 @@
 	    q top = (q) &(sptr->localA);
 	    derefone(wk) = top;
 	    derefone(top) = wk;
-	    push_gc_stack(&top, gcsp, gcmax);
+	    push_gc_stack(&top, gcsp0, gcmax0);
 
 	    /* patch for debugging of hirata problem */
 	    hirata_bug1 = 1;
-	    copy_terms(gcsp, gcmax);
+	    copy_terms(gcsp0, gcmax0);
 	    hirata_bug1 = 0;
 
 	    wk = derefone(top);
@@ -618,8 +625,8 @@
 	    sptr->localA = (q*) tag_local(wk);
 	    derefone(wk) = 0;
 	  }else{ /* generator */
-	    push_gc_stack(&wk, gcsp, gcmax);
-	    copy_terms(gcsp, gcmax);
+	    push_gc_stack(&wk, gcsp0, gcmax0);
+	    copy_terms(gcsp0, gcmax0);
 	    sptr->localA = (q*) tag_local(wk);
 	  }
 	  push_shm_stack(&sptr->globalA, shm_sp, shm_gcmax);
@@ -632,9 +639,9 @@
 	  }else if( !wqp->pred ){
 	    sptr->localA = (q*) wqp->next;
 	  }else if( isint(wqp->next) ){
-	    copy_one_goal(wqp, gcsp, gcmax, 1);
+	    copy_one_goal(wqp, gcsp0, gcmax0, 1);
 	    sptr->localA = (q*) wqp;
-	    copy_terms(gcsp, gcmax);
+	    copy_terms(gcsp0, gcmax0);
 	    if( isref(sptr->globalA) ){
 	      for(;;){
 		q ww = derefone(sptr->globalA);
@@ -716,9 +723,9 @@
 	sgl->goal = sgl->goal->next;
       }else{
 	/* not copied yet */
-	copy_one_goal(sgl->goal, gcsp, gcmax, 0);
+	copy_one_goal(sgl->goal, gcsp0, gcmax0, 0);
 	set_heapp(hp);
-	copy_terms(gcsp, gcmax);
+	copy_terms(gcsp0, gcmax0);
 	hp = heapp();
 	dead_goal = sgl->goal;
       }
@@ -754,8 +761,8 @@
   q* term;
 {
   declare_globals;
-  push_gc_stack(term, gcsp, gcmax);
-  copy_terms(gcsp, gcmax);
+  push_gc_stack(term, gcsp0, gcmax0);
+  copy_terms(gcsp0, gcmax0);
 }
 
 /*
@@ -768,7 +775,7 @@
 {
   declare_globals;
 
-  push_gc_stack(term, sp, gcmax);
-  copy_terms(sp, gcmax);
+  push_gc_stack(term, sp, gcmax0);
+  copy_terms(sp, gcmax0);
   return *term;
 }
diff -ruN klic-3.003-2002-02-25a/runtime/generic.c klic-3.003-2002-02-25b/runtime/generic.c
--- klic-3.003-2002-02-25a/runtime/generic.c	Sun Feb 24 14:56:42 2002
+++ klic-3.003-2002-02-25b/runtime/generic.c	Mon Feb 25 15:00:39 2002
@@ -187,7 +187,7 @@
   q** g_sp;
 {
   declare_globals;
-  gcsp = g_sp;
+  set_gcsp(g_sp);
   return g_allocp;
 }
 
diff -ruN klic-3.003-2002-02-25a/runtime/gg_shvar.c klic-3.003-2002-02-25b/runtime/gg_shvar.c
--- klic-3.003-2002-02-25a/runtime/gg_shvar.c	Sat Feb 16 11:57:08 2002
+++ klic-3.003-2002-02-25b/runtime/gg_shvar.c	Mon Feb 25 13:15:12 2002
@@ -261,7 +261,7 @@
     gptr->chain = sptr;
     sptr->next = NULL;
     sptr->PE_num = my_node;
-    sptr->prio = current_prio;
+    sptr->prio = current_prio();
     sptr->indp = create_local_tbl(GG_GOAL, GG_SELF);
     n_unlock(temp, tag_generator_susp(gptr));
     return makeref(0);
@@ -290,7 +290,7 @@
     gvar->method = SHM_VAR;
     gvar->chain = sptr;
     sptr->PE_num = my_node;
-    sptr->prio = current_prio;
+    sptr->prio = current_prio();
     sptr->indp = create_local_tbl(GG_GOAL, GG_SELF);
     shm_request_queueing(pe_num, prio, ind);
     n_unlock(temp, addi);
@@ -314,7 +314,7 @@
     bgp->next = sptr;
     sptr->next = gp;
     sptr->PE_num = my_node;
-    sptr->prio = current_prio;
+    sptr->prio = current_prio();
     sptr->indp = create_local_tbl(GG_GOAL, GG_SELF);
     n_unlock(temp, addi);
     return makeref(0);
diff -ruN klic-3.003-2002-02-25a/runtime/gio.c klic-3.003-2002-02-25b/runtime/gio.c
--- klic-3.003-2002-02-25a/runtime/gio.c	Sun Feb 24 14:31:32 2002
+++ klic-3.003-2002-02-25b/runtime/gio.c	Mon Feb 25 14:49:08 2002
@@ -144,8 +144,8 @@
 	GCSET_MESSAGE_INT_ARG(n, message, 0);
 	if( n<0 ) goto message_error;
 	space_needed = sizeof(struct byte_string_object) + n + sizeof(q);
-	if( (char*) g_allocp+space_needed >= (char*) real_heaplimit ){
-	  this_more_space += (space_needed+sizeof(q)-1)/sizeof(q);
+	if( (char*) g_allocp+space_needed >= (char*) real_heaplimit() ){
+	  add_this_more_space((space_needed + sizeof(q) - 1) / sizeof(q));
 	  goto gc_request;
 	}
 	buf = (char*) malloc_check(n);
diff -ruN klic-3.003-2002-02-25a/runtime/gmvv.c klic-3.003-2002-02-25b/runtime/gmvv.c
--- klic-3.003-2002-02-25a/runtime/gmvv.c	Sun Feb 24 17:02:01 2002
+++ klic-3.003-2002-02-25b/runtime/gmvv.c	Mon Feb 25 15:07:19 2002
@@ -150,7 +150,7 @@
     long size = GD_SELF->index;
     q *newbody;
     long k;
-    if ((g_allocp+size)>real_heaplimit) fatal("Not enough space collected");
+    if ((g_allocp+size)>real_heaplimit()) fatal("Not enough space collected");
     newbody = g_allocp;
     g_allocp += size;
     newself->next = VECTOR_SHALLOW_MARK;
@@ -170,7 +170,7 @@
      * GD_COPY_KL1_TERM_TO_NEWGEN(GD_SELF->body, newself->body);
      */
     newself->body = GD_SELF->body;
-    if ((g_sp) == gcmax) {
+    if (g_sp == gcmax()) {
       (g_sp) = make_larger_stack(g_sp);
     }
     *(g_sp++) = (q *)&(newself->body);
@@ -670,7 +670,7 @@
   /* G_HEAPALLOC(newvect, G_SIZE_IN_Q(GD_OBJ_TYPE), (GD_OBJ_TYPE*)); */
 
   if(GENERIC_GCREQUEST == res){
-      this_more_space += G_SIZE_IN_Q(GD_OBJ_TYPE);
+      add_this_more_space(G_SIZE_IN_Q(GD_OBJ_TYPE));
       
       inbuf->rd_index--;
 
@@ -689,7 +689,7 @@
         (res==GENERIC_SUCCEEDED && g_allocp >= heapp()+size) );
   /* G_HEAPALLOC(body, size, (q*)); */
   if(GD_GCREQUEST == res){
-      this_more_space += size;
+      add_this_more_space(size);
       
       inbuf->rd_index -= 2;
 
diff -ruN klic-3.003-2002-02-25a/runtime/gstring.c klic-3.003-2002-02-25b/runtime/gstring.c
--- klic-3.003-2002-02-25a/runtime/gstring.c	Sun Feb 24 17:02:28 2002
+++ klic-3.003-2002-02-25b/runtime/gstring.c	Mon Feb 25 14:50:02 2002
@@ -139,7 +139,7 @@
     unsigned char *newbody;
     unsigned long size = GD_SELF->index;
     unsigned long qsize = ROUND_UP(size);
-    if ((g_allocp+qsize)>real_heaplimit) fatal("Not enough space collected");
+    if ((g_allocp+qsize)>real_heaplimit()) fatal("Not enough space collected");
     newbody = (unsigned char *)g_allocp;
     g_allocp += qsize;
     newself->next = STRING_SHALLOW_MARK;
@@ -697,7 +697,7 @@
   /* G_HEAPALLOC(newstring, G_SIZE_IN_Q(GD_OBJ_TYPE), (GD_OBJ_TYPE*)); */
 
   if(GENERIC_GCREQUEST == res){ 
-      this_more_space += G_SIZE_IN_Q(GD_OBJ_TYPE);
+      add_this_more_space(G_SIZE_IN_Q(GD_OBJ_TYPE));
       
       inbuf->rd_index--;
 
@@ -720,7 +720,7 @@
   /* G_HEAPALLOC(body, size, (unsigned char*)); */
 
   if(GD_GCREQUEST == res){ 
-      this_more_space += size;
+      add_this_more_space(size);
       
       inbuf->rd_index -= 2;
 
diff -ruN klic-3.003-2002-02-25a/runtime/gunix.kl1 klic-3.003-2002-02-25b/runtime/gunix.kl1
--- klic-3.003-2002-02-25a/runtime/gunix.kl1	Fri Feb 22 22:27:35 2002
+++ klic-3.003-2002-02-25b/runtime/gunix.kl1	Mon Feb 25 14:03:22 2002
@@ -814,8 +814,8 @@
     if( toread > iob->lim - iob->ptr ) toread = iob->lim - iob->ptr;
     if( (char*) allocp +
         sizeof(struct byte_string_object) + toread + sizeof(long) >=
-        (char*) real_heaplimit ){
-      allocp = real_heaplimit;
+        (char*) real_heaplimit() ){
+      allocp = real_heaplimit();
       goto async__io_5_ext_interrupt;
     }
     for( k=0, nnl=0; k<toread; k++ ){
@@ -993,8 +993,8 @@
     if( toread > iob->lim - iob->ptr ) toread = iob->lim - iob->ptr;
     if( (char*) allocp +
         sizeof(struct byte_string_object) + toread + sizeof(long) >=
-        (char*) real_heaplimit ){
-      allocp = real_heaplimit;
+        (char*) real_heaplimit() ){
+      allocp = real_heaplimit();
       goto async__input_4_ext_interrupt;
     }
     for( k=0, nnl=0; k<toread; k++ ){
diff -ruN klic-3.003-2002-02-25a/runtime/intrpt.c klic-3.003-2002-02-25b/runtime/intrpt.c
--- klic-3.003-2002-02-25a/runtime/intrpt.c	Wed Feb 20 16:07:08 2002
+++ klic-3.003-2002-02-25b/runtime/intrpt.c	Mon Feb 25 14:50:32 2002
@@ -50,7 +50,7 @@
     rsmg->next = qp;
     qp = newqp;
     resumed_goals = NULL;
-    if( interrupt_off ) heaplimit = real_heaplimit;
+    if( interrupt_off ) heaplimit = real_heaplimit();
   }
   return qp;
 }
@@ -84,7 +84,7 @@
       set_heapp(allocp);
       klic_signal_handler();
       allocp = heapp();
-      retry = (allocp + this_more_space >= real_heaplimit);
+      retry = (allocp + this_more_space() >= real_heaplimit());
       /* some goals may have been resumed by the signal handler */
       qp = enqueue_resumed_goals(qp);
     }
@@ -93,9 +93,9 @@
     {
       int again = receive_message(allocp, 0);
       if( again == 0 )
-	heaplimit = real_heaplimit;
+	heaplimit = real_heaplimit();
       allocp = heapp();
-      retry = (allocp + this_more_space >= real_heaplimit);
+      retry = (allocp + this_more_space() >= real_heaplimit());
       /* some goals may have been resumed by the message reception */
       qp = enqueue_resumed_goals(qp);
     }
@@ -111,25 +111,25 @@
       klic_barrier();
       qp = get_invoked_goals(qp);
       interrupt_off = -1;
-      heaplimit = real_heaplimit;
-      retry |= (allocp + this_more_space >= heaplimit);
+      heaplimit = real_heaplimit();
+      retry |= (allocp + this_more_space() >= heaplimit);
     }
 #endif
 
     /* priority support */
     if( higher_priority_goal ){
       higher_priority_goal = 0;
-      put_priority_queue(qp, current_prio);
+      put_priority_queue(qp, current_prio());
       qp = get_top_priority_queue();
-      if( interrupt_off ) heaplimit = real_heaplimit;
+      if( interrupt_off ) heaplimit = real_heaplimit();
     }
 
 #ifdef SHM
-    if( ck_shm_gc() || allocp + this_more_space >= real_heaplimit ){
+    if( ck_shm_gc() || allocp + this_more_space() >= real_heaplimit() ){
       *cur_status = 3;
     /* ck_shm_gc will call another GC */
 #else
-    if( allocp + this_more_space >= real_heaplimit ){
+    if( allocp + this_more_space() >= real_heaplimit() ){
 #endif
       GC_ON();
       qp = klic_gc(qp);
diff -ruN klic-3.003-2002-02-25a/runtime/kmain.c klic-3.003-2002-02-25b/runtime/kmain.c
--- klic-3.003-2002-02-25a/runtime/kmain.c	Wed Feb 20 15:44:56 2002
+++ klic-3.003-2002-02-25b/runtime/kmain.c	Mon Feb 25 14:34:50 2002
@@ -63,6 +63,18 @@
 extern int start_tracing;
 extern int count_suspension;
 
+static unsigned long heapsize0, maxheapsize0, incrementsize0;
+static double maxactiveratio0;
+extern unsigned long heapsize(void){ return heapsize0; }
+extern unsigned long maxheapsize(void){ return maxheapsize0; }
+extern unsigned long incrementsize(void){ return incrementsize0; }
+extern double maxactiveratio(void){ return maxactiveratio0; }
+extern void
+double_heapsize(void){
+  heapsize0 *= 2;
+  if( heapsize0 > maxheapsize0 ) heapsize0 = maxheapsize0;
+}
+
 #ifdef USETIMER
 static unsigned long dl_det_interval;
 #endif /*USETIMER*/
@@ -270,12 +282,12 @@
 #endif /* DIST */
   /* All processing depending on the argument variables must be done
      after spawn_children() or it fails to read the arguments. */
-  maxactiveratio = max_a_ratio;
-  heapsize = h_size;
-  maxheapsize = max_h_size;
-  incrementsize = inc_size;
-  if (heapsize > maxheapsize)
-    maxheapsize = heapsize;
+  maxactiveratio0 = max_a_ratio;
+  heapsize0 = h_size;
+  maxheapsize0 = max_h_size;
+  incrementsize0 = inc_size;
+  if (heapsize0 > maxheapsize0)
+    maxheapsize0 = heapsize0;
   initalloc();
 
 #ifdef SHM
@@ -338,7 +350,7 @@
       suspensions = 0;
       cum_resumps += resumes;
       resumes = 0;
-      current_prio = -1;
+      set_current_prio(-1);
       suspended_goal_list = 0;
       if (start_tracing) {
 	  initiate_trace();
@@ -379,7 +391,7 @@
 #else /*!DIST*/
       if (postmortem_pred == 0 || postmortem_args == 0) break;
       klic_fprintf(stderr, "Starting postmortem processing...\n");
-      set_heapp (heapp() + incrementsize/2);  /* dirty patch */
+      set_heapp (heapp() + incrementsize()/2);  /* dirty patch */
       initiate_prioq();
       allocp = heapp();
       qp = (struct goalrec *) allocp;
@@ -577,7 +589,7 @@
 #ifdef USETIMER
     if (dl_det_interval != 0)
 #endif
-      allocp = real_heaplimit;
+      allocp = real_heaplimit();
   set_heapp(allocp);
   klic_interrupt(qp);
   allocp = heapp();
diff -ruN klic-3.003-2002-02-25a/runtime/random.c klic-3.003-2002-02-25b/runtime/random.c
--- klic-3.003-2002-02-25a/runtime/random.c	Mon Feb 25 11:00:19 2002
+++ klic-3.003-2002-02-25b/runtime/random.c	Mon Feb 25 15:01:07 2002
@@ -78,7 +78,7 @@
 
   BCOPY(GG_SELF, g_allocp, sizeof(GG_OBJ_TYPE));
   g_allocp += sizeof(GG_OBJ_TYPE)/sizeof(q);
-  gcsp = g_sp;
+  set_gcsp(g_sp);
   set_heapp(g_allocp);
   return newself;
 }
diff -ruN klic-3.003-2002-02-25a/runtime/sched.c klic-3.003-2002-02-25b/runtime/sched.c
--- klic-3.003-2002-02-25a/runtime/sched.c	Mon Feb 18 15:40:47 2002
+++ klic-3.003-2002-02-25b/runtime/sched.c	Mon Feb 25 13:32:00 2002
@@ -52,7 +52,6 @@
   prioqrec_free = pqr; \
 }while(0)
 
-
 extern char* calloc();
 extern module topsucceed();
 
@@ -82,6 +81,14 @@
 struct goalrec goal_queue_tail = { 0, &queue_empty_pred, { 0 } };
 
 
+static unsigned long current_prio0;	/* current priority */
+extern unsigned long current_prio(void){ return current_prio0; }
+extern void set_current_prio(unsigned long prio){ current_prio0 = prio; }
+
+static struct prioqrec prioq0;	/* priority queue head */
+extern struct prioqrec prioq(void){ return prioq0; }
+
+
 static struct prioqrec* prioqrec_free = NULL;
 
 static struct prioqrec*
@@ -134,7 +141,7 @@
   allocp += 2;
 #endif
 
-  prioq.next = pq;
+  prioq0.next = pq;
 
   set_heapp(allocp);
 }
@@ -169,7 +176,7 @@
   struct global_variables* glbl;
 {
   if( prio<0 ) prio = 0;
-  if( current_prio == prio ){
+  if( current_prio() == prio ){
     gp->next = qp;
     qp = gp;
   }else{
@@ -185,7 +192,7 @@
     }else
 #endif
     {
-      struct prioqrec* pq = &prioq;
+      struct prioqrec* pq = &prioq0;
       while( pq->next->prio > prio ){
 	pq = pq->next;
       }
@@ -207,7 +214,7 @@
       }
 
       /* interrupt for higher priority goal */
-      if( current_prio < prio ){
+      if( current_prio() < prio ){
 	higher_priority_goal = 1;
 	heaplimit = 0;
       }
@@ -238,7 +245,7 @@
   if( isint(prio) ){
     return
       enqueue_goal(qp,
-		   (is_relative ? current_prio-intval(prio) : intval(prio)),
+		   (is_relative ? current_prio()-intval(prio) : intval(prio)),
 		   gp, glbl);
   }
   if( !isref(prio) ) priority_type_error(qp);
@@ -313,10 +320,10 @@
 # ifdef SHM
       return throw_goal_routine(intval(penum), qp, gp);
 # else
-      return enqueue_goal(qp, current_prio, gp, glbl);
+      return enqueue_goal(qp, current_prio(), gp, glbl);
 # endif
 #endif
-    }else return enqueue_goal(qp, current_prio, gp, glbl);
+    }else return enqueue_goal(qp, current_prio(), gp, glbl);
   }
   if( !isref(penum) ) fatal("inter cluster pragma error");
   {
@@ -375,11 +382,11 @@
   struct goalrec* newqp;
   struct prioqrec* newprioq;
 
-  newqp = prioq.next->q;
-  current_prio = prioq.next->prio;
-  newprioq = prioq.next->next;
-  free_prioqrec(prioq.next);
-  prioq.next = newprioq;
+  newqp = prioq0.next->q;
+  set_current_prio(prioq0.next->prio);
+  newprioq = prioq0.next->next;
+  free_prioqrec(prioq0.next);
+  prioq0.next = newprioq;
   return newqp;
 }
 
@@ -389,7 +396,7 @@
   long prio;
 {
   declare_globals;
-  struct prioqrec* pq = &prioq;
+  struct prioqrec* pq = &prioq0;
 
   while( pq->next->prio >= prio ){
     pq = pq->next;
@@ -417,7 +424,7 @@
   long prio;
 {
   declare_globals;
-  struct prioqrec* pq = &prioq;
+  struct prioqrec* pq = &prioq0;
 
   while( pq->next->prio > prio ){
     pq = pq->next;
@@ -489,7 +496,7 @@
   ex_qp = eqp;
   s_unlock(key);
 
-  put_priority_queue(qp, current_prio);
+  put_priority_queue(qp, current_prio());
   eqp = sqp;
   for(;;){
     put_priority_goal(&eqp->goal, eqp->prio);
diff -ruN klic-3.003-2002-02-25a/runtime/sendrecv.c klic-3.003-2002-02-25b/runtime/sendrecv.c
--- klic-3.003-2002-02-25a/runtime/sendrecv.c	Tue Feb 19 15:21:48 2002
+++ klic-3.003-2002-02-25b/runtime/sendrecv.c	Mon Feb 25 15:01:15 2002
@@ -155,7 +155,7 @@
   declare_globals;
   /* static combuf* pending_msg = NULL; */
 
-  if( allocp + this_more_space >= real_heaplimit ){
+  if( allocp + this_more_space() >= real_heaplimit() ){
     set_heapp(allocp);
     return 1;
   }
@@ -196,7 +196,7 @@
       module decoder;
       decoder = (module) GET_BUFFER(inbuf);
       allocp = (q*) decoder(inbuf, allocp);
-      if( allocp + this_more_space >= real_heaplimit ){
+      if( allocp + this_more_space() >= real_heaplimit() ){
 	/* fprintf(stderr, "Node %d, decode pending\n", my_node); */
 	pending_msg = inbuf;
 
@@ -205,11 +205,11 @@
       }
     }
 
-    if( allocp + this_more_space >= real_heaplimit ){
+    if( allocp + this_more_space() >= real_heaplimit() ){
       /* Heap over in msg_handler.  this should not happen */
       fprintf(stderr,
 	"Node %d, heap over in msg_handler allocp = %x tms = %x rhl = %x\n",
-	my_node, allocp, this_more_space, real_heaplimit );
+	my_node, allocp, this_more_space(), real_heaplimit() );
 
       set_heapp(allocp);
       return 1;
@@ -537,7 +537,7 @@
 
   decode_stack_tmp = decode_stack;
   while( decode_stack_tmp != decode_stack_ptr ){
-    newdata = general_gc(decode_stack_tmp, gcsp);
+    newdata = general_gc(decode_stack_tmp, gcsp());
     *decode_stack_tmp = newdata;
     decode_stack_tmp++;
 
diff -ruN klic-3.003-2002-02-25a/runtime/shm_gc.c klic-3.003-2002-02-25b/runtime/shm_gc.c
--- klic-3.003-2002-02-25a/runtime/shm_gc.c	Mon Jan 21 20:55:25 2002
+++ klic-3.003-2002-02-25b/runtime/shm_gc.c	Mon Feb 25 13:28:20 2002
@@ -210,7 +210,7 @@
   struct goalrec* qp;
 {
   declare_globals;
-  struct prioqrec* pq = prioq.next;
+  struct prioqrec* pq = prioq().next;
 
   struct timeval before, after;
   int i, j;
diff -ruN klic-3.003-2002-02-25a/runtime/shm_obj.c klic-3.003-2002-02-25b/runtime/shm_obj.c
--- klic-3.003-2002-02-25a/runtime/shm_obj.c	Sun Feb 24 14:29:34 2002
+++ klic-3.003-2002-02-25b/runtime/shm_obj.c	Mon Feb 25 13:16:37 2002
@@ -199,7 +199,7 @@
     bp->next = sptr;
     sptr->next = shrec;
     sptr->PE_num = my_node;
-    sptr->prio = current_prio;
+    sptr->prio = current_prio();
     mid = derefone(cvar);
     derefone(cvar) = shv;
     derefone(mid) = 0;
@@ -213,7 +213,7 @@
     vr->chain = sptr;
     sptr->next = 0;
     sptr->PE_num = my_node;
-    sptr->prio = current_prio;
+    sptr->prio = current_prio();
     mid = derefone(cvar);
     derefone(cvar) = shv;
     derefone(mid) = 0;
@@ -290,7 +290,7 @@
 	struct goalrec* goal = (struct goalrec*) term;
 	if( goal != NULL && isatomic(goal->next) ){
 	  long prio = intval(goal->next);
-	  if( current_prio != prio ){
+	  if( current_prio() != prio ){
 	    enqueue_goal(NULL, prio, goal, glbl);
 	  }else{
 	    resume_same_prio(goal);
@@ -342,7 +342,7 @@
     shm_arg_copy(&indp->localA, &temp);
     allocp = do_unify(allocp, indp->globalA, temp);
   }else{
-    shm_request_queueing(penum, current_prio, indp);
+    shm_request_queueing(penum, current_prio(), indp);
   }
   return allocp;
 }
diff -ruN klic-3.003-2002-02-25a/runtime/shm_throw.c klic-3.003-2002-02-25b/runtime/shm_throw.c
--- klic-3.003-2002-02-25a/runtime/shm_throw.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-02-25b/runtime/shm_throw.c	Mon Feb 25 14:30:44 2002
@@ -20,7 +20,7 @@
 #endif
 
 #define is_locala(X) \
-    ( (unsigned long)((long)(X)-(long)heaptop) < real_heapbytesize )
+  ((unsigned long) ((long) (X) - (long) heaptop()) < real_heapbytesize())
 
 #define makeshvar(svar) \
 do{ \
@@ -101,7 +101,7 @@
   }
 #endif
 
-  sh_goal = shm_goal_copy(gp, current_prio);
+  sh_goal = shm_goal_copy(gp, current_prio());
   shm_goal_stack(sh_goal, num);
   *cur_status = 1;
   return qp;
diff -ruN klic-3.003-2002-02-25a/runtime/signal.c klic-3.003-2002-02-25b/runtime/signal.c
--- klic-3.003-2002-02-25a/runtime/signal.c	Wed Feb 20 16:12:29 2002
+++ klic-3.003-2002-02-25b/runtime/signal.c	Mon Feb 25 14:04:55 2002
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#define SIGMAIN
+
 #include <klic/basic.h>  /* fatalf */
 
 #ifdef USESIG
@@ -12,8 +12,13 @@
 #include <klic/struct.h>
 #include <klic/sighndl.h>
 
+#define signal_handlers		(klic_sgnl_flags->sgnl_handlers)
+
 extern void copy_one_term();
 
+static struct klic_sgnl_flags my_klic_sgnl_flags;
+volatile struct klic_sgnl_flags* klic_sgnl_flags = &my_klic_sgnl_flags;
+
 /****************************************
   GENERAL SIGNAL HANDLING UTILITY
 ****************************************/
@@ -59,7 +64,7 @@
       }
     }
     interrupt_off = -1;
-    heaplimit = real_heaplimit;
+    heaplimit = real_heaplimit();
     for (sig = 0; sig < NSIG; sig++) {
       if (signal_flags[sig]) {
 	signal_done = 0;
diff -ruN klic-3.003-2002-02-25a/runtime/step.c klic-3.003-2002-02-25b/runtime/step.c
--- klic-3.003-2002-02-25a/runtime/step.c	Mon Feb 18 15:17:52 2002
+++ klic-3.003-2002-02-25b/runtime/step.c	Mon Feb 25 13:17:20 2002
@@ -143,7 +143,7 @@
     }
     /* make goal list in reverse order */
     /* first, those queued with higher priority */
-    for (k = 0; k < num_queued && queued_prio[k] > current_prio; k++) {
+    for (k = 0; k < num_queued && queued_prio[k] > current_prio(); k++) {
       q gobj = make_goal_object(queued_goals[k], allocp);
       allocp = heapp();
       allocp[0] = gobj;
@@ -204,7 +204,7 @@
     for (k = 0; k < num_wokenup; k++) {
       q gobj = make_goal_object(wokenup_goals[k], allocp);
       allocp = heapp();
-      if (wokenup_prio[k] != current_prio) {
+      if (wokenup_prio[k] != current_prio()) {
 	allocp[0] = gobj;
 	allocp[1] = makeint(queued_prio[k]);
 	gobj = makecons(&allocp[0]);
diff -ruN klic-3.003-2002-02-25a/runtime/sysc.kl1 klic-3.003-2002-02-25b/runtime/sysc.kl1
--- klic-3.003-2002-02-25a/runtime/sysc.kl1	Fri Feb 22 22:27:35 2002
+++ klic-3.003-2002-02-25b/runtime/sysc.kl1	Mon Feb 25 14:05:08 2002
@@ -43,7 +43,7 @@
 gc(Before, After) :- inline:"
   {
     %0 = makeint(allocp - new_space_top());
-    allocp = real_heaplimit;
+    allocp = real_heaplimit();
     heaplimit = 0;
   }": [Before0-int] |
   Before = Before0,
diff -ruN klic-3.003-2002-02-25a/runtime/trace.c klic-3.003-2002-02-25b/runtime/trace.c
--- klic-3.003-2002-02-25a/runtime/trace.c	Sat Feb 16 12:05:53 2002
+++ klic-3.003-2002-02-25b/runtime/trace.c	Mon Feb 25 14:05:18 2002
@@ -689,7 +689,7 @@
 
   parent = 0;
   set_heapp(allocp);
-  if (interrupt_off) heaplimit = real_heaplimit;
+  if (interrupt_off) heaplimit = real_heaplimit();
   else heaplimit = 0;
   return qp;
 }
@@ -1752,10 +1752,10 @@
      struct trace_info_rec *info;
 {
   declare_globals;
-  if (prio < current_prio) {
-    trace_printf(info, "@prio(-%ld)", current_prio-prio);
-  } else if (prio > current_prio) {
-    trace_printf(info, "@prio(+%ld)", prio-current_prio);
+  if (prio < current_prio()) {
+    trace_printf(info, "@prio(-%ld)", current_prio()-prio);
+  } else if (prio > current_prio()) {
+    trace_printf(info, "@prio(+%ld)", prio-current_prio());
   }
 }
 
@@ -1949,8 +1949,8 @@
      struct trace_info_rec *info;
 {
   declare_globals;
-  struct prioqrec *pq = prioq.next;
-  dump_seq = dump_one_queue(current_prio, qp, dump_seq, info);
+  struct prioqrec* pq = prioq().next;
+  dump_seq = dump_one_queue(current_prio(), qp, dump_seq, info);
   while (pq->prio >= 0) {
     dump_seq = dump_one_queue(pq->prio, pq->q, dump_seq, info);
     pq = pq->next;
diff -ruN klic-3.003-2002-02-25a/runtime/unify.c klic-3.003-2002-02-25b/runtime/unify.c
--- klic-3.003-2002-02-25a/runtime/unify.c	Wed Feb 20 13:20:57 2002
+++ klic-3.003-2002-02-25b/runtime/unify.c	Mon Feb 25 13:18:24 2002
@@ -26,7 +26,7 @@
 #define enqueue_unify_terms(x, y) \
 { \
   struct goalrec *gp = (struct goalrec *)allocp; \
-  gp->next = (struct goalrec*)makeint(current_prio); \
+  gp->next = (struct goalrec*) makeint(current_prio()); \
   gp->pred = &predicate_unify__term__dcode_xunify_2; \
   gp->args[0] = x; \
   gp->args[1] = y; \
@@ -37,7 +37,7 @@
 #define enqueue_unify_goal(x, y) \
 { \
   struct goalrec *gp = (struct goalrec *)allocp; \
-  gp->next = (struct goalrec*)makeint(current_prio); \
+  gp->next = (struct goalrec*) makeint(current_prio()); \
   gp->pred = &predicate_unify__term__dcode_xunify__goal_2; \
   gp->args[0] = (x); \
   gp->args[1] = (y); \
@@ -181,7 +181,7 @@
 	  } else
 #endif
 	    {
-	      if (gp != current_prio) {
+	      if (gp != current_prio()) {
 		(void) enqueue_goal(NULL, gp, u.g, glbl);
 	      } else {
 		resume_same_prio(u.g);
