diff -ruN klic-3.003-2001-12-28/ChangeLog klic-3.003-2001-12-29/ChangeLog
--- klic-3.003-2001-12-28/ChangeLog	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/ChangeLog	Sat Dec 29 12:46:20 2001
@@ -1,3 +1,12 @@
+2001-12-29 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* include/klic/basic.h:
+	remove Const and Volatile.
+	change NoReturn to NeverReturn.
+
+	* runtime/config/pvm-tcp/distpkt.c, runtime/sendrecv.c:
+	correct some call fatal to fatalf.
+
 2001-12-28 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
 
 	* include/klic/asyncio.h, include/klic/g_pointer.h,
diff -ruN klic-3.003-2001-12-28/compiler/klicdb.c klic-3.003-2001-12-29/compiler/klicdb.c
--- klic-3.003-2001-12-28/compiler/klicdb.c	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/compiler/klicdb.c	Sat Dec 29 12:46:20 2001
@@ -514,8 +514,10 @@
   if (!nocfiles) {
     atomh = open_cwd_out("atom.h");
     atomc = open_db_out("atom.c");
-    (void) fprintf(atomh, "#include <klic/atomstuffs.h>\n");
+    (void) fprintf(atomh,
+      "#include <klic/atomstuffs.h>  /* ATOMNUMBERBASE */\n\n");
     (void) fprintf(atomc,
+      "#include <klic/atomstuffs.h>  /* atomname */\n" \
       "#include <klic/basic.h>\n\n" \
       "unsigned char* const init_atomname[] = {\n" );
   }
@@ -549,11 +551,13 @@
   if (!nocfiles) {
     functh = open_cwd_out("funct.h");
     functc = open_db_out("funct.c");
-    (void) fprintf(functh, "#include <klic/functorstuffs.h>\n\n");
+    (void) fprintf(functh,
+      "#include <klic/functorstuffs.h>  /* FUNCTORNUMBERBASE */\n\n");
     (void) fprintf(functc,
-		"#include <klic/basic.h>\n" \
-		"#include <klic/atomstuffs.h>\n\n" \
-		"const unsigned long init_functors[] = {\n" );
+      "#include <klic/atomstuffs.h>  /* ATOMNUMBERBASE */\n" \
+      "#include <klic/functorstuffs.h>  /* functors, arities */\n" \
+      "#include <klic/basic.h>\n\n" \
+      "const unsigned long init_functors[] = {\n" );
   }
   for (f=functroot; f!=NULL; f=f->next) {
     if (!nocfiles) {
@@ -576,7 +580,7 @@
       (void)fprintf(functc, "\t%dL,\n", f->arity);
     }
     assert(f == NULL);
-    (void) fprintf(functc, "};\n" \
+    (void) fprintf(functc, "};\n\n" \
 		"const unsigned long initial_functors = %d;\n" \
 		"unsigned long* functors = (unsigned long*) init_functors;\n" \
 		"unsigned long* arities = (unsigned long*) init_arities;\n",
diff -ruN klic-3.003-2001-12-28/compiler/macro.kl1 klic-3.003-2001-12-29/compiler/macro.kl1
--- klic-3.003-2001-12-28/compiler/macro.kl1	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/compiler/macro.kl1	Sat Dec 29 12:46:20 2001
@@ -40,7 +40,7 @@
     dlclause_1(F,G0,B0,H,G,B,N0,N,V).
 otherwise.
 dlclause(H0,G0,B0,H,G,B,N0,N,V) :-
-    klic_comp_message:report_error("Illegal head: ~w",[H0]).
+    klic_comp_message:report_error("Invalid head: ~w",[H0]).
 
  % ---------- Extra Arguments are added to the head goal ----------
  % If Head Goal is a functor, then 
@@ -159,7 +159,7 @@
  dlgoal(functor(variable(I)/=Expr0),X,V)-N-Vinfo :-
     dl_compute(Expr0,X,V)-N-Vinfo+I+(/).
  dlgoal(variable(X0), X, V)-N-Vinfo :-
-    klic_comp_message:report_error("Illegal goal: ~W",[variable(X0)]),
+    klic_comp_message:report_error("Invalid goal: ~W",[variable(X0)]),
     X=variable(X0).
  otherwise.
  dlgoal(X0,X,V)-N-Vinfo :-
@@ -367,7 +367,7 @@
          exp_body(B,V1,_,NewT,_,Exp,[],NewB,[]).
     otherwise.
     body_or_one(X,                  _,_,_)-OR :-
-         klic_comp_message:report_error("Illegal body or case: ~w", [X]).
+         klic_comp_message:report_error("Invalid body or case: ~w", [X]).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %          ----- MACRO GOAL -----           %
@@ -378,7 +378,7 @@
     B <= atom(G).
 otherwise.
 macro_goal(G)-V-After-B+GB :-
-    klic_comp_message:report_error("Illegal Goal: ~w",[G]).
+    klic_comp_message:report_error("Invalid Goal: ~w",[G]).
 
 macro_goal_functor((LHS0:=RHS0))-V-After-B+GB :-
     macro_arg_n([.(LHS0,LHS),.(RHS0,RHS)])-V-After-B+GB,
diff -ruN klic-3.003-2001-12-28/compiler/normalize.kl1 klic-3.003-2001-12-29/compiler/normalize.kl1
--- klic-3.003-2001-12-28/compiler/normalize.kl1	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/compiler/normalize.kl1	Sat Dec 29 12:46:20 2001
@@ -195,7 +195,7 @@
 otherwise.
   norm_inline_arg(Arg,_X,Ans,_Info0,_Info,_Vars0,_Vars)-CCT-P :-
       _Info = _Info0,
-      klic_comp_message:warning("Illegal argument to inline: ~w",[Arg])-P,
+      klic_comp_message:warning("Invalid argument to inline: ~w",[Arg])-P,
       Ans=abnormal.
 
    norm_inline_arg_1(yes(_),Vars0,K,Type,Ans)-P :-
@@ -605,7 +605,7 @@
 otherwise.
 norm_pragma_1(G0,G,V0,V,Pragma,Ans)-Pool :- 
       klic_comp_message:report_error(
-	"Illegal pragma: ~w attached to goal: ~w", [Pragma,G0])-Pool.
+	"Invalid pragma: ~w attached to goal: ~w", [Pragma,G0])-Pool.
 
 norm_pragma_priority(functor(atom(M):G1),G,V0,V,P0,Ans)-Pool :- 
     G=xpcall(P,M,F,A,Args),
@@ -659,7 +659,7 @@
     F = G0, A = 0, Args = [], Vars = Vars0, Ans=normal.
 otherwise.
 norm_body_args(G,F,A,Args,Vars0,Vars,Ans)-Pool :-
-    klic_comp_message:report_error("Illegal body goal: ~w", [G])-Pool,
+    klic_comp_message:report_error("Invalid body goal: ~w", [G])-Pool,
     Ans=abnormal.
 
 norm_body_args([],     Args,Vars0,Vars,Ans)-Pool :- 
diff -ruN klic-3.003-2001-12-28/include/klic/alloc.h klic-3.003-2001-12-29/include/klic/alloc.h
--- klic-3.003-2001-12-28/include/klic/alloc.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/alloc.h	Sat Dec 29 12:46:20 2001
@@ -13,13 +13,13 @@
 
 
 /** Reverse allocation from "heaptop"
- * revalloc: procedure
+ * heapalloc: procedure
  *   s: maketype&
  *   words > 0: offset_t
  *   maketype: type cast or function returning q
  */
 
-#define revalloc(s, words, maketype) \
+#define heapalloc(s, words, maketype) \
 do{ \
   heapbottom -= (words); \
   (s) = maketype(heapbottom); \
@@ -28,9 +28,6 @@
   if(heaplimit != 0) \
     heaplimit = (interrupt_off ? real_heaplimit : 0); \
 }while(0)
-
-#define heapalloc(s, words, maketype) \
-  revalloc((s), (words), maketype)
 
 
 /* runtime/intrpt.c */
diff -ruN klic-3.003-2001-12-28/include/klic/atomstuffs.h klic-3.003-2001-12-29/include/klic/atomstuffs.h
--- klic-3.003-2001-12-28/include/klic/atomstuffs.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/atomstuffs.h	Sat Dec 29 12:46:20 2001
@@ -8,6 +8,8 @@
 #ifndef _KLIC_ATOMSTUFFS_H_
 #define _KLIC_ATOMSTUFFS_H_
 
+#include <klic/functorstuffs.h>  /* functoratom */
+
 /* atomnumber stuffs */
 
 /* atom.c */
diff -ruN klic-3.003-2001-12-28/include/klic/basic.h klic-3.003-2001-12-29/include/klic/basic.h
--- klic-3.003-2001-12-28/include/klic/basic.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/basic.h	Sat Dec 29 12:46:20 2001
@@ -14,35 +14,28 @@
 #ifdef MAIN
 #define Extern
 #define Init(x)		= (x)
-#define Size(size)	(size)
 #else
 #define Extern		extern
 #define Init(x)
-#define Size(size)
 #endif
 
-#ifdef __STDC__
-#define Const		const
-#define Volatile	volatile
-#else
-#define Const
-#define Volatile
+#ifndef __STDC__
+#define const
+#define volatile
 #endif
 
 #ifdef __GNUC__
 #define Inline		__inline__
-#define NoReturn	Volatile
+#define NeverReturn	volatile
 #else
 #define Inline
-#define NoReturn
+#define NeverReturn
 #endif
 
-typedef void voidfn ();
-
 /* runtime/debug.c */
-extern NoReturn voidfn fatal;
-extern NoReturn voidfn fatalf;
-extern NoReturn voidfn fatalp;
+extern NeverReturn void fatal(char* message);
+extern NeverReturn void fatalf();
+extern NeverReturn void fatalp();
 extern void debug_printf();
 extern void debug_fprintf();
 extern void klic_fprintf();
@@ -67,7 +60,5 @@
 extern int klic_fwrite(const void* pt, size_t size, size_t items, FILE* f);
 extern int klic_fflush(FILE* f);
 
-
-#define klic_local_fprintf fprintf
 
 #endif /* _KLIC_BASIC_H_ */
diff -ruN klic-3.003-2001-12-28/include/klic/control.h klic-3.003-2001-12-29/include/klic/control.h
--- klic-3.003-2001-12-28/include/klic/control.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/control.h	Sat Dec 29 12:46:20 2001
@@ -10,10 +10,6 @@
 
 #include <klic/alloc.h>  /* klic_interrupt */
 
-/* Reasons of interruption */
-#define EXTEVENT	(makeint(0))
-#define FAILURE		(makeint(1))
-
 /* runtime/faisus.c */
 extern q* interrupt_goal(q* allocp, struct predicate* pred, q* reasonp);
 extern int check_stack_for_alternatively(q* allocp, q* reasonp);
diff -ruN klic-3.003-2001-12-28/include/klic/g_basic.h klic-3.003-2001-12-29/include/klic/g_basic.h
--- klic-3.003-2001-12-28/include/klic/g_basic.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/g_basic.h	Sat Dec 29 12:46:20 2001
@@ -172,7 +172,7 @@
 */
 
 /* runtime/generic.c */
-extern NoReturn void
+extern NeverReturn void
 G_error(char* errmsg, char* where, char* object_kind, char* class);
 
 #endif /* _KLIC_G_BASIC_H_ */
diff -ruN klic-3.003-2001-12-28/include/klic/gb.h klic-3.003-2001-12-29/include/klic/gb.h
--- klic-3.003-2001-12-28/include/klic/gb.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/gb.h	Sat Dec 29 12:46:20 2001
@@ -8,6 +8,9 @@
 #ifndef _KLIC_GB_H_
 #define _KLIC_GB_H_
 
+#include <klic/functorstuffs.h>  /* functoratom, arityof */
+#include <klic/control.h>  /* check_stack_for_alternatively */
+
 /* runtime/cmphsh.c */
 extern q builtin_compare_terms(q x, q y);
 extern q builtin_hash_term(q x, long l);
diff -ruN klic-3.003-2001-12-28/include/klic/gc_macro.h klic-3.003-2001-12-29/include/klic/gc_macro.h
--- klic-3.003-2001-12-28/include/klic/gc_macro.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/gc_macro.h	Sat Dec 29 12:46:20 2001
@@ -8,6 +8,8 @@
 #ifndef _KLIC_GC_MACRO_H_
 #define _KLIC_GC_MACRO_H_
 
+#include <klic/basic.h>  /* fatal, debug_printf, klic_fprintf, klic_putc */
+
 extern q GC_wakeup_g_new();
 
 /* runtime/unify.c */
@@ -99,7 +101,7 @@
     GC_TERMINATE; \
   } else { \
     debug_printf("### %k ###", GC_TERM); \
-    fatal("Illegal data"); \
+    fatal("Invalid data"); \
   } \
 }while(0)
 
