diff -ruN klic-3.003-2001-12-02/ChangeLog klic-3.003-2001-12-22/ChangeLog
--- klic-3.003-2001-12-02/ChangeLog	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/ChangeLog	Sat Dec 22 18:09:13 2001
@@ -1,3 +1,47 @@
+2001-11-26 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* runtime/gunix.kl1: change a call of mktemp to of mkstemp.
+
+2001-11-25 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* compiler/klicdb.c: correct arguments of error_exit calls.
+
+2001-11-24 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* compiler/klicdb.c: correct module variables/functions to 'static'.
+
+2001-11-23 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* compiler/klic.c: correct -C option and regenerating *.ext.
+
+2001-11-21 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* runtime/termio.kl1:
+	support fork_with_pipes on klicio (thanks kaneki@ueda..).
+
+2001-11-20 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* Makefile.tail: remove shared libraries when distclean/realclean.
+
+	* include/klic/*.h: parenthesis macros and its arguments occurences.
+	
+2001-11-19 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* include/klic/*.h: support multiple includings.
+	
+2001-11-18 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* compiler/klic.c: correct arguments of an exec_command call.
+	
+	* include/klic/control.h: correct a spelling REDCTION_COUNT.
+	
+	* include/klic/gg_macro.h: rename GG_ERROR_IN_IN to GG_ERROR_IN_NEW.
+
+	* runtime/debug.c:
+	change a reference to sys_errlist[] to a strerror() call.
+
+	* runtime/gunix.kl1: correct fork_with_pipes (thanks kaneki@ueda..).
+
 Wed Oct 11 16:33:41 2000  Yusuke TAKAGI  <takagi@ueda.info.waseda.ac.jp>
 
 	* runtime/termio.kl1: support prolog-like IO for socket stream.
diff -ruN klic-3.003-2001-12-02/compiler/write.kl1 klic-3.003-2001-12-22/compiler/write.kl1
--- klic-3.003-2001-12-02/compiler/write.kl1	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/compiler/write.kl1	Sat Dec 22 18:09:13 2001
@@ -25,7 +25,7 @@
 	"  struct global_variables *glbl;\n"
 	"  struct goalrec *qp;\n"
 	"  register q *allocp;\n"
-	"  Const struct predicate *toppred;\n{\n",
+	"  const struct predicate *toppred;\n{\n",
 	[Name])-Out,
     declare_const(InfoSorted)+0+_-Out,
     pred_min_max(Preds,99999,MinArity,0,MaxArity),
@@ -62,7 +62,7 @@
     Id=string(K),
     klic_comp_obj:klicformat(
 	"  declare_method_table_of(byte__string);\n"
-	"  static Const string_structure_type_~d string_const_~d =\n"
+	"  static const string_structure_type_~d string_const_~d =\n"
 	"      declare_string_constant_~d(0,0);\n",
 	[E,K, E])-Out,
     K += 1.
@@ -70,13 +70,13 @@
     Id=string(K),
     L4 := (L+3)/4*4,
     klic_comp_obj:klicformat(
-	"  static Const unsigned char strconst_body_~d[~d] =\n    ",
+	"  static const unsigned char strconst_body_~d[~d] =\n    ",
 	[K,L4])-Out,
     write_string_body(L,S)-Out,
     Out <= fwrite(";\n"),
     klic_comp_obj:klicformat(
 	"  declare_method_table_of(byte__string);\n"
-	"  static Const string_structure_type_~d string_const_~d =\n"
+	"  static const string_structure_type_~d string_const_~d =\n"
 	"      declare_string_constant_~d(strconst_body_~d,~d);\n",
 	[E,K, E,K,L])-Out,
     K += 1.
@@ -84,7 +84,7 @@
     Id=vector(K),
     klic_comp_obj:klicformat(
 	"  declare_method_table_of(vector);\n"
-	"  static Const vector_structure_type vector_const_~d =\n"
+	"  static const vector_structure_type vector_const_~d =\n"
 	"      declare_vector_constant(0,0);\n",
 	[K])-Out,
     K += 1.
@@ -93,13 +93,13 @@
     declare_const_list(Elems0,Elems)-K-Out,
     Id=vector(K),
     klic_comp_obj:klicformat(
-	"  static Const q vectconst_body_~d[] = {\n",
+	"  static const q vectconst_body_~d[] = {\n",
 	[K])-Out,
     write_const_elems(Elems)-Out,
     Out <= fwrite("  };\n"),
     klic_comp_obj:klicformat(
 	"  declare_method_table_of(vector);\n"
-	"  static Const vector_structure_type vector_const_~d =\n"
+	"  static const vector_structure_type vector_const_~d =\n"
 	"      declare_vector_constant(vectconst_body_~d,~d);\n",
 	[K, K,L])-Out,
     K += 1.
@@ -107,7 +107,7 @@
     Id=float(K),
     klic_comp_obj:klicformat(
 	"  declare_method_table_of(float);\n"
-	"  static Const float_structure_type float_const_~d =\n"
+	"  static const float_structure_type float_const_~d =\n"
 	"    declare_float_constant(~g);\n",
 	[K, X])-Out,
     K += 1.
@@ -116,7 +116,7 @@
     klic_comp_obj:klicformat(
 	"  declare_method_table_of(module);\n"
 	"  extern module module_~q();\n"
-	"  static Const module_structure_type mod_const_~d =\n"
+	"  static const module_structure_type mod_const_~d =\n"
 	"    declare_module_constant(module_~q, ~a);\n",
 	[M, K, M,M])-Out,
     K += 1.
@@ -125,7 +125,7 @@
     Id=predicate(K),
     klic_comp_obj:klicformat(
 	"  declare_method_table_of(predicate);\n"
-	"  static Const predicate_structure_type pred_const_~d =\n"
+	"  static const predicate_structure_type pred_const_~d =\n"
 	"    declare_pred_constant(~p, mod_const_~d, ~a);\n",
 	[K, M,F,A,Mid,F])-Out,
     K += 1.
@@ -134,7 +134,7 @@
     declare_const(H0,H)-K-Out,
     Id=list(K),
     klic_comp_obj:klicformat(
-	"  static Const q cons_const_~d[] = {\n",
+	"  static const q cons_const_~d[] = {\n",
 	[K])-Out,
     write_const_elems([T,H])-Out,
     klic_comp_obj:klicformat("  };\n")-Out,
@@ -144,7 +144,7 @@
     declare_const_list(Args,Elems)-K-Out,
     Id=functor(K),
     klic_comp_obj:klicformat(
-	"  static Const q funct_const_~d[] = {\n"
+	"  static const q funct_const_~d[] = {\n"
 	"    makesym(~f),\n",
 	[K, F/A])-Out,
     write_const_elems(Elems)-Out,
@@ -233,7 +233,7 @@
 write_pred_structs([], _)-Out.
 write_pred_structs([pred(Name, Arity, SeqNum, _, _)|Rest], Module)-Out :-
     klic_comp_obj:klicformat(
-	"Const struct predicate ~p =\n"
+	"const struct predicate ~p =\n"
 	"   { module_~q, ~d, ~d };\n", 
 	[Module,Name,Arity, Module, SeqNum, Arity])-Out,
     write_pred_structs(Rest, Module)-Out.
@@ -244,7 +244,7 @@
     declare_externals(T)-Out.
 
 declare_one_external(ext(M,P,A))-Out :-
-    klic_comp_obj:klicformat("extern Const struct predicate ~p;\n",
+    klic_comp_obj:klicformat("extern const struct predicate ~p;\n",
 	[M,P,A])-Out.
 declare_one_external(gnew(Class))-Out :-
     klic_comp_obj:klicformat("extern q ~q_g_new();\n",[Class])-Out.
diff -ruN klic-3.003-2001-12-02/include/klic/alloc.h klic-3.003-2001-12-22/include/klic/alloc.h
--- klic-3.003-2001-12-02/include/klic/alloc.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/alloc.h	Sat Dec 22 18:09:13 2001
@@ -8,9 +8,15 @@
 #ifndef _KLIC_ALLOC_H_
 #define _KLIC_ALLOC_H_
 
-extern q* klic_interrupt();
+extern q* klic_interrupt(q* allocp, struct goalrec* qp);
 
-/* Reverse allocation from "heaptop" */
+
+/** Reverse allocation from "heaptop"
+ * revalloc: procedure
+ *   s: maketype&
+ *   words > 0: offset_t
+ *   maketype: type cast or function returning q
+ */
 
 #define revalloc(s, words, maketype) \
 do{ \
diff -ruN klic-3.003-2001-12-02/include/klic/basic.h klic-3.003-2001-12-22/include/klic/basic.h
--- klic-3.003-2001-12-02/include/klic/basic.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/basic.h	Sat Dec 22 18:10:56 2001
@@ -8,6 +8,7 @@
 #ifndef _KLIC_BASIC_H_
 #define _KLIC_BASIC_H_
 
+#include <stdio.h>
 #include <klic/config.h>
 
 #ifdef MAIN
@@ -55,12 +56,12 @@
   we use our own version of getc &c
 */
 
-extern int klic_getc();
-extern int klic_fread();
+extern int klic_getc(FILE* f);
+extern int klic_fread(void* pt, size_t size, size_t items, FILE* f);
 
-extern int klic_putc();
-extern int klic_fwrite();
-extern int klic_fflush();
+extern int klic_putc(int c, FILE* out);
+extern int klic_fwrite(const void* pt, size_t size, size_t items, FILE* f);
+extern int klic_fflush(FILE* f);
 
 extern void debug_fprintf();
 
diff -ruN klic-3.003-2001-12-02/include/klic/bb.h klic-3.003-2001-12-22/include/klic/bb.h
--- klic-3.003-2001-12-02/include/klic/bb.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/bb.h	Sat Dec 22 18:09:13 2001
@@ -12,7 +12,7 @@
   Addition
 */
 
-extern q bblt_add_3();
+extern q bblt_add_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -63,7 +63,7 @@
   Subtraction
 */
 
-extern q bblt_sub_3();
+extern q bblt_sub_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -114,7 +114,7 @@
   Multiplication
 */
 
-extern q bblt_mult_3();
+extern q bblt_mult_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -165,7 +165,7 @@
   Division
 */
 
-extern q bblt_div_3();
+extern q bblt_div_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -216,7 +216,7 @@
   Modulo
 */
 
-extern q bblt_mod_3();
+extern q bblt_mod_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -267,7 +267,7 @@
   Bitwise Logical And
 */
 
-extern q bblt_and_3();
+extern q bblt_and_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -318,7 +318,7 @@
   Bitwise Logical Or
 */
 
-extern q bblt_or_3();
+extern q bblt_or_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -369,7 +369,7 @@
   Bitwise Logical Exclusive Or
 */
 
-extern q bblt_exclusive_or_3();
+extern q bblt_exclusive_or_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -420,7 +420,7 @@
   Right Shift
 */
 
-extern q bblt_rshift_3();
+extern q bblt_rshift_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -471,7 +471,7 @@
   Left Shift
 */
 
-extern q bblt_lshift_3();
+extern q bblt_lshift_3(q x, q y);
 
 #ifdef COMPACTCODE
 
@@ -522,7 +522,7 @@
   Bitwise Complement
 */
 
-extern q bblt_complement_2();
+extern q bblt_complement_2(q x);
 
 #ifdef COMPACTCODE
 
@@ -549,7 +549,7 @@
   Unary Plus
 */
 
-extern q bblt_plus_2();
+extern q bblt_plus_2(q x);
 
 #ifdef COMPACTCODE
 
@@ -576,7 +576,7 @@
   Unary Minus
 */
 
-extern q bblt_minus_2();
+extern q bblt_minus_2(q x);
 
 #ifdef COMPACTCODE
 
@@ -603,7 +603,7 @@
   Floating Point
 */
 
-extern q bblt_fix_2();
+extern q bblt_fix_2(q x);
 
 #define bblt_fix(x, z)						\
 do{								\
diff -ruN klic-3.003-2001-12-02/include/klic/control.h klic-3.003-2001-12-22/include/klic/control.h
--- klic-3.003-2001-12-02/include/klic/control.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/control.h	Sat Dec 22 18:09:13 2001
@@ -12,11 +12,26 @@
 #define EXTEVENT	(makeint(0))
 #define FAILURE		(makeint(1))
 
-extern q *interrupt_goal();
-extern int check_stack_for_alternatively();
-extern struct goalrec *enqueue_goal();
-extern struct goalrec *enqueue_after_waiting();
-extern struct goalrec *enqueue_throw_goal();
+extern q* interrupt_goal(q* allocp, struct predicate* pred, q* reasonp);
+extern int check_stack_for_alternatively(q* allocp, q* reasonp);
+
+extern struct goalrec* enqueue_goal(
+  struct goalrec* qp, long prio,
+  struct goalrec* gp, struct global_variables* glbl );
+
+extern struct goalrec* enqueue_after_waiting(
+  struct goalrec* qp, q prio,
+  struct goalrec* gp, q* allocp, int is_relative );
+
+extern struct goalrec* enqueue_throw_goal(
+  q penum, struct goalrec* gp, struct goalrec* qp, q* allocp );
+
+
+/** enqueue_at_priority: procedure
+ * p: q  priority
+ * q0: struct goalrec*
+ * q: struct goalrec*
+ */
 
 #define enqueue_at_priority(p,q0,q)			\
 do{							\
@@ -40,12 +55,14 @@
   qp = enqueue_goal((q0), prio, (q), glbl);		\
 }while(0)
 
+
 #define switch_on_pred()	switch (toppred->pred)
 
 #define case_pred(p, label)	case (p): goto label;
 
 #define last_case_pred(p, label) default: goto label;
 
+
 #if defined(DIST) && defined(USE_REDUCTION_COUNT)
 #define _INC_REDUCTION_COUNT(maxcount) \
 do{ \
@@ -60,6 +77,10 @@
 #define _INC_REDUCTION_COUNT(maxcount)
 #endif
 
+
+/** loop_witin_module: procedure
+ * f: module (*)()
+ */
 #define loop_within_module(f)				\
 do{ \
   module (*func)(); \
@@ -88,6 +109,12 @@
   goto proceed_label;		\
 }while(0)
 
+
+/** throw_goal: procedure
+ * node > 0: q  number of the processor element
+ * oldqp: struct goalrec*
+ * goal: struct goalrec*
+ */
 #define throw_goal(node, oldqp, goal) \
 do{ \
   qp = enqueue_throw_goal((node), (goal), (oldqp), allocp);\
diff -ruN klic-3.003-2001-12-02/include/klic/g_basic.h klic-3.003-2001-12-22/include/klic/g_basic.h
--- klic-3.003-2001-12-02/include/klic/g_basic.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/g_basic.h	Sat Dec 22 18:09:13 2001
@@ -11,7 +11,7 @@
 /* external module/class reference */
 
 #define G_USE_PREDICATE(name) \
-extern Const struct predicate name
+extern const struct predicate name
 
 /* type judgement. */
 #define G_ISATOMIC(x) isatomic(x)
@@ -76,12 +76,26 @@
 #define G_guard0(class,fa) G_guard1(class,fa)
 #define G_body0(class,fa) G_body1(class,fa)
 
+
+/** G_HEAPALLOC: procedure
+ * from: type&
+ * size > 0: offset_t
+ * type: type cast or function returning q
+ */
 #define G_HEAPALLOC(from,size,type) \
 do{ \
   (from) = type(g_allocp); \
   g_allocp += (size); \
 }while(0)
 
+
+/** G_HEAPALLOC_WITH_CHECK: procedure
+ * from: type&
+ * size > 0: offset_t
+ * type: type cast or function returning q
+ * allocp: q*
+ * res: {GENERIC_GCREQUEST, GENERIC_SUCCEEDED}&
+ */
 #define G_HEAPALLOC_WITH_CHECK(from,size,type,allocp,res) \
 do{ \
   if ((long) real_heaplimit <= (long) ((allocp) + (size))) { \
@@ -94,18 +108,28 @@
   } \
 }while(0)
 
+
+/** G_MAKE_VAR: procedure
+ * x: q&
+ */
 #define G_MAKE_VAR(x) \
 do{ \
   G_HEAPALLOC((x), 1, (q)); \
   derefone(x) = (x); \
 }while(0)
 
+
 #define G_STD_DECL struct global_variables *glbl = My_glbl
 
 #define G_SIZE_IN_Q(type) ((sizeof(type)+sizeof(q)-1) / sizeof(q))
 
-extern q** make_larger_stack();
+extern q** make_larger_stack(q** sp);
+
 
+/** G_COPY_KL1_TERM_TO_NEWGEN: procedure
+ * from: q
+ * to: q&
+ */
 #define G_COPY_KL1_TERM_TO_NEWGEN(from,to) \
 do{ \
   if ((g_sp) == gcmax) { \
@@ -122,12 +146,18 @@
   } \
 }while(0)
 
+
+/** G_PUSH_GOAL: procedure
+ * goal: struct goalrec*
+ */
+
 #define G_PUSH_GOAL(goal) \
 do{ resume_same_prio(goal); }while(0)
 
 #define G_PUSH_GOAL_TO_SPECIAL_QUEUE(goal) \
   G_PUSH_GOAL(goal)
 
+
 /*
   deta flag for Object Table
 */
@@ -140,10 +170,6 @@
   external functions
 */
 
-#ifdef __GNUC__
-extern Volatile voidfn G_error;
-#else
-extern voidfn G_error;
-#endif
+extern NoReturn voidfn G_error;
 
 #endif /* _KLIC_G_BASIC_H_ */
diff -ruN klic-3.003-2001-12-02/include/klic/g_extern.h klic-3.003-2001-12-22/include/klic/g_extern.h
--- klic-3.003-2001-12-02/include/klic/g_extern.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/g_extern.h	Sat Dec 22 18:09:13 2001
@@ -8,9 +8,10 @@
 #ifndef _KLIC_G_EXTERN_H_
 #define _KLIC_G_EXTERN_H_
 
-extern q general_gc( /* q *term, q* allocp */ );
+extern q general_gc(q* term, q* allocp, q** sp);
 
-extern general_print( /* q *a, FILE stream, unsigned long depth,length */ );
+extern void general_print(
+  q* a, FILE* stream, unsigned long depth, unsigned long length );
 
 extern struct data_object_method_table argblock_object_method_table;
 
diff -ruN klic-3.003-2001-12-02/include/klic/gb.h klic-3.003-2001-12-22/include/klic/gb.h
--- klic-3.003-2001-12-02/include/klic/gb.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/gb.h	Sat Dec 22 18:09:13 2001
@@ -8,8 +8,15 @@
 #ifndef _KLIC_GB_H_
 #define _KLIC_GB_H_
 
-extern q builtin_compare_terms();
-extern q builtin_hash_term();
+extern q builtin_compare_terms(q x, q y);
+extern q builtin_hash_term(q x, long l);
+
+
+/** gblt_compare: procedure
+ * x, y: q
+ * r: q&
+ * fail: LABEL
+ */
 
 #define gblt_compare(x, y, r, fail) \
 do{ \
@@ -23,6 +30,13 @@
 #define gblt_hash(x, r, fail) \
   ((r) = builtin_hash_term((x), 0))
 
+
+/** gblt_deep_hash: procedure
+ * x: q
+ * l: q  long hash value
+ * r: q&
+ * fail: LABEL
+ */
 #define gblt_deep_hash(x, l, r, fail) \
 do{ \
   (r) = builtin_hash_term((x), intval(l)); \
@@ -32,6 +46,7 @@
   } \
 }while(0)
 
+
 #define gblt_current_prio(p, fail) \
   ((p) = makeint(current_prio))
 
@@ -212,7 +227,7 @@
 
 /* Guard General Unification */
 
-q eq_terms_body();
+q eq_terms_body(q x, q y);
 
 #define if_not_equal(x, y, faillab) \
 do{ \
diff -ruN klic-3.003-2001-12-02/include/klic/gc_macro.h klic-3.003-2001-12-22/include/klic/gc_macro.h
--- klic-3.003-2001-12-02/include/klic/gc_macro.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/gc_macro.h	Sat Dec 22 18:09:13 2001
@@ -9,9 +9,14 @@
 #define _KLIC_GC_MACRO_H_
 
 extern q GC_wakeup_g_new();
-extern q *G_MAKE_THE_NEW_GOAL();
-extern q *do_shallow_unify(), *do_shallow_unify_value();
-extern q *G_SUSPEND();
+
+extern q* G_MAKE_THE_NEW_GOAL(
+  q* var, struct goalrec** goalp1, q(*myself)(),
+  unsigned long argc, q argv[], q* g_allocp );
+
+extern q* do_shallow_unify(q* allocp, q x, q y);
+extern q* do_shallow_unify_value(q* allocp, q x, q y);
+extern q* G_SUSPEND(q x, struct goalrec* goal, q* g_allocp);
 
 /*
   datas for general utility with consumer object
@@ -55,7 +60,7 @@
 #define GC_rappend(pref) G_rappend0(GC_CLASS_NAME(),pref)
 #define GC_body(fa) G_body0(GC_CLASS_NAME(),fa)
 
-extern q GC_MAKE_HOOK_VAR();
+extern q GC_MAKE_HOOK_VAR(struct consumer_object* obj);
 
 #ifdef __STDC__
 #define GC_method_table1(class) class##_g_data_method_table
diff -ruN klic-3.003-2001-12-02/include/klic/gc_methtab.h klic-3.003-2001-12-22/include/klic/gc_methtab.h
--- klic-3.003-2001-12-02/include/klic/gc_methtab.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/gc_methtab.h	Sat Dec 22 18:09:13 2001
@@ -8,13 +8,13 @@
 #ifndef _KLIC_GC_METHTAB_H_
 #define _KLIC_GC_METHTAB_H_
 
-extern q * GC_STD_UNIFY();
+extern q* GC_STD_UNIFY();
 extern long GC_STD_PRINT();
-extern q *GC_STD_GC();
-extern long GD_STD_REGIST();
-extern long GD_STD_DEALLOCATE();
-extern q *GD_STD_CLOSE();
-extern q GD_STD_ENCODE();
+extern q* GC_STD_GC();
+extern long GD_STD_REGIST(struct data_object* GD_SELF, q* g_allocp);
+extern long GD_STD_DEALLOCATE(struct data_object* GD_SELF);
+extern q* GD_STD_CLOSE(struct data_object* GD_SELF, q* g_allocp);
+extern q GD_STD_ENCODE(struct data_object* self, void* buffer);
 
 #define GC_STD_REGIST GD_STD_REGIST
 #define GC_STD_DEALLOCATE GD_STD_DEALLOCATE
diff -ruN klic-3.003-2001-12-02/include/klic/gd_macro.h klic-3.003-2001-12-22/include/klic/gd_macro.h
--- klic-3.003-2001-12-02/include/klic/gd_macro.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/gd_macro.h	Sat Dec 22 18:09:13 2001
@@ -8,10 +8,19 @@
 #ifndef _KLIC_GD_MACRO_H_
 #define _KLIC_GD_MACRO_H_
 
-extern q eq_terms_body();
-extern q *GD_MAKE_GENERIC_GOAL(), *G_MAKE_THE_NEW_GOAL();
-extern q *do_shallow_unify(), *do_shallow_unify_value();
-extern q *G_SUSPEND();
+extern q eq_terms_body(q x, q y);
+
+extern q* GD_MAKE_GENERIC_GOAL(
+  struct goalrec** goalp1, q var,
+  unsigned long method_functor, q argv[], q* g_allocp );
+
+extern q* G_MAKE_THE_NEW_GOAL(
+  q* var, struct goalrec** goalp1, q(*myself)(),
+  unsigned long argc, q argv[], q* g_allocp );
+
+extern q* do_shallow_unify(q* allocp, q x, q y);
+extern q* do_shallow_unify_value(q* allocp, q x, q y);
+extern q* G_SUSPEND(q x, struct goalrec* goal, q* g_allocp);
 
 #define GD_rappend(pref) G_rappend0(GD_CLASS_NAME(),pref)
 #define GD_guard(fa) G_guard0(GD_CLASS_NAME(),fa)
diff -ruN klic-3.003-2001-12-02/include/klic/gd_methtab.h klic-3.003-2001-12-22/include/klic/gd_methtab.h
--- klic-3.003-2001-12-02/include/klic/gd_methtab.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/gd_methtab.h	Sat Dec 22 18:09:13 2001
@@ -8,19 +8,32 @@
 #ifndef _KLIC_GD_METHTAB_H_
 #define _KLIC_GD_METHTAB_H_
 
-extern q GD_STD_GUNIFY();
-extern q * GD_STD_UNIFY();
-extern long GD_STD_PRINT();
-extern q *GD_STD_GC();
-extern long GD_STD_REGIST();
-extern long GD_STD_DEALLOCATE();
-extern q *GD_STD_CLOSE();
-extern q *GD_STD_GENERIC();
-extern q GD_STD_GGENERIC();
-extern q GD_STD_COMPARE();
-extern q GD_STD_HASH();
-extern q GD_STD_ENCODE();
-extern q GD_STD_SHMCOPY();
+extern q GD_STD_GUNIFY(
+  struct data_object* GD_SELF, struct data_object* GD_OTHER );
+
+extern q* GD_STD_UNIFY(
+  struct data_object* GD_SELF, struct data_object* GD_OTHER, q* g_allocp );
+
+extern long GD_STD_PRINT(
+  struct data_object* GD_SELF, FILE* g_fp,
+  unsigned long g_depth, unsigned long g_length );
+
+extern q* GD_STD_GC(struct data_object* GD_SELF, q* g_allocp, q** g_sp);
+extern long GD_STD_REGIST(struct data_object* GD_SELF, q* g_allocp);
+extern long GD_STD_DEALLOCATE(struct data_object* GD_SELF);
+extern q* GD_STD_CLOSE(struct data_object* GD_SELF, q* g_allocp);
+
+extern q* GD_STD_GENERIC(
+  struct data_object* GD_SELF, long g_method_functor, q GD_ARGV[], q* g_allocp );
+extern q GD_STD_GGENERIC(
+  struct data_object* GD_SELF, long g_method_functor, q GD_ARGV[] );
+
+extern q GD_STD_COMPARE(
+  struct data_object* GD_SELF, struct data_object* GD_OTHER );
+
+extern q GD_STD_HASH(struct data_object* GD_SELF, long level);
+extern q GD_STD_ENCODE(struct data_object* self, void* buffer);
+extern q GD_STD_SHMCOPY(struct data_object* self);
 
 struct data_object_method_table GD_method_table
   = {
diff -ruN klic-3.003-2001-12-02/include/klic/generic.h klic-3.003-2001-12-22/include/klic/generic.h
--- klic-3.003-2001-12-02/include/klic/generic.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/generic.h	Sat Dec 22 18:09:13 2001
@@ -10,7 +10,8 @@
 
 #include <klic/g_methtab.h>
 
-extern q *gd_generic();
+extern q* gd_generic(
+  q* g_allocp, q g_object, long g_method_functor, q* g_argv );
 
 #define new_generic(name,argc,out,offset)  \
 do{ \
diff -ruN klic-3.003-2001-12-02/include/klic/gg_macro.h klic-3.003-2001-12-22/include/klic/gg_macro.h
--- klic-3.003-2001-12-02/include/klic/gg_macro.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/gg_macro.h	Sat Dec 22 18:09:13 2001
@@ -9,14 +9,19 @@
 #define _KLIC_GG_MACRO_H_
 
 extern q GC_wakeup_g_new();
-extern q *G_MAKE_THE_NEW_GOAL();
-extern q *do_shallow_unify(), *do_shallow_unify_value();
-extern q *G_SUSPEND();
+
+extern q* G_MAKE_THE_NEW_GOAL(
+  q* var, struct goalrec** goalp1, q(*myself)(),
+  unsigned long argc, q argv[], q* g_allocp );
+
+extern q* do_shallow_unify(q* allocp, q x, q y);
+extern q* do_shallow_unify_value(q* allocp, q x, q y);
+extern q* G_SUSPEND(q x, struct goalrec* goal, q* g_allocp);
 
 #define GG_rappend(pref) G_rappend0(GG_CLASS_NAME(),pref)
 #define GG_body(fa) G_body0(GG_CLASS_NAME(),fa)
 
-extern q GG_MAKE_HOOK_VAR();
+extern q GG_MAKE_HOOK_VAR(struct generator_object* obj);
 
 #define GG_OBJ_SIZE G_SIZE_IN_Q(GG_OBJ_TYPE)
 
diff -ruN klic-3.003-2001-12-02/include/klic/gg_methtab.h klic-3.003-2001-12-22/include/klic/gg_methtab.h
--- klic-3.003-2001-12-02/include/klic/gg_methtab.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/gg_methtab.h	Sat Dec 22 18:09:13 2001
@@ -8,14 +8,14 @@
 #ifndef _KLIC_GG_METHTAB_H_
 #define _KLIC_GG_METHTAB_H_
 
-extern q * GG_STD_UNIFY();
+extern q* GG_STD_UNIFY();
 extern q GG_STD_SUSPEND();
 extern long GG_STD_PRINT();
-extern q *GG_STD_GC();
-extern long GD_STD_REGIST();
-extern long GD_STD_DEALLOCATE();
-extern q *GD_STD_CLOSE();
-extern q GD_STD_ENCODE();
+extern q* GG_STD_GC();
+extern long GD_STD_REGIST(struct data_object* GD_SELF, q* g_allocp);
+extern long GD_STD_DEALLOCATE(struct data_object* GD_SELF);
+extern q* GD_STD_CLOSE(struct data_object* GD_SELF, q* g_allocp);
+extern q GD_STD_ENCODE(struct data_object* self, void* buffer);
 
 #define GG_STD_REGIST GD_STD_REGIST
 #define GG_STD_DEALLOCATE GD_STD_DEALLOCATE
diff -ruN klic-3.003-2001-12-02/include/klic/gobjutil.h klic-3.003-2001-12-22/include/klic/gobjutil.h
--- klic-3.003-2001-12-02/include/klic/gobjutil.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/gobjutil.h	Sat Dec 22 18:09:13 2001
@@ -16,7 +16,7 @@
 #define general_active_unify(obj, anothor, allocp) \
   do_shallow_unify((allocp), (obj), (anothor))
 
-extern q general_gc( /* q *term, q* allocp */ );
+extern q general_gc(q* term, q* allocp, q** sp);
 
 /*
 extern struct goalrec *general_active_unify_method();
diff -ruN klic-3.003-2001-12-02/include/klic/options.h klic-3.003-2001-12-22/include/klic/options.h
--- klic-3.003-2001-12-02/include/klic/options.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/options.h	Sat Dec 22 18:09:13 2001
@@ -12,8 +12,9 @@
     int i;
     long l;
     double d;
-    char *s;
+    char* s;
 };
+
 enum argtype {
     ARG_DOUBLE,
     ARG_SIZE,
@@ -23,9 +24,9 @@
     ARG_NOT_USED
 };
 
-extern Const struct opttable opttable[];
+extern const struct opttable opttable[];
 
-char *parse_opts();
+extern char* parse_opts(const struct opttable* opttbl, int* acp, char*** avp);
 
 /* not copied when spawned */
 #define ARG_SHOULD_NOT_COPY(X)	((int)(X) >= (int)ARG_NOT_USED)
@@ -37,14 +38,14 @@
     (ARG_SHOULD_NOT_COPY(X) ? (int)(X)-(int)ARG_NOT_USED : (int)(X)))
 
 struct opttable {
-    char *opt_str;
-    union all_type *opt_dest;
+    char* opt_str;
+    union all_type* opt_dest;
     enum argtype opt_type;
-    char *opt_usage;
+    char* opt_usage;
 };
 
 #ifndef MAIN
-extern Const struct opttable opttable[];
+extern const struct opttable opttable[];
 #else  /* MAIN */
 static long num_pes;
 static double max_a_ratio;
@@ -57,7 +58,7 @@
 #ifdef USETIMER
 static unsigned long dl_det_interval;
 #endif /*USETIMER*/
-Const struct opttable opttable[] = {
+const struct opttable opttable[] = {
 #ifdef USER_OPTIONS
     USER_OPTIONS
 #endif
@@ -65,7 +66,7 @@
     POLLING_OPTIONS
 #endif
 #ifdef PARALLEL
-    "p",        (union all_type *)&num_pes, ARG_SIZE,
+    "p",        (union all_type*) &num_pes, ARG_SIZE,
     "-p <# of workers>: number of worker processes ",
 #endif
 #ifdef DIST_OPTIONS
@@ -73,48 +74,52 @@
 #endif
 #ifdef DIST
 #ifdef SHM_DIST
-    "B",	(union all_type *)&shared_buffer_size, ARG_SIZE,
+    "B",	(union all_type*) &shared_buffer_size, ARG_SIZE,
     "-B <communication buffer size>",
 #endif
 #endif
 #ifdef SHM
-    "S",        (union all_type *)&SHM_SIZE, ARG_SIZE,
+    "S",        (union all_type*) &SHM_SIZE, ARG_SIZE,
     "-S <shared-memory heap size>: shared-memory heap size, never expand",
 
-    "D",        (union all_type *)&Disp_child, ARG_SET,
+    "D",        (union all_type*) &Disp_child, ARG_SET,
     "-D: display child process number on UNIX",
 
 #endif
-    "a",	(union all_type *)&max_a_ratio, ARG_DOUBLE,
-    "-a <ratio>: active cell ratio to triger heap extension\n\t  <ratio> should be a floating point number >0 and <1",
-    "h",	(union all_type *)&h_size, ARG_SIZE,
+    "a",	(union all_type*) &max_a_ratio, ARG_DOUBLE,
+    "-a <ratio>: active cell ratio to triger heap extension\n"
+    "\t  <ratio> should be a floating point number >0 and <1",
+
+    "h",	(union all_type*) &h_size, ARG_SIZE,
     "-h <initial heap size>: initial size of heap",
 
-    "H",	(union all_type *)&max_h_size, ARG_SIZE,
+    "H",	(union all_type*) &max_h_size, ARG_SIZE,
     "-H <max heap size>: maximum possible heap size",
 
-    "i",	(union all_type *)&inc_size, ARG_SIZE,
-    "-i <increment>: gap between heap top and bottom\n\t  for -h, -H and -i, 32k means 32KW and 2m means 2MW",
+    "i",	(union all_type*) &inc_size, ARG_SIZE,
+    "-i <increment>: gap between heap top and bottom\n"
+    "\t  for -h, -H and -i, 32k means 32KW and 2m means 2MW",
 
-    "g",	(union all_type *)&measure_gc, ARG_SET,
+    "g",	(union all_type*) &measure_gc, ARG_SET,
     "-g: set garbage collection measurement on",
 
-    "v",	(union all_type *)&verbose, ARG_SET,
+    "v",	(union all_type*) &verbose, ARG_SET,
     "-v: display KLIC runtime version",
 #ifdef DEBUGLIB
-    "t",	(union all_type *)&start_tracing, ARG_SET,
+    "t",	(union all_type*) &start_tracing, ARG_SET,
     "-t: start execution with tracing",
 
-    "s",	(union all_type *)&count_suspension, ARG_SET,
+    "s",	(union all_type*) &count_suspension, ARG_SET,
     "-s: count suspension",
 #endif /* DEBUGLIB */
 #ifdef USETIMER
     "deadlock-detection-interval",
-		(union all_type *)&dl_det_interval, ARG_SIZE,
-    "-deadlock-detection-interval <interval>:\n\t  specify deadlock detect interval in micro sec.\n\t  Set <interval> to 0 to supress early deadlock detection completely.",
+		(union all_type*) &dl_det_interval, ARG_SIZE,
+    "-deadlock-detection-interval <interval>:\n"
+    "\t  specify deadlock detect interval in micro sec.\n"
+    "\t  Set <interval> to 0 to supress early deadlock detection completely.",
 #endif /*USETIMER*/
-    0, 0,
-};
+    0, 0 };
 #endif /* MAIN */
 
 #endif /* _KLIC_OPTIONS_H_ */
diff -ruN klic-3.003-2001-12-02/include/klic/predinfo.h klic-3.003-2001-12-22/include/klic/predinfo.h
--- klic-3.003-2001-12-02/include/klic/predinfo.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/predinfo.h	Sat Dec 22 18:09:13 2001
@@ -9,13 +9,13 @@
 #define _KLIC_PREDINFO_H_
 
 struct predinfo {
-  Const unsigned char *name;
-  Const struct predicate *predstruct;
+  const unsigned char* name;
+  const struct predicate* predstruct;
 };
 
 struct modinfo {
-  Const unsigned char *name;
-  Const struct predinfo * Const *preds;
+  const unsigned char* name;
+  const struct predinfo* const* preds;
 };
 
 #endif /* _KLIC_PREDINFO_H_ */
diff -ruN klic-3.003-2001-12-02/include/klic/schedule.h klic-3.003-2001-12-22/include/klic/schedule.h
--- klic-3.003-2001-12-02/include/klic/schedule.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/schedule.h	Sat Dec 22 18:09:13 2001
@@ -8,11 +8,17 @@
 #ifndef _KLIC_SCHEDULE_H_
 #define _KLIC_SCHEDULE_H_
 
-extern struct prioqrec * more_prioqrec();
+extern struct prioqrec* more_prioqrec(void);
 
-extern module topsucceed();
-extern struct goalrec * enqueue_goal();
-extern struct goalrec * get_top_priority_queue();
-extern void put_top_priority_queue();
+extern module topsucceed(
+  struct global_variables* glbl, struct goalrec* qp,
+  q* allocp, const struct predicate* toppred );
+
+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_top_priority_queue(struct goalrec* qp, long prio);
 
 #endif /* _KLIC_SCHEDULE_H_ */
diff -ruN klic-3.003-2001-12-02/include/klic/shm.h klic-3.003-2001-12-22/include/klic/shm.h
--- klic-3.003-2001-12-02/include/klic/shm.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/shm.h	Sat Dec 22 18:09:13 2001
@@ -63,8 +63,8 @@
 #define tag_genhook(X) ((Sinfo*)((long)(X)+1))
 #define untag_genhook(X) ((Sinfo*)((long)(X)-1))
   /* local consumer or generator */
-#define tag_local(x)	((q)((char *)(x) + ATOMIC))
-#define untag_local(x)	((q)((char *)(x) - ATOMIC))
+#define tag_local(x)	((q)((char*)(x) + ATOMIC))
+#define untag_local(x)	((q)((char*)(x) - ATOMIC))
 #define ext_queued (glbl->par.aux.shm.queued0)
 #define ex_qp (glbl->par.aux.shm.ex_qp0)
 
@@ -172,28 +172,28 @@
 
   /* Structures */
 typedef struct addr_tbl {
-   struct addr_tbl *next;
-   struct addr_tbl *prev;
-   q *localA;
-   q *globalA;
+   struct addr_tbl* next;
+   struct addr_tbl* prev;
+   q* localA;
+   q* globalA;
 } TADDRtbl;
 
 struct ex_goalrec {
-   struct ex_goalrec *next;
+   struct ex_goalrec* next;
    long prio;
    struct goalrec goal;
 } ;
 
 typedef struct PE_shook {
-   struct PE_shook    *next;
+   struct PE_shook*   next;
    long               PE_num;
    long               prio;
-   TADDRtbl          *indp;
+   TADDRtbl*          indp;
 } Sinfo;
 
 typedef struct shvar {
-   struct generator_object_method_table *method;
-   Sinfo *chain;
+   struct generator_object_method_table* method;
+   Sinfo* chain;
 } Shvar;
 
 /* Management table of a shared memory plain */
@@ -216,18 +216,18 @@
 /* common variables */
 extern int F_shm_gc;
 
-extern Volatile PLNE* PLNE_ptr[];
+extern volatile PLNE* PLNE_ptr[];
 
-extern int* Volatile pe_status;
-extern int* Volatile cur_status;
+extern int* volatile pe_status;
+extern int* volatile cur_status;
 
-extern long* Volatile Prof_measure;
+extern long* volatile Prof_measure;
 
 extern struct global_variables* top_shm_glbl;
 
 extern int* top_shm_pid;
 
-extern struct ex_goalrec ** Volatile top_shm_qp;
+extern struct ex_goalrec** volatile top_shm_qp;
 
 /* memorized the last generated variable on shm */
 extern q last_shm_var;
@@ -242,42 +242,43 @@
 extern q* glimit;
 
 extern TADDRtbl ADDRtbl;
-extern TADDRtbl *ADDRtbl_free;
+extern TADDRtbl* ADDRtbl_free;
 
 /* Declarations of functions */
 /* convert real PE number from Logical PE number */
-extern int phisc_pe();
+extern int phisc_pe(int NO);
 
 /* common routines */
-extern struct global_variables* shm_init();
+extern struct global_variables* shm_init(struct global_variables* glbl);
 
 /* copy into shared memory */
-extern struct ex_goalrec* shm_goal_copy();
+extern struct ex_goalrec* shm_goal_copy(struct goalrec* qp, long prio);
 
 /* copy argument into shared memory */
-extern q shm_copy();
+extern q shm_copy(q src);
 
 /* stack a goal */
-extern int shm_goal_stack();
+extern int shm_goal_stack(struct ex_goalrec* goal, int num);
 
-extern Shvar* create_genhook();
+extern Shvar* create_genhook(q* la, q* ga);
 
-extern Shvar* shm_add_consumer();
+extern Shvar* shm_add_consumer(
+  q shv, Shvar* shobj, q cvar, struct global_variables* glbl );
 
-extern q* shm_ck_request();
-extern q* shm_resume_goals();
+extern q* shm_ck_request(q* allocp, Sinfo* chain);
+extern q* shm_resume_goals(q* allocp, Sinfo* hook);
 
 
-extern struct goalrec *get_invoked_goals();
+extern struct goalrec* get_invoked_goals(struct goalrec* qp);
 
 /* allocate shared memory routines */
-extern q* shm_galloc();
+extern q* shm_galloc(int siz);
 
 /* GC routines */
-extern int ck_shm_gc();
-extern struct goalrec* shm_gc();
+extern int ck_shm_gc(void);
+extern struct goalrec* shm_gc(struct goalrec* qp);
 
-extern TADDRtbl* create_local_tbl();
+extern TADDRtbl* create_local_tbl(q* lcl, q* gbl);
 
 /* for GC */
 
diff -ruN klic-3.003-2001-12-02/include/klic/struct.h klic-3.003-2001-12-22/include/klic/struct.h
--- klic-3.003-2001-12-02/include/klic/struct.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/struct.h	Sat Dec 22 18:09:13 2001
@@ -24,7 +24,7 @@
   Using "struct gazonk *" type is for reducing confusion.
 ****************************************/
 
-typedef struct gazonk *q;
+typedef struct gazonk* q;
 
 /****************************************
   POINTER TAGS
@@ -117,13 +117,13 @@
 /* Predicate structures are constant structures outside of heap */
 /* They are pointed to by atomic tags and treated as atomic in GC */
 
-typedef char * (*module)();
+typedef char*(* module)();
 
 struct predicate {
-  module (*func)();		/* pointer to function */
+  module(* func)();		/* pointer to function */
   unsigned short int pred;	/* predicate number */
   unsigned short int arity;	/* number of args */
-  Const struct arginfo *info;	/* argument mode info */
+  const struct arginfo* info;	/* argument mode info */
 };
 
 /* Argument mode infomation */
@@ -136,8 +136,8 @@
 /* Goal records */
 
 struct goalrec {
-  struct goalrec *next;		/* pointer to next goal */
-  Const struct predicate *pred;	/* predicate descriptor of the goal */
+  struct goalrec* next;		/* pointer to next goal */
+  const struct predicate* pred;	/* predicate descriptor of the goal */
   q args[6];			/* arguments; number 6 is meaningless */
 };
 
@@ -145,9 +145,9 @@
 /* priority queue records, in descending order of precedence */
 
 struct prioqrec {
-  struct prioqrec *next;
+  struct prioqrec* next;
   long prio;			/* signed, to use -1 as sentinel */
-  struct goalrec *q;
+  struct goalrec* q;
 };
 
 /****************************************
@@ -156,11 +156,11 @@
 
 /* Type conversion */
 
-#define refp(x)		((q *)((unsigned long)(x) - VARREF))
-#define consp(x)	((struct cons *)((unsigned long)(x) - CONS))
-#define functorp(x)	((struct functor *)((unsigned long)(x) - FUNCTOR))
-#define goalp(x)	((struct goalrec *)((unsigned long)(x) - ATOMIC))
-#define predp(x)	((struct predicate *)((unsigned long)(x) - ATOMIC))
+#define refp(x)		((q*) ((unsigned long)(x) - VARREF))
+#define consp(x)	((struct cons*) ((unsigned long)(x) - CONS))
+#define functorp(x)	((struct functor*) ((unsigned long)(x) - FUNCTOR))
+#define goalp(x)	((struct goalrec*) ((unsigned long)(x) - ATOMIC))
+#define predp(x)	((struct predicate*) ((unsigned long)(x) - ATOMIC))
 
 /* Variables */
 
@@ -199,19 +199,19 @@
 /* Structures for linkage */
 
 struct ext_atom {
-  char *name;			/* name string */
+  char* name;			/* name string */
   q value;			/* its value with symbol tag */
 };
 
 struct ext_funct {
-  char *name;			/* name string */
+  char* name;			/* name string */
   long arity;			/* arity */
   q value;			/* functor id with atomic tag */
 };
 
 struct ext_pred {
-  char *module;			/* module name string */
-  char *name;			/* predicate name */
+  char* module;			/* module name string */
+  char* name;			/* predicate name */
   long arity;			/* arity */
   q value;			/* pred id with atomic tag */
 };
@@ -277,29 +277,30 @@
 
 Extern struct global_variables {
   /* First four items are accessed frequently */
-  q *heapp0;			/* top of free area (when decached) */
-  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 */
+  q* heapp0;			/* top of free area (when decached) */
+  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 */
   unsigned long top_prio0;	/* highest priority with ready goal */
   /* 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 */
+  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 *new_space_top0, *old_space_top0;
+  q* new_space_top0;
+  q* old_space_top0;
   unsigned long new_space_size0, old_space_size0;
-  q **gcstack0;
-  q **gcsp0;
-  q **gcmax0;
+  q** gcstack0;
+  q** gcsp0;
+  q** gcmax0;
   unsigned long gcstack_size0;
-  Volatile long interrupt_off0;
-  struct goalrec *interrupt_qp0;
+  volatile long interrupt_off0;
+  struct goalrec* interrupt_qp0;
 
   struct {
    /* parallel comm Imp. */
@@ -321,19 +322,18 @@
     } aux;
   } par;
 
-  char *program_name0;
+  char* program_name0;
   int command_argc0;
-  char **command_argv0;
-  q* (**gc_hook_table0)();
+  char** command_argv0;
+  q*(** gc_hook_table0)();
   int gc_hooktab_size0;
   int num_gc_hooks0;
-  q* (**after_gc_hook_table0)();
+  q*(** after_gc_hook_table0)();
   int after_gc_hooktab_size0;
   int num_after_gc_hooks0;
-  unsigned long
-    suspensions0, resumes0, copied_susp0, cum_susps0, cum_resumps0;
-  struct suspended_goal_rec *suspended_goal_list0;
-  Const struct predicate *postmortem_pred0;
+  unsigned long suspensions0, resumes0, copied_susp0, cum_susps0, cum_resumps0;
+  struct suspended_goal_rec* suspended_goal_list0;
+  const struct predicate* postmortem_pred0;
   q postmortem_args0;
   long generic_argc0;		/* number of arguments to generic methods */
   q generic_arg0[MAXGENERICARGS]; /* arguments of generic methods */
@@ -345,7 +345,7 @@
 
 Extern struct global_variables* My_glbl  Init(&globals);
 
-#define declare_globals struct global_variables *glbl = My_glbl
+#define declare_globals struct global_variables* glbl = My_glbl
 
 /*
   memory block outside of heap.
diff -ruN klic-3.003-2001-12-02/include/klic/susp.h klic-3.003-2001-12-22/include/klic/susp.h
--- klic-3.003-2001-12-02/include/klic/susp.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/susp.h	Sat Dec 22 18:09:13 2001
@@ -19,11 +19,11 @@
 */
 
 struct hook {
-  struct hook *next;		/* next suspension structure */
+  struct hook* next;		/* next suspension structure */
   union goal_or_consumer {
     long l;			/* long integer for tag manipulation */
-    struct goalrec *g;		/* pointer to a goal record */
-    struct consumer_object *o;	/* pointer to a consumer object */
+    struct goalrec* g;		/* pointer to a goal record */
+    struct consumer_object* o;	/* pointer to a consumer object */
   } u;
 };
 
@@ -33,10 +33,10 @@
   ((u.l&CONSUMER_HOOK_TAG) == 1)
 
 #define tag_consumer_hook(obj) \
-  ((struct consumer_object *)((long)(obj)+CONSUMER_HOOK_TAG))
+  ((struct consumer_object*) ((long)(obj)+CONSUMER_HOOK_TAG))
 
 #define untag_consumer_hook(obj) \
-  ((struct consumer_object *)((long)(obj)-CONSUMER_HOOK_TAG))
+  ((struct consumer_object*) ((long)(obj)-CONSUMER_HOOK_TAG))
 
 struct susprec {
   q backpt;
@@ -46,12 +46,12 @@
   } u;
 };
 
-#define suspp(x)	((struct susprec *)((unsigned long)(x) - VARREF))
+#define suspp(x)	((struct susprec*) ((unsigned long)(x) - VARREF))
 
 #define allocnewsusp(var,srec)						\
 do{									\
-  q *temp;								\
-  heapalloc(temp, (sizeof(struct susprec))/sizeof(q)+1, (q *));		\
+  q* temp;								\
+  heapalloc(temp, (sizeof(struct susprec))/sizeof(q)+1, (q*));		\
   initnewsusp(temp, (var), (srec));					\
 }while(0)
 
@@ -64,7 +64,7 @@
 #define initnewsusp(temp,var,srec)					\
 do{									\
   (var) = makeref(temp);						\
-  (srec) = (struct susprec *) ((temp) + 1);				\
+  (srec) = (struct susprec*) ((temp) + 1);				\
   derefone(var) = (q) (srec);						\
   (srec)->backpt = (var);						\
   (srec)->u.first_hook.next = &(srec)->u.first_hook;			\
@@ -72,7 +72,7 @@
 
 #define allochook(oldhook,newhook)					\
 do{									\
-  heapalloc((newhook), sizeof(struct hook)/sizeof(q), (struct hook *));	\
+  heapalloc((newhook), sizeof(struct hook)/sizeof(q), (struct hook*));	\
   initnewhook((oldhook), (newhook));					\
 }while(0)
 
@@ -96,12 +96,12 @@
 struct generator_susp {
   q backpt;
   union {
-    struct generator_object *o;
+    struct generator_object* o;
     long l;
   } u;
 };
 
-#define generator_suspp(susp) ((struct generator_susp *)(susp))
+#define generator_suspp(susp) ((struct generator_susp*) (susp))
 
 #define GENERATOR_OBJECT_TAG 1
 
@@ -109,15 +109,15 @@
   ((u.l)&GENERATOR_OBJECT_TAG == 1)
 
 #define tag_generator_susp(obj) \
-  ((struct generator_object *)((long)(obj) + GENERATOR_OBJECT_TAG))
+  ((struct generator_object*) ((long)(obj) + GENERATOR_OBJECT_TAG))
 
 #define untag_generator_susp(obj) \
-  ((struct generator_object *)((long)(obj) - GENERATOR_OBJECT_TAG))
+  ((struct generator_object*) ((long)(obj) - GENERATOR_OBJECT_TAG))
 
 #define allocnewgensusp(var,gsusp) \
 do{ \
-  q *tmp; \
-  heapalloc(tmp, (sizeof(struct generator_susp))/sizeof(q)+1 , (q*)); \
+  q* tmp; \
+  heapalloc(tmp, (sizeof(struct generator_susp))/sizeof(q)+1, (q*)); \
   initnewgensusp(tmp, (var), (gsusp)); \
 }while(0)
 
@@ -132,8 +132,8 @@
 /* Perpetual Suspension Detection */
 
 struct suspended_goal_rec {
-  struct goalrec *goal;
-  struct suspended_goal_rec *next;
+  struct goalrec* goal;
+  struct suspended_goal_rec* next;
 };
 
 #endif /* _KLIC_SUSP_H_ */
diff -ruN klic-3.003-2001-12-02/include/klic/timer.h klic-3.003-2001-12-22/include/klic/timer.h
--- klic-3.003-2001-12-02/include/klic/timer.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/timer.h	Sat Dec 22 18:09:13 2001
@@ -9,10 +9,10 @@
 #define _KLIC_TIMER_H_
 
 struct klic_timer_wait_rec {
-  struct klic_timer_wait_rec *next;
+  struct klic_timer_wait_rec* next;
   struct timeval on_at;
   struct timeval interval;
-  void (*func)();
+  void(* func)();
 };
 
 #define NotLaterThan(x, y) 				\
@@ -49,11 +49,10 @@
   } \
 }while(0)
 
-extern void
-  klic_gettod(),
-  call_at_specified_time(),
-  call_after_specified_interval(),
-  call_at_time_intervals(),
-  init_virtualized_timer();
+extern void klic_gettod(struct timeval* now);
+extern void call_at_specified_time(long sec, long usec, void(* func)());
+extern void call_after_specified_interval(long sec, long usec, void(* func)());
+extern void call_at_time_intervals(long sec, long usec, void(* func)());
+extern void init_virtualized_timer(void);
 
 #endif /* _KLIC_TIMER_H_ */
diff -ruN klic-3.003-2001-12-02/include/klic/trace.h klic-3.003-2001-12-22/include/klic/trace.h
--- klic-3.003-2001-12-02/include/klic/trace.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/trace.h	Sat Dec 22 18:09:13 2001
@@ -13,8 +13,8 @@
 */
 
 struct trace_info_rec {
-  FILE *in;
-  FILE *out;
+  FILE* in;
+  FILE* out;
   q original_arg;
   int enabled, leashed, leaping, spying;
   int verbose;
@@ -39,8 +39,8 @@
 */
 
 struct enqueue_trace_rec {
-  struct enqueue_trace_rec *next;
-  struct goalrec *g;
+  struct enqueue_trace_rec* next;
+  struct goalrec* g;
   long prio;
 };
 
@@ -49,14 +49,14 @@
 */
 
 struct mod_table_entry {
-  module (*func)();
-  Const unsigned char *name;
+  module(* func)();
+  const unsigned char* name;
 };
 
 struct pred_table_entry {
-  Const struct predicate *pred;
-  Const struct mod_table_entry *mte;
-  Const unsigned char *name;
+  const struct predicate* pred;
+  const struct mod_table_entry* mte;
+  const unsigned char* name;
   char spied;
   char default_trace;
 };
diff -ruN klic-3.003-2001-12-02/include/klic/unify.h klic-3.003-2001-12-22/include/klic/unify.h
--- klic-3.003-2001-12-02/include/klic/unify.h	Sat Dec 22 18:08:34 2001
+++ klic-3.003-2001-12-22/include/klic/unify.h	Sat Dec 22 18:09:13 2001
@@ -8,10 +8,14 @@
 #ifndef _KLIC_UNIFY_H_
 #define _KLIC_UNIFY_H_
 
-extern q
-  *do_unify(), *do_unify2(), *do_unify3(), *do_unify4(),
-  *do_unify_value(), *do_unify_value2(),
-  *do_unify_value3(), *do_unify_value4();
+extern q* do_unify(q* allocp, q x, q y);
+extern q* do_unify2(q* allocp, q x, q y, q z, q w);
+extern q* do_unify3(q* allocp, q x, q y, q z, q w, q s, q t);
+extern q* do_unify4(q* allocp, q x, q y, q z, q w, q s, q t, q u, q v);
+extern q* do_unify_value(q* allocp, q x, q y);
+extern q* do_unify_value2(q* allocp, q x, q y, q z, q w);
+extern q* do_unify_value3(q* allocp, q x, q y, q z, q w, q s, q t);
+extern q* do_unify_value4(q* allocp, q x, q y, q z, q w, q s, q t, q u, q v);
 
 #define unify(x, y) \
 do{ allocp = do_unify(allocp, (x), (y)); }while(0)
