diff -ruN klic-3.003-2002-01-18/ChangeLog klic-3.003-2002-01-21/ChangeLog
--- klic-3.003-2002-01-18/ChangeLog	Tue Jan 15 18:03:40 2002
+++ klic-3.003-2002-01-21/ChangeLog	Mon Jan 21 20:55:25 2002
@@ -1,3 +1,13 @@
+2002-01-18 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* Configure: not to configure SHM implementation.
+
+	* include/klic/g_extinl.h: remove.
+
+	* runtime/susp.h: move to 'include/klic/'.
+
+	* runtime/alloc.c: inverse real_heapbytesize (by n-kato@ueda...).
+
 2002-01-15 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
 
 	* include/klic/{ g_methtab.h, gc_macro.h, gc_methtab.h,
diff -ruN klic-3.003-2002-01-18/compiler/kl1cmp.kl1 klic-3.003-2002-01-21/compiler/kl1cmp.kl1
--- klic-3.003-2002-01-18/compiler/kl1cmp.kl1	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2002-01-21/compiler/kl1cmp.kl1	Mon Jan 21 20:57:00 2002
@@ -152,7 +152,7 @@
       klic_comp_version:compiler_version(Version),  % version.kl1
       klic_comp_version:compiler_date(Date),        %
       klic_comp_obj:klicformat(
-	"/* Compiled by KLIC compiler ~w (~w) */\n"
+	"/* Compiled by KLIC compiler ~w (~w) */\n\n"
 	"#include <klic/klichdr.h>\n"
 	"#include \"atom.h\"\n"
 	"#include \"funct.h\"\n",
@@ -183,7 +183,7 @@
 
 analyze(module(Name,Module),Result) :-
     Result = module(Name,Predicates,Ex),
-%    pool:keyed_set([empty(A)|Pool]),
+    % pool:keyed_set([empty(A)|Pool]),
     keyed_sorted_set:create([empty(A)|Pool]),
     analyze1(Module,Name,Predicates,Ex,A,Pool).
 otherwise.
@@ -262,8 +262,6 @@
   rename_macro_preds([expanded(OR,NewName)|Exp],Prefix,K,Rest0,Rest) :-
       klic_comp_util:name(K,KS),
       klic_comp_util:append(Prefix,[#"$"|KS],NewNameS),
-%  patched by Fujise
-%      atom_table:make_atom(NewNameS,NewName),
       klic_comp_util:make_atom(NewNameS,NewName),
       rename_macro_clauses(OR,Rest1,Rest0),
       K1 := K+1,
@@ -282,7 +280,6 @@
       rename_macro_clauses(T,Rest0,Rest).
 
   %  H0=..[_,NewName|Args], H=..[NewName|Args],
-% rewritten  by Fujise
   shift_vector(H0,H) :- functor(H0,_,A) |
   	A1 := A - 1,
   	shift_vector(A1,H0,H).
diff -ruN klic-3.003-2002-01-18/compiler/klic.c klic-3.003-2002-01-21/compiler/klic.c
--- klic-3.003-2002-01-18/compiler/klic.c	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-21/compiler/klic.c	Mon Jan 21 20:55:25 2002
@@ -4,6 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
+
 #include <stdio.h>
 #include <klic/stdc.h>
 #include <ctype.h>
@@ -23,6 +24,7 @@
 #define KL1_TO_C_COMPILER   KLIC_COMPILER
 
 extern void* malloc();
+extern char* option_value();
 
 enum filetype { kl1_file, prog_file, asm_file, obj_file, other_file };
 
@@ -89,9 +91,9 @@
   struct lang_info* info;
 };
 
-static void initialize_lang_info(void)
+static void
+initialize_lang_info(void)
 {
-  extern char* option_value();
   struct lang_info* info;
   for(info = lang_infos; info->ext != NULL; ++info) {
     info->comp = option_value(info->comp_env, info->comp_default);
@@ -101,7 +103,8 @@
   }
 }
 
-static struct lang_info* search_lang_info(
+static struct lang_info*
+search_lang_info(
   char* suffix )
 {
   int i;
@@ -114,7 +117,8 @@
   return NULL;
 }
 
-static void reverse_names(
+static void
+reverse_names(
   struct namerec** names )
 {
   struct namerec* one = NULL;
@@ -128,16 +132,18 @@
   *names = one;
 }
 
-static void error_exit(
+static void
+error_exit(
   char* format,
   char* arg )
 {
-  (void) fprintf(stderr, format, arg);
+  fprintf(stderr, format, arg);
   putc('\n', stderr);
   exit(-1);
 }
 
-static void sync_and_exit(void)
+static void
+sync_and_exit(void)
 {
   int status;
   for(;;)
@@ -148,7 +154,8 @@
 
 #define USAGE  "Usage: %s -options files ...\n"
 
-static void usage_error(
+static void
+usage_error(
   char* cmd )
 {
   error_exit(
@@ -156,7 +163,8 @@
     cmd );
 }
 
-static void usage_help(
+static void
+usage_help(
   char* cmd )
 {
   fprintf(stderr, USAGE, cmd);
@@ -186,13 +194,15 @@
   fprintf(stderr, "  -X initdbdir: specifies database initiation directory\n");
 }
 
-static void access_error(
+static void
+access_error(
   char* file )
 {
   error_exit("Can't access file %s", file);
 }
 
-static void get_stat(
+static void
+get_stat(
   char* file,
   struct stat* st )
 {
@@ -241,14 +251,15 @@
 static char buf[BUFSIZE];
 static time_t inittime;
 
-static void exec_command(
+static void
+exec_command(
   char* msg,
   char* info,
   void (* garbage)() )
 {
   if (verbose) {
-    (void) fputs(buf, stderr);
-    (void) putc('\n', stderr);
+    fputs(buf, stderr);
+    putc('\n', stderr);
   }
 
   if(dryrun) return;
@@ -256,8 +267,8 @@
   assert(!dryrun);
   if (parallelism == 0) {
     if (system(buf) != 0) {
-	(void) fprintf(stderr, msg, info);
-	(void) putc('\n', stderr);
+	fprintf(stderr, msg, info);
+	putc('\n', stderr);
 	garbage(info);
 	exit(1);
     }
@@ -286,8 +297,8 @@
 	forked++;
 	return;
     } else if (system(buf) != 0) {
-	(void) fprintf(stderr, msg, info);
-	(void) putc('\n', stderr);
+	fprintf(stderr, msg, info);
+	putc('\n', stderr);
 	garbage(info);
 	exit(1);
     } else {
@@ -296,7 +307,8 @@
   }
 }
 
-static void sync_with_subtasks(void)
+static void
+sync_with_subtasks(void)
 {
   int status;
   while (wait(&status) >= 0) {
@@ -307,13 +319,14 @@
   }
 }
 
-static char* make_path(
+static char*
+make_path(
   char* name )
 {
   char* path;
   if (dbdir != NULL) {
     path = (char*) malloc(strlen(dbdir) + 1 + strlen(name) + 1);
-    (void) sprintf(path, "%s/%s", dbdir, name);
+    sprintf(path, "%s/%s", dbdir, name);
   } else {
     path = name;
   }
@@ -321,29 +334,32 @@
 }
 
 /* Cleaning after commmand failure */
-static void delete_file(
+static void
+delete_file(
   char* file,
   char* prefix,
   char* suffix )
 {
   buf[0] = '\0';
-  (void) sprintf(buf, "%s%s%s%s",
+  sprintf(buf, "%s%s%s%s",
     (prefix != NULL ? prefix : ""),
     (prefix != NULL ? "/" : ""),
     file,
     (suffix != NULL ? suffix : ""));
   if (unlink(buf) == 0)
-    (void) fprintf(stderr, "%s removed\n", buf);
+    fprintf(stderr, "%s removed\n", buf);
 }
 
-static void failed_kl1c(
+static void
+failed_kl1c(
   char* file )
 {
   delete_file(file, NULL, ".c");
   delete_file(file, NULL, ".ext");
 }
 
-static void failed_makedb(
+static void
+failed_makedb(
   char *dbdir )
 {
   delete_file("atom", NULL, ".h");
@@ -352,13 +368,15 @@
   delete_file("funct", dbdir, ".c");
 }
 
-static void noop(
+static void
+noop(
   char* dummy )
 {
 }
 
 /* Decide what linker to use */
-static void guess_linker(void)
+static void
+guess_linker(void)
 {
   int prio = -1;
   struct namerec* f;
@@ -372,7 +390,8 @@
   }
 }
 
-static void kl1_to_c(void)
+static void
+kl1_to_c(void)
 {
   struct namerec* f;
   for(f = files; f != NULL; f = f->next) {
@@ -385,17 +404,17 @@
         goto COMPILE;
       }
 
-      (void) sprintf(buf, "%s.kl1", f->name);
+      sprintf(buf, "%s.kl1", f->name);
       get_stat(buf, &kl1_stat);
 
-      (void) sprintf(buf, "%s.c", f->name);
+      sprintf(buf, "%s.c", f->name);
       if (stat(buf, &c_stat) != 0 ||
 	  kl1_stat.st_mtime > c_stat.st_mtime) {
 	recompile = 1;
 	goto COMPILE;
       }
 
-      (void) sprintf(buf, "%s.ext", f->name);
+      sprintf(buf, "%s.ext", f->name);
       if (stat(buf, &ext_stat) != 0 ||
           kl1_stat.st_mtime > ext_stat.st_mtime) {
         recompile = 1;
@@ -404,7 +423,7 @@
 
     COMPILE:
       if (recompile) {
-	(void) sprintf(buf, "%s %s.kl1 </dev/null", klic_compiler, f->name);
+	sprintf(buf, "%s %s.kl1 </dev/null", klic_compiler, f->name);
 	exec_command("KL1 to C translation failed for %s",
 		     f->name, failed_kl1c);
       }
@@ -415,19 +434,20 @@
   assert(f == NULL);
 }
 
-static void make_database(void)
+static void
+make_database(void)
 {
   struct namerec* f;
   struct stat initstat;
   int makedb = 0;
 
-  (void) sprintf(buf, "%s%s" "klicdb.init",
+  sprintf(buf, "%s%s" "klicdb.init",
     (initdbdir != NULL ? initdbdir : ""),
     (initdbdir != NULL ? "/" : ""));
   get_stat(buf, &initstat);
   inittime = initstat.st_mtime;
 
-  (void) sprintf(buf, "%s" "%s" "%s" "%s%s" "%s%s",
+  sprintf(buf, "%s" "%s" "%s" "%s%s" "%s%s",
     klic_dbmaker,
     (no_cc ? " -C" : ""),
     (no_link ? " -c" : ""),
@@ -436,11 +456,11 @@
 
   for (f = files; f != NULL; f = f->next) {
     char xbuf[BUFSIZE];
-    (void) sprintf(xbuf, "%s.ext", f->name);
+    sprintf(xbuf, "%s.ext", f->name);
     if (access(xbuf, F_OK) == 0) {
       makedb = 1;
-      (void) strcat(buf, " ");
-      (void) strcat(buf, xbuf);
+      strcat(buf, " ");
+      strcat(buf, xbuf);
     }
   }
   assert(f == NULL);
@@ -451,7 +471,8 @@
   }
 }
 
-static void compile_c_file(
+static void
+compile_c_file(
   char* name,
   struct lang_info* inf,
   int masm )
@@ -461,10 +482,10 @@
   char* bufp;
   struct stat c_stat, o_stat;
 
-  (void) sprintf(buf, "%s%s", name, inf->ext);
+  sprintf(buf, "%s%s", name, inf->ext);
   get_stat(buf, &c_stat);
 
-  (void) sprintf(buf, "%s.%c", name, suffix);
+  sprintf(buf, "%s.%c", name, suffix);
   recompile =
     (do_recompile ||
      stat(buf, &o_stat) != 0 ||
@@ -481,30 +502,31 @@
 	      name, suffix);
     bufp = buf + strlen(buf);
     for (inc = incdirs; inc != NULL; inc = inc->next) {
-      (void) sprintf(bufp, " -I%s", inc->name);
+      sprintf(bufp, " -I%s", inc->name);
       bufp += strlen(bufp);
     }
     /*** for Distributed KLIC system ***/
     if (distklic) {
       DIST_COMPILER_FLAG(name, inf->ext);
     } else if ( shmklic ) {
-      (void) sprintf(bufp, " -DSHM -I%s -I. %s%s",
+      sprintf(bufp, " -DSHM -I%s -I. %s%s",
         klic_incdir, name, inf->ext);
     } else {
-      (void) sprintf(bufp, " -I%s -I. %s%s",
+      sprintf(bufp, " -I%s -I. %s%s",
         klic_incdir, name, inf->ext);
     }
 
     {
       char tmpbuf[256];
-      (void) sprintf(tmpbuf, "%s%s", name, inf->ext);
+      sprintf(tmpbuf, "%s%s", name, inf->ext);
       exec_command("Compilation failed for file %s",
 		   tmpbuf, noop);
     }
   }
 }
 
-static void compile_s_file(
+static void
+compile_s_file(
   char* name,
   int masm )
 {
@@ -513,14 +535,14 @@
   if(masm) return;
   assert(!masm);
 
-  (void) sprintf(buf, "%s.s", name);
+  sprintf(buf, "%s.s", name);
   get_stat(buf, &s_stat);
 
-  (void) sprintf(buf, "%s.o", name);
+  sprintf(buf, "%s.o", name);
   if (do_recompile ||
       stat(buf, &o_stat) != 0 ||
       s_stat.st_mtime >= o_stat.st_mtime) {
-    (void) sprintf(buf, "%s -c %s%s -I%s %s -o %s.o %s.s",
+    sprintf(buf, "%s -c %s%s -I%s %s -o %s.o %s.s",
 		   klic_cc, optflags,
 		   (cdebug ? " -g" : ""),
 		   klic_incdir,
@@ -531,7 +553,8 @@
   }
 }
 
-static void c_to_o(void)
+static void
+c_to_o(void)
 {
   struct namerec* f;
   int status;
@@ -548,22 +571,26 @@
   }
 }
 
-static void make_atom_o(void)
+static void
+make_atom_o(void)
 {
   compile_c_file(make_path("atom"), c_info, 0);
 }
 
-static void make_funct_o(void)
+static void
+make_funct_o(void)
 {
   compile_c_file(make_path("funct"), c_info, 0);
 }
 
-static void make_pred_o(void)
+static void
+make_pred_o(void)
 {
   compile_c_file(make_path("predicates"), c_info, 0);
 }
 
-static void linkage(void)
+static void
+linkage(void)
 {
   struct namerec* f;
   char* bufp;
@@ -585,7 +612,7 @@
   /* We will link the program anyway, as we can't tell whether the */
   /* existing executable was linked with the tracing library or not */
 
-  (void) sprintf(buf, "%s" "%s%s" "%s %s %s %s %s",
+  sprintf(buf, "%s" "%s%s" "%s %s %s %s %s",
     ld,
     (ofile != NULL ? " -o " : ""),
     (ofile != NULL ? ofile : ""),
@@ -596,14 +623,14 @@
     (debug ? make_path("predicates.o") : "") );
   bufp = buf + strlen(buf);
   for (f = files; f != NULL; f = f->next) {
-    (void) sprintf(bufp, " %s.o", f->name);
+    sprintf(bufp, " %s.o", f->name);
     bufp += strlen(bufp);
   }
   for (f = libdirs; f != NULL; f = f->next) {
-    (void) sprintf(bufp, " -L%s", f->name);
+    sprintf(bufp, " -L%s", f->name);
     bufp += strlen(bufp);
   }
-  (void) sprintf(bufp, " -L%s", klic_libdir);
+  sprintf(bufp, " -L%s", klic_libdir);
   bufp += strlen(bufp);
   {
     char* tptr;
@@ -616,11 +643,11 @@
     } else {
       tptr = LIBRARIES;
     }
-    (void) sprintf(bufp, " %s", tptr);
+    sprintf(bufp, " %s", tptr);
   }
   bufp += strlen(bufp);
   for (f = libraries; f != NULL; f = f->next) {
-    (void) sprintf(bufp, " -l%s", f->name);
+    sprintf(bufp, " -l%s", f->name);
     bufp += strlen(bufp);
   }
   if (distklic) {
@@ -638,11 +665,11 @@
 #define Nextarg() \
 ( optind++, argv[optind] )
 
-extern int main(
+extern int
+main(
   int argc,
   char** argv )
 {
-  extern char* option_value();
   int optind;
   int optc;
   int c;
@@ -780,9 +807,9 @@
     optflags = "";
   } else {
     if (optlevel<1) {
-      (void) sprintf(buf, " -O %s", UOPTFLAGS);
+      sprintf(buf, " -O %s", UOPTFLAGS);
     } else {
-      (void) sprintf(buf, " -O%d %s", optlevel, UOPTFLAGS);
+      sprintf(buf, " -O%d %s", optlevel, UOPTFLAGS);
     }
     optflags = (char*) malloc(strlen(buf)+1);
     optflags = strcpy(optflags, buf);
diff -ruN klic-3.003-2002-01-18/include/klic/alloc.h klic-3.003-2002-01-21/include/klic/alloc.h
--- klic-3.003-2002-01-18/include/klic/alloc.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2002-01-21/include/klic/alloc.h	Mon Jan 21 20:55:25 2002
@@ -34,8 +34,8 @@
 extern q* klic_interrupt(q* allocp, struct goalrec* qp);
 
 /* runtime/alloc.c */
-extern char* malloc_check(unsigned long size);
-extern char* realloc_check(char* original, unsigned long newsize);
+extern void* malloc_check(unsigned long size);
+extern void* realloc_check(void* original, unsigned long newsize);
 extern void initalloc(void);
 extern void register_gc_hook(q*(* routine)());
 extern void register_after_gc_hook(q*(* routine)());
diff -ruN klic-3.003-2002-01-18/include/klic/basic.h klic-3.003-2002-01-21/include/klic/basic.h
--- klic-3.003-2002-01-18/include/klic/basic.h	Mon Dec 31 12:04:47 2001
+++ klic-3.003-2002-01-21/include/klic/basic.h	Mon Jan 21 20:55:25 2002
@@ -10,7 +10,6 @@
 
 #include <stdio.h>
 #include <klic/stdc.h>  /* const, volatile */
-#include <klic/config.h>
 
 #ifdef MAIN
 #define Extern
diff -ruN klic-3.003-2002-01-18/include/klic/bb.h klic-3.003-2002-01-21/include/klic/bb.h
--- klic-3.003-2002-01-18/include/klic/bb.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2002-01-21/include/klic/bb.h	Mon Jan 21 20:55:25 2002
@@ -543,7 +543,7 @@
 #endif
 
 #define bblt_complement_no_check(x, z)				\
-do{ (z) = ((long)(x) ^ ((-1L) << ATAGBITS)); }while(0)
+do{ (z) = (q) ((long)(x) ^ ((-1L) << ATAGBITS)); }while(0)
 
 /*
   Unary Plus
diff -ruN klic-3.003-2002-01-18/include/klic/stdc.h klic-3.003-2002-01-21/include/klic/stdc.h
--- klic-3.003-2002-01-18/include/klic/stdc.h	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-21/include/klic/stdc.h	Mon Jan 21 20:55:25 2002
@@ -6,6 +6,8 @@
 #ifndef _KLIC_STDC_H_
 #define _KLIC_STDC_H_
 
+#include <klic/config.h>
+
 /* for compatibility with non-standard C */
 
 #ifdef __STDC__
diff -ruN klic-3.003-2002-01-18/runtime/alloc.c klic-3.003-2002-01-21/runtime/alloc.c
--- klic-3.003-2002-01-18/runtime/alloc.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-01-21/runtime/alloc.c	Mon Jan 21 20:57:59 2002
@@ -10,11 +10,11 @@
 #include <klic/struct.h>
 #include <klic/primitives.h>  /* extern */
 
-extern char*
+extern void*
 malloc_check(size)
      unsigned long size;
 {
-  char* res = malloc(size);
+  void* res = malloc(size);
   if (res == NULL) {
     fatalf("No more memory available from Unix\nMalloc failed for %d bytes",
 	   size);
@@ -22,12 +22,12 @@
   return res;
 }
 
-extern char*
+extern void*
 realloc_check(original, newsize)
-     char* original;
+     void* original;
      unsigned long newsize;
 {
-  char* res = realloc(original, newsize);
+  void* res = realloc(original, newsize);
   if (res == NULL) {
     fatalf("No more memory available from Unix\nRealloc failed for %d bytes",
 	   newsize);
diff -ruN klic-3.003-2002-01-18/runtime/bb.c klic-3.003-2002-01-21/runtime/bb.c
--- klic-3.003-2002-01-18/runtime/bb.c	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2002-01-21/runtime/bb.c	Mon Jan 21 20:55:25 2002
@@ -4,6 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
+
 #include <klic/basic.h>  /* fatalf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
@@ -109,7 +110,8 @@
   return suspend_builtin_2(x, &pred);			\
 }
 
-static void enqueue_as_resumed(goal)
+static void
+enqueue_as_resumed(goal)
      struct goalrec *goal;
 {
   declare_globals;
@@ -125,7 +127,8 @@
   heaplimit = 0;
 }
 
-static q suspend_builtin_3(v, x, y, pred)
+static q
+suspend_builtin_3(v, x, y, pred)
      q v, x, y;
      const struct predicate* pred;
 {
@@ -142,7 +145,8 @@
   return z;
 }
 
-static q suspend_builtin_2(v, pred)
+static q
+suspend_builtin_2(v, pred)
      q v;
      const struct predicate* pred;
 {
@@ -158,7 +162,8 @@
   return z;
 }
 
-static void builtin_3_type_error(x, y, pred, name)
+static void
+builtin_3_type_error(x, y, pred, name)
      q x, y;
      struct predicate *pred;
      char *name;
@@ -166,7 +171,8 @@
   fatalf("Argument type error in builtin predicate: %s\n", name);
 }
 
-static void builtin_2_type_error(x, pred, name)
+static void
+builtin_2_type_error(x, pred, name)
      q x;
      struct predicate *pred;
      char *name;
@@ -174,65 +180,86 @@
   fatalf("Argument type error in builtin predicate %s", name);
 }
 
-extern q bblt_add_3(x, y)
-builtin_body_3(bblt_add_no_check, predicate_integer__arithmetics_xadd_3,
-	       "add/3")
-
-extern q bblt_sub_3(x, y)
-builtin_body_3(bblt_sub_no_check, predicate_integer__arithmetics_xsubtract_3,
-	       "subtract/3")
-
-extern q bblt_mult_3(x, y)
-builtin_body_3(bblt_mult_no_check, predicate_integer__arithmetics_xmultiply_3,
-	       "multiply/3")
-
-extern q bblt_div_3(x, y)
-builtin_body_3(bblt_div_no_check, predicate_integer__arithmetics_xdivide_3,
-	       "divide/3")
-
-extern q bblt_mod_3(x, y)
-builtin_body_3(bblt_mod_no_check, predicate_integer__arithmetics_xmodulo_3,
-	       "modulo/3")
-
-extern q bblt_and_3(x, y)
-builtin_body_3(bblt_and_no_check, predicate_integer__arithmetics_xand_3,
-	       "and/3")
-
-extern q bblt_or_3(x, y)
-builtin_body_3(bblt_or_no_check, predicate_integer__arithmetics_xor_3,
-	       "or/3")
-
-extern q bblt_exclusive_or_3(x, y)
-builtin_body_3(bblt_exclusive_or_no_check,
-	       predicate_integer__arithmetics_xexclusive__or_3,
-	       "exlclusive_or/3")
-
-extern q bblt_rshift_3(x, y)
-builtin_body_3(bblt_rshift_no_check,
-	       predicate_integer__arithmetics_xshift__right_3,
-	       "shift_right/3")
-
-extern q bblt_lshift_3(x, y)
-builtin_body_3(bblt_lshift_no_check,
-	       predicate_integer__arithmetics_xshift__left_3,
-	       "shift_left/3")
-
-extern q bblt_plus_2(x)
-builtin_body_2(bblt_plus_no_check,
-	       predicate_integer__arithmetics_xplus_2,
-	       "plus/2")
-
-extern q bblt_minus_2(x)
-builtin_body_2(bblt_minus_no_check,
-	       predicate_integer__arithmetics_xminus_2,
-	       "minus/2")
-
-extern q bblt_complement_2(x)
-builtin_body_2(bblt_complement_no_check,
-	       predicate_integer__arithmetics_xcomplement_2,
-	       "complement/2")
+extern q
+bblt_add_3(x, y)
+  builtin_body_3(bblt_add_no_check,
+		 predicate_integer__arithmetics_xadd_3,
+		 "add/3")
+
+extern q
+bblt_sub_3(x, y)
+  builtin_body_3(bblt_sub_no_check,
+		 predicate_integer__arithmetics_xsubtract_3,
+		 "subtract/3")
+
+extern q
+bblt_mult_3(x, y)
+  builtin_body_3(bblt_mult_no_check,
+		 predicate_integer__arithmetics_xmultiply_3,
+		 "multiply/3")
+
+extern q
+bblt_div_3(x, y)
+  builtin_body_3(bblt_div_no_check,
+		 predicate_integer__arithmetics_xdivide_3,
+		 "divide/3")
+
+extern q
+bblt_mod_3(x, y)
+  builtin_body_3(bblt_mod_no_check,
+		 predicate_integer__arithmetics_xmodulo_3,
+		 "modulo/3")
+
+extern q
+bblt_and_3(x, y)
+  builtin_body_3(bblt_and_no_check,
+		 predicate_integer__arithmetics_xand_3,
+		 "and/3")
+
+extern q
+bblt_or_3(x, y)
+  builtin_body_3(bblt_or_no_check,
+		 predicate_integer__arithmetics_xor_3,
+		 "or/3")
+
+extern q
+bblt_exclusive_or_3(x, y)
+  builtin_body_3(bblt_exclusive_or_no_check,
+		 predicate_integer__arithmetics_xexclusive__or_3,
+		 "exlclusive_or/3")
+
+extern q
+bblt_rshift_3(x, y)
+  builtin_body_3(bblt_rshift_no_check,
+		 predicate_integer__arithmetics_xshift__right_3,
+		 "shift_right/3")
+
+extern q
+bblt_lshift_3(x, y)
+  builtin_body_3(bblt_lshift_no_check,
+		 predicate_integer__arithmetics_xshift__left_3,
+		 "shift_left/3")
+
+extern q
+bblt_plus_2(x)
+  builtin_body_2(bblt_plus_no_check,
+		 predicate_integer__arithmetics_xplus_2,
+		 "plus/2")
+
+extern q
+bblt_minus_2(x)
+  builtin_body_2(bblt_minus_no_check,
+		 predicate_integer__arithmetics_xminus_2,
+		 "minus/2")
+
+extern q
+bblt_complement_2(x)
+  builtin_body_2(bblt_complement_no_check,
+		 predicate_integer__arithmetics_xcomplement_2,
+		 "complement/2")
 
-extern q bblt_fix_2(x)
+extern q
+bblt_fix_2(x)
      q x;
 {
   extern struct predicate
diff -ruN klic-3.003-2002-01-18/runtime/gc.c klic-3.003-2002-01-21/runtime/gc.c
--- klic-3.003-2002-01-18/runtime/gc.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-01-21/runtime/gc.c	Mon Jan 21 20:55:25 2002
@@ -4,6 +4,7 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
+
 #include <klic/basic.h>  /* fatal, fatalf, klic_fprintf */
 #include <klic/struct.h>
 #include <klic/primitives.h>  /* malloc_check, realloc_check */
@@ -135,7 +136,7 @@
   declare_globals;
   q** newstack;
   gcstack_size *= 2;
-  newstack = (q**) realloc_check(gcstack, gcstack_size*sizeof(q*));
+  newstack = (q**) realloc_check((void*) gcstack, gcstack_size*sizeof(q*));
   sp = newstack + (sp - gcstack);
   gcstack = newstack;
   gcmax = newstack + gcstack_size;
@@ -150,7 +151,7 @@
   declare_globals;
   q** newstack;
   shm_gcstack_size *= 2;
-  newstack = (q**) realloc_check(shm_gcstack, shm_gcstack_size*sizeof(q*));
+  newstack = (q**) realloc_check((void*) shm_gcstack, shm_gcstack_size*sizeof(q*));
   sp = newstack + (sp - shm_gcstack);
   shm_gcstack = newstack;
   shm_gcmax = newstack + shm_gcstack_size;
diff -ruN klic-3.003-2002-01-18/runtime/ge_exref.c klic-3.003-2002-01-21/runtime/ge_exref.c
--- klic-3.003-2002-01-18/runtime/ge_exref.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-01-21/runtime/ge_exref.c	Mon Jan 21 20:55:25 2002
@@ -177,7 +177,7 @@
   new_exref->index = (long) intval(GG_ARGV[1]);
   new_exref->wec   = (long) intval(GG_ARGV[2]);
 
-  new_exref->to_exref = GG_MAKE_HOOK_VAR(new_exref);
+  new_exref->to_exref = GG_MAKE_HOOK_VAR((struct generator_object*) new_exref);
 
   new_exref->gc_flag  = IMPREC_NOT_COPIED;
 
diff -ruN klic-3.003-2002-01-18/runtime/ge_readhook.c klic-3.003-2002-01-21/runtime/ge_readhook.c
--- klic-3.003-2002-01-18/runtime/ge_readhook.c	Sat Jan 12 20:05:30 2002
+++ klic-3.003-2002-01-21/runtime/ge_readhook.c	Mon Jan 21 20:55:25 2002
@@ -100,7 +100,8 @@
   new_read_hook->index = (long) intval(GC_ARGV[1]);
   new_read_hook->wec   = (long) intval(GC_ARGV[2]);
 
-  new_read_hook->to_read_hook = GC_MAKE_HOOK_VAR(new_read_hook);
+  new_read_hook->to_read_hook =
+    GC_MAKE_HOOK_VAR((struct consumer_object*) new_read_hook);
 
   new_read_hook->return_index = send_read(new_read_hook->node,
 					  new_read_hook->index,
diff -ruN klic-3.003-2002-01-18/runtime/ge_replyhook.c klic-3.003-2002-01-21/runtime/ge_replyhook.c
--- klic-3.003-2002-01-18/runtime/ge_replyhook.c	Sat Jan 12 20:05:30 2002
+++ klic-3.003-2002-01-21/runtime/ge_replyhook.c	Mon Jan 21 20:55:25 2002
@@ -76,6 +76,6 @@
   new_reply_hook->index  = intval(GC_ARGV[1]);
   new_reply_hook->wec    = intval(GC_ARGV[2]);
 
-  var = GC_MAKE_HOOK_VAR(new_reply_hook);
+  var = GC_MAKE_HOOK_VAR((struct consumer_object*) new_reply_hook);
   GC_RETURN_FROM_NEW(var);
 }
diff -ruN klic-3.003-2002-01-18/runtime/gfloat.c klic-3.003-2002-01-21/runtime/gfloat.c
--- klic-3.003-2002-01-18/runtime/gfloat.c	Sat Jan 12 20:05:30 2002
+++ klic-3.003-2002-01-21/runtime/gfloat.c	Mon Jan 21 20:55:25 2002
@@ -126,7 +126,7 @@
   q str;
   char buf[100];
   sprintf(buf, "%1.16g", value);
-  if( STRCHR(buf, '.') == 0 &&
+  if( STRCHR(buf, '.') == NULL &&
       strcmp(buf, "Infinity") != 0 && strcmp(buf, "-Infinity") != 0 &&
       strcmp(buf, "NaN") != 0 ){
     char* exponent = STRCHR(buf, 'e');
diff -ruN klic-3.003-2002-01-18/runtime/gg_shvar.c klic-3.003-2002-01-21/runtime/gg_shvar.c
--- klic-3.003-2002-01-18/runtime/gg_shvar.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-01-21/runtime/gg_shvar.c	Mon Jan 21 20:55:25 2002
@@ -36,6 +36,7 @@
 static Inline int
 cmp_forward_ptr(q x, q y)
 {
+  declare_globals;
   int xv = get_space(x);
   int yv = get_space(y);
   return (xv==yv) ? (x < y) : (xv < yv);
@@ -67,7 +68,7 @@
   if( pair != derefone(GG_SELF) )  return One_more;
 
   gobjp = (Shvar*) untag_generator_susp(addi);
-  GG_SWITCH_ON_TERM(cons, atomic, func, dobj, susp)
+  GG_SWITCH_ON_TERM(cons, atomic, func, dobj, susp);
 
  atomic:
   {
@@ -267,10 +268,13 @@
   }
   /* already any hooks */
   else if( is_genhook(gp) ){ /* shared generator hook */
+    int pe_num;
+    long prio;
+    TADDRtbl* ind;
     sptr = (Sinfo*) untag_generator_susp(gp);
-    int pe_num = sptr->PE_num;
-    long prio = sptr->prio;
-    TADDRtbl* ind = sptr->indp;
+    pe_num = sptr->PE_num;
+    prio = sptr->prio;
+    ind = sptr->indp;
     if( pe_num == my_node ){
       q temp;
       q* tp = ind->globalA;
diff -ruN klic-3.003-2002-01-18/runtime/gio.c klic-3.003-2002-01-21/runtime/gio.c
--- klic-3.003-2002-01-18/runtime/gio.c	Fri Jan 11 11:48:04 2002
+++ klic-3.003-2002-01-21/runtime/gio.c	Mon Jan 21 20:55:25 2002
@@ -491,6 +491,6 @@
   newobj->inname = inpath;
   newobj->outname = outpath;
   newobj->stream = 0;
-  var = GC_MAKE_HOOK_VAR(newobj);
+  var = GC_MAKE_HOOK_VAR((struct consumer_object*) newobj);
   GC_RETURN_FROM_NEW(var);
 }
diff -ruN klic-3.003-2002-01-18/runtime/gmerge.c klic-3.003-2002-01-21/runtime/gmerge.c
--- klic-3.003-2002-01-18/runtime/gmerge.c	Fri Jan 11 10:42:18 2002
+++ klic-3.003-2002-01-21/runtime/gmerge.c	Mon Jan 21 20:55:25 2002
@@ -90,7 +90,8 @@
 	  argv[0] = G_MAKEINT(i);
 	  GD_CALL_GMETHOD(GC_TERM,element_2,argv);
 	  GC_TRY_TO_ALLOC(hook_var,(q),1,gc_request2);
-	  derefone(hook_var) = GC_MAKE_HOOK_VAR(GC_SELF);
+	  derefone(hook_var) =
+	    GC_MAKE_HOOK_VAR((struct consumer_object*) GC_SELF);
 	  GC_KL1_UNIFY(argv[1],hook_var);
 	}
       }
@@ -150,6 +151,6 @@
   GCSET_NEWOBJ_FOR_NEW(newmerger,GC_OBJ_SIZE(newmerger));
   newmerger->count = 1;
   newmerger->outstream = GC_ARGV[0];
-  var = GC_MAKE_HOOK_VAR(newmerger);
+  var = GC_MAKE_HOOK_VAR((struct consumer_object*) newmerger);
   GC_RETURN_FROM_NEW(var);
 }
diff -ruN klic-3.003-2002-01-18/runtime/shm_gc.c klic-3.003-2002-01-21/runtime/shm_gc.c
--- klic-3.003-2002-01-18/runtime/shm_gc.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-01-21/runtime/shm_gc.c	Mon Jan 21 20:55:25 2002
@@ -136,6 +136,10 @@
 static int shm_gc_times = 0;
 static int measure_shmgc = 1;
 
+static void shm_copy_terms(q** sp, q** max);
+static void enter_shm_gc(void);
+static void exit_shm_gc(void);
+
 /* checks shared-memory GC.  called by "intrpt" routine */
 extern int
 ck_shm_gc()
@@ -627,8 +631,9 @@
   declare_globals;
   q obj;
   while( sp > shm_gcstack ){
+    q* objp;
     sp--;
-    q* objp = *sp;
+    objp = *sp;
     switch( ptagof(objp) ){
     case ATOMIC: {  /* in case of UPDATE */
       q* conta = (q*) ((long)objp - ATOMIC);
diff -ruN klic-3.003-2002-01-18/runtime/shm_obj.c klic-3.003-2002-01-21/runtime/shm_obj.c
--- klic-3.003-2002-01-18/runtime/shm_obj.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-01-21/runtime/shm_obj.c	Mon Jan 21 20:55:25 2002
@@ -321,6 +321,26 @@
 }
 
 
+extern void
+shm_request_queueing(peno, prio, indp)
+  int peno;
+  long prio;
+  TADDRtbl* indp;
+{
+  struct ex_goalrec* tp;
+  struct goalrec *goal;
+
+  tp = (struct ex_goalrec*) galloc(5);
+  tp->prio = prio;
+  goal = &tp->goal;
+  goal->next = 0;
+  goal->pred = &shm_xrequest_1;
+  goal->args[0] = (q) ((unsigned long)indp + ATOMIC);
+
+  shm_goal_stack(tp, peno);
+}
+
+
 extern q*
 shm_ck_request(allocp, chain)
   q* allocp;
@@ -339,26 +359,6 @@
     shm_request_queueing(penum, current_prio, indp);
   }
   return allocp;
-}
-
-
-extern void
-shm_request_queueing(peno, prio, indp)
-  int peno;
-  long prio;
-  TADDRtbl* indp;
-{
-  struct ex_goalrec* tp;
-  struct goalrec *goal;
-
-  tp = (struct ex_goalrec*) galloc(5);
-  tp->prio = prio;
-  goal = &tp->goal;
-  goal->next = 0;
-  goal->pred = &shm_xrequest_1;
-  goal->args[0] = (q) ((unsigned long)indp + ATOMIC);
-
-  shm_goal_stack(tp, peno);
 }
 
 
diff -ruN klic-3.003-2002-01-18/runtime/step.c klic-3.003-2002-01-21/runtime/step.c
--- klic-3.003-2002-01-18/runtime/step.c	Tue Jan  1 17:09:10 2002
+++ klic-3.003-2002-01-21/runtime/step.c	Mon Jan 21 20:55:25 2002
@@ -270,9 +270,9 @@
   if (num_wokenup >= max_wokenup) {
     int newmax = max_wokenup * 2;
     wokenup_goals = (struct goalrec **)
-      realloc_check(wokenup_goals, newmax*sizeof(struct goalrec *));
+      realloc_check((void*) wokenup_goals, newmax*sizeof(struct goalrec*));
     wokenup_prio = (long *)
-      realloc_check(wokenup_prio, newmax*sizeof(long));
+      realloc_check((void*) wokenup_prio, newmax*sizeof(long));
     max_wokenup = newmax;
   }
   wokenup_goals[num_wokenup] = goal;
@@ -287,7 +287,7 @@
   if (num_failed >= max_failed) {
     int newmax = max_failed * 2;
     failed_goals = (struct goalrec **)
-      realloc_check(failed_goals, newmax*sizeof(struct goalrec *));
+      realloc_check((void*) failed_goals, newmax*sizeof(struct goalrec*));
     max_failed = newmax;
   }
   failed_goals[num_failed] = goal;
diff -ruN klic-3.003-2002-01-18/runtime/trace.c klic-3.003-2002-01-21/runtime/trace.c
--- klic-3.003-2002-01-18/runtime/trace.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-01-21/runtime/trace.c	Mon Jan 21 20:55:25 2002
@@ -60,10 +60,16 @@
 enum trace_port { Call, Susp, Redu, Fail, AllPorts, NoMorePort, UnknownPort };
 
 
-extern module wait_penum_routine();
-
 extern char* calloc();
 extern void free();
+extern module wait_penum_routine();
+
+static void trace_fflush(struct trace_info_rec* info);
+static void trace_printf();
+static void trace_fgets(char* buf, int n, struct trace_info_rec* info);
+static void print_priority(long prio, struct trace_info_rec* info);
+static void print_goal
+  (struct goalrec* g, module mod, struct trace_info_rec* info);
 
 static struct trace_info_rec* trace_info_recs;
 static long num_info_recs, info_rec_size;
@@ -739,8 +745,8 @@
   if (++n_resumed == max_different_prio_resume) {
     max_different_prio_resume *= 2;
     different_prio_resume = (struct goalrec **)
-      realloc_check(different_prio_resume,
-		    max_different_prio_resume*sizeof(struct goalrec *));
+      realloc_check((void*) different_prio_resume,
+		    max_different_prio_resume*sizeof(struct goalrec*));
   }
   different_prio_resume[n_resumed-1] = qp;
 }
@@ -1973,8 +1979,8 @@
 
 extern void
 fprint_pred(fp, pred)
-     FILE *fp;
-     struct predicate *pred;
+  FILE* fp;
+  const struct predicate* pred;
 {
   static int name_table_init = 0;
   if(!name_table_init) {
diff -ruN klic-3.003-2002-01-18/runtime/trace.h klic-3.003-2002-01-21/runtime/trace.h
--- klic-3.003-2002-01-18/runtime/trace.h	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-21/runtime/trace.h	Mon Jan 21 20:55:25 2002
@@ -43,7 +43,7 @@
 extern void trace_failure(struct goalrec* qp);
 extern void trace_deadlock(struct goalrec* qp);
 
-extern void fprint_pred(FILE* fp, struct predicate* pred);
+extern void fprint_pred(FILE* fp, const struct predicate* pred);
 extern void fprint_goal
   ( FILE* stream, struct goalrec* g, module mod,
     unsigned long depth, unsigned long length, int verbose );
diff -ruN klic-3.003-2002-01-18/runtime/wakeup.c klic-3.003-2002-01-21/runtime/wakeup.c
--- klic-3.003-2002-01-18/runtime/wakeup.c	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2002-01-21/runtime/wakeup.c	Mon Jan 21 20:55:25 2002
@@ -69,6 +69,6 @@
   GCSET_NEWOBJ_FOR_NEW(wakeup,GC_OBJ_SIZE(wakeup));
   wakeup->x = GC_ARGV[0];
   wakeup->y = GC_ARGV[1];
-  var = GC_MAKE_HOOK_VAR(wakeup);
+  var = GC_MAKE_HOOK_VAR((struct consumer_object*) wakeup);
   GC_RETURN_FROM_NEW(var);
 }