@@ -162,7 +164,7 @@
   } \
 }while(0)
 
-#define GC_SWITCH_ON_METHOD_BEFORE(atomic,list,functor,generic,susp,illegal_data) \
+#define GC_SWITCH_ON_METHOD_BEFORE(atomic,list,functor,generic,susp,invalid_data) \
 do{ \
   while (1) { \
     switch(ptagof(GC_TERM)) { \
@@ -182,11 +184,11 @@
     case ATOMIC: \
       if (GC_TERM == NILATOM) { \
         GC_TERMINATE; \
-      } else goto illegal_data; \
+      } else goto invalid_data; \
     case FUNCTOR: goto functor; \
     case VARREF: \
       GC_DEREF_AND_TEST(GC_TERM, susp); \
-    default: goto illegal_data; \
+    default: goto invalid_data; \
     } \
   } \
 }while(0)
diff -ruN klic-3.003-2001-12-28/include/klic/gd_macro.h klic-3.003-2001-12-29/include/klic/gd_macro.h
--- klic-3.003-2001-12-28/include/klic/gd_macro.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/gd_macro.h	Sat Dec 29 12:47:41 2001
@@ -8,6 +8,9 @@
 #ifndef _KLIC_GD_MACRO_H_
 #define _KLIC_GD_MACRO_H_
 
+#include <klic/functorstuffs.h>  /* functors, arities, FUNCTORNUMBERBASE */
+#include <klic/basic.h>  /* fatal, klic_fprintf, klic_putc */
+
 /* runtime/unify2.c */
 extern q eq_terms_body(q x, q y);
 
diff -ruN klic-3.003-2001-12-28/include/klic/gg_macro.h klic-3.003-2001-12-29/include/klic/gg_macro.h
--- klic-3.003-2001-12-28/include/klic/gg_macro.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/gg_macro.h	Sat Dec 29 12:46:20 2001
@@ -8,6 +8,8 @@
 #ifndef _KLIC_GG_MACRO_H_
 #define _KLIC_GG_MACRO_H_
 
+#include <klic/basic.h>  /* fatal, klic_fprintf */
+
 extern q GC_wakeup_g_new();
 
 /* runtime/unify.c */
diff -ruN klic-3.003-2001-12-28/include/klic/gmodule.h klic-3.003-2001-12-29/include/klic/gmodule.h
--- klic-3.003-2001-12-28/include/klic/gmodule.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/gmodule.h	Sat Dec 29 12:46:20 2001
@@ -23,7 +23,7 @@
 
 typedef struct predicate_object {
   struct data_object_method_table *method_table;
-  Const struct predicate *pdesc; /* atom tag */
+  const struct predicate* pdesc; /* atom tag */
   q module_obj;
   q predicate_name;
 } predicate_structure_type;
diff -ruN klic-3.003-2001-12-28/include/klic/struct.h klic-3.003-2001-12-29/include/klic/struct.h
--- klic-3.003-2001-12-28/include/klic/struct.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-29/include/klic/struct.h	Sat Dec 29 12:48:20 2001
@@ -14,6 +14,7 @@
   fix for DEC alpha
 */
 
+#include <klic/basic.h>  /* Extern */
 #include <klic/param.h>
 
 /****************************************
diff -ruN klic-3.003-2001-12-28/runtime/alloc.c klic-3.003-2001-12-29/runtime/alloc.c
--- klic-3.003-2001-12-28/runtime/alloc.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/alloc.c	Sat Dec 29 12:46:20 2001
@@ -6,7 +6,7 @@
 ----------------------------------------------------------- */
 
 #include <stdlib.h>  /* malloc, realloc */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatalf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/alloc.h>  /* extern */
@@ -59,7 +59,7 @@
   if(heapsize != 0  && incrementsize != 0) {
     bytesize = (heapsize + incrementsize)*sizeof(q);
   } else {
-    fatalf("Illegal memory size specification: heap = %d, incremental = %d",
+    fatalf("Invalid memory size specification: heap = %d, incremental = %d",
 	    heapsize, incrementsize);
   }
   old_space_size = new_space_size = bytesize;
diff -ruN klic-3.003-2001-12-28/runtime/asyncio.c klic-3.003-2001-12-29/runtime/asyncio.c
--- klic-3.003-2001-12-28/runtime/asyncio.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/asyncio.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal, klic_fprintf */
 #include <klic/struct.h>
 #include <klic/unify.h>
 #include <klic/alloc.h>  /* register_gc_hook */
diff -ruN klic-3.003-2001-12-28/runtime/bb.c klic-3.003-2001-12-29/runtime/bb.c
--- klic-3.003-2001-12-28/runtime/bb.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/bb.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatalf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
@@ -127,7 +127,7 @@
 
 static q suspend_builtin_3(v, x, y, pred)
      q v, x, y;
-     Const struct predicate *pred;
+     const struct predicate* pred;
 {
   declare_globals;
   struct goalrec *goal;
@@ -144,7 +144,7 @@
 
 static q suspend_builtin_2(v, pred)
      q v;
-     Const struct predicate *pred;
+     const struct predicate* pred;
 {
   declare_globals;
   struct goalrec *goal = 0;
diff -ruN klic-3.003-2001-12-28/runtime/cmphsh.c klic-3.003-2001-12-29/runtime/cmphsh.c
--- klic-3.003-2001-12-28/runtime/cmphsh.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/cmphsh.c	Sat Dec 29 12:46:20 2001
@@ -8,7 +8,7 @@
 #include <klic/struct.h>
 #include <klic/index.h>
 #include <klic/generic.h>
-#include <klic/functorstuffs.h>
+#include <klic/functorstuffs.h>  /* arityof */
 #include <klic/atomstuffs.h>
 #include "runtime.h"  /* hash_kl1_term */
 
diff -ruN klic-3.003-2001-12-28/runtime/cntlmsg.c klic-3.003-2001-12-29/runtime/cntlmsg.c
--- klic-3.003-2001-12-28/runtime/cntlmsg.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/cntlmsg.c	Sat Dec 29 12:46:20 2001
@@ -4,18 +4,17 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
-#include <klic/primitives.h>
+#include <klic/primitives.h>  /* enqueue_goal */
 #include <klic/unify.h>
 #include <klic/functorstuffs.h> 
 
 #include <klic/gb.h>
 
-#include <klic/functorstuffs.h>
 #include <klic/atomstuffs.h>
 
-#include <stdio.h>
+#include <stdio.h>  /* NULL */
 #include <setjmp.h>
 
 #include <klic/generic.h> 
@@ -466,7 +465,7 @@
   if(prio == current_prio){
     resume_same_prio(newgoal); 
   } else {
-    (void) enqueue_goal(0, prio, newgoal, glbl);    
+    (void) enqueue_goal(NULL, prio, newgoal, glbl);    
   }
   return(allocp);
 }
diff -ruN klic-3.003-2001-12-28/runtime/config/pvm/distio.c klic-3.003-2001-12-29/runtime/config/pvm/distio.c
--- klic-3.003-2001-12-28/runtime/config/pvm/distio.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/config/pvm/distio.c	Sat Dec 29 12:46:20 2001
@@ -7,7 +7,7 @@
 /* PVM dependent I/O communication library */
 /* $Id: distio.c,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
 #include <stdio.h>
-#include <klic/basic.h>
+#include <klic/basic.h>  /* debug_fprintf, klic_fprintf, klic_getc */
 #include <klic/struct.h>
 #include <klic/distio.h>
 #include <signal.h>
diff -ruN klic-3.003-2001-12-28/runtime/config/pvm/distpkt.c klic-3.003-2001-12-29/runtime/config/pvm/distpkt.c
--- klic-3.003-2001-12-28/runtime/config/pvm/distpkt.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/config/pvm/distpkt.c	Sat Dec 29 12:46:20 2001
@@ -6,7 +6,7 @@
 ----------------------------------------------------------- */
 /* PVM dependent inter-pe communication library */
 /* $Id: distpkt.c,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
diff -ruN klic-3.003-2001-12-28/runtime/config/pvm/distproc.c klic-3.003-2001-12-29/runtime/config/pvm/distproc.c
--- klic-3.003-2001-12-28/runtime/config/pvm/distproc.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/config/pvm/distproc.c	Sat Dec 29 12:46:20 2001
@@ -7,7 +7,7 @@
 /* PVM dependent process spawn library */
 /* $Id: distproc.c,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
 #include <stdio.h>
-#include <klic/basic.h>
+#include <klic/basic.h>  /* klic_fprintf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/distio.h>
@@ -208,7 +208,7 @@
 
 static void
 setup_send_args(opttable)
-Const struct opttable *opttable;
+  const struct opttable* opttable;
 {
     int i;
     for (i = 0; opttable[i].opt_str; ++i) {
@@ -245,7 +245,7 @@
 
 static void
 recv_extract_args(opttable)
-Const struct opttable *opttable;
+  const struct opttable* opttable;
 {
     int i;
     for (i = 0; opttable[i].opt_str; ++i) {
@@ -295,7 +295,7 @@
 static int
 io_spawn_children(num_child, opttable, prog_name, argc, argv)
 int num_child;
-Const struct opttable *opttable;
+const struct opttable* opttable;
 char *prog_name;
 int argc;
 char **argv;
@@ -412,7 +412,7 @@
 static int
 child_spawn_children(par_tid, opttable, prog_name, argc, argv)
 int par_tid;
-Const struct opttable *opttable;
+const struct opttable* opttable;
 char *prog_name;
 int argc;
 char **argv;
@@ -466,7 +466,7 @@
 int
 spawn_children(num_child, opttable, prog_name, argc, argv)
 int num_child;
-Const struct opttable *opttable;
+const struct opttable* opttable;
 char *prog_name;
 int argc;
 char **argv;
diff -ruN klic-3.003-2001-12-28/runtime/config/pvm/distrmon.c klic-3.003-2001-12-29/runtime/config/pvm/distrmon.c
--- klic-3.003-2001-12-28/runtime/config/pvm/distrmon.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/config/pvm/distrmon.c	Sat Dec 29 12:46:20 2001
@@ -5,7 +5,7 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include "timing.h"
diff -ruN klic-3.003-2001-12-28/runtime/config/pvm-tcp/distpkt.c klic-3.003-2001-12-29/runtime/config/pvm-tcp/distpkt.c
--- klic-3.003-2001-12-28/runtime/config/pvm-tcp/distpkt.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/config/pvm-tcp/distpkt.c	Sat Dec 29 12:46:20 2001
@@ -7,7 +7,10 @@
 ----------------------------------------------------------- */
 /* PVM-TCP dependent inter-pe communication library */
 /* distpkt.c,v 1.3 1997/06/06 10:41:13 sekita Exp */
+
+/* fatal, fatalf, debug_printf, debug_fprintf, klic_fprintf */
 #include <klic/basic.h>
+
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
@@ -483,13 +486,13 @@
 			 my_node, the_fd, i);
 #endif
 		if (fcntl(the_fd, F_SETOWN, getpid()) < 0)
-		  fatal("fcntl(setown) errno=%d\n", errno);
+		  fatalf("fcntl(setown) errno=%d\n", errno);
 #ifdef FASYNC
 		if (fcntl(the_fd, F_SETFL, FASYNC) < 0)
-		  fatal("fcntl(setfl) errno=%d\n", errno);
+		  fatalf("fcntl(setfl) errno=%d\n", errno);
 #else
 		if (ioctl(the_fd, I_SETSIG, S_INPUT) < 0)
-		  fatal("ioctl(setsig) errno=%d\n", errno);
+		  fatalf("ioctl(setsig) errno=%d\n", errno);
 #endif
 	    }
 	}
@@ -639,13 +642,13 @@
     ioprintf("useless:%d -> %d\n", from, my_node);
     the_fd = port_tbl[from].fd;
     if (fcntl(the_fd, F_SETOWN, getpid()) < 0)
-      fatal("fcntl(setown) errno=%d\n", errno);
+      fatalf("fcntl(setown) errno=%d\n", errno);
 #ifdef FASYNC
     if (fcntl(the_fd, F_SETFL, FASYNC) < 0)
-      fatal("fcntl(setfl) errno=%d\n", errno);
+      fatalf("fcntl(setfl) errno=%d\n", errno);
 #else
     if (ioctl(the_fd, I_SETSIG, S_INPUT) < 0)
-      fatal("ioctl(setsig) errno=%d\n", errno);
+      fatalf("ioctl(setsig) errno=%d\n", errno);
 #endif
     if (from < my_node)
       send_useless_message();
diff -ruN klic-3.003-2001-12-28/runtime/config/shm/distio.c klic-3.003-2001-12-29/runtime/config/shm/distio.c
--- klic-3.003-2001-12-28/runtime/config/shm/distio.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/config/shm/distio.c	Sat Dec 29 12:46:20 2001
@@ -14,7 +14,7 @@
 
 #include <stdio.h>
 #include <errno.h>
-#include <klic/basic.h>
+#include <klic/basic.h>  /* klic_getc */
 #include <klic/sighndl.h>
 #include <klic/struct.h>
 #include <klic/distio.h>
diff -ruN klic-3.003-2001-12-28/runtime/config/shm/distpkt.c klic-3.003-2001-12-29/runtime/config/shm/distpkt.c
--- klic-3.003-2001-12-28/runtime/config/shm/distpkt.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/config/shm/distpkt.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal, klic_fprintf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
@@ -275,9 +275,9 @@
      long node;
      int sig;
 {
-  Volatile struct global_variables 
+  volatile struct global_variables 
     *dest_glbl = &(shmp[node]->globals);
-  Volatile struct klic_sgnl_flags 
+  volatile struct klic_sgnl_flags 
     *dest_sgnl_flags = &(shmp[node]->klic_sgnl_flags);
   
   dest_sgnl_flags->done = 0;
diff -ruN klic-3.003-2001-12-28/runtime/config/shm/distpkt.h klic-3.003-2001-12-29/runtime/config/shm/distpkt.h
--- klic-3.003-2001-12-28/runtime/config/shm/distpkt.h	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/config/shm/distpkt.h	Sat Dec 29 12:46:20 2001
@@ -15,10 +15,10 @@
 
 /* Network Buffer Type */
 typedef struct {
-    Volatile long *buffer;		/* pointer to the actual buffer */
-    Volatile long rd_index;		/* pointer used for reading */
-    Volatile long wt_index;		/* pointer used for writing */
-    Volatile long buf_size;		/* the physical size of buffer */
+    volatile long* buffer;		/* pointer to the actual buffer */
+    volatile long rd_index;		/* pointer used for reading */
+    volatile long wt_index;		/* pointer used for writing */
+    volatile long buf_size;		/* the physical size of buffer */
 } combuf;
 
 Extern combuf *kumon_inbuf;	/* for input packet */
@@ -118,25 +118,25 @@
 
 
 typedef struct {
-  Volatile int lockwd;
-  Volatile int syncwd;
+  volatile int lockwd;
+  volatile int syncwd;
   struct global_variables globals;
   struct klic_sgnl_flags klic_sgnl_flags;
-  Volatile long buffer_size;
-  Volatile long rd_index;
-  Volatile long wt_index;
+  volatile long buffer_size;
+  volatile long rd_index;
+  volatile long wt_index;
   char* top_ptr;
   char* bottom_ptr;
   char buffer[1];
 } SHARED_BLOCK;
 
 typedef struct {
-  Volatile int lockwd;
-  Volatile int syncwd;
+  volatile int lockwd;
+  volatile int syncwd;
 } IO_LOCKWORD;
 
 Extern SHARED_BLOCK **shmp;
-Volatile Extern IO_LOCKWORD *io_lockwds;
+Extern volatile IO_LOCKWORD* io_lockwds;
 Extern long shared_buffer_size Init(0x10000);
 Extern int my_io_lock_flag;
 
diff -ruN klic-3.003-2001-12-28/runtime/config/shm/distproc.c klic-3.003-2001-12-29/runtime/config/shm/distproc.c
--- klic-3.003-2001-12-28/runtime/config/shm/distproc.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/config/shm/distproc.c	Sat Dec 29 12:46:20 2001
@@ -12,7 +12,7 @@
 #include <sys/cnx_mman.h>
 #endif
 #include <sys/mman.h>
-#include <klic/basic.h>
+#include <klic/basic.h>  /* klic_fprintf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/sighndl.h>
@@ -86,7 +86,7 @@
 
 int r_spawn_children(num_child, opttable, prog_name, argc, argv)
      long num_child; 
-     Const struct opttable *opttable;
+     const struct opttable* opttable;
      char *prog_name;
      int argc;
      char **argv;
diff -ruN klic-3.003-2001-12-28/runtime/config/shm/distrmon.c klic-3.003-2001-12-29/runtime/config/shm/distrmon.c
--- klic-3.003-2001-12-28/runtime/config/shm/distrmon.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/config/shm/distrmon.c	Sat Dec 29 12:46:20 2001
@@ -5,7 +5,7 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include "timing.h"
diff -ruN klic-3.003-2001-12-28/runtime/datamsg.c klic-3.003-2001-12-29/runtime/datamsg.c
--- klic-3.003-2001-12-28/runtime/datamsg.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/datamsg.c	Sat Dec 29 12:46:20 2001
@@ -4,18 +4,17 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
-#include <klic/functorstuffs.h> 
+#include <klic/atomstuffs.h>  /* ATOMNUMBERBASE */
+#include <klic/functorstuffs.h>   /* arityof, FUNCTORNUMBERBASE */
 #include "timing.h"
 
 #include <klic/gb.h>
 #include "gobj.h"
 #include "susp.h"
-#include <klic/functorstuffs.h>
-#include <klic/atomstuffs.h>
 
 #include <stdio.h>
 
@@ -27,8 +26,8 @@
 
 #include <klic/distio.h>
 
-extern Const long initial_atoms;
-extern Const long initial_functors;
+extern const long initial_atoms;
+extern const long initial_functors;
 q search_exptbl();
 extern q exref_g_new();
 /* 
diff -ruN klic-3.003-2001-12-28/runtime/debug.c klic-3.003-2001-12-29/runtime/debug.c
--- klic-3.003-2001-12-28/runtime/debug.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/debug.c	Sat Dec 29 12:46:20 2001
@@ -9,13 +9,18 @@
 #include <ctype.h>
 #include <errno.h>
 #include <string.h>
+
+/* fatal, fatalf, fatalp, debug_printf, debug_fprintf, klic_fprintf,
+ * klic_putc
+ */
 #include <klic/basic.h>
+
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
 #include <klic/index.h>
-#include <klic/atomstuffs.h>
-#include <klic/functorstuffs.h>
+#include <klic/atomstuffs.h>  /* atomname, ATOMNUMBERBASE */
+#include <klic/functorstuffs.h>  /* functors, arities, FUNCTORNUMBERBASE */
 
 #ifdef DIST
 #include <klic/distio.h>
@@ -42,7 +47,8 @@
 extern struct predicate topsucceed_pred;
 extern jmp_buf klic_topmost;
 
-void fatal(message)
+extern void
+fatal(message)
      char *message;
 {
   declare_globals;
@@ -82,7 +88,8 @@
   exit(N);
 }
 
-void fatalf(format, a0, a1, a2, a3, a4, a5, a6, a7)
+extern void
+fatalf(format, a0, a1, a2, a3, a4, a5, a6, a7)
      char *format;
      long a0, a1, a2, a3, a4, a5, a6, a7;
 {
@@ -91,7 +98,8 @@
   fatal(buf);
 }
 
-void fatalp(where, format, a0, a1, a2, a3, a4, a5, a6, a7)
+extern void
+fatalp(where, format, a0, a1, a2, a3, a4, a5, a6, a7)
      char *where, *format;
      long a0, a1, a2, a3, a4, a5, a6, a7;
 {
@@ -345,7 +353,7 @@
 #endif
 }
 
-void
+extern void
 klic_fprintf(out, format,
 		  a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab)
      FILE *out;
@@ -365,7 +373,7 @@
 		     a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab);
 }
 
-void
+extern void
 debug_fprintf(out, format,
 		  a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab)
      FILE *out;
@@ -377,7 +385,8 @@
 }
 
 
-void debug_printf(format,
+extern void
+debug_printf(format,
 		  a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab)
      char *format;
      long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab;
@@ -385,4 +394,3 @@
   debug_fprintf(stderr, format,
 		a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab);
 }
-
diff -ruN klic-3.003-2001-12-28/runtime/export_table.c klic-3.003-2001-12-29/runtime/export_table.c
--- klic-3.003-2001-12-28/runtime/export_table.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/export_table.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
@@ -136,7 +136,7 @@
 
   data = exp_table[index].data;
   if((long)data == UNUSED_EXPREC){
-    ioeprintf("illegal exp record %d\n", index);
+    ioeprintf("invalid exp record %d\n", index);
     ERROR_STOP;
   }
 
diff -ruN klic-3.003-2001-12-28/runtime/faisus.c klic-3.003-2001-12-29/runtime/faisus.c
--- klic-3.003-2001-12-28/runtime/faisus.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/faisus.c	Sat Dec 29 12:46:20 2001
@@ -5,9 +5,12 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 #include <stdio.h>
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
+
+/* interrupt_goal, check_stack_for_alternatively */
 #include <klic/primitives.h>
+
 #include "susp.h"
 #include <klic/generic.h>
 #include "gobj.h"
@@ -144,7 +147,8 @@
   return(allocp);
 }
 
-q *interrupt_goal(allocp, pred, reasonp)
+extern q*
+interrupt_goal(allocp, pred, reasonp)
      q *allocp;
      struct predicate *pred;
      q *reasonp;
@@ -283,7 +287,8 @@
   }
 }
 
-int check_stack_for_alternatively(allocp, reasonp)
+extern int
+check_stack_for_alternatively(allocp, reasonp)
      q *allocp;
      q *reasonp;
 {
diff -ruN klic-3.003-2001-12-28/runtime/gc.c klic-3.003-2001-12-29/runtime/gc.c
--- klic-3.003-2001-12-28/runtime/gc.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/gc.c	Sat Dec 29 12:46:20 2001
@@ -4,12 +4,12 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal, fatalf, klic_fprintf */
 #include <klic/struct.h>
-#include <klic/primitives.h>
+#include <klic/primitives.h>  /* malloc_check, realloc_check */
 #include "timing.h"
 #include <stdio.h>
-#include <klic/functorstuffs.h>
+#include <klic/functorstuffs.h>  /* arityof */
 #include "gobj.h"
 #include "susp.h"
 
@@ -32,7 +32,6 @@
 
 #endif
 
-extern char *malloc(), *malloc_check(), *realloc_check();
 extern struct goalrec goal_queue_tail;
 
 static Inline void flip_spaces()
@@ -720,7 +719,7 @@
     heapp = hp;
     if (dead_goal != 0) {
       /* we have to make the dead goal look like a normal ready queue */
-      extern Const struct predicate queue_empty_pred;
+      extern const struct predicate queue_empty_pred;
       ((struct goalrec *)hp)->pred = &queue_empty_pred;
       dead_goal->next = (struct goalrec *)hp;
       hp += sizeof(struct goalrec)/sizeof(q);
diff -ruN klic-3.003-2001-12-28/runtime/gcode.c klic-3.003-2001-12-29/runtime/gcode.c
--- klic-3.003-2001-12-28/runtime/gcode.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/gcode.c	Sat Dec 29 12:46:20 2001
@@ -17,7 +17,7 @@
 #include <klic/gdobject.h>
 #include <klic/predinfo.h>
 #include "atom.h"
-#include "funct.h"
+#include "funct.h"  /* arities, arityof, FUNCTORNUMBERBASE */
 
 #ifdef STRINGH
 #include <string.h>
@@ -90,7 +90,7 @@
 GDDEF_METHOD(arity_1)
 {
   G_STD_DECL;
-  Const struct predicate *pred = GD_SELF->pdesc;
+  const struct predicate* pred = GD_SELF->pdesc;
 
   GD_UNIFY(GD_ARGV[0], makeint(pred->arity));
   GD_RETURN;
@@ -116,7 +116,7 @@
   GD_DEREF(GD_ARGV[0]);
   func = GD_ARGV[0];
   if (!G_ISFUNCTOR(func) || !(GD_IS_CLASS(vector, func))) {
-    GD_ERROR_IN_METHOD("Illegal argument specification", "apply");
+    GD_ERROR_IN_METHOD("Invalid argument specification", "apply");
   }
 
   {
@@ -196,7 +196,7 @@
 GDDEF_GMETHOD(arity_1)
 {
   G_STD_DECL;
-  Const struct predicate *pred = GD_SELF->pdesc;
+  const struct predicate* pred = GD_SELF->pdesc;
 
   GD_ARGV[0] =  makeint(pred->arity);
   GD_GSUCCEED;
@@ -227,17 +227,17 @@
 
 #include <klic/gd_methtab.h>
 
-Const struct predicate *locate_predicate_in_module(mname, pname, arity)
+const struct predicate* locate_predicate_in_module(mname, pname, arity)
      q mname, pname;
      long arity;
 {
   unsigned char *modname = namestringof(mname);
   unsigned char *predname = namestringof(pname);
-  extern Const struct modinfo defined_modules[];
-  Const struct modinfo *mp;
+  extern const struct modinfo defined_modules[];
+  const struct modinfo* mp;
   for (mp = defined_modules; mp->name != 0; mp++) {
     if (strcmp((char *)mp->name, (char *)modname) == 0) {
-      Const struct predinfo * Const *pp;
+      const struct predinfo* const* pp;
       for (pp = mp->preds; *pp != 0; pp++) {
 	if (strcmp((char *)((*pp)->name), (char *)predname) == 0 &&
 	    (*pp)->predstruct->arity == arity) {
@@ -258,7 +258,7 @@
 {
   GD_STD_DECL_FOR_NEW;
   struct module_object *module_obj;
-  Const struct predicate *predaddr;
+  const struct predicate* predaddr;
   q predname;
   int arity;
 
diff -ruN klic-3.003-2001-12-28/runtime/ge_exref.c klic-3.003-2001-12-29/runtime/ge_exref.c
--- klic-3.003-2001-12-28/runtime/ge_exref.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/ge_exref.c	Sat Dec 29 12:46:20 2001
@@ -6,7 +6,7 @@
 ----------------------------------------------------------- */
 #include <stdio.h>
 
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal, klic_fprintf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
@@ -107,14 +107,14 @@
   return(NULL);  /* Cannot unify now */
 }
 
-Extern void *decode_exref();
+extern void* decode_exref();
 
 GGDEF_ENCODE()
 {
   long send_wec;
 
   if (GG_SELF->wec < MIN_WEC){
-    fatal("illegal WEC in exref object");      
+    fatal("invalid WEC in exref object");      
   }
 
   if (GG_SELF->wec < MIN_WEC*2){
@@ -140,7 +140,7 @@
   INT_CL_DEBUG_X(klic_fprintf(stdout,"exref GC invoked\n"));
 
   if(GG_SELF->gc_flag != IMPREC_NOT_COPIED){
-    ioeprintf("illegal exref in GC\n");
+    ioeprintf("invalid exref in GC\n");
     ERROR_STOP;
   }
 
diff -ruN klic-3.003-2001-12-28/runtime/ge_readhook.c klic-3.003-2001-12-29/runtime/ge_readhook.c
--- klic-3.003-2001-12-28/runtime/ge_readhook.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/ge_readhook.c	Sat Dec 29 12:46:20 2001
@@ -5,7 +5,7 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 #include <stdio.h>
-#include <klic/gdobject.h>
+#include <klic/gdobject.h>  /* fatal, klic_fprintf */
 #include "interpe.h"
 #include <klic/distio.h>
 
@@ -62,7 +62,7 @@
 
   GC_TERMINATE;
  susp0:
-  fatal("illegal data for unify rdhok");
+  fatal("invalid data for unify rdhok");
 }
 
 GCDEF_GC()
diff -ruN klic-3.003-2001-12-28/runtime/ge_replyhook.c klic-3.003-2001-12-29/runtime/ge_replyhook.c
--- klic-3.003-2001-12-28/runtime/ge_replyhook.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/ge_replyhook.c	Sat Dec 29 12:46:20 2001
@@ -5,7 +5,7 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 #include <stdio.h>
-#include <klic/gdobject.h>
+#include <klic/gdobject.h>  /* fatal */
 #include "atom.h"
 #include "funct.h"
 
@@ -42,7 +42,7 @@
 		    
   GC_TERMINATE;
  susp0:
-  fatal("illegal data for unify rhook");
+  fatal("invalid data for unify rhook");
 }
 
 GCDEF_GC()
diff -ruN klic-3.003-2001-12-28/runtime/generic.c klic-3.003-2001-12-29/runtime/generic.c
--- klic-3.003-2001-12-28/runtime/generic.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/generic.c	Sat Dec 29 12:46:20 2001
@@ -5,8 +5,10 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 
+/* G_error, fatal, fatalf, debug_printf, klic_fprintf */
 #include <klic/gdobject.h>
-#include <klic/functorstuffs.h>
+
+#include <klic/functorstuffs.h>  /* arities, FUNCTORNUMBERBASE */
 #include <klic/atomstuffs.h>
 #include <stdio.h>
 #include <klic/gd_macro.h>
@@ -19,7 +21,7 @@
 
 module module_generic();
 
-Extern Const struct predicate predicate_generic_xgeneric_2;
+extern const struct predicate predicate_generic_xgeneric_2;
 
 #define G_NEW_GOAL &predicate_generic_xnew_3
 #define GD_GENERIC_GOAL &predicate_generic_xgeneric_2
@@ -235,11 +237,8 @@
   return makeint((long)GD_SELF->method_table);
 }
 
-#ifdef __GNUC__
-Volatile void G_error(errmsg, where, object_kind, class)
-#else
-void G_error(errmsg, where, object_kind, class)
-#endif
+extern NeverReturn void
+G_error(errmsg, where, object_kind, class)
      char *errmsg, *where, *object_kind, *class;
 {
   fatalf("%s\n\t(in %s of %s object of class \"%s\")",
diff -ruN klic-3.003-2001-12-28/runtime/gfloat.c klic-3.003-2001-12-29/runtime/gfloat.c
--- klic-3.003-2001-12-28/runtime/gfloat.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/gfloat.c	Sat Dec 29 12:46:20 2001
@@ -7,7 +7,7 @@
 
 #include <math.h>
 #include <stdio.h>
-#include <klic/gdobject.h>
+#include <klic/gdobject.h>  /* debug_printf, klic_fprintf */
 #include <klic/gd_macro.h>
 
 #ifdef DIST
@@ -227,7 +227,7 @@
 	  GD_SELF->method_table) {
 	debug_printf("### \"%k\" given to floating point method %F ###\n",
 		     another, g_method_functor);
-	GD_FAIL("Illegal argument in floating point object method.");
+	GD_FAIL("Invalid argument in floating point object method.");
       }
       another_value = ((GD_OBJ_TYPE *)functorp(another))->value;
       GD_SWITCH_ON_METHOD {
@@ -407,7 +407,7 @@
     newobj->value = atof((char *)generic_string_body(G_FUNCTORP(init)));
   } else {
     debug_printf("### %k ###\n", init);
-    GD_FAIL("Illegal initial value for floating point objects");
+    GD_FAIL("Invalid initial value for floating point objects");
   }
   GD_RETURN_FROM_NEW(newobj);
 }
diff -ruN klic-3.003-2001-12-28/runtime/gg_shbusy.c klic-3.003-2001-12-29/runtime/gg_shbusy.c
--- klic-3.003-2001-12-28/runtime/gg_shbusy.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/gg_shbusy.c	Sat Dec 29 12:46:20 2001
@@ -9,7 +9,7 @@
 */
 #include <stdio.h>
 
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/g_methtab.h>
 #include <klic/g_basic.h>
diff -ruN klic-3.003-2001-12-28/runtime/gg_shvar.c klic-3.003-2001-12-29/runtime/gg_shvar.c
--- klic-3.003-2001-12-28/runtime/gg_shvar.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/gg_shvar.c	Sat Dec 29 12:46:20 2001
@@ -6,7 +6,7 @@
 ----------------------------------------------------------- */
 #include <stdio.h>
 
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/g_methtab.h>
 #include <klic/g_basic.h>
diff -ruN klic-3.003-2001-12-28/runtime/ggoal.c klic-3.003-2001-12-29/runtime/ggoal.c
--- klic-3.003-2001-12-28/runtime/ggoal.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/ggoal.c	Sat Dec 29 12:46:20 2001
@@ -7,7 +7,7 @@
   Goal Object
 */
 
-#include <klic/gdobject.h>
+#include <klic/gdobject.h>  /* fatal */
 #include "goalobj.h"
 #include "atom.h"
 #include "funct.h"
@@ -31,12 +31,12 @@
   predicate_g_data_method_table,
   vector_g_data_method_table;
 
-extern Const struct predicate step_trigger_pred;
+extern const struct predicate step_trigger_pred;
 
 /* Predicate Table */
 
 struct pred_tab_ent {
-  Const struct predicate *pred;
+  const struct predicate* pred;
   q modname;			/* module name atom */
   q name;			/* predicate name atom */
 } *pred_tab;
@@ -50,13 +50,13 @@
 {
   declare_globals;
   int k, n_pred;
-  Const struct modinfo *dm;
-  extern Const struct modinfo defined_modules[];
+  const struct modinfo* dm;
+  extern const struct modinfo defined_modules[];
 
   /* Let's first count the number predicates in this program */
   n_pred = 0;
   for (dm = &defined_modules[0]; dm->name != 0; dm++) {
-    Const struct predinfo * Const *dp;
+    const struct predinfo* const* dp;
     for (dp = &dm->preds[0]; *dp != 0; dp++) {
       n_pred++;
     }
@@ -79,9 +79,9 @@
   for (dm = &defined_modules[0]; dm->name != 0; dm++) {
     extern unsigned long enter_atom_body();
     q modname = makesym(enter_atom_body(dm->name, strlen(dm->name)));
-    Const struct predinfo * Const *dp;
+    const struct predinfo* const* dp;
     for (dp = &dm->preds[0]; *dp != 0; dp++) {
-      Const struct predicate *pred = (*dp)->predstruct;
+      const struct predicate* pred = (*dp)->predstruct;
       long h = HashFunc(pred);
       while (pred_tab[h].pred != pred) {
 	if (pred_tab[h].pred == 0) {
@@ -240,7 +240,7 @@
   GD_OBJ_TYPE *newobj;
   struct goalrec *oldgoal, *newgoal;
   q predq;
-  Const struct predicate_object *pred;
+  const struct predicate_object* pred;
   long k;
 
   oldgoal = GD_SELF->goal;
@@ -252,7 +252,7 @@
     GD_ERROR_IN_METHOD("First argument is not a predicate object",
 		       "set_predicate");
   }
-  pred = (Const struct predicate_object *)functorp(predq);
+  pred = (const struct predicate_object*) functorp(predq);
   if (pred->pdesc->arity != arity) {
     GD_ERROR_IN_METHOD("Arity of given predicate object doesn't agree with the goal",
 		       "set_predicate");
diff -ruN klic-3.003-2001-12-28/runtime/gio.c klic-3.003-2001-12-29/runtime/gio.c
--- klic-3.003-2001-12-28/runtime/gio.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/gio.c	Sat Dec 29 12:46:20 2001
@@ -6,7 +6,11 @@
 ----------------------------------------------------------- */
 
 #include <stdio.h>
+#include <klic/alloc.h>  /* malloc_check */
+
+/* debug_printf, klic_getc, klic_fread, klic_putc, klic_fwrite, klic_fflush */
 #include <klic/gcobject.h>
+
 #include "g_pointer.h"
 #include <klic/g_string.h>
 #include <klic/gd_macro.h>
@@ -122,7 +126,6 @@
 	break;
       }
       case functor_fread_2: {
-	extern char *malloc_check();
 	extern q convert_binary_c_string_to_klic_string();
 	long n, k;
 	char *buf;
@@ -338,7 +341,7 @@
       if (inname == 0) inname = "";
       outname = (char *)generic_string_body(G_FUNCTORP(GC_SELF->outname));
       if (outname == 0) outname = "";
-      debug_printf("Illegal message %k to I/O stream for %s%s%s\n",
+      debug_printf("Invalid message %k to I/O stream for %s%s%s\n",
 		   message,
 		   inname,
 		   ((*inname !=0 && *outname !=0 &&
diff -ruN klic-3.003-2001-12-28/runtime/gmerge.c klic-3.003-2001-12-29/runtime/gmerge.c
--- klic-3.003-2001-12-28/runtime/gmerge.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/gmerge.c	Sat Dec 29 12:46:20 2001
@@ -6,7 +6,7 @@
 ----------------------------------------------------------- */
 
 #include <stdio.h>
-#include <klic/gdobject.h>
+#include <klic/gdobject.h>  /* debug_printf */
 #include "atom.h"
 #include "funct.h"
 
@@ -22,7 +22,7 @@
 
 #include <klic/gc_macro.h>
 #include <klic/gd_macro.h>
-extern Const struct goalrec *module_gcmerger();
+extern const struct goalrec* module_gcmerger();
 G_USE_PREDICATE(predicate_gcmerge_xin_4);
 
 #define GC_MERGE_IN_GOAL &predicate_gcmerge_xin_4
@@ -76,9 +76,9 @@
 */
       }
       GC_TERMINATE;
-    } else goto illegal_data;
+    } else goto invalid_data;
   functor0:
-    goto illegal_data;
+    goto invalid_data;
   generic_data0:
     if (GD_IS_CLASS(vector,GC_TERM)) {
       unsigned long size;
@@ -111,12 +111,12 @@
       G_MAKE_VAR(newvar);
       GC_MAKE_MERGE_IN_GOAL(newvar,GC_TERM,i,size);
       GC_RETURN_WITH_HOOK(newvar);
-    } else goto illegal_data;
+    } else goto invalid_data;
  susp0: 
   GC_RETURN_WITH_HOOK(GC_TERM);
- illegal_data:
+ invalid_data:
   debug_printf("### %k ###\n", GC_TERM);
-  GC_FAIL("Illegal data unified with merger");
+  GC_FAIL("Invalid data unified with merger");
  gc_request:
   G_MAKE_VAR(newvar);
   GC_KL1_UNIFY(GC_TERM,newvar);
diff -ruN klic-3.003-2001-12-28/runtime/gmodule.c klic-3.003-2001-12-29/runtime/gmodule.c
--- klic-3.003-2001-12-28/runtime/gmodule.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/gmodule.c	Sat Dec 29 12:46:20 2001
@@ -153,8 +153,8 @@
 {
   GD_STD_DECL_FOR_NEW;
   q atom;
-  extern Const struct modinfo defined_modules[];
-  Const struct modinfo *mp;
+  extern const struct modinfo defined_modules[];
+  const struct modinfo* mp;
   unsigned char *name;
 
   GDSET_SYMARG_FOR_NEW(atom,GD_ARGV[0]);
diff -ruN klic-3.003-2001-12-28/runtime/gmvv.c klic-3.003-2001-12-29/runtime/gmvv.c
--- klic-3.003-2001-12-28/runtime/gmvv.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/gmvv.c	Sat Dec 29 12:46:20 2001
@@ -10,7 +10,7 @@
 */
 
 #include <stdio.h>
-#include <klic/gdobject.h>
+#include <klic/gdobject.h>  /* fatal, debug_printf */
 #include <klic/g_vector.h>
 
 #ifdef DIST
@@ -408,7 +408,7 @@
   if (!G_ISFUNCTOR(anotherq) ||
       another->method_table != GD_SELF->method_table) {
     debug_printf("### %k ###\n", another);
-    GD_FAIL("Illegal argument to string join");
+    GD_FAIL("Invalid argument to string join");
   }
   Shallow(another);
   size2 = another->index;
@@ -586,7 +586,7 @@
       init = G_CDR_OF(init);
       GD_DEREF_FOR_NEW(init);
       if (init!=NILATOM && !G_ISCONS(init))
-	GD_ERROR_IN_NEW("Illegal parameter");
+	GD_ERROR_IN_NEW("Invalid parameter");
     }
     init = GD_ARGV[0];
     GD_ALLOC_AREA_FOR_NEW(body, (q*), size);
@@ -596,7 +596,7 @@
       init = G_CDR_OF(init);
     }
   } else {
-    GD_ERROR_IN_NEW("Illegal parameter");
+    GD_ERROR_IN_NEW("Invalid parameter");
   }
   newvect->next = VECTOR_SHALLOW_MARK;
   newvect->iscnst = 0;
diff -ruN klic-3.003-2001-12-28/runtime/gstring.c klic-3.003-2001-12-29/runtime/gstring.c
--- klic-3.003-2001-12-28/runtime/gstring.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/gstring.c	Sat Dec 29 12:46:20 2001
@@ -7,7 +7,8 @@
 
 #include <stdio.h>
 #include <ctype.h>
-#include <klic/gdobject.h>
+#include <klic/alloc.h>  /* malloc_check */
+#include <klic/gdobject.h>  /* fatal, debug_printf */
 #include <klic/g_string.h>
 #include "atom.h"
 #include "funct.h"
@@ -329,7 +330,7 @@
   if (!G_ISFUNCTOR(anotherq) ||
       another->method_table != GD_SELF->method_table) {
     debug_printf("### %k ###\n", another);
-    GD_FAIL("Illegal argument to string join");
+    GD_FAIL("Invalid argument to string join");
   }
   Shallow(another);
   size2 = another->index;
@@ -625,12 +626,12 @@
       elem = G_CAR_OF(init);
       GD_DEREF_FOR_NEW(elem);
       if (!G_ISINT(elem) || G_INTVAL(elem) < 0 || 256 <= G_INTVAL(elem)) {
-	GD_ERROR_IN_NEW("Illegal parameter");
+	GD_ERROR_IN_NEW("Invalid parameter");
       }
       init = G_CDR_OF(init);
       GD_DEREF_FOR_NEW(init);
       if (init!=NILATOM && !G_ISCONS(init))
-	GD_ERROR_IN_NEW("Illegal parameter");
+	GD_ERROR_IN_NEW("Invalid parameter");
     }
     qsize = ROUND_UP(size);
     init = GD_ARGV[0];
@@ -644,7 +645,7 @@
       init = G_CDR_OF(init);
     }
   } else {
-    GD_ERROR_IN_NEW("Illegal parameter");
+    GD_ERROR_IN_NEW("Invalid parameter");
   }
   newstr->next = STRING_SHALLOW_MARK;
   newstr->iscnst = 0;
@@ -827,7 +828,6 @@
 char *convert_klic_string_to_c_string(s)
      q s;
 {
-  extern char *malloc_check();
   struct byte_string_object *str =
     (struct byte_string_object *)functorp(s);
   char *cstr;
diff -ruN klic-3.003-2001-12-28/runtime/gunix.kl1 klic-3.003-2001-12-29/runtime/gunix.kl1
--- klic-3.003-2001-12-28/runtime/gunix.kl1	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/gunix.kl1	Sat Dec 29 12:46:20 2001
@@ -41,7 +41,6 @@
 #define O_NONBLOCK FNDELAY
 #endif
 
-extern char* malloc_check();
 GD_USE_CLASS(pointer);
 extern q* register_streamed_signal();
 
diff -ruN klic-3.003-2001-12-28/runtime/import_table.c klic-3.003-2001-12-29/runtime/import_table.c
--- klic-3.003-2001-12-28/runtime/import_table.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/import_table.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
diff -ruN klic-3.003-2001-12-28/runtime/intrpt.c klic-3.003-2001-12-29/runtime/intrpt.c
--- klic-3.003-2001-12-28/runtime/intrpt.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/intrpt.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/sighndl.h>
 #include <klic/primitives.h>
@@ -92,7 +92,7 @@
     }
 
 #ifdef SHM
-    while( (Volatile int)ext_queued ) {
+    while( (volatile int) ext_queued ) {
       *cur_status = 1;
       ext_queued = 0;
       klic_barrier();
diff -ruN klic-3.003-2001-12-28/runtime/kmain.c klic-3.003-2001-12-29/runtime/kmain.c
--- klic-3.003-2001-12-28/runtime/kmain.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/kmain.c	Sat Dec 29 12:46:20 2001
@@ -8,12 +8,17 @@
 #ifdef DIST
 /*#define exit(X) myexit(__FILE__, __LINE__, X)*/
 #endif
-#include <klic/basic.h>
-#include <klic/struct.h>
+
+/* klic_interrupt, initalloc, register_gc_hook, register_after_gc_hook,
+ * enqueue_goal
+ */
 #include <klic/primitives.h>
+
+#include <klic/basic.h>  /* fatal, fatalf, fatalp, klic_fprintf */
+#include <klic/struct.h>
 #include <klic/unify.h>
 #include "timing.h"
-#include <klic/functorstuffs.h>
+#include <klic/functorstuffs.h>  /* arityof */
 
 #include <string.h>
 #include <stdio.h>
@@ -45,6 +50,8 @@
 #endif
 #include "options.h"
 
+#define klic_local_fprintf fprintf
+
 
 extern char *runtime_version, *runtime_date;
 
@@ -54,13 +61,13 @@
 int count_suspension = 0;
 #endif
 #ifdef USETIMER
-static Volatile int dummy_alarm_set;
+static volatile int dummy_alarm_set;
 #endif /*USETIMER*/
 module module_main();
 
-extern Const struct predicate predicate_main_xmain_0;
+extern const struct predicate predicate_main_xmain_0;
 #ifdef DIST
-extern Const struct predicate topsucceed_pred;
+extern const struct predicate topsucceed_pred;
 #endif
 
 char *optarg;
@@ -81,7 +88,7 @@
 {
   declare_globals;
   struct goalrec *qp = current_queue;
-  Const struct predicate *toppred = qp->pred;
+  const struct predicate* toppred = qp->pred;
   module func = (module)toppred->func;
   while (1) {
     func = ((module (*)())func)(glbl, qp, heapp, toppred);
@@ -95,7 +102,6 @@
      char **argv;
 {
   declare_globals;
-  void initalloc();
   q *initiate_prioq();
   q *reinitiate_prioq();
 #ifdef USESIG
@@ -272,7 +278,7 @@
 #ifdef SHM
       if ( my_node == MASTER )
 #endif
-	(void) enqueue_goal(0, HIGHESTPRIO-1, qp, glbl);
+	(void) enqueue_goal(NULL, HIGHESTPRIO-1, qp, glbl);
 
       current_queue = get_top_priority_queue();
       resumed_goals = 0;
@@ -339,12 +345,11 @@
      struct global_variables *glbl;
      struct goalrec *qp;
      q *allocp;
-     Const struct predicate *toppred;
+     const struct predicate* toppred;
 #ifdef DIST
 {
-  extern q *klic_interrupt();
   extern void send_return_wtc();
-  extern Const struct predicate topsucceed_pred;
+  extern const struct predicate topsucceed_pred;
 
 #ifdef USE_REDUCTION_COUNT
   fd_set rfds;
@@ -358,8 +363,8 @@
       
   if (IS_SHOEN_NODE(my_node)) {	/* if shoen node */
       if (shoen_wtc > 0) { 
-	  ioeprintf("illegal wtc in shoen node\n");
-	  fatal("illegal WTC");
+	  ioeprintf("invalid wtc in shoen node\n");
+	  fatal("invalid WTC");
       } else if(shoen_wtc == 0){
 	  struct timeval tp;
 	  if(!gettimeofday(&tp, NULL)){
@@ -433,8 +438,7 @@
 
 #else /* #ifndef DIST */
 {
-  extern q *klic_interrupt();
-  extern Const struct predicate topsucceed_pred;
+  extern const struct predicate topsucceed_pred;
   if (suspensions == resumes) {
 #ifdef DEBUGLIB
     if(count_suspension) {
diff -ruN klic-3.003-2001-12-28/runtime/ktimer.c klic-3.003-2001-12-29/runtime/ktimer.c
--- klic-3.003-2001-12-28/runtime/ktimer.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/ktimer.c	Sat Dec 29 12:46:20 2001
@@ -8,11 +8,10 @@
 #include <klic/basic.h>
 #ifdef USETIMER
 #include <sys/time.h>
+#include <klic/alloc.h>  /* malloc_check, register_gc_hook */
 #include <klic/struct.h>
 #include "timer.h"
 #include <klic/sighndl.h>
-
-extern char *malloc_check();
 
 void klic_timer_interrupt_handler()
 {
diff -ruN klic-3.003-2001-12-28/runtime/newatom.c klic-3.003-2001-12-29/runtime/newatom.c
--- klic-3.003-2001-12-28/runtime/newatom.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/newatom.c	Sat Dec 29 12:46:20 2001
@@ -4,13 +4,13 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
-#include <klic/primitives.h>
+#include <klic/primitives.h>  /* malloc_check */
 #include <klic/unify.h>
 #include <klic/index.h>
-#include <klic/atomstuffs.h>
-#include <klic/functorstuffs.h>
+#include <klic/atomstuffs.h>  /* atomname, ATOMNUMBERBASE */
+#include <klic/functorstuffs.h>  /* functors, arities, FUNCTORNUMBERBASE */
 #include <klic/newatom.h>
 
 #ifdef STRINGH
@@ -45,9 +45,7 @@
 static struct functorhashtable functhtable;
 static struct functorhashtable* functhp = &functhtable;
 
-#ifndef SHM
-#include <klic/alloc.h>  /* malloc_check */
-#else  /* SHM */
+#ifdef SHM
 #include "shm.h"
 
 static char* Buff_S;
diff -ruN klic-3.003-2001-12-28/runtime/options.c klic-3.003-2001-12-29/runtime/options.c
--- klic-3.003-2001-12-28/runtime/options.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/options.c	Sat Dec 29 12:46:20 2001
@@ -35,14 +35,14 @@
 }
 char *
 parse_opts(opttbl, acp, avp)
-Const struct opttable *opttbl;
+const struct opttable* opttbl;
 int *acp;
 char ***avp;
 {
     char **argv = *avp;
     char *errp;
     int argc = *acp;
-    Const struct opttable *tblp;
+    const struct opttable* tblp;
     int argc_adv;
     int no_set = 0;		/* -$ option suppress setting variables */
     double atof();
diff -ruN klic-3.003-2001-12-28/runtime/otbl.c klic-3.003-2001-12-29/runtime/otbl.c
--- klic-3.003-2001-12-28/runtime/otbl.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/otbl.c	Sat Dec 29 12:46:20 2001
@@ -7,7 +7,8 @@
 /*
   Object table
 */
-#include <klic/basic.h>
+#include <klic/alloc.h>  /* register_after_gc_hook */
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/g_basic.h>
 #include <klic/g_methtab.h>
@@ -107,7 +108,6 @@
 {
   struct object_table *newent = allocOtblEnt();
   struct object_table *tbl = tbl_root;
-  void register_after_gc_hook();
 
   if(!gc_hook_initialized) {
     register_after_gc_hook(deallocate_garbage);
diff -ruN klic-3.003-2001-12-28/runtime/print.c klic-3.003-2001-12-29/runtime/print.c
--- klic-3.003-2001-12-28/runtime/print.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/print.c	Sat Dec 29 12:46:20 2001
@@ -4,13 +4,13 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* klic_fprintf, klic_putc */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/index.h>
 #include <klic/gb.h>
-#include <klic/functorstuffs.h>
-#include <klic/atomstuffs.h>
+#include <klic/functorstuffs.h>  /* arityof */
+#include <klic/atomstuffs.h>  /* functoratomname, namestringof */
 #include <stdio.h>
 #include "gobj.h"
 #include "susp.h"
diff -ruN klic-3.003-2001-12-28/runtime/random.c klic-3.003-2001-12-29/runtime/random.c
--- klic-3.003-2001-12-28/runtime/random.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/random.c	Sat Dec 29 12:46:20 2001
@@ -7,7 +7,7 @@
 /*
   random number generator
 */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatalf */
 
 #ifdef NRAND48
 #include <klic/struct.h>
@@ -123,7 +123,7 @@
     seed = 0;
   }
   if (range <1) {
-    fatalf("Illegal first argument (%d) in creation of random number generator",
+    fatalf("Invalid first argument (%d) in creation of random number generator",
 	   range);
   }
   GGSET_NEWOBJ_FOR_NEW(obj, (GG_OBJ_TYPE *));
diff -ruN klic-3.003-2001-12-28/runtime/recsusp.c klic-3.003-2001-12-29/runtime/recsusp.c
--- klic-3.003-2001-12-28/runtime/recsusp.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/recsusp.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* klic_fprinf, klic_putc */
 #include <klic/struct.h>
 #include <stdio.h>
 #define SUSPTABLESIZE 256
@@ -12,7 +12,7 @@
 extern char *calloc(), *malloc();
 
 struct susp_count_ent {
-  Const struct predicate *pred;
+  const struct predicate* pred;
   long counter;
   struct susp_count_ent *next;
 };
@@ -62,7 +62,7 @@
 record_suspended_pred(goal)
      struct goalrec *goal;
 {
-  Const struct predicate *pred = goal->pred;
+  const struct predicate* pred = goal->pred;
   unsigned int key = hash_pred(pred);
   
   if (suspension_count_table[key]) {
diff -ruN klic-3.003-2001-12-28/runtime/sched.c klic-3.003-2001-12-29/runtime/sched.c
--- klic-3.003-2001-12-28/runtime/sched.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/sched.c	Sat Dec 29 12:46:20 2001
@@ -4,9 +4,13 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal, fatalf */
 #include <klic/struct.h>
-#include <klic/alloc.h>
+
+/* klic_interrupt, malloc_check,
+ * enqueue_goal, enqueue_after_waiting, enqueue_throw_goal
+ */
+#include <klic/primitives.h>
 
 #include <stdio.h>
 #ifdef DEBUGLIB
@@ -18,8 +22,6 @@
 extern jmp_buf klic_topmost;
 #endif
 
-extern char *malloc_check();
-
 #define new_prioqrec(pqr)			\
 {						\
   struct prioqrec *temp;			\
@@ -55,13 +57,13 @@
 module queue_empty();
 extern module topsucceed();
 
-Const struct predicate queue_empty_pred = { queue_empty, 0, 0 };
-Const struct predicate topsucceed_pred = { topsucceed, 0, 0 };
+const struct predicate queue_empty_pred = { queue_empty, 0, 0 };
+const struct predicate topsucceed_pred = { topsucceed, 0, 0 };
 #ifdef SHM
 module mastersucceed();
-Const struct predicate mastersucceed_pred = { mastersucceed, 0, 0 };
+const struct predicate mastersucceed_pred = { mastersucceed, 0, 0 };
 module childsucceed();
-Const struct predicate childsucceed_pred = { childsucceed, 0, 0 };
+const struct predicate childsucceed_pred = { childsucceed, 0, 0 };
 #endif
 
 struct goalrec
@@ -128,7 +130,7 @@
   return reinitiate_prioq(allocp);
 }
 
-struct goalrec *
+extern struct goalrec*
 enqueue_goal(qp, prio, gp, glbl)
      struct goalrec *qp;
      long prio;
@@ -192,7 +194,7 @@
   fatal("Non-integer priority specified");
 }
 
-struct goalrec *
+extern struct goalrec*
 enqueue_after_waiting(qp, prio, gp, allocp, is_relative)
      struct goalrec *qp;
      q prio;
@@ -245,7 +247,7 @@
   struct global_variables *glbl;
   struct goalrec *qp;
   q *allocp;
-  Const struct predicate *toppred;
+  const struct predicate* toppred;
 {
   int arity = toppred->pred;
   q prio = qp->args[arity+1];
@@ -265,7 +267,7 @@
 struct goalrec *throw_goal_routine();
 #endif
 
-struct goalrec *
+extern struct goalrec*
 enqueue_throw_goal(penum, gp, qp, allocp)
      q penum;
      struct goalrec *gp;
@@ -326,7 +328,7 @@
   struct global_variables *glbl;
   struct goalrec *qp;
   q *allocp;
-  Const struct predicate *toppred;
+  const struct predicate* toppred;
 {
   int arity = toppred->pred;
   q penum = qp->args[arity+1];
@@ -425,7 +427,7 @@
      struct goalrec *qp;
      struct goalrec *fg;
      q *allocp;
-     Const struct predicate *toppred;
+     const struct predicate* toppred;
 {
 #ifdef SHM
   if ( ext_queued ) {
@@ -474,7 +476,7 @@
 struct global_variables *glbl;
 struct goalrec *qp;
 q *allocp;
-Const struct predicate *toppred;
+const struct predicate* toppred;
 {
     int first,i;
 
@@ -559,7 +561,7 @@
 struct global_variables *glbl;
 struct goalrec *qp;
 q *allocp;
-Const struct predicate *toppred;
+const struct predicate* toppred;
 {
 
     while ( !(ex_qp->next) ) {
diff -ruN klic-3.003-2001-12-28/runtime/schedule.h klic-3.003-2001-12-29/runtime/schedule.h
--- klic-3.003-2001-12-28/runtime/schedule.h	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/schedule.h	Sat Dec 29 12:46:20 2001
@@ -13,10 +13,6 @@
 
 extern struct prioqrec* more_prioqrec(void);
 
-extern struct goalrec* enqueue_goal(
-  struct goalrec* qp, long prio,
-  struct goalrec* gp, struct global_variables* glbl );
-
 extern struct goalrec* get_top_priority_queue(void);
 extern void put_priority_queue(struct goalrec* qp, long prio);
 
diff -ruN klic-3.003-2001-12-28/runtime/sendrecv.c klic-3.003-2001-12-29/runtime/sendrecv.c
--- klic-3.003-2001-12-28/runtime/sendrecv.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/sendrecv.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal, fatalf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
@@ -205,7 +205,7 @@
 	    heapp = allocp;
 	    return 1;
 
-/*	    fatal("Heap over in msg_handler: 0x%lx+0x%lx >= 0x%lx\n",
+/*	    fatalf("Heap over in msg_handler: 0x%lx+0x%lx >= 0x%lx\n",
 		  (long)allocp, (long)this_more_space, (long)real_heaplimit);*/
 	}
     }
diff -ruN klic-3.003-2001-12-28/runtime/shm_gc.c klic-3.003-2001-12-29/runtime/shm_gc.c
--- klic-3.003-2001-12-28/runtime/shm_gc.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/shm_gc.c	Sat Dec 29 12:46:20 2001
@@ -6,11 +6,11 @@
 ----------------------------------------------------------- */
 
 #include <stdio.h>
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include "timing.h"
 #include <klic/primitives.h>
-#include <klic/functorstuffs.h>
+#include <klic/functorstuffs.h>  /* arityof */
 #include "gobj.h"
 #include "susp.h"
 #include "shm.h"
diff -ruN klic-3.003-2001-12-28/runtime/shm_obj.c klic-3.003-2001-12-29/runtime/shm_obj.c
--- klic-3.003-2001-12-28/runtime/shm_obj.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/shm_obj.c	Sat Dec 29 12:46:20 2001
@@ -5,10 +5,10 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 
+#include <stdio.h>  /* NULL */
 #include <klic/basic.h>
 #include <klic/struct.h>
-#include <klic/primitives.h>
-#include <klic/alloc.h>
+#include <klic/primitives.h>  /* enqueue_goal */
 #include <klic/functorstuffs.h>
 #include <klic/index.h>
 #include <klic/unify.h>
@@ -72,9 +72,9 @@
 
 
 module shm_resume();
-Const struct predicate shm_xresume_1 = { shm_resume, 0, 1 };
+const struct predicate shm_xresume_1 = { shm_resume, 0, 1 };
 module shm_request();
-Const struct predicate shm_xrequest_1 = { shm_request, 0, 1 };
+const struct predicate shm_xrequest_1 = { shm_request, 0, 1 };
 
 
 TADDRtbl *more_addr_rec()
@@ -271,7 +271,7 @@
 	   if ( goal && isatomic(goal->next) ) {
 	     long prio = intval(goal->next);
 	     if ( current_prio != prio ) {
-	       (void) enqueue_goal(0,prio,goal,glbl);
+	       (void) enqueue_goal(NULL, prio, goal, glbl);
 	     } else {
 	       resume_same_prio(goal);
 	     }
@@ -368,7 +368,7 @@
 struct global_variables *glbl;
 struct goalrec *qp;
 q *allocp;
-Const struct predicate *toppred;
+const struct predicate* toppred;
 {
     TADDRtbl *tp = (TADDRtbl*)((unsigned long)(qp->args[0])-ATOMIC);
     free_local_tbl(tp);
@@ -399,7 +399,7 @@
 struct global_variables *glbl;
 struct goalrec *qp;
 q *allocp;
-Const struct predicate *toppred;
+const struct predicate* toppred;
 {
     TADDRtbl *tp = (TADDRtbl*)((unsigned long)(qp->args[0])-ATOMIC);
     q var = (q)tp->globalA;
diff -ruN klic-3.003-2001-12-28/runtime/shm_rsv.c klic-3.003-2001-12-29/runtime/shm_rsv.c
--- klic-3.003-2001-12-28/runtime/shm_rsv.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/shm_rsv.c	Sat Dec 29 12:46:20 2001
@@ -47,7 +47,7 @@
 int* lockp[6+MAX_N_PE];
 
 
-Volatile PLNE* PLNE_ptr[MAX_N_PLNE];
+volatile PLNE* PLNE_ptr[MAX_N_PLNE];
 
   /* Management variables on shared memory */
 struct global_variables* shm_glblp = &globals;
diff -ruN klic-3.003-2001-12-28/runtime/shm_throw.c klic-3.003-2001-12-29/runtime/shm_throw.c
--- klic-3.003-2001-12-28/runtime/shm_throw.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/shm_throw.c	Sat Dec 29 12:46:20 2001
@@ -9,7 +9,7 @@
 #include <klic/struct.h>
 #include <klic/primitives.h>
 #include <klic/unify.h>
-#include <klic/functorstuffs.h>
+#include <klic/functorstuffs.h>  /* arityof */
 #include "susp.h"
 #include "gobj.h"
 #include "shm.h"
@@ -125,7 +125,7 @@
     if ( NO >= 0 && NO < total_node )
        return(NO);
     else
-       abend("Illegal PE number !!!");
+       abend("Invalid PE number !!!");
 }
 
 /* ***************  Copy Routines  ****************************** */
diff -ruN klic-3.003-2001-12-28/runtime/signal.c klic-3.003-2001-12-29/runtime/signal.c
--- klic-3.003-2001-12-28/runtime/signal.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/signal.c	Sat Dec 29 12:46:20 2001
@@ -5,9 +5,10 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 #define SIGMAIN
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatalf */
 
 #ifdef USESIG
+#include <klic/alloc.h>  /* register_gc_hook */
 #include <klic/struct.h>
 #include <klic/sighndl.h>
 
@@ -74,7 +75,7 @@
      int (*func)();
 {
   if (sig >= NSIG) {
-    fatalf("Illegal signal number %d", sig);
+    fatalf("Invalid signal number %d", sig);
   }
   if (signal_handlers[sig] != 0) {
     fatalf("Trying to redefine a signal handler for signal %d", sig);
diff -ruN klic-3.003-2001-12-28/runtime/step.c klic-3.003-2001-12-29/runtime/step.c
--- klic-3.003-2001-12-28/runtime/step.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/step.c	Sat Dec 29 12:46:20 2001
@@ -9,7 +9,7 @@
 
 #include <klic/basic.h>
 #include <klic/struct.h>
-#include <klic/primitives.h>
+#include <klic/primitives.h>  /* malloc_check, realloc_check */
 #include "goalobj.h"
 #include <klic/generic.h>
 #include "atom.h"
@@ -53,8 +53,6 @@
 
 static void init_stepping()
 {
-  extern char *malloc_check();
-
   queued_goals = InitialAlloc(struct goalrec *);
   queued_prio = InitialAlloc(long);
   max_queued = MIN_ALLOC;
@@ -72,18 +70,18 @@
 
 /* Dummy predicate to trigger stepping */
 static module module_step__trigger();
-Const struct predicate step_trigger_pred = {
+const struct predicate step_trigger_pred = {
   module_step__trigger, 0, 5 };
 
 module module_step__trigger(glbl, qp, allocp, toppred)
      struct global_variables *glbl;
      struct goalrec *qp;
      q *allocp;
-     Const struct predicate *toppred;
+     const struct predicate* toppred;
 {
   struct goal_object *obj = (struct goal_object *)functorp(qp->args[0]);
   struct goalrec *goal = obj->goal;
-  Const struct predicate *stepped_pred = goal->pred;
+  const struct predicate* stepped_pred = goal->pred;
 
   if (!stepping_initiated) {
     init_stepping();
@@ -266,7 +264,6 @@
      long prio;
 {
   if (num_queued >= max_queued) {
-    extern char *realloc_check();
     int newmax = max_queued * 2;
     queued_goals = (struct goalrec **)
       realloc_check(queued_goals, newmax*sizeof(struct goalrec *));
@@ -284,7 +281,6 @@
      long prio;
 {
   if (num_wokenup >= max_wokenup) {
-    extern char *realloc_check();
     int newmax = max_wokenup * 2;
     wokenup_goals = (struct goalrec **)
       realloc_check(wokenup_goals, newmax*sizeof(struct goalrec *));
@@ -302,7 +298,6 @@
      long node, prio;
 {
   if (num_thrown >= max_thrown) {
-    extern char *realloc_check();
     int newmax = max_thrown * 2;
     thrown_goals = (struct goalrec **)
       realloc_check(thrown_goals, newmax*sizeof(struct goalrec *));
@@ -322,7 +317,6 @@
      struct goalrec *goal;
 {
   if (num_failed >= max_failed) {
-    extern char *realloc_check();
     int newmax = max_failed * 2;
     failed_goals = (struct goalrec **)
       realloc_check(failed_goals, newmax*sizeof(struct goalrec *));
diff -ruN klic-3.003-2001-12-28/runtime/sysc.kl1 klic-3.003-2001-12-29/runtime/sysc.kl1
--- klic-3.003-2001-12-28/runtime/sysc.kl1	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/sysc.kl1	Sat Dec 29 12:46:20 2001
@@ -6,6 +6,7 @@
 ----------------------------------------------------------- */
 
 :- inline:"
+#include <klic/alloc.h>  /* register_gc_hook */
 #include <klic/gd_macro.h>
 
 GD_USE_CLASS(predicate);
diff -ruN klic-3.003-2001-12-28/runtime/timer.c klic-3.003-2001-12-29/runtime/timer.c
--- klic-3.003-2001-12-28/runtime/timer.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/timer.c	Sat Dec 29 12:46:20 2001
@@ -5,24 +5,23 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 
-#include <klic/basic.h>
+#include <klic/alloc.h>  /* malloc_check */
+#include <klic/basic.h>  /* fatalp */
 #ifdef USETIMER
 #include <signal.h>
 #include <sys/time.h>
 #include "timer.h"
 
-extern char *malloc_check();
-
-static struct klic_timer_wait_rec * Volatile
+static struct klic_timer_wait_rec* volatile
   timer_wait_root = 0;
-static struct klic_timer_wait_rec * Volatile
+static struct klic_timer_wait_rec* volatile
   timer_wait_free = 0;
 
 static Inline void
 insert_timer_queue(newtwr)
      struct klic_timer_wait_rec *newtwr;
 {
-  struct klic_timer_wait_rec * Volatile *twr;
+  struct klic_timer_wait_rec* volatile* twr;
   for (twr = &timer_wait_root;
        *twr != 0 && NotLaterThan((*twr)->on_at, newtwr->on_at);
        twr = &(*twr)->next) {
diff -ruN klic-3.003-2001-12-28/runtime/timing.c klic-3.003-2001-12-29/runtime/timing.c
--- klic-3.003-2001-12-28/runtime/timing.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/timing.c	Sat Dec 29 12:46:20 2001
@@ -6,7 +6,7 @@
 ----------------------------------------------------------- */
 #include <sys/types.h>
 #include <sys/times.h>
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal */
 
 long blt_times()
 {
diff -ruN klic-3.003-2001-12-28/runtime/trace.c klic-3.003-2001-12-29/runtime/trace.c
--- klic-3.003-2001-12-28/runtime/trace.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/trace.c	Sat Dec 29 12:46:20 2001
@@ -5,12 +5,12 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 #include <ctype.h>
-#include <klic/basic.h>
+#include <klic/basic.h>  /* fatal, klic_fprintf, klic_getc, klic_fflush */
 #include <klic/struct.h>
-#include <klic/primitives.h>
+#include <klic/primitives.h>  /* malloc_check, realloc_check, enqueue_goal */
 #include <klic/predinfo.h>
 #include <klic/generic.h>
-#include <klic/functorstuffs.h>
+#include <klic/functorstuffs.h>  /* arityof */
 #include "susp.h"
 #ifdef STRINGH
 #include <string.h>
@@ -31,8 +31,6 @@
 
 extern module wait_penum_routine();
 
-extern char *realloc_check();
-extern char *malloc_check();
 extern char *calloc();
 extern void free();
 
@@ -197,7 +195,7 @@
   return pred_hash[h].pte;
 }  
 
-extern Const struct modinfo defined_modules[];
+extern const struct modinfo defined_modules[];
 
 static make_name_tables()
 {
@@ -210,9 +208,9 @@
   n_pred = 0;
   n_mod = 0;
   {
-    Const struct modinfo *dm;
+    const struct modinfo* dm;
     for (dm = &defined_modules[0]; dm->name != 0; dm++) {
-      Const struct predinfo * Const *dp;
+      const struct predinfo* const* dp;
       n_mod++;
       for (dp = &dm->preds[0]; *dp != 0; dp++) {
 	n_pred++;
@@ -240,9 +238,9 @@
   /* fill predicate table */
   pte = pred_table;
   {
-    Const struct modinfo *dm;
+    const struct modinfo* dm;
     for (dm = &defined_modules[0]; dm->name != 0; dm++) {
-      Const struct predinfo * Const *dp;
+      const struct predinfo* const* dp;
       for (dp = &dm->preds[0]; *dp != 0; dp++) {
 	pte->name = (*dp)->name;
 	pte->pred = (*dp)->predstruct;
@@ -265,7 +263,7 @@
 
   /* fill module table */
   {
-    Const struct modinfo *dm;
+    const struct modinfo* dm;
     for (dm = &defined_modules[0]; dm->name != 0; dm++) {
       mte->name = dm->name;
       mte->func = (*dm->preds)->predstruct->func;
@@ -380,7 +378,7 @@
   if (!Traced(g)) {
     declare_globals;
     struct goalrec *ng;
-    Const struct predicate *pred = g->pred;
+    const struct predicate* pred = g->pred;
     unsigned int k, arity;
     arity = pred->arity;
     heapalloc(ng, arity+5, (struct goalrec *));
@@ -440,10 +438,10 @@
   struct global_variables *glbl;
   struct goalrec *qp;
   q *allocp;
-  Const struct predicate *toppred;
+  const struct predicate* toppred;
 {
   extern module wait_prio_routine();
-  Const struct predicate *traced_pred;
+  const struct predicate* traced_pred;
   struct pred_table_entry *pte;
   struct trace_info_rec *info;
 
@@ -816,9 +814,9 @@
 static enum tracer_command trace_parse_command(info)
      struct trace_info_rec *info;
 {
-  Const struct command_table_entry *cte;
+  const struct command_table_entry* cte;
   static char command_name[256];
-  static Const struct command_table_entry {
+  static const struct command_table_entry {
     char *name;
     enum tracer_command command;
   } command_table[] = {
@@ -1045,7 +1043,7 @@
 static q subterm_of_goal(g)
      struct goalrec *g;
 {
-  Const struct predicate *pred;
+  const struct predicate* pred;
   int k;
   q term;
 
@@ -1102,7 +1100,7 @@
      struct trace_info_rec **info;
 {
   enum trace_port port;
-  Const struct mod_table_entry *mte;
+  const struct mod_table_entry* mte;
   struct pred_table_entry *pte;
   int arity;
   int is_spy, set_flag, only_spied;
@@ -1195,8 +1193,8 @@
     set_flag = 0;
   set_reset:
     {
-      static Const char *set_reset[] = { "reset", "set" };
-      static Const char *spy_trace[] = { "Default trace", "Spy point" };
+      static const char* set_reset[] = { "reset", "set" };
+      static const char* spy_trace[] = { "Default trace", "Spy point" };
       switch (trace_parse_predicate_name(&mte, &pte, &arity, curmod, *info)) {
       case -1:
 	break;
@@ -1383,7 +1381,7 @@
   }
 }
 
-static Const char *common_help[] = {
+static const char* common_help[] = {
  "E: enable port;   D: disable port;  L: leash port;    U: unleash port;",
  "S <pred>: spy;    N <pred>: nospy;  t <pred>: trace;  n <pred>: notrace;",
  "pd: print depth;  pl: print length; pv: toggle verbose print;",
@@ -1418,7 +1416,7 @@
     err = 1;
   }    
   if (err) {
-    static Const char *call_help[] = {
+    static const char* call_help[] = {
       "\t*** Commands available at CALL ports ***",
       "<cr>: continue;   c: continue;      s: skip;          l: leap;",
       0
@@ -1499,7 +1497,7 @@
     break;
   }    
   if (err) {
-    static Const char *reduce_help[] = {
+    static const char* reduce_help[] = {
       "\t*** Commands available at REDUCE ports ***",
       "<cr>: continue;   c: continue;      s: skip;          l: leap;",
       "+ <n>: trace;     - <n>: no trace;  <n>: toggle trace",
@@ -1533,7 +1531,7 @@
     break;
   }    
   if (err) {
-    static Const char *susp_help[] = {
+    static const char* susp_help[] = {
       "\t*** Commands available at SUSPENSION ports ***",
       "<cr>: continue;   c: continue;      s: skip;          l: leap;",
       0
@@ -1568,7 +1566,7 @@
     break;
   }    
   if (err) {
-    static Const char *fail_help[] = {
+    static const char* fail_help[] = {
       "\t*** Commands available at FAIL ports ***",
       0
     };
@@ -1609,7 +1607,7 @@
 static print_port_names(info)
      struct trace_info_rec *info;
 {
-  static Const char *port_help[] = {
+  static const char* port_help[] = {
     "Available ports are \"call\", \"susp\", \"redu\" and \"fail\".",
     "You can also specify \"all\".",
     0 };
@@ -1631,7 +1629,7 @@
 }
 
 static print_help(messages, info)
-     Const char **messages;
+     const char** messages;
      struct trace_info_rec *info;
 {
   while (*messages) {
@@ -1749,7 +1747,7 @@
     klic_fprintf(stream, " ");
     trace_print(stream, term, depth, length);
   } else {
-    Const struct predicate *pred;
+    const struct predicate* pred;
     struct pred_table_entry *pte;
     int traced;
 
@@ -1878,8 +1876,8 @@
      long dump_seq;
      struct trace_info_rec *info;
 {
-  extern Const struct predicate queue_empty_pred;
-  extern Const struct predicate topsucceed_pred;
+  extern const struct predicate queue_empty_pred;
+  extern const struct predicate topsucceed_pred;
   if (qp->pred != &queue_empty_pred &&
       qp->pred != &topsucceed_pred) {
     do {
diff -ruN klic-3.003-2001-12-28/runtime/unify.c klic-3.003-2001-12-29/runtime/unify.c
--- klic-3.003-2001-12-28/runtime/unify.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/unify.c	Sat Dec 29 12:46:20 2001
@@ -4,11 +4,12 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+
+#include <stdio.h>  /* NULL */
+#include <klic/basic.h>  /* fatal, klic_fprintf, klic_putc */
 #include <klic/struct.h>
-#include <klic/primitives.h>
+#include <klic/primitives.h>  /* enqueue_goal */
 #include "schedule.h"
-#include <stdio.h>
 #include <klic/gb.h>
 #include "gobj.h"
 #include "susp.h"
@@ -97,7 +98,7 @@
 	enqueue_unify_goal(derefone(x), y);
 	break;
       case (long)makecons(0):
-	fatal("illegal situation in generator unification");
+	fatal("invalid situation in generator unification");
       default:
 	allocp = heapp;
 	derefone(gsusp->backpt) =  tmp;
@@ -181,7 +182,7 @@
 #endif
 	    {
 	      if (gp != current_prio) {
-		(void) enqueue_goal(0, gp, u.g, glbl);
+		(void) enqueue_goal(NULL, gp, u.g, glbl);
 	      } else {
 		resume_same_prio(u.g);
 	      }
@@ -247,7 +248,7 @@
 	    enqueue_unify_goal(gsx->backpt, sy->backpt);
 	    break;
 	  case (long)makecons(0):
-	    fatal("illegal situation at the generator unification");
+	    fatal("invalid situation at the generator unification");
 	  default:
 	    allocp = heapp;
 	    derefone(gsy->backpt) = tmpy;
@@ -260,7 +261,7 @@
 	  break;
 	}
 	case (long)makecons(0):
-	  fatal("illegal situation at the generator unification");
+	  fatal("invalid situation at the generator unification");
 	default:
 	  allocp = heapp;
 	  gsx->backpt = tmpx;
@@ -280,8 +281,8 @@
       case (long)makeref(0): /* GC request */
 	enqueue_unify_goal(gsx->backpt, sy->backpt);
 	break;
-      case (long)makecons(0): /* illegal */
-	fatal("illegal situation at the generator unification");
+      case (long)makecons(0): /* invalid */
+	fatal("invalid situation at the generator unification");
       default:
         allocp = heapp;
 	derefone(gsx->backpt) = tmpx;
@@ -604,7 +605,7 @@
     klic_fprintf(stdout, \
 		 "%x:%d/%d\n", g->pred->func, g->pred->pred, g->pred->arity); \
   } else { \
-    klic_fprintf(stdout, "Illegal goal !: %x\n", g); \
+    klic_fprintf(stdout, "Invalid goal !: %x\n", g); \
   } \
 }
 
diff -ruN klic-3.003-2001-12-28/runtime/unify2.c klic-3.003-2001-12-29/runtime/unify2.c
--- klic-3.003-2001-12-28/runtime/unify2.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2001-12-29/runtime/unify2.c	Sat Dec 29 12:46:20 2001
@@ -11,7 +11,7 @@
 #include <klic/unify.h>
 #include <klic/index.h>
 #include <klic/gb.h>
-#include <klic/functorstuffs.h>
+#include <klic/functorstuffs.h>  /* arityof */
 #include "gobj.h"
 
 /* 
diff -ruN klic-3.003-2001-12-28/runtime/xio.c klic-3.003-2001-12-29/runtime/xio.c
--- klic-3.003-2001-12-28/runtime/xio.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-29/runtime/xio.c	Sat Dec 29 12:46:20 2001
@@ -4,7 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
-#include <klic/basic.h>
+#include <klic/basic.h>  /* extern */
 
 #include <stdio.h>
 #include <errno.h>
@@ -81,7 +81,7 @@
 }
 
 Inline int debug_fwrite(pt, size, items, f)
-     Const void *pt;
+     const void* pt;
      size_t size, items;
      FILE *f;
 {
@@ -103,7 +103,8 @@
   klic_XXXX redirect stdout/err
 */
 
-int klic_getc(f)
+extern int
+klic_getc(f)
 FILE *f;
 {
 #ifdef DIST
@@ -114,7 +115,8 @@
   return debug_getc(f);
 }
 
-int klic_fread(pt, size, items, f)
+extern int
+klic_fread(pt, size, items, f)
      void *pt;
      size_t size;
      size_t items;
@@ -144,7 +146,8 @@
   return debug_fgets(buf, len, f);
 }
 
-int klic_putc(c, out)
+extern int
+klic_putc(c, out)
 int c;
 FILE *out;
 {
@@ -157,9 +160,9 @@
   return debug_fputc(c, out);
 }
 
-int
+extern int
 klic_fwrite(pt, size, items, f)
-     Const void *pt;
+     const void* pt;
      size_t size, items;
      FILE *f;
 {
@@ -172,7 +175,7 @@
   return debug_fwrite(pt, size, items, f);
 }
 
-int
+extern int
 klic_fflush(f)
      FILE *f;
 {
