diff -ruN klic-3.003-2002-01-12a/ChangeLog klic-3.003-2002-01-13/ChangeLog
--- klic-3.003-2002-01-12a/ChangeLog	Tue Jan  1 17:09:10 2002
+++ klic-3.003-2002-01-13/ChangeLog	Sun Jan 13 17:29:02 2002
@@ -1,3 +1,28 @@
+2002-01-12 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* include/klic/gd_macro.h: remove GD_body_no_arity.
+
+2002-01-11 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* runtime/gio.c: get functor_fclose_1 not to FALL THRU.
+
+	* runtime/gobj.h: move local macros to
+	datamsg.c, faisus.c, gc.c, print.c, unify2.c.
+
+2002-01-07 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* runtime/gunix.kl1: remove NO_USESOCKET.
+
+	* runtime/init_dist.c:
+	move before_exec, after_exec, init_rusage to cntlmsg.c.
+
+	* runtime/interpe.h: move locals to
+	cntlmsg.c, export_table.c, import_table.c, sendrecv.c.
+
+2002-01-06 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* runtime/options.h: move 'Extern's to runtime/kmain.c.
+
 2002-01-02 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
 
 	* runtime/step.h: new file.
diff -ruN klic-3.003-2002-01-12a/runtime/config/pvm/distio.c klic-3.003-2002-01-13/runtime/config/pvm/distio.c
--- klic-3.003-2002-01-12a/runtime/config/pvm/distio.c	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-13/runtime/config/pvm/distio.c	Sun Jan 13 13:24:38 2002
@@ -6,6 +6,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>  /* debug_fprintf, klic_fprintf, klic_getc */
 #include <klic/struct.h>
@@ -13,6 +14,7 @@
 #include <signal.h>
 #include <unistd.h>
 #include <malloc.h>
+
 /*
   For io-node
   IO NODE SERVER PROGRAM		void io_server(argc,argv)
@@ -24,276 +26,276 @@
 static void
 sigint_handler()
 {
-    klic_fprintf(stdout, "kill tasks from io_server\n");
-    kill_child();
-    exit(-1);
+  klic_fprintf(stdout, "kill tasks from io_server\n");
+  kill_child();
+  exit(-1);
 }
-static FILE *
+
+static FILE*
 open_tty()
 {
-    FILE *f;
-    f = fopen("/dev/tty", "r");
-    if (f)
-      return f;
-    klic_fprintf(stderr, "Can't open /dev/tty for trace command input\n");
-    return stdin;
-}    
-
-void
-io_server(argc,argv)
-int argc;
-char **argv;
+  FILE* f;
+  f = fopen("/dev/tty", "r");
+  if (f != NULL)
+    return f;
+
+  klic_fprintf(stderr, "Can't open /dev/tty for trace command input\n");
+  return stdin;
+}
+
+extern void
+io_server(argc, argv)
+  int argc;
+  char** argv;
 {
   int his_tid;
   int dest_tid;
   int info;
   int bufid;
   enum io_tag kind;
-  FILE *tracer_input = 0;
+  FILE* tracer_input = NULL;
   char buf[1024];
   int pe_count = tid_table.child_count;
 
-  signal(SIGINT,sigint_handler);
+  signal(SIGINT, sigint_handler);
 
   his_tid = -1;
 
   while (1) {
-    FILE *tmpstream;
-    {
-	int len;
-	int msgtag;
-	int tkind;
-	bufid = pvm_recv(his_tid,-1);
-	info = pvm_bufinfo(bufid,&len,&msgtag,&dest_tid);
-	info = pvm_upkint(&tkind,1,1);
-	kind = tkind;
-    }
+    FILE* tmpstream;
+    int len;
+    int msgtag;
+    int tkind;
+    bufid = pvm_recv(his_tid, -1);
+    info = pvm_bufinfo(bufid, &len, &msgtag, &dest_tid);
+    info = pvm_upkint(&tkind, 1, 1);
+    kind = tkind;
+
     switch(kind) {
     case FinishTag:
-	if (--pe_count == 0) {
-	    pvm_exit();
-	    exit(0);
-	}
-	break;
-     case AttachTag:
-	his_tid = dest_tid;
-	break;
-     case DetachTag:
-	his_tid = -1;
-	break;
-     case Emergency_stopTag:
-	kill_child();
+      pe_count--;
+      if (pe_count == 0) {
 	pvm_exit();
 	exit(0);
-     case System_IsEOFTag:
-	{
-	    int result;
-	    if (!tracer_input)
-	      tracer_input = open_tty();
-	    result = feof(tracer_input);
-	    bufid = pvm_initsend(PvmDataRaw);
-	    info = pvm_pkint(&result,1,1);
-	    info = pvm_send(dest_tid,3);
-	    break;
-	}
-	
-     case System_putcTag:
-     case User_eputcTag:
-	tmpstream = stderr; goto putc_common;
-     case User_putcTag:
-	tmpstream = stdout;
-     putc_common:
-	info  = pvm_upkbyte(buf,1,1);
-	debug_fputc(buf[0],tmpstream);
-	break;
-
-     case User_getcTag:
-	tmpstream = stdin; goto getc_common;
-     case System_getcTag:
-	if (!tracer_input)
-	  tracer_input = open_tty();
-	tmpstream = tracer_input;
-     getc_common:
-	{
-	    int ch;
-	    ch = klic_getc(tmpstream);
-	    bufid =pvm_initsend(PvmDataRaw);
-	    info = pvm_pkint(&ch,1,1);
-	    info = pvm_send(dest_tid,3);
-	}
-	break;
-     case User_ungetcTag:
-	info = pvm_upkbyte(buf,1,1);
-	ungetc(buf[0], stdin);
-	break;
-     case System_writeTag:
-     case User_ewriteTag:
-	tmpstream = stderr; goto write_common;
-     case User_writeTag:
-	tmpstream = stdout; goto write_common;
-     write_common:
-	{
-	    long len;
-	    char *write_buf;
-	    long written = 0;
-	    info = pvm_upklong(&len, 1, 1);
-	    write_buf = (char *) malloc(len);
-	    info = pvm_upkbyte(write_buf,len,1);
-	    while (written < len) {
-		written += debug_fwrite(write_buf+written, 1, len, tmpstream);
-	    }
-	    free(write_buf);
-	}
-	break;
-     case System_fflushTag:
-     case User_efflushTag:
-	tmpstream = stderr; goto flush_common;
-     case User_fflushTag:
-	tmpstream = stdout; goto flush_common;
-     flush_common:
-	{
-	    int result = debug_fflush(tmpstream);
-	    bufid =pvm_initsend(PvmDataRaw);
-	    info = pvm_pkint(&result,1,1);
-	    info = pvm_send(dest_tid,3);
-	}
-	break;
-
-     case System_putbTag:
-     case EPutbTag:
-	tmpstream = stderr; goto putb_common;
-     case PutbTag:
-	tmpstream = stdout;
-     putb_common:
-	info  = pvm_upkstr(buf);
-	debug_fprintf(tmpstream, "%s", buf);
-	break;
-
-     case GetsTag:
-	tmpstream = stdin; goto gets_common;
-     case System_getsTag:
-	if (!tracer_input)
-	  tracer_input = open_tty();
-	tmpstream = tracer_input;
-     gets_common:
-	{
-	    char *ret;
-	    ret = fgets(buf, 255, tmpstream);
-	    if (ret == NULL)
-	      buf[0] = 0;
-	    bufid = pvm_initsend(PvmDataRaw);
-	    info = pvm_pkstr(buf);
-	    info = pvm_send(dest_tid,3);
-	    break;
-	}
-   default:
-      debug_fprintf(stderr,"Unknown message %d\n",kind);
-/*
+      }
+      break;
+    case AttachTag:
+      his_tid = dest_tid;
+      break;
+    case DetachTag:
+      his_tid = -1;
+      break;
+    case Emergency_stopTag:
+      kill_child();
       pvm_exit();
-      exit(1);
-*/
+      exit(0);
+    case System_IsEOFTag:
+      {
+	int result;
+	if (tracer_input == NULL)
+	  tracer_input = open_tty();
+	result = feof(tracer_input);
+	bufid = pvm_initsend(PvmDataRaw);
+	info = pvm_pkint(&result, 1, 1);
+	info = pvm_send(dest_tid, 3);
+	break;
+      }
+
+    case System_putcTag:
+    case User_eputcTag:
+      tmpstream = stderr;
+      goto putc_common;
+    case User_putcTag:
+      tmpstream = stdout;
+    putc_common:
+      info  = pvm_upkbyte(buf, 1, 1);
+      debug_fputc(buf[0], tmpstream);
+      break;
+
+    case User_getcTag:
+      tmpstream = stdin;
+      goto getc_common;
+    case System_getcTag:
+      if (tracer_input == NULL)
+	tracer_input = open_tty();
+      tmpstream = tracer_input;
+    getc_common:
+      {
+	int ch;
+	ch = klic_getc(tmpstream);
+	bufid = pvm_initsend(PvmDataRaw);
+	info = pvm_pkint(&ch, 1, 1);
+	info = pvm_send(dest_tid, 3);
+      }
+      break;
+    case User_ungetcTag:
+      info = pvm_upkbyte(buf, 1, 1);
+      ungetc(buf[0], stdin);
+      break;
+    case System_writeTag:
+    case User_ewriteTag:
+      tmpstream = stderr; goto write_common;
+    case User_writeTag:
+      tmpstream = stdout; goto write_common;
+    write_common:
+      {
+	long len;
+	char* write_buf;
+	long written = 0;
+	info = pvm_upklong(&len, 1, 1);
+	write_buf = (char*) malloc(len);
+	info = pvm_upkbyte(write_buf, len, 1);
+	while (written < len) {
+	  written += debug_fwrite(write_buf+written, 1, len, tmpstream);
+	}
+	free(write_buf);
+      }
+      break;
+    case System_fflushTag:
+    case User_efflushTag:
+      tmpstream = stderr; goto flush_common;
+    case User_fflushTag:
+      tmpstream = stdout; goto flush_common;
+    flush_common:
+      {
+	int result = debug_fflush(tmpstream);
+	bufid = pvm_initsend(PvmDataRaw);
+	info = pvm_pkint(&result, 1, 1);
+	info = pvm_send(dest_tid, 3);
+      }
+      break;
+
+    case System_putbTag:
+    case EPutbTag:
+      tmpstream = stderr; goto putb_common;
+    case PutbTag:
+      tmpstream = stdout;
+    putb_common:
+      info  = pvm_upkstr(buf);
+      debug_fprintf(tmpstream, "%s", buf);
+      break;
+
+    case GetsTag:
+      tmpstream = stdin; goto gets_common;
+    case System_getsTag:
+      if (tracer_input == NULL)
+	tracer_input = open_tty();
+      tmpstream = tracer_input;
+    gets_common:
+      {
+	char* ret;
+	ret = fgets(buf, 255, tmpstream);
+	if (ret == NULL)
+	  buf[0] = 0;
+	bufid = pvm_initsend(PvmDataRaw);
+	info = pvm_pkstr(buf);
+	info = pvm_send(dest_tid, 3);
+	break;
+      }
+    default:
+      debug_fprintf(stderr,"Unknown message %d\n", kind);
     }
-    /*mm = pvm_probe(-1,-1);*/
   }
 }
-int
+
+extern int
 #ifdef USE_STDARG
 io_client(enum io_tag msg_tag, ...)
 #else
 io_client(msg_tag, va_alist)
-enum io_tag msg_tag;
-va_dcl
+  enum io_tag msg_tag;
+  va_dcl
 #endif
 {
-    int bufid;
-    int info;
-    int msg = (int)msg_tag;
-    va_list args;
-    VA_START(args, msg_tag);
-
-    bufid = pvm_initsend(PvmDataRaw);
-
-    switch (msg_tag) {
-     case AttachTag:
-	has_attached = 1; goto simple_common;
-     case DetachTag:
-	has_attached = 0; goto simple_common;
-     case FinishTag:
-     case Emergency_stopTag:
-     simple_common:
-	info = pvm_pkint(&msg,1,1);
-	info = pvm_send(Tid_of_io(), 3);
-	break;
-     case System_putbTag:
-     case PutbTag:
-     case EPutbTag:
-	{
-	    char *str = va_arg(args, char *);
-	    info = pvm_pkint(&msg,1,1);
-	    info = pvm_pkstr(str);
-	    info = pvm_send(Tid_of_io(),3);
-	}
-	break;
-     case System_getsTag:
-     case GetsTag:
-	{
-	    char *str = va_arg(args, char *);
-	    info = pvm_pkint(&msg,1,1);
-	    info = pvm_send(Tid_of_io(),3);
-	    bufid = pvm_recv(Tid_of_io(),-1);
-	    info = pvm_upkstr(str);
-	}
-	break;
-     case System_putcTag:
-     case User_putcTag:
-     case User_eputcTag:
-	{
-	    char ch = va_arg(args, int);
-	    info = pvm_pkint(&msg,1,1);
-	    info = pvm_pkbyte(&ch,1,1);
-	    info = pvm_send(Tid_of_io(),3);
-	}
-	break;
-     case User_ungetcTag:
-        {
-	    char ch = va_arg(args, int);
-	    info = pvm_pkint(&msg,1,1);
-	    info = pvm_pkbyte(&ch,1,1);
-	    info = pvm_send(Tid_of_io(),3);
-	 }
-	break;
-     case System_writeTag:
-     case User_ewriteTag:
-     case User_writeTag:
-     write_common:
-	{
-	    char *write_buf = va_arg(args, char *);
-	    long len = va_arg(args, long);
-	    info = pvm_pkint(&msg,1,1);
-	    info = pvm_pklong(&len,1,1);
-	    info = pvm_pkbyte(write_buf, len, 1);
-	    info = pvm_send(Tid_of_io(), 3);
-	    break;
-	}
-     case System_fflushTag:
-     case User_fflushTag:
-     case User_efflushTag:
-     case User_getcTag:
-     case System_getcTag:
-     case System_IsEOFTag:
-	{
-	    int result;
-	    info = pvm_pkint(&msg,1,1);
-	    info = pvm_send(Tid_of_io(),3);
-	    bufid = pvm_recv(Tid_of_io(),-1);
-	    info = pvm_upkint(&result,1,1);
-	    va_end(args);
-	    return result;
-	}
-	break;
-    default:			/* must be program bug */
-	abort();
+  int bufid;
+  int info;
+  int msg = (int) msg_tag;
+  va_list args;
+  VA_START(args, msg_tag);
+
+  bufid = pvm_initsend(PvmDataRaw);
+
+  switch (msg_tag) {
+  case AttachTag:
+    has_attached = 1; goto simple_common;
+  case DetachTag:
+    has_attached = 0; goto simple_common;
+  case FinishTag:
+  case Emergency_stopTag:
+  simple_common:
+    info = pvm_pkint(&msg, 1, 1);
+    info = pvm_send(Tid_of_io(), 3);
+    break;
+
+  case System_putbTag:
+  case PutbTag:
+  case EPutbTag:
+    {
+      char* str = va_arg(args, char*);
+      info = pvm_pkint(&msg, 1, 1);
+      info = pvm_pkstr(str);
+      info = pvm_send(Tid_of_io(), 3);
+    }
+    break;
+  case System_getsTag:
+  case GetsTag:
+    {
+      char* str = va_arg(args, char*);
+      info = pvm_pkint(&msg, 1, 1);
+      info = pvm_send(Tid_of_io(), 3);
+      bufid = pvm_recv(Tid_of_io(), -1);
+      info = pvm_upkstr(str);
+    }
+    break;
+  case System_putcTag:
+  case User_putcTag:
+  case User_eputcTag:
+    {
+      char ch = va_arg(args, int);
+      info = pvm_pkint(&msg, 1, 1);
+      info = pvm_pkbyte(&ch, 1, 1);
+      info = pvm_send(Tid_of_io(), 3);
     }
-    va_end(args);
-    return 0;
+    break;
+  case User_ungetcTag:
+    {
+      char ch = va_arg(args, int);
+      info = pvm_pkint(&msg, 1, 1);
+      info = pvm_pkbyte(&ch, 1, 1);
+      info = pvm_send(Tid_of_io(), 3);
+    }
+    break;
+  case System_writeTag:
+  case User_ewriteTag:
+  case User_writeTag:
+    {
+      char* write_buf = va_arg(args, char*);
+      long len = va_arg(args, long);
+      info = pvm_pkint(&msg, 1, 1);
+      info = pvm_pklong(&len, 1, 1);
+      info = pvm_pkbyte(write_buf, len, 1);
+      info = pvm_send(Tid_of_io(), 3);
+      break;
+    }
+  case System_fflushTag:
+  case User_fflushTag:
+  case User_efflushTag:
+  case User_getcTag:
+  case System_getcTag:
+  case System_IsEOFTag:
+    {
+      int result;
+      info = pvm_pkint(&msg, 1, 1);
+      info = pvm_send(Tid_of_io(), 3);
+      bufid = pvm_recv(Tid_of_io(), -1);
+      info = pvm_upkint(&result, 1, 1);
+      va_end(args);
+      return result;
+    }
+    break;
+  default:			/* must be program bug */
+    abort();
+  }
+  va_end(args);
+  return 0;
 }
diff -ruN klic-3.003-2002-01-12a/runtime/config/pvm/distio.h klic-3.003-2002-01-13/runtime/config/pvm/distio.h
--- klic-3.003-2002-01-12a/runtime/config/pvm/distio.h	Mon Dec 31 12:04:47 2001
+++ klic-3.003-2002-01-13/runtime/config/pvm/distio.h	Sun Jan 13 13:46:21 2002
@@ -7,37 +7,12 @@
 /* PVM dependent I/O communication library */
 /* $Id: distio.h,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
 
-#include <klic/stdc.h>  /* VA_ARGS */
-
-enum io_tag {
-    FinishTag,
-    AttachTag,
-    DetachTag,
-    System_putbTag,
-    System_getsTag,
-    System_putcTag,
-    System_getcTag,
-    System_writeTag,
-    System_fflushTag,
-    PutbTag,
-    EPutbTag,
-    GetsTag,
-    User_putcTag,
-    User_eputcTag,
-    User_getcTag,
-    User_ungetcTag,
-    User_writeTag,
-    User_ewriteTag,
-    User_fflushTag,
-    User_efflushTag,
-    Emergency_stopTag,
-    System_IsEOFTag
-};
+#ifndef _KLIC_DISTIO_H_
+#define _KLIC_DISTIO_H_
 
+#include <klic/stdc.h>  /* VA_ARGS */
+#include <klic/distproc.h>
 
-int io_client VA_ARGS((enum io_tag msg_tag, ...));
-
-Extern int has_attached Init(0);
 #define CloseIO()		io_client(FinishTag)
 #define AttachIO()		if (!has_attached) io_client(AttachTag)
 #define DetachIO()		if(has_attached) io_client(DetachTag)
@@ -61,8 +36,32 @@
 #define EmergencyStop()		io_client(Emergency_stopTag)
 #define SystemIsEOF()		io_client(System_IsEOFTag)
 
-extern void ioprintf VA_ARGS((char *format, ...));
-extern void ioeprintf VA_ARGS((char *format, ...));
-extern void iosprintf VA_ARGS((char *format, ...));
+enum io_tag {
+  FinishTag,
+  AttachTag,
+  DetachTag,
+  System_putbTag,
+  System_getsTag,
+  System_putcTag,
+  System_getcTag,
+  System_writeTag,
+  System_fflushTag,
+  PutbTag,
+  EPutbTag,
+  GetsTag,
+  User_putcTag,
+  User_eputcTag,
+  User_getcTag,
+  User_ungetcTag,
+  User_writeTag,
+  User_ewriteTag,
+  User_fflushTag,
+  User_efflushTag,
+  Emergency_stopTag,
+  System_IsEOFTag };
 
-#include <klic/distproc.h>
+Extern int has_attached Init(0);
+
+extern int io_client VA_ARGS((enum io_tag msg_tag, ...));
+
+#endif /* _KLIC_DISTIO_H_ */
diff -ruN klic-3.003-2002-01-12a/runtime/config/pvm/distpkt.c klic-3.003-2002-01-13/runtime/config/pvm/distpkt.c
--- klic-3.003-2002-01-12a/runtime/config/pvm/distpkt.c	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2002-01-13/runtime/config/pvm/distpkt.c	Sun Jan 13 14:14:18 2002
@@ -6,18 +6,6 @@
 ----------------------------------------------------------- */
 /* 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>  /* fatal */
-#include <klic/struct.h>
-#include <klic/primitives.h>
-#include <klic/unify.h>
-#include "timing.h"
-
-#include <stdio.h>
-#include <signal.h>
-
-#include <klic/distio.h>
-#include "interpe.h"
-#include "rmon.h"
 
 /*
   Communication buffer management
@@ -37,216 +25,234 @@
   SEND_PACKET			void send_packet(node, sendbuf)
 */
 
+#include <klic/basic.h>  /* fatal */
+#include <klic/struct.h>
+#include <klic/primitives.h>
+#include <klic/unify.h>
+#include "timing.h"
+
+#include <stdio.h>
+#include <signal.h>
+
+#include <klic/distio.h>
+#include "interpe.h"
+#include "rmon.h"
+
 #define INITIAL_COMBUF_SIZE	0x10000	/* for inbuf and outbuf */
 
+extern int add_signal_handler();
+extern void call_at_time_intervals();
+extern int receive_message();
+extern int send_profile();
+extern int send_profile_trigger();
+extern void count_profile();
+extern q* set_simple_interval_timer_handler();
+
 /* Communication buffer management functions */
-combuf *
+static combuf*
 alloc_combuf(bufsize)
-long bufsize;
+  long bufsize;
 {
-    combuf *buf = (combuf *)malloc(sizeof(combuf));
-    if (!buf)
-      fatal("malloc failed in alloc_combuf (1)");
-    buf->buf_size = bufsize;
-    buf->buffer = (long *)malloc(bufsize * sizeof(long));
-    buf->rd_index = 0;		/* pointer for read */
-    buf->wt_index = 0;		/* pointer for write */
-    if (buf->buffer == NULL)
-      fatal("malloc failed in alloc_combuf (2)");
-    return buf;
+  combuf* buf = (combuf*) malloc(sizeof(combuf));
+  if (buf == NULL)
+    fatal("malloc failed in alloc_combuf (1)");
+  buf->buf_size = bufsize;
+  buf->buffer = (long*) malloc(bufsize * sizeof(long));
+  buf->rd_index = 0;		/* pointer for read */
+  buf->wt_index = 0;		/* pointer for write */
+  if (buf->buffer == NULL)
+    fatal("malloc failed in alloc_combuf (2)");
+  return buf;
 }
 
-static combuf *
+static combuf*
 realloc_combuf(inbuf, bufsize)
-combuf *inbuf;
-long bufsize;
+  combuf* inbuf;
+  long bufsize;
 {
-    inbuf->buffer = (long *)realloc((char *)inbuf->buffer,
-				    bufsize * sizeof(long));
-    if (inbuf->buffer == NULL)
-      return 0;
-    inbuf->buf_size = bufsize;
-    return inbuf;
+  inbuf->buffer = (long*) realloc((char*) inbuf->buffer, bufsize * sizeof(long));
+  if (inbuf->buffer == NULL)
+    return NULL;
+  inbuf->buf_size = bufsize;
+  return inbuf;
 }
 
-void *
+extern void
 free_combuf(buf)
-combuf *buf;
+  combuf* buf;
 {
-    free(buf->buffer);
-    free(buf);
+  free(buf->buffer);
+  free(buf);
 }
+
 /* backup_combuf() is called only within message_suspend() */
-combuf *
+extern combuf*
 backup_combuf(buf)
-combuf *buf;
+  combuf* buf;
 {
-    combuf *retbuf;
+  combuf* retbuf;
 
-    /* backup the contents of BUF into newly created combuf  */
-    retbuf = alloc_combuf(buf->wt_index);
-    BCOPY((char *)buf->buffer, (char *)retbuf->buffer,
-	  sizeof(long)* buf->wt_index);
-    retbuf->wt_index = buf->wt_index;
-    retbuf->rd_index = buf->rd_index;
-    buf->wt_index = 0;		/* Clear the write buffer */
-    return retbuf;
+  /* backup the contents of BUF into newly created combuf  */
+  retbuf = alloc_combuf(buf->wt_index);
+  BCOPY((char*) buf->buffer, (char*) retbuf->buffer,
+	sizeof(long)* buf->wt_index);
+  retbuf->wt_index = buf->wt_index;
+  retbuf->rd_index = buf->rd_index;
+  buf->wt_index = 0;		/* Clear the write buffer */
+  return retbuf;
 }
 
 /* expand_outbuf() is called only within the macro PUT_BUFFER() */
-void
+extern void
 expand_outbuf(outbuf)
-combuf *outbuf;
+  combuf* outbuf;
 {
-    /* always double the size */
-    /* expand_outbuf() must expand the buffer at least 4-words.
-       Otherwise, PUT4_BUFFER() in distpkt.h will crash.        */ 
-    declare_globals;       
-    long bufsize = outbuf->buf_size * 2;
-    outbuf = realloc_combuf(outbuf, bufsize);
-    if (!outbuf)
-      fatal("realloc failed in expanding outbuf");
-    ioprintf("PE %d outbuf expanded to %d\n", my_node, bufsize);
+  /* always double the size */
+  /* expand_outbuf() must expand the buffer at least 4-words.
+     Otherwise, PUT4_BUFFER() in distpkt.h will crash.        */
+  declare_globals;
+  long bufsize = outbuf->buf_size * 2;
+  outbuf = realloc_combuf(outbuf, bufsize);
+  if (outbuf == NULL)
+    fatal("realloc failed in expanding outbuf");
+  ioprintf("PE %d outbuf expanded to %d\n", my_node, bufsize);
 }
 
-void
+extern void
 init_comm()
 {
-    /* initialize out buffer */
-    kumon_outbuf = alloc_combuf(INITIAL_COMBUF_SIZE);
-    /* initialize in buffer */
-    kumon_inbuf = alloc_combuf(INITIAL_COMBUF_SIZE);
-    /* allow faster PVM message passing */
-    pvm_setopt(PvmRoute, PvmAllowDirect);
+  /* initialize out buffer */
+  kumon_outbuf = alloc_combuf(INITIAL_COMBUF_SIZE);
+  /* initialize in buffer */
+  kumon_inbuf = alloc_combuf(INITIAL_COMBUF_SIZE);
+  /* allow faster PVM message passing */
+  pvm_setopt(PvmRoute, PvmAllowDirect);
 }
-void
+
+extern void
 io_init_comm()
 {}
 
-void
+extern void
 init_dist_signal_setup()
 {
-    declare_globals;
-    int add_signal_handler();
-    void call_at_time_intervals();
-    int receive_message();
-    int send_profile();
-    int send_profile_trigger();
-    void count_profile();
+  declare_globals;
 
-    q *set_simple_interval_timer_handler();
+  add_signal_handler(SIGUSR1, receive_message);
 
-    add_signal_handler(SIGUSR1, receive_message);
 #ifdef USETIMER
-    if(rmonnode){
-	if (IS_SHOEN_NODE(my_node)){
-	    struct itimerval interval;
-	    long isec, usec;
-	    heapp = set_simple_interval_timer_handler(heapp, 
-						      PROF_GATHER_INTERVAL_SEC,
-						      0, send_profile_trigger);
-	}else {	
-	    call_at_time_intervals(0, PROF_SAMPLE_INTERVAL_uSEC, 
-				   count_profile);
-/*	    add_signal_handler(SIGUSR2, send_profile);*/
-	}
+  if(rmonnode){
+    if (IS_SHOEN_NODE(my_node)){
+      struct itimerval interval;
+      long isec, usec;
+      heapp = set_simple_interval_timer_handler(heapp,
+						PROF_GATHER_INTERVAL_SEC,
+						0, send_profile_trigger);
+    }else{
+      call_at_time_intervals(0, PROF_SAMPLE_INTERVAL_uSEC, count_profile);
+      /* add_signal_handler(SIGUSR2, send_profile); */
     }
+  }
 
-    if (!noitimer) {
-	struct itimerval interval;
-	long isec, usec;
-	if (interval_usec == 0)
-	  interval_usec = 10000;
-	isec = interval_usec / 1000000;
-	usec = interval_usec % 1000000;
-	heapp = set_simple_interval_timer_handler(heapp, isec, usec,
-						  receive_message);
-    }
-#endif
+  if (!noitimer) {
+    struct itimerval interval;
+    long isec, usec;
+    if (interval_usec == 0)
+      interval_usec = 10000;
+    isec = interval_usec / 1000000;
+    usec = interval_usec % 1000000;
+    heapp = set_simple_interval_timer_handler(heapp, isec, usec,
+					      receive_message);
+  }
+#endif /* USETIMER */
 }
 
 /* Raw packet send/receive functions */
-combuf *
+extern combuf*
 receive_packet(heap_neededp)
-long *heap_neededp;	/* this variable will be obsoleted in the future. */
+  long* heap_neededp;	/* this variable will be obsoleted in the future. */
 {
-    declare_globals;
-    long last_index;
-    int buf_id;
-    int bufsize;
-    int info;
-    combuf *inbuf = kumon_inbuf;
-    buf_id = pvm_nrecv(-1, -1);
-    if (!buf_id)
-      return 0;		/* no message arrived */
-    {
-	int msgtag, tid;
-	info = pvm_bufinfo(buf_id, &bufsize, &msgtag, &tid);
-	if(info < 0)
-	  fatal("Error in pvm_bufinfo\n");
+  declare_globals;
+  long last_index;
+  int buf_id;
+  int bufsize;
+  int info;
+  combuf* inbuf = kumon_inbuf;
+  buf_id = pvm_nrecv(-1, -1);
+  if (!buf_id)
+    return NULL;		/* no message arrived */
+
+  {
+    int msgtag, tid;
+    info = pvm_bufinfo(buf_id, &bufsize, &msgtag, &tid);
+    if(info < 0)
+      fatal("Error in pvm_bufinfo\n");
+  }
+  last_index = bufsize / sizeof(long);
+  if (last_index > inbuf->buf_size)
+    if (realloc_combuf(inbuf, last_index)) {
+      ioprintf("PE %d inbuf expanded to %d\n", my_node, bufsize);
+    } else {
+      fatal("realloc failed in expanding inbuf");
     }
-    last_index = bufsize / sizeof(long);
-    if (last_index > inbuf->buf_size)
-      if (realloc_combuf(inbuf, last_index)) {
-	  ioprintf("PE %d inbuf expanded to %d\n", my_node, bufsize);
-      } else {
-	  fatal("realloc failed in expanding inbuf");
-      }
-    info = pvm_upklong(inbuf->buffer, last_index, 1);
-    if (info < 0)
-      fatal("Error in pvm_upk\n");
-    inbuf->wt_index = last_index;
-    inbuf->rd_index = 0;  /* clear rd_index */
-    INT_CL_PROBE_X(netstat.recv_data_siz += bufsize);
-    *heap_neededp = last_index * DECODE_MAX_OBJ_RATIO;
-    return inbuf;
+  info = pvm_upklong(inbuf->buffer, last_index, 1);
+  if (info < 0)
+    fatal("Error in pvm_upk\n");
+  inbuf->wt_index = last_index;
+  inbuf->rd_index = 0;  /* clear rd_index */
+  INT_CL_PROBE_X(netstat.recv_data_siz += bufsize);
+  *heap_neededp = last_index * DECODE_MAX_OBJ_RATIO;
+  return inbuf;
 }
 
-void
+extern void
 send_packet(node, sendbuf)
-long node;
-combuf *sendbuf;
+  long node;
+  combuf* sendbuf;
 {
-    int info;
+  int info;
 
-    info = pvm_initsend(PvmDataRaw);
-    if (info < 0)
-      fatal("Error in pvm_initsend\n");
-    info = pvm_pklong(sendbuf->buffer, sendbuf->wt_index, 1);
-    if (info < 0)
-      fatal("Error in pvm_pklong\n");
-    info = pvm_send(Tid_of(node),3);
-    if (info < 0)
-      fatal("Error in pvm_send\n");
-    INT_CL_PROBE_X(netstat.send_data_siz += sendbuf->wt_index * sizeof(long));
-
-    sendbuf->wt_index = 0;
-    if (!no_sendsig) {
-	info = pvm_sendsig(Tid_of(node), SIGUSR1);
-	if (info != 0) {
-	    ioprintf("PVM_SENDSIG_ERROR sig_info = %d\n",info);
-	}
+  info = pvm_initsend(PvmDataRaw);
+  if (info < 0)
+    fatal("Error in pvm_initsend\n");
+  info = pvm_pklong(sendbuf->buffer, sendbuf->wt_index, 1);
+  if (info < 0)
+    fatal("Error in pvm_pklong\n");
+  info = pvm_send(Tid_of(node), 3);
+  if (info < 0)
+    fatal("Error in pvm_send\n");
+  INT_CL_PROBE_X(netstat.send_data_siz += sendbuf->wt_index * sizeof(long));
+
+  sendbuf->wt_index = 0;
+  if (!no_sendsig) {
+    info = pvm_sendsig(Tid_of(node), SIGUSR1);
+    if (info != 0) {
+      ioprintf("PVM_SENDSIG_ERROR sig_info = %d\n", info);
     }
+  }
 }
-void
+
+extern void
 close_network()
 {
-    pvm_exit();
+  pvm_exit();
 }
+
 struct recv_int_stat recv_int_stat[NSIG];
-char *
+
+extern char*
 print_interrupt_statistics(ptr)
-char *ptr;
+  char* ptr;
 {
-    sprintf(ptr, " sigalrm=(%d+%d)/%d, sigio=(%d+%d)/%d, sigusr1=(%d+%d)/%d\n",
-	    recv_int_stat[SIGALRM].usefull,
-	    recv_int_stat[SIGALRM].useless,
-	    recv_int_stat[SIGALRM].enter,
-	    recv_int_stat[SIGIO].usefull,
-	    recv_int_stat[SIGIO].useless,
-	    recv_int_stat[SIGIO].enter,
-	    recv_int_stat[SIGUSR1].usefull,
-	    recv_int_stat[SIGUSR1].useless,
-	    recv_int_stat[SIGUSR1].enter);
-    return strlen(ptr)+ptr;
+  sprintf(ptr, " sigalrm=(%d+%d)/%d, sigio=(%d+%d)/%d, sigusr1=(%d+%d)/%d\n",
+	  recv_int_stat[SIGALRM].usefull,
+	  recv_int_stat[SIGALRM].useless,
+	  recv_int_stat[SIGALRM].enter,
+	  recv_int_stat[SIGIO].usefull,
+	  recv_int_stat[SIGIO].useless,
+	  recv_int_stat[SIGIO].enter,
+	  recv_int_stat[SIGUSR1].usefull,
+	  recv_int_stat[SIGUSR1].useless,
+	  recv_int_stat[SIGUSR1].enter );
+  return ptr + strlen(ptr);
 }
diff -ruN klic-3.003-2002-01-12a/runtime/config/pvm/distpkt.h klic-3.003-2002-01-13/runtime/config/pvm/distpkt.h
--- klic-3.003-2002-01-12a/runtime/config/pvm/distpkt.h	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2002-01-13/runtime/config/pvm/distpkt.h	Sun Jan 13 14:29:18 2002
@@ -6,6 +6,7 @@
 ----------------------------------------------------------- */
 /* PVM dependent inter-pe communication library */
 /* $Id: distpkt.h,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
+
 #include <pvm3.h>
 
 /* Maximum ratio of the output KL1 words created by one communication word. */
@@ -14,16 +15,16 @@
 
 /* Network Buffer Type */
 typedef struct {
-    long *buffer;		/* pointer to the actual buffer */
-    long rd_index;		/* pointer used for reading */
-    long wt_index;		/* pointer used for writing */
-    long buf_size;		/* the physical size of buffer */
+  long* buffer;		/* pointer to the actual buffer */
+  long rd_index;		/* pointer used for reading */
+  long wt_index;		/* pointer used for writing */
+  long buf_size;		/* the physical size of buffer */
 } combuf;
 
-Extern combuf *kumon_inbuf;	/* for input packet */
-Extern combuf *kumon_outbuf;	/* for output packet */
+Extern combuf* kumon_inbuf;	/* for input packet */
+Extern combuf* kumon_outbuf;	/* for output packet */
 
-Extern combuf *pending_msg Init(0);
+Extern combuf* pending_msg Init(0);
 
 /* Buffer I/O primitives and its associates */
 #define IS_BUFFER_EMPTY(inbuf)	((inbuf)->rd_index == (inbuf)->wt_index)
@@ -31,35 +32,36 @@
 #define GET_BUFFER(inbuf)	((inbuf)->buffer[(inbuf)->rd_index++])
 
 #define PUT_BUFFER(outbuf, data) 				\
-{								\
+do{								\
     (outbuf)->buffer[(outbuf)->wt_index] = (long)(data);	\
     (outbuf)->wt_index++;					\
     if ((outbuf)->wt_index >= (outbuf)->buf_size){		\
 	expand_outbuf(outbuf);					\
     }								\
-}
+}while(0)
+
 /* The followings are needed to optimize the buffer operations */
 #define PUT2_BUFFER(outbuf, data, data1)			\
-{								\
+do{								\
     if ((outbuf)->wt_index + 2 >= (outbuf)->buf_size)		\
 	expand_outbuf(outbuf);					\
     (outbuf)->buffer[(outbuf)->wt_index] = (long)(data);	\
     (outbuf)->buffer[(outbuf)->wt_index+1] = (long)(data1);	\
     (outbuf)->wt_index += 2;					\
-}
+}while(0)
 
 #define PUT3_BUFFER(outbuf, data, data1, data2)			\
-{								\
+do{								\
     if ((outbuf)->wt_index + 3 >= (outbuf)->buf_size)		\
 	expand_outbuf(outbuf);					\
     (outbuf)->buffer[(outbuf)->wt_index] = (long)(data);	\
     (outbuf)->buffer[(outbuf)->wt_index + 1] = (long)(data1);	\
     (outbuf)->buffer[(outbuf)->wt_index + 2] = (long)(data2);	\
     (outbuf)->wt_index += 3;					\
-}
+}while(0)
 
 #define PUT4_BUFFER(outbuf, data, data1, data2, data3)		\
-{								\
+do{								\
     if ((outbuf)->wt_index + 4 >= (outbuf)->buf_size)		\
 	expand_outbuf(outbuf);					\
     (outbuf)->buffer[(outbuf)->wt_index] = (long)(data);	\
@@ -67,26 +69,30 @@
     (outbuf)->buffer[(outbuf)->wt_index + 2] = (long)(data2);	\
     (outbuf)->buffer[(outbuf)->wt_index + 3] = (long)(data3);	\
     (outbuf)->wt_index += 4;					\
-}
+}while(0)
 
 struct recv_int_stat {
     long enter;
     long usefull;
     long useless;
 };
+
+extern struct recv_int_stat recv_int_stat[NSIG];
+
 #define INTERRUPT_RECEIVE_STAT0(SIG)	\
-{						\
-    extern struct recv_int_stat recv_int_stat[NSIG];	\
+do{						\
     recv_int_stat[SIG].enter++;			\
-}
+}while(0)
+
 #define INTERRUPT_RECEIVE_STAT1(SIG,RECV)	\
-{						\
-    extern struct recv_int_stat recv_int_stat[NSIG];	\
+do{						\
     if (RECV) recv_int_stat[SIG].usefull++;	\
     else      recv_int_stat[SIG].useless++;	\
-}
+}while(0)
+
+extern char* print_interrupt_statistics();
+
 #define MACDEP_DIST_STATISTICS()		\
-{						\
-    extern char * print_interrupt_statistics();	\
+do{						\
     ptr = print_interrupt_statistics(ptr);	\
-}
+}while(0)
diff -ruN klic-3.003-2002-01-12a/runtime/config/pvm/distproc.c klic-3.003-2002-01-13/runtime/config/pvm/distproc.c
--- klic-3.003-2002-01-12a/runtime/config/pvm/distproc.c	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-13/runtime/config/pvm/distproc.c	Sun Jan 13 15:56:44 2002
@@ -6,6 +6,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>  /* klic_fprintf */
 #include <klic/struct.h>
@@ -14,6 +15,7 @@
 #include "interpe.h"
 #include "rmon.h"
 #include <signal.h>
+
 #ifdef USEPROCBIND
 #include <unistd.h>
 #include <sys/processor.h>
@@ -21,18 +23,9 @@
 #endif
 
 #include "options.h"
-
 #include <stdlib.h>
 
 #define SYNCID_SPAWN 0x3193
-/*
-  char *expand_prog_name(buffer, progname)
-  static void setup_send_args(opttable)
-  static void recv_extract_args(opttable)
-  static int io_spawn_children(num_child, opttable, prog_name, argc, argv)
-  static int child_spawn_children(par_tid, opttable, prog_name, argc, argv)
-  int spawn_children(num_child, opttable, prog_name, argc, argv)
-  */
 
 #define OPT_DEBUG(X) 
 
@@ -42,496 +35,525 @@
 #define NHOSTNAMEBUF  10
 #define HOSTNAMETABLESIZE 2
 
-static int nhostnames, hostnamebufsize;
-static char *hostnamebuf;
-static char **hostnametable;
-static char **gethostnametable()
-{
- FILE *cfile;
- char *cfilename, *dirname;
-
- if (NULL == (dirname = getenv("HOME"))) return 0;
- cfilename = (char *) malloc(strlen(dirname)+strlen(CONFIGFILENAME)+1);
- strcpy(cfilename, dirname);
- strcat(cfilename, CONFIGFILENAME);
-
- cfile = fopen(cfilename,"r");
-
- if (cfile) {
-  int tablesize = NHOSTNAMEBUF,
-      realtablesize = NHOSTNAMEBUF,
-      readsize, hosttablesize, p0;
-  char *tmphostnamebuf;
-  tmphostnamebuf = hostnamebuf = (char *)malloc(realtablesize);
-  readsize = fread(tmphostnamebuf, 1, tablesize, cfile);
-  while (!feof(cfile)) {
-    if (readsize < tablesize) tablesize -= readsize;
-    else {
-      int tmprealtablesize = 2*realtablesize;
-      if (hostnamebuf = (char *)realloc(hostnamebuf, tmprealtablesize)) {
-        tmphostnamebuf = hostnamebuf+realtablesize;
-        realtablesize = tmprealtablesize;
-      } else { klic_fprintf(stderr, "can't get memory\n"); exit(1); }
-    }
+extern int main();
+
+static int nhostnames;
+
+static char**
+gethostnametable()
+{
+  FILE* cfile;
+  char* cfilename;
+  char* dirname;
+
+  dirname = getenv("HOME");
+  if (dirname == NULL) return NULL;
+
+  cfilename = (char*) malloc(strlen(dirname)+strlen(CONFIGFILENAME)+1);
+  strcpy(cfilename, dirname);
+  strcat(cfilename, CONFIGFILENAME);
+
+  cfile = fopen(cfilename, "r");
+  if (cfile == NULL) return NULL;
+
+  {
+    int hostnamebufsize;
+    char* hostnamebuf;
+    char** hostnametable;
+    int tablesize = NHOSTNAMEBUF;
+    int realtablesize = NHOSTNAMEBUF;
+    int readsize, hosttablesize, p0;
+    char* tmphostnamebuf;
+    tmphostnamebuf = hostnamebuf = (char*) malloc(realtablesize);
     readsize = fread(tmphostnamebuf, 1, tablesize, cfile);
-  }
-  fclose(cfile);
-  hostnamebufsize = realtablesize - (tablesize - readsize);
+    while (!feof(cfile)) {
+      if (readsize < tablesize) tablesize -= readsize;
+      else {
+	int tmprealtablesize = 2*realtablesize;
+	hostnamebuf = (char*) realloc(hostnamebuf, tmprealtablesize);
+	if (hostnamebuf != NULL) {
+	  tmphostnamebuf = hostnamebuf+realtablesize;
+	  realtablesize = tmprealtablesize;
+	} else {
+	  klic_fprintf(stderr, "can't get memory\n");
+	  exit(1);
+	}
+      }
+      readsize = fread(tmphostnamebuf, 1, tablesize, cfile);
+    }
+    fclose(cfile);
+    hostnamebufsize = realtablesize - (tablesize - readsize);
 
-  hosttablesize = HOSTNAMETABLESIZE;
-  hostnametable = (char **)malloc(hosttablesize*sizeof(char *));
-  nhostnames = 0;
-  p0 = 0;
-  for (;;) {
-    for (; (hostnamebuf[p0] == '\n' && p0 < hostnamebufsize); p0++);
-    if (p0 >= hostnamebufsize) break;
-    if (hosttablesize <= nhostnames) {
-      hosttablesize *= 2;
-      if (!(hostnametable = (char **)realloc(hostnametable, 
-					     sizeof(char *)*hosttablesize))){
-      	  klic_fprintf(stderr, "can't get memory\n"); exit(1); }
+    hosttablesize = HOSTNAMETABLESIZE;
+    hostnametable = (char**) malloc(hosttablesize*sizeof(char*));
+    nhostnames = 0;
+    for( p0 = 0; ; p0++ ){
+      for( ; ; p0++ ){
+	if( p0 >= hostnamebufsize ) goto end_for;
+	if( hostnamebuf[p0] != '\n' ) break;
+      }
+      if (hosttablesize <= nhostnames) {
+	hosttablesize *= 2;
+	hostnametable = (char**) realloc(hostnametable,
+					 sizeof(char*) * hosttablesize);
+	if (hostnametable == NULL){
+	  klic_fprintf(stderr, "can't get memory\n");
+	  exit(1);
+	}
+      }
+      hostnametable [nhostnames] = &(hostnamebuf[p0]);
+      for( p0++; ; p0++ ){
+	if( p0 >= hostnamebufsize ) goto end_for;
+	if( hostnamebuf[p0] == '\n' ) break;
+      }
+      nhostnames++;
+      hostnamebuf[p0] = '\0';
     }
-    hostnametable [nhostnames] = &(hostnamebuf[p0]);
-    for (p0++; (hostnamebuf[p0] != '\n' && p0 < hostnamebufsize); p0++);
-    if (p0 >= hostnamebufsize) break;
-    nhostnames++;
-    hostnamebuf[p0++] = 0;
-  }
-  if (!nhostnames) {
-    free(hostnametable);
-    free(hostnamebuf);
-    return 0;
-  } else return hostnametable; 
- } else return 0;
+  end_for:
+    if (nhostnames == 0) {
+      free(hostnametable);
+      free(hostnamebuf);
+      return NULL;
+    } else return hostnametable;
+  }
 }
 
 /* distprocs */   
 
-void
+extern void
 kill_child()
 {
-    int i;
-    int mytid;
-    mytid = pvm_mytid();
-    for (i = 0; i < tid_table.child_count; i++) {
-	if (Tid_of(i) > 0 && mytid != Tid_of(i))
-	  pvm_kill(Tid_of(i));
-    }
-    pvm_exit();
+  int i;
+  int mytid;
+  mytid = pvm_mytid();
+  for (i = 0; i < tid_table.child_count; i++) {
+    if (Tid_of(i) > 0 && mytid != Tid_of(i))
+      pvm_kill(Tid_of(i));
+  }
+  pvm_exit();
 }
 
-void
+extern void
 child_sync(syncid)
-int syncid;
+  int syncid;
 {
-    int info;
-    info = pvm_initsend(PvmDataRaw);
-    info = pvm_pkint(&syncid, 1, 1);
-    info = pvm_send(Tid_of_io(), 3);
+  int info;
+  info = pvm_initsend(PvmDataRaw);
+  info = pvm_pkint(&syncid, 1, 1);
+  info = pvm_send(Tid_of_io(), 3);
 }
-void
+
+extern void
 io_wait_sync(syncid)
-int syncid;
+  int syncid;
 {
-    int i;
-    for (i = 0; i < tid_table.child_count; ++i) {
-	int syncid_recv;
-	int info;
-	info = pvm_recv(Tid_of(i), -1);
-	info = pvm_upkint(&syncid_recv, 1, 1);
-	if (syncid != syncid_recv) {
-	    klic_fprintf(stderr,
-			 "IOnode sync-error expected %d but %d at pe%d\n",
-			 syncid, syncid_recv, i);
-	    exit(1);
-	}
-    }
-}
-void
-child_wait_sync(syncid)
-int syncid;
-{
-    declare_globals;
-    int info;
+  int i;
+  for (i = 0; i < tid_table.child_count; ++i) {
     int syncid_recv;
-    info = pvm_recv(Tid_of_io(), -1);
+    int info;
+    info = pvm_recv(Tid_of(i), -1);
     info = pvm_upkint(&syncid_recv, 1, 1);
     if (syncid != syncid_recv) {
-	klic_fprintf(stderr, "%d: sync-error expected %d but %d\n",
-		     my_node, syncid, syncid_recv);
-	exit(1);
+      klic_fprintf(stderr,
+		   "IOnode sync-error expected %d but %d at pe%d\n",
+		   syncid, syncid_recv, i);
+      exit(1);
     }
+  }
+}
+
+extern void
+child_wait_sync(syncid)
+  int syncid;
+{
+  declare_globals;
+  int info;
+  int syncid_recv;
+  info = pvm_recv(Tid_of_io(), -1);
+  info = pvm_upkint(&syncid_recv, 1, 1);
+  if (syncid != syncid_recv) {
+    klic_fprintf(stderr, "%d: sync-error expected %d but %d\n",
+		 my_node, syncid, syncid_recv);
+    exit(1);
+  }
 }
-void
+
+extern void
 io_sync(syncid)
-int syncid;
+  int syncid;
 {
-    int i;
+  int i;
+  int info;
+  info = pvm_initsend(PvmDataRaw);
+  info = pvm_pkint(&syncid, 1, 1);
+  for (i = 0; i < tid_table.child_count; ++i) {
     int info;
-    info = pvm_initsend(PvmDataRaw);
-    info = pvm_pkint(&syncid, 1, 1);
-    for (i = 0; i < tid_table.child_count; ++i) {
-	int info;
-	info = pvm_send(Tid_of(i), 1);
-    }
+    info = pvm_send(Tid_of(i), 1);
+  }
 }
 
 static void
 sigint_handler()
 {
-    klic_fprintf(stdout, "kill tasks in children_spawn()\n");
-    kill_child();
-    exit(1);
+  klic_fprintf(stdout, "kill tasks in children_spawn()\n");
+  kill_child();
+  exit(1);
 }
 
-static char *
+static char*
 expand_prog_name(buffer, progname)
-char *buffer;
-char *progname;
+  char* buffer;
+  char* progname;
 {
-    char dir[256];
-    if (rel_spawn_path || progname[0] == '/') {
-	strcpy(buffer, progname);
-    } else {
-	getcwd(dir, 255);
-	sprintf(buffer, "%s/%s", dir, progname);
-    }
-    if (network_statistics_flag)
-      klic_fprintf(stderr, "%s\n", buffer);
-    return buffer;
+  char dir[256];
+  if (rel_spawn_path || progname[0] == '/') {
+    strcpy(buffer, progname);
+  } else {
+    getcwd(dir, 255);
+    sprintf(buffer, "%s/%s", dir, progname);
+  }
+  if (network_statistics_flag)
+    klic_fprintf(stderr, "%s\n", buffer);
+  return buffer;
 }
 
 static void
 setup_send_args(opttable)
   const struct opttable* opttable;
 {
-    int i;
-    for (i = 0; opttable[i].opt_str; ++i) {
-	if (ARG_SHOULD_NOT_COPY(opttable[i].opt_type))
-	  continue;
-	switch (ARG_ORIGINAL_TYPE(opttable[i].opt_type)) {
-	 case ARG_DOUBLE:
-	    pvm_pkdouble(&(opttable[i].opt_dest->d), 1, 1);
-	    break;
-	 case ARG_SIZE:
-	    pvm_pklong(&(opttable[i].opt_dest->l), 1, 1);
-	    break;
-	 case ARG_RESET:
-	 case ARG_SET:
-	    pvm_pkint(&(opttable[i].opt_dest->i), 1, 1);
-	    break;
-	 case ARG_STRING:
-	    {
-		int len;
-		if (!opttable[i].opt_dest->s) {
-		    /* When the option is not set */
-		    len = -1;
-		    pvm_pkint(&len, 1, 1);
-		} else {
-		    len = strlen(opttable[i].opt_dest->s);
-		    pvm_pkint(&len, 1, 1);
-		    pvm_pkstr(opttable[i].opt_dest->s);
-		}
-	    }
-	    break;
+  int i;
+  for (i = 0; opttable[i].opt_str; ++i) {
+    if (ARG_SHOULD_NOT_COPY(opttable[i].opt_type))
+      continue;
+
+    switch (ARG_ORIGINAL_TYPE(opttable[i].opt_type)) {
+    case ARG_DOUBLE:
+      pvm_pkdouble(&(opttable[i].opt_dest->d), 1, 1);
+      break;
+    case ARG_SIZE:
+      pvm_pklong(&(opttable[i].opt_dest->l), 1, 1);
+      break;
+    case ARG_RESET:
+    case ARG_SET:
+      pvm_pkint(&(opttable[i].opt_dest->i), 1, 1);
+      break;
+    case ARG_STRING:
+      {
+	int len;
+	if (!opttable[i].opt_dest->s) {
+	  /* When the option is not set */
+	  len = -1;
+	  pvm_pkint(&len, 1, 1);
+	} else {
+	  len = strlen(opttable[i].opt_dest->s);
+	  pvm_pkint(&len, 1, 1);
+	  pvm_pkstr(opttable[i].opt_dest->s);
 	}
+      }
+      break;
     }
+  }
 }
 
 static void
 recv_extract_args(opttable)
   const struct opttable* opttable;
 {
-    int i;
-    for (i = 0; opttable[i].opt_str; ++i) {
-	if (ARG_SHOULD_NOT_COPY(opttable[i].opt_type))
-	  continue;
-	switch (ARG_ORIGINAL_TYPE(opttable[i].opt_type)) {
-	 case ARG_DOUBLE:
-	    pvm_upkdouble(&(opttable[i].opt_dest->d), 1, 1);
-	    OPT_DEBUG(klic_fprintf(stderr, "%s=%f\n", opttable[i].opt_str,
-				   opttable[i].opt_dest->d));
-	    break;
-	 case ARG_SIZE:
-	    pvm_upklong(&(opttable[i].opt_dest->l), 1, 1);
-	    OPT_DEBUG(klic_fprintf(stderr, "%s=%ld\n",
-				   opttable[i].opt_str,
-				   opttable[i].opt_dest->l));
-	    break;
-	 case ARG_RESET:
-	 case ARG_SET:
-	    pvm_upkint(&(opttable[i].opt_dest->i), 1, 1);
-	    OPT_DEBUG(klic_fprintf(stderr, "%s=%d\n",
-				   opttable[i].opt_str,
-				   opttable[i].opt_dest->i));
-	    break;
-	 case ARG_STRING:
-	    {
-		int len;
-		char *recv_str;
-		pvm_upkint(&len, 1, 1);
-		if (len < 0)
-		  /* When the option is not set */
-		  opttable[i].opt_dest->s = NULL;
-		else {
-		    recv_str = malloc(len+1);
-		    pvm_upkstr(recv_str);
-		    opttable[i].opt_dest->s = recv_str;
-		    OPT_DEBUG(klic_fprintf(stderr,
-					   "%s=%s\n", opttable[i].opt_str,
-					   opttable[i].opt_dest->s));
-		}
-	    }
-	    break;
+  int i;
+  for (i = 0; opttable[i].opt_str; ++i) {
+    if (ARG_SHOULD_NOT_COPY(opttable[i].opt_type))
+      continue;
+
+    switch (ARG_ORIGINAL_TYPE(opttable[i].opt_type)) {
+    case ARG_DOUBLE:
+      pvm_upkdouble(&(opttable[i].opt_dest->d), 1, 1);
+      OPT_DEBUG(klic_fprintf(stderr, "%s=%f\n", opttable[i].opt_str,
+			     opttable[i].opt_dest->d));
+      break;
+    case ARG_SIZE:
+      pvm_upklong(&(opttable[i].opt_dest->l), 1, 1);
+      OPT_DEBUG(klic_fprintf(stderr, "%s=%ld\n",
+			     opttable[i].opt_str,
+			     opttable[i].opt_dest->l));
+      break;
+    case ARG_RESET:
+    case ARG_SET:
+      pvm_upkint(&(opttable[i].opt_dest->i), 1, 1);
+      OPT_DEBUG(klic_fprintf(stderr, "%s=%d\n",
+			     opttable[i].opt_str,
+			     opttable[i].opt_dest->i));
+      break;
+    case ARG_STRING:
+      {
+	int len;
+	char* recv_str;
+	pvm_upkint(&len, 1, 1);
+	if (len < 0) {
+	  /* When the option is not set */
+	  opttable[i].opt_dest->s = NULL;
+	} else {
+	  recv_str = malloc(len+1);
+	  pvm_upkstr(recv_str);
+	  opttable[i].opt_dest->s = recv_str;
+	  OPT_DEBUG(klic_fprintf(stderr,
+				 "%s=%s\n", opttable[i].opt_str,
+				 opttable[i].opt_dest->s));
 	}
+      }
+      break;
     }
+  }
 }
 
 static int
 io_spawn_children(num_child, opttable, prog_name, argc, argv)
-int num_child;
-const struct opttable* opttable;
-char *prog_name;
-int argc;
-char **argv;
-{
-    char binname[256];
-    char arg_buf[20];
-    int ntask;
-    int *pid_tbl;
-    int i;
-
-    pid_tbl = (int *)calloc(num_child, sizeof(int));
-
-    Tid_of_io() = pvm_mytid();
-    tid_table.child = (int *)calloc(num_child, sizeof(int));
-    tid_table.child_count = num_child;
-    if (Tid_of_io() < 0) {
-	klic_fprintf(stderr, "PVM has not been started!!\n");
-	exit(1);
-    }
-    expand_prog_name(binname, prog_name);
-    sprintf(arg_buf, "-%s%d", OPT_PARENT_TID, Tid_of_io());
+  int num_child;
+  const struct opttable* opttable;
+  char* prog_name;
+  int argc;
+  char** argv;
+{
+  char binname[256];
+  char arg_buf[20];
+  int ntask;
+  int* pid_tbl;
+  int i;
+
+  pid_tbl = (int*) calloc(num_child, sizeof(int));
+
+  Tid_of_io() = pvm_mytid();
+  tid_table.child = (int*) calloc(num_child, sizeof(int));
+  tid_table.child_count = num_child;
+  if (Tid_of_io() < 0) {
+    klic_fprintf(stderr, "PVM has not been started!!\n");
+    exit(1);
+  }
+  expand_prog_name(binname, prog_name);
+  sprintf(arg_buf, "-%s%d", OPT_PARENT_TID, Tid_of_io());
+  {
+    char** sargv = (char**) malloc(sizeof(char*) * (argc + 3));
+    sargv[0] = arg_buf;
+    sargv[1] = "--";
+    for (i = 0; i < argc; ++i)
+      sargv[2+i] = argv[i];
+    sargv[2+argc] = 0;
+    /*  preliminary patch for host configuration */
     {
-      char **sargv = (char **)malloc(sizeof(char *) * (argc + 3));
-      sargv[0] = arg_buf;
-      sargv[1] = "--";
-      for (i = 0; i < argc; ++i)
-	sargv[2+i] = argv[i];
-      sargv[2+argc] = 0;
-      /*  preliminary patch for host configuration */
-      {
-	char **htable;
-	if (useconfig_flag && (htable = gethostnametable())) {
-	  if (!pvm_spawn(binname, sargv, PvmTaskHost, htable[0], 1,
-			 &(tid_table.child[0])) ) {
+      char** htable;
+      if (useconfig_flag && (htable = gethostnametable())) {
+	if (!pvm_spawn(binname, sargv, PvmTaskHost, htable[0], 1,
+		       &(tid_table.child[0])) ) {
+	  klic_fprintf(stderr, "Can't execute tasks!!\n");
+	  exit(1);
+	}
+	switch (nhostnames) {
+	case 1:
+	  ntask = pvm_spawn(binname, sargv, PvmTaskDefault, 0,
+			    num_child - 1, &(tid_table.child[1]));
+	  if (ntask != num_child - 1) {
 	    klic_fprintf(stderr, "Can't execute tasks!!\n");
+	    kill_child();
 	    exit(1);
 	  }
-	  switch (nhostnames) {
-	  case 1:
-	    ntask = pvm_spawn(binname, sargv, PvmTaskDefault, 0,
-			      num_child - 1, &(tid_table.child[1]));
-	    if (ntask != num_child - 1) {
+	  break;
+	default:
+	  for (i = 0; i < num_child - 1; i++) {
+	    if (0 == pvm_spawn(binname, sargv, PvmTaskHost,
+			       htable[i % (num_child - 1) + 1 ], 1,
+			       &(tid_table.child[i+1]))) {
 	      klic_fprintf(stderr, "Can't execute tasks!!\n");
 	      kill_child();
 	      exit(1);
 	    }
-	    break;
-	  default:
-	    for (i = 0; i < num_child - 1; i++) {
-	      if (0 == pvm_spawn(binname, sargv, PvmTaskHost,
-				 htable[i % (num_child - 1) + 1 ], 1,
-				 &(tid_table.child[i+1]))) {
-		klic_fprintf(stderr, "Can't execute tasks!!\n");
-		kill_child();
-		exit(1);
-	      }
-	    }
-	  }
-	  free(htable);
-	} else {
-	  ntask = pvm_spawn(binname, sargv, PvmTaskDefault, 0,
-			    num_child , tid_table.child);
-	  if (ntask != num_child) {
-	    klic_fprintf(stderr, "Can't execute tasks!!\n");
-	    kill_child();
-	    exit(1);
 	  }
 	}
+	free(htable);
+      } else {
+	ntask = pvm_spawn(binname, sargv, PvmTaskDefault, 0,
+			  num_child , tid_table.child);
+	if (ntask != num_child) {
+	  klic_fprintf(stderr, "Can't execute tasks!!\n");
+	  kill_child();
+	  exit(1);
+	}
       }
-      signal(SIGINT, sigint_handler);
-      free(sargv);
     }
+    signal(SIGINT, sigint_handler);
+    free(sargv);
+  }
 
-    for (i = 0; i < num_child; i++) {
-	int his_tid;
-	/* accept initial greetings of child */
-	pvm_recv(Tid_of(i), -1);
-	pvm_upkint(&his_tid,1,1);
-	pvm_upkint(&pid_tbl[i],1,1);
-	if (his_tid != Tid_of(i)) {
-	    klic_fprintf(stderr, "%dth child tid mismatch(%d != %d)\n",
-			 i, his_tid, Tid_of(i));
-	    kill_child();
-	    exit(1);
-	}
+  for (i = 0; i < num_child; i++) {
+    int his_tid;
+    /* accept initial greetings of child */
+    pvm_recv(Tid_of(i), -1);
+    pvm_upkint(&his_tid, 1, 1);
+    pvm_upkint(&pid_tbl[i], 1, 1);
+    if (his_tid != Tid_of(i)) {
+      klic_fprintf(stderr, "%dth child tid mismatch(%d != %d)\n",
+		   i, his_tid, Tid_of(i));
+      kill_child();
+      exit(1);
+    }
 
-	pvm_initsend(PvmDataRaw);
-	pvm_pkint(&num_child, 1, 1);
-	pvm_pkint(&Tid_of(0), num_child, 1);
-	setup_send_args(opttable);
-	pvm_send(Tid_of(i), 3);
+    pvm_initsend(PvmDataRaw);
+    pvm_pkint(&num_child, 1, 1);
+    pvm_pkint(&Tid_of(0), num_child, 1);
+    setup_send_args(opttable);
+    pvm_send(Tid_of(i), 3);
+  }
 
+  /* receive ack from all children */
+  io_wait_sync(SYNCID_SPAWN);
+  if (network_statistics_flag) {
+    klic_fprintf(stderr, "reduction_node:\n");
+    for (i = 0; i < num_child; ++i) {
+      if (i == num_child - 1)
+	klic_fprintf(stderr, "shoen_node:\n");
+      klic_fprintf(stderr,"\tPE = %d,\tTID = %x,\tPID = %d\n",
+		   i, Tid_of(i), pid_tbl[i]);
     }
-    /* receive ack from all children */
-    io_wait_sync(SYNCID_SPAWN);
-    if (network_statistics_flag) {
-	klic_fprintf(stderr, "reduction_node:\n");
-	for (i = 0; i < num_child; ++i) {
-	    if (i == num_child - 1)
-	      klic_fprintf(stderr, "shoen_node:\n");
-	    klic_fprintf(stderr,"\tPE = %d,\tTID = %x,\tPID = %d\n",
-			 i, Tid_of(i), pid_tbl[i]);
-	}
-    }
-    free(pid_tbl);
-    { /* send start-semaphore to the master node */
-	int start_semaphore = 0;
-	pvm_initsend(PvmDataRaw);
-	pvm_pkint(&start_semaphore, 1, 1);
-	pvm_send(Tid_of(MASTER_NODE), 3);
-    }
+  }
+  free(pid_tbl);
+
+  { /* send start-semaphore to the master node */
+    int start_semaphore = 0;
+    pvm_initsend(PvmDataRaw);
+    pvm_pkint(&start_semaphore, 1, 1);
+    pvm_send(Tid_of(MASTER_NODE), 3);
+  }
 }
 
 static int
 child_spawn_children(par_tid, opttable, prog_name, argc, argv)
-int par_tid;
-const struct opttable* opttable;
-char *prog_name;
-int argc;
-char **argv;
-{
-    int mytid;
-    int num_child;
-    int pid;
-    declare_globals;
-
-    Tid_of_io() = par_tid;
-
-    mytid = pvm_mytid();
-    /* initial greetings */
-    pvm_initsend(PvmDataRaw);
-    pvm_pkint(&mytid, 1, 1);
-    pid = getpid();
-    pvm_pkint(&pid, 1, 1);
-    pvm_send(Tid_of_io(), 3);
-
-    pvm_recv(Tid_of_io(), -1);
-    pvm_upkint(&num_child, 1, 1);
-    tid_table.child_count = num_child;
-    tid_table.child = (int *)calloc(num_child, sizeof(int));
-    pvm_upkint(&Tid_of(0), num_child, 1);
-
-    recv_extract_args(opttable);
-
-    /* send ack to io node */
-    child_sync(SYNCID_SPAWN);
-    {
-	int i;
-	/* find my tid from the table sent */
-	for (i = 0; i < num_child; ++i) 
-	  if (Tid_of(i) == mytid) {
-	      if (IS_MASTER_NODE(i)) {
-		  /* master node must receive the start-semaphore from
-		     io_node */
-		  int start_semaphore;
-		  pvm_recv(Tid_of_io(), -1);
-		  pvm_upkint(&start_semaphore, 1, 1);
-	      }
-	      return i;
-	  }
-	/* I cannot find my tid in the child-tid table??? */
-	kill_child();
-	abort();
-	return -1;
+  int par_tid;
+  const struct opttable* opttable;
+  char* prog_name;
+  int argc;
+  char** argv;
+{
+  int mytid;
+  int num_child;
+  int pid;
+  declare_globals;
+
+  Tid_of_io() = par_tid;
+
+  mytid = pvm_mytid();
+  /* initial greetings */
+  pvm_initsend(PvmDataRaw);
+  pvm_pkint(&mytid, 1, 1);
+  pid = getpid();
+  pvm_pkint(&pid, 1, 1);
+  pvm_send(Tid_of_io(), 3);
+
+  pvm_recv(Tid_of_io(), -1);
+  pvm_upkint(&num_child, 1, 1);
+  tid_table.child_count = num_child;
+  tid_table.child = (int*) calloc(num_child, sizeof(int));
+  pvm_upkint(&Tid_of(0), num_child, 1);
+
+  recv_extract_args(opttable);
+
+  /* send ack to io node */
+  child_sync(SYNCID_SPAWN);
+  {
+    int i;
+    /* find my tid from the table sent */
+    for (i = 0; i < num_child; ++i) {
+      if (Tid_of(i) == mytid) {
+	if (IS_MASTER_NODE(i)) {
+	  /* master node must receive the start-semaphore from io_node */
+	  int start_semaphore;
+	  pvm_recv(Tid_of_io(), -1);
+	  pvm_upkint(&start_semaphore, 1, 1);
+	}
+	return i;
+      }
     }
+    /* I cannot find my tid in the child-tid table??? */
+    kill_child();
+    abort();
+    return -1;
+  }
 }
 
-int
+extern int
 spawn_children(num_child, opttable, prog_name, argc, argv)
-int num_child;
-const struct opttable* opttable;
-char *prog_name;
-int argc;
-char **argv;
+  int num_child;
+  const struct opttable* opttable;
+  char* prog_name;
+  int argc;
+  char** argv;
 {
-    declare_globals;
+  declare_globals;
+
 #if defined(VPP) || defined(AP3000)
-    int mytid = pvm_mytid();
-    if ( pvm_parent() == PvmNoParent )
+  int mytid = pvm_mytid();
+  if ( pvm_parent() == PvmNoParent )
 #else
-    if ( parent_tid == 0 ) 
+  if ( parent_tid == 0 )
 #endif
-      {	/* original process */
+
+  {	/* original process */
 #ifdef AP3000
-        extern int main();
-	parent_tid = 0;
-        __pvm_set_node_name(main);
+    parent_tid = 0;
+    __pvm_set_node_name(main);
 #endif
-	io_spawn_children(num_child, opttable, prog_name, argc, argv);
-	return 0;
-    } else {
-	/* at this poine, don't rely on the value num_child for child.
-	   the value is transfered by send_args/recv_args in the function */
-	int my_penum =
-	  child_spawn_children(parent_tid, opttable, prog_name, argc, argv);
+
+    io_spawn_children(num_child, opttable, prog_name, argc, argv);
+    return 0;
+  } else {
+    /* at this poine, don't rely on the value num_child for child.
+     * the value is transfered by send_args/recv_args in the function */
+    int my_penum =
+      child_spawn_children(parent_tid, opttable, prog_name, argc, argv);
+
 #ifdef USEPROCBIND
-/*	if (!no_procbind && !IS_SHOEN_NODE(my_penum)) {*/
-	if (!no_procbind){
-	    /* fix process to the pe */
-	    processorid_t obind;
-	    long nprocs = sysconf(_SC_NPROCESSORS_ONLN);
-	    processor_bind(P_PID, P_MYID,
-			   (processorid_t)(my_penum % nprocs), &obind);
-	}
-#endif
-	return my_penum + 1;
+    if (!no_procbind){
+      /* fix process to the pe */
+      processorid_t obind;
+      long nprocs = sysconf(_SC_NPROCESSORS_ONLN);
+      processor_bind(P_PID, P_MYID,
+		     (processorid_t)(my_penum % nprocs), &obind);
     }
+#endif
+
+    return my_penum + 1;
+  }
 }
 
-void
+extern void
 count_profile()
 {
-    perfmon_counter.intr_count++;
-    if (perfmon_state.idle_on) {
-	perfmon_counter.idle_count++;
-	return;
-    }
-    if (perfmon_state.ms_on) {
-	perfmon_counter.ms_count++;
-	return;
-    }
-    if (perfmon_state.mr_on) {
-	perfmon_counter.mr_count++;
-	return;
-    }
-    if (perfmon_state.gc_on) {
-	perfmon_counter.gc_count++;
-	return;
-    }
+  perfmon_counter.intr_count++;
+  if (perfmon_state.idle_on) {
+    perfmon_counter.idle_count++;
+    return;
+  }
+  if (perfmon_state.ms_on) {
+    perfmon_counter.ms_count++;
+    return;
+  }
+  if (perfmon_state.mr_on) {
+    perfmon_counter.mr_count++;
+    return;
+  }
+  if (perfmon_state.gc_on) {
+    perfmon_counter.gc_count++;
+    return;
+  }
 }
 
 #if 0
-myexit(char *s, int *l, int *c)
+extern NeverReturn void
+myexit(char* s, int l, int c)
 {
-    FILE *f;
-    char buf[10];
-    sprintf(buf,"/tmp/%d",getpid());
-    f=fopen(buf,"w");
-    klic_fprintf(f, "exit(pid=%d,my_node=%d) %s:%d\n",
-		 getpid(), my_node,  s, l);
-    fclose(f);
-    exit(c);
+  FILE* f;
+  char buf[10];
+  sprintf(buf, "/tmp/%d", getpid());
+  f = fopen(buf, "w");
+  klic_fprintf(f, "exit(pid=%d,my_node=%d) %s:%d\n", getpid(), my_node, s, l);
+  fclose(f);
+  exit(c);
 }
 #endif
diff -ruN klic-3.003-2002-01-12a/runtime/config/pvm/distproc.h klic-3.003-2002-01-13/runtime/config/pvm/distproc.h
--- klic-3.003-2002-01-12a/runtime/config/pvm/distproc.h	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2002-01-13/runtime/config/pvm/distproc.h	Sun Jan 13 16:21:06 2002
@@ -6,6 +6,7 @@
 ----------------------------------------------------------- */
 /* PVM dependent inter-pe communication library */
 /* $Id: distproc.h,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
+
 #include <pvm3.h>
 
 /* Definition for command options for the distributed system */
@@ -18,9 +19,11 @@
 
 Extern int useconfig_flag;
 
-#if defined(USETIMER) && !defined(USE_REDUCTION_COUNT)
+#ifndef USE_REDUCTION_COUNT
+#ifdef USETIMER
 Extern unsigned long interval_usec;
 Extern unsigned int noitimer;
+
 #define TIMER_OPTIONS							\
     "noitimer",	(union all_type *)&noitimer, ARG_SET,			\
     "-noitimer: disable itimer interrupt",				\
@@ -28,83 +31,85 @@
     "I",	(union all_type *)&interval_usec, ARG_SIZE,		\
     "-I <timer value>: specify interrupt timer interval",
 
-#else
-/* If USETIMER is not defined USE_REDUCTION_COUNT is forcedly defined */
-#if !defined(USE_REDUCTION_COUNT)
+#else /* not USETIMER */
 #define USE_REDUCTION_COUNT
-#endif  /* defined(DIST) && !defined(USE_REDUCTION_COUNT) */
-#endif	/* USETIMER */
+#endif
+#endif /* not USE_REDUCTION_COUNT */
+
+#ifndef TIMER_OPTIONS
+#define TIMER_OPTIONS
+#endif
+
 Extern int no_sendsig;
 
 /* Solaris. Bind a process to a specific processor */
 #ifdef USEPROCBIND
 Extern long no_procbind Init(0); 	/* flag for disabling procbind() */
+
 #define PROCBIND_OPTION							\
     "noprocbind",(union all_type *)&no_procbind, ARG_SET,		\
     "-noprocbind: disable procbind",
 #endif /* USEPROCBIND */
 
+#ifndef PROCBIND_OPTION
+#define PROCBIND_OPTION
+#endif
+
   /* The option name must be mached to the argument of child invocation.
      So, we define it as a macro */
 #define OPT_PARENT_TID   "=parent_tid="
+
 Extern unsigned long parent_tid;/* the value used in child_spawn() */
 Extern int rel_spawn_path; 	/* relative spawn path flag */
 
 #ifdef USE_REDUCTION_COUNT
 #define DEFAULT_POLLING_INTERVAL 300
 #define SHOEN_POLLING_INTERVAL 300
-Extern int polling_interval Init(DEFAULT_POLLING_INTERVAL);
-#endif
 
-#ifndef PROCBIND_OPTION
-#define PROCBIND_OPTION
-#endif
-#ifndef TIMER_OPTIONS
-#define TIMER_OPTIONS
-#endif
+Extern int polling_interval Init(DEFAULT_POLLING_INTERVAL);
+#endif /* USE_REDUCTION_COUNT */
 
 #define USER_OPTIONS							\
-    OPT_PARENT_TID,	(union all_type *)&parent_tid, ARG_SIZE, 0,	\
+    OPT_PARENT_TID,	(union all_type*) &parent_tid, ARG_SIZE, 0,	\
 									\
-    "rmon",	(union all_type *)&rmonnode,  ARG_STRING, 		\
+    "rmon",	(union all_type*) &rmonnode,  ARG_STRING, 		\
     "-rmon <rmonitor node>: runtime monitor node name", 		\
 									\
-    "relsp",	(union all_type *)&rel_spawn_path, ARG_SET,		\
+    "relsp",	(union all_type*) &rel_spawn_path, ARG_SET,		\
     "-relsp: spawn using relative path",				\
                                                                         \
-    "msgbw",	(union all_type *)&msg_busywait_flag, ARG_SET,		\
+    "msgbw",	(union all_type*) &msg_busywait_flag, ARG_SET,		\
     "-msgbw: busy waiting message arrival in idle loop",        	\
                                                                         \
-    "e",	(union all_type *)&eager_transfer_all_flag, ARG_SET,	\
+    "e",	(union all_type*) &eager_transfer_all_flag, ARG_SET,	\
     "-e: transfer all level",						\
 									\
-    "E",	(union all_type *)&eager_transfer_level, ARG_SIZE,	\
+    "E",	(union all_type*) &eager_transfer_level, ARG_SIZE,	\
     "-E <level>: specify transfer level",				\
                                                                         \
-    "useconfig", (union all_type *)&useconfig_flag, ARG_SET,            \
+    "useconfig", (union all_type*) &useconfig_flag, ARG_SET,            \
     "-useconfig:  preliminary option, don't use!",                      \
 									\
     PROCBIND_OPTION							\
 									\
     TIMER_OPTIONS							\
 									\
-    "n",	(union all_type *)&network_statistics_flag, ARG_SET,	\
+    "n",	(union all_type*) &network_statistics_flag, ARG_SET,	\
     "-n: gather network statistics",					\
 									\
-    "S",	(union all_type *)&no_sendsig, ARG_SET,			\
+    "S",	(union all_type*) &no_sendsig, ARG_SET,			\
     "-S: disable sendsig",						\
 
 #ifdef USE_REDUCTION_COUNT
 #define POLLING_OPTIONS \
-    "I",   (union all_type *)&polling_interval, ARG_SIZE,           \
+    "I",   (union all_type*) &polling_interval, ARG_SIZE,           \
     "-I <usec>: polling interval for checking arrival messages",    \
-
-#endif
+#endif /* USE_REDUCTION_COUNT */
 
 struct tid_table {
-    int child_count;
-    int io;
-    int *child;
+  int child_count;
+  int io;
+  int* child;
 };
 
 Extern struct tid_table tid_table;
diff -ruN klic-3.003-2002-01-12a/runtime/config/pvm/distrmon.c klic-3.003-2002-01-13/runtime/config/pvm/distrmon.c
--- klic-3.003-2002-01-12a/runtime/config/pvm/distrmon.c	Sun Jan  6 11:54:00 2002
+++ klic-3.003-2002-01-13/runtime/config/pvm/distrmon.c	Sun Jan 13 16:32:16 2002
@@ -26,109 +26,111 @@
   */
 
 #if defined(VPP) || defined(AP3000)
-static FILE *rmonfile;
+static FILE* rmonfile;
 #else
 static int rmon_tid;
 #endif
 
-void
+extern void
 output_profile_information()
 {
-    declare_globals;
-    int  i;
-    int  bufindex = 0;
+  declare_globals;
+  int  i;
+  int  bufindex = 0;
+
 #if defined(VPP) || defined(AP3000)
-    int req_size, n;
-    char *rmon_buf = (char *) send_pbuf;
+  int req_size, n;
+  char* rmon_buf = (char*) send_pbuf;
 #else
-    int  info;
+  int  info;
 #endif
 
-    send_pbuf[bufindex++] = SHOEN_OUTPUT_PROF_TAG;
-    send_pbuf[bufindex++] = total_node;
-    for(i = 0; i < total_node ; i++){
-	send_pbuf[bufindex++] = shoen_profile[i].stimes;
-      	send_pbuf[bufindex++] = shoen_profile[i].itimes;
-      	send_pbuf[bufindex++] = shoen_profile[i].gctimes;
-      	send_pbuf[bufindex++] = shoen_profile[i].mstimes;
-      	send_pbuf[bufindex++] = shoen_profile[i].mrtimes;
-    }
+  send_pbuf[bufindex++] = SHOEN_OUTPUT_PROF_TAG;
+  send_pbuf[bufindex++] = total_node;
+  for(i = 0; i < total_node ; i++){
+    send_pbuf[bufindex++] = shoen_profile[i].stimes;
+    send_pbuf[bufindex++] = shoen_profile[i].itimes;
+    send_pbuf[bufindex++] = shoen_profile[i].gctimes;
+    send_pbuf[bufindex++] = shoen_profile[i].mstimes;
+    send_pbuf[bufindex++] = shoen_profile[i].mrtimes;
+  }
+
 #if defined(VPP) || defined(AP3000)
-    req_size = bufindex * sizeof(long);
+  req_size = bufindex * sizeof(long);
 
-    while ((n = fwrite((char *)rmon_buf,1,req_size,rmonfile)) < req_size) {
-      if (n <= 0 ) {
-	fclose(rmonfile);
-	fatal("Cannot send to 'pg-server'!!");
-      }
-      req_size -= n;
-      rmon_buf += n;
+  while ((n = fwrite((char*) rmon_buf, 1, req_size, rmonfile)) < req_size) {
+    if (n <= 0 ) {
+      fclose(rmonfile);
+      fatal("Cannot send to 'pg-server'!!");
     }
-    fflush(rmonfile);
+    req_size -= n;
+    rmon_buf += n;
+  }
+  fflush(rmonfile);
 #else
-    info = pvm_initsend(PvmDataDefault);
-    if (info < 0)
-      fatal("Error in pvm_initsend\n");
-    info = pvm_pklong(send_pbuf, bufindex, 1);
-    if (info < 0)
-      fatal("Error in pvm_pklong\n");
-    info = pvm_send(rmon_tid,3);
-    if (info < 0)
-      fatal("Error in pvm_send\n");
+  info = pvm_initsend(PvmDataDefault);
+  if (info < 0)
+    fatal("Error in pvm_initsend\n");
+  info = pvm_pklong(send_pbuf, bufindex, 1);
+  if (info < 0)
+    fatal("Error in pvm_pklong\n");
+  info = pvm_send(rmon_tid, 3);
+  if (info < 0)
+    fatal("Error in pvm_send\n");
 #endif
 }
 
-void
+static void
 profiling_ctr_tag(tag)
-     long tag;
+  long tag;
 {
 #if defined(VPP) || defined(AP3000)
-    declare_globals;
-    int req_size = sizeof(long), n;
-    union { long v; char b[sizeof(long)]; } tagb;
-    char *buf = (char *)&tagb;
-
-    tagb.v = tag;
-
-    while ((n = fwrite(buf,1,req_size,rmonfile)) < req_size) {
-      if (n <= 0) {
-	fclose(rmonfile);
-	fatal("Cannot send to 'pg-server'!!");
-      }
-      req_size -= n;  buf += n;
+  declare_globals;
+  int req_size = sizeof(long), n;
+  union { long v; char b[sizeof(long)]; } tagb;
+  char* buf = (char*) &tagb;
+
+  tagb.v = tag;
+
+  while ((n = fwrite(buf,1,req_size,rmonfile)) < req_size) {
+    if (n <= 0) {
+      fclose(rmonfile);
+      fatal("Cannot send to 'pg-server'!!");
     }
-    fflush(rmonfile);
+    req_size -= n;  buf += n;
+  }
+  fflush(rmonfile);
 #else
-    int info;
-    info = pvm_initsend(PvmDataDefault);
-    if (info < 0)
-      fatal("Error in pvm_initsend\n");
-    info = pvm_pklong(&tag, 1, 1);
-    if (info < 0)
-      fatal("Error in pvm_pklong\n");
-    info = pvm_send(rmon_tid,3);
-    if (info < 0)
-      fatal("Error in pvm_send\n");
+  int info;
+  info = pvm_initsend(PvmDataDefault);
+  if (info < 0)
+    fatal("Error in pvm_initsend\n");
+  info = pvm_pklong(&tag, 1, 1);
+  if (info < 0)
+    fatal("Error in pvm_pklong\n");
+  info = pvm_send(rmon_tid,3);
+  if (info < 0)
+    fatal("Error in pvm_send\n");
 #endif
 }
 
-void
+static void
 start_profiling()
 {
 #if defined(VPP) || defined(AP3000)
   declare_globals;
   int family = PF_UNIX, n, max, req_size, i, j, sock;
   struct sockaddr addr;
-  char *path;
+  char* path;
 
   max = total_node;
   path = rmonnode;
 
   addr.sa_family = family;
-  strcpy(addr.sa_data,"/tmp/");
-  strcat(addr.sa_data,path);
+  strcpy(addr.sa_data, "/tmp/");
+  strcat(addr.sa_data, path);
 
-  sock = socket(family,SOCK_STREAM,0);
+  sock = socket(family, SOCK_STREAM, 0);
   if (sock < 0) {
     fatal("Cannot make a socket!!");
   }
@@ -136,20 +138,23 @@
     fatal("Cannot be connected with 'pg-server'!!");
   }
 
-  rmonfile  = fdopen(sock,"w+");
+  rmonfile = fdopen(sock, "w+");
 #endif
-    profiling_ctr_tag(SHOEN_START_TAG);
+
+  profiling_ctr_tag(SHOEN_START_TAG);
 }
 
-void
+extern void
 terminate_profiling()
 {
 #if defined(VPP) || defined(AP3000)
-    declare_globals;
+  declare_globals;
 #endif
-    profiling_ctr_tag(SHOEN_TERMINATE_TAG);
+
+  profiling_ctr_tag(SHOEN_TERMINATE_TAG);
+
 #if defined(VPP) || defined(AP3000)
-    fclose(rmonfile);
+  fclose(rmonfile);
 #endif
 }
 
@@ -158,29 +163,25 @@
   Initiate profile data structure in SHOEN NODE
 */
 
-void
+extern void
 init_rmonitor()
 {
   declare_globals;
-  if(IS_SHOEN_NODE(my_node)){
-      if(rmonnode){
-#ifndef VPP
-#ifndef AP3000
-	  sscanf(rmonnode,"%x",&rmon_tid);
-#endif
-#endif
-	  
-	  start_profiling();
-
-	  shoen_profile = 
-	    (struct profile_rec *)malloc(total_node*sizeof(struct profile_rec));	  
-	  if(shoen_profile == NULL)
-	    fatal("malloc failed in init_rmonitor");
-	  
-	  send_pbuf = 
-	    (long *)malloc(total_node*sizeof(struct profile_rec)+2);
-	  if(send_pbuf == NULL)
-	    fatal("malloc failed in init_rmonitor");
-      }
+  if( IS_SHOEN_NODE(my_node) && rmonnode ){
+#if !defined(VPP) && !defined(AP3000)
+    sscanf(rmonnode,"%x", &rmon_tid);
+#endif
+
+    start_profiling();
+
+    shoen_profile =
+      (struct profile_rec*) malloc(total_node*sizeof(struct profile_rec));
+    if(shoen_profile == NULL)
+      fatal("malloc failed in init_rmonitor");
+
+    send_pbuf =
+      (long*) malloc(total_node*sizeof(struct profile_rec)+2);
+    if(send_pbuf == NULL)
+      fatal("malloc failed in init_rmonitor");
   }
 }
diff -ruN klic-3.003-2002-01-12a/runtime/config/pvm/rmon_server.c klic-3.003-2002-01-13/runtime/config/pvm/rmon_server.c
--- klic-3.003-2002-01-12a/runtime/config/pvm/rmon_server.c	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2002-01-13/runtime/config/pvm/rmon_server.c	Sun Jan 13 17:13:38 2002
@@ -4,17 +4,21 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
+
 #if defined(VPP) || defined(AP3000)
 #define VPPAP
 #endif
+
 #ifndef VPPAP
 #include <pvm3.h>
 #endif
+
 #include <stdio.h>
 #include <signal.h>
 #include <klic/config.h>
 #include <klic/basic.h>
 #include "rmon.h"
+
 #ifdef VPPAP
 #include <sys/param.h>
 #include <sys/types.h>
@@ -27,28 +31,29 @@
 
 #ifdef VPPAP
 static int sock;
-static char *filename;
+static char* filename;
 
-static void finish()
+static void
+finish()
 {
   close(sock);
-  shutdown(sock,2);
+  shutdown(sock, 2);
   unlink(filename);
   exit(1);
 }
 
-static int readbuf(rf, bufp, req_size)
-     FILE *rf;
-     char *bufp;  int req_size;
+static int
+readbuf(rf, bufp, req_size)
+  FILE* rf;
+  char* bufp;
+  int req_size;
 {
   int n;
 
-  while ((n = fread((char *)bufp, 1, req_size, rf)) < req_size) {
-    if ( n < 0 || (n == 0 && !feof(rf))) {
-      fclose(rf);
-      fprintf(stderr,"Read Error\n");
-      return -1;
-    } else if (n == 0) {
+  while ((n = fread((char*) bufp, 1, req_size, rf)) < req_size) {
+    if( n <= 0 ){
+      if( n < 0 || !feof(rf) )
+	fprintf(stderr, "Read Error\n");
       fclose(rf);
       return -1;
     }
@@ -57,29 +62,32 @@
   return 0;
 }
 
+static void
 last_column(disp_nodes)
-     int disp_nodes;
+  int disp_nodes;
 {
-  int i,j;
+  int i, j;
   for(i = 0; i < 2 ; i++) {
-    printf("CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl\n");	  
+    printf("CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl\n");
     for (j = 0; j < disp_nodes; j++) {
-      printf(" %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n",j);
-    }	  
+      printf(" %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n", j);
+    }
     fflush(stdout);
     sleep(2);
   }
 }
 
-main(argc,argv)
-     int argc; char **argv;
+extern int
+main(argc, argv)
+  int argc;
+  char** argv;
 {
   long s_times, i_times, gc_times, sm_times, rm_times;
-  int i,j,n,disp_nodes;
+  int i, j, n, disp_nodes;
   int family = PF_UNIX, sock2, sock2len, max, req_size;
   struct sockaddr *addr, addr2;
-  char *path;
-  FILE *rf;
+  char* path;
+  FILE* rf;
   union  {
     long v; char b[sizeof(long)];
   } prof_tag, nodes;
@@ -90,7 +98,7 @@
   } ibuf;
 
 
-/* init */
+ /* init */
   switch (argc) {
   case 3:
     disp_nodes = atoi(argv[2]);
@@ -99,18 +107,18 @@
     disp_nodes = 20;
     break;
   default:
-    fprintf(stderr,"usage: rmon socket_name [nodes]\n");
+    fprintf(stderr, "usage: rmon socket_name [nodes]\n");
     exit(1);
   }
 
   path = argv[1];
 
-  addr = (struct sockaddr *)malloc(sizeof(struct sockaddr)+strlen(path)+5);
+  addr = (struct sockaddr*) malloc(sizeof(struct sockaddr)+strlen(path)+5);
   addr->sa_family = family;
-  strcpy(addr->sa_data,"/tmp/");
-  strcat(addr->sa_data,path);
+  strcpy(addr->sa_data, "/tmp/");
+  strcat(addr->sa_data, path);
 
-  sock = socket(family,SOCK_STREAM,0);
+  sock = socket(family, SOCK_STREAM, 0);
   if (sock < 0) {
     perror("socket");
     exit(1);
@@ -126,50 +134,51 @@
 
   filename = addr->sa_data;
 
-  signal(SIGINT,finish);
+  signal(SIGINT, finish);
 
   sock2len = sizeof(addr2);
   addr2.sa_family = family;
 
-/* server loop */
+ /* server loop */
  top:
-  if ((sock2 = accept(sock, &addr2, &sock2len)) < 0) {
+  sock2 = accept(sock, &addr2, &sock2len);
+  if (sock2 < 0) {
     perror("accept");
     close(sock);
     exit(1);
   }
 
-  rf = fdopen(sock2,"r");
- 
+  rf = fdopen(sock2, "r");
+
  /* client loop */
   for (;;) {
     if ( readbuf(rf, prof_tag.b, sizeof(long)) < 0 ) {
-      last_column(disp_nodes); fclose(rf); goto top;
+      goto gototop;
     }
 
     switch(prof_tag.v){
     case SHOEN_START_TAG:
       for (j = 0; j < disp_nodes; j++) {
-	printf(" %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n",j);
-      }	  
+	printf(" %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n", j);
+      }
       fflush(stdout);
       break;
 
     case SHOEN_OUTPUT_PROF_TAG:
-      
+
       if ( readbuf(rf, nodes.b, sizeof(long)) < 0 ) {
-	last_column(disp_nodes);  fclose(rf);  goto top;
+	goto gototop;
       }
-      
+
       if(nodes.v > disp_nodes){
 	fprintf(stderr, "Please restart : rmon_server %d\n", nodes);
 	finish();
       }
 
       if (readbuf(rf, ibuf.b, nodes.v * 5 *sizeof(long)) < 0 )  {
-	last_column(disp_nodes); fclose(rf); goto top;
+	goto gototop;
       }
-      
+
       printf("CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl\n");
       n = 0;
 
@@ -179,9 +188,9 @@
 	gc_times = ibuf.v[n+2];
 	sm_times = ibuf.v[n+3];
 	rm_times = ibuf.v[n+4];
-	      
+
 	printf(" %d    0   0    0    0    0    0    0    0    0    0     0 ",j);
-	if (s_times) { 
+	if (s_times) {
 	  int idle_times = i_times + sm_times + rm_times;
 	  printf(" %d 0 0 %d\n",
 		 100 * (s_times - idle_times)/ s_times,
@@ -189,115 +198,115 @@
 	} else {
 	  printf(" 0 0 0 100\n");
 	}
-	n+=5;
+	n += 5;
       }
 
       for (j = nodes.v ; j < disp_nodes ;j++){
-	printf(" %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n",j);
+	printf(" %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n", j);
       }
       fflush(stdout);
       break;
 
     case SHOEN_TERMINATE_TAG:
+    gototop:
       last_column(disp_nodes);
       fclose(rf);
       goto top;
-     
+
     default:
       fprintf(stderr, "rmon_server invalid msg from shoen\n");
       finish();
     }
   }
 }
-#else
-main(argc,argv)
-     int argc; char **argv;
+
+#else /* not VPPAP */
+extern int
+main(argc, argv)
+  int argc;
+  char** argv;
 {
-  int i,j,mytid,histid,bufsize,msgtag,info,buf_id,n,disp_nodes;
+  int i, j, mytid, histid, bufsize, msgtag, info, buf_id, n, disp_nodes;
   long nodes, ibuf[MAXNUM*5], s_times, i_times, gc_times, sm_times, rm_times;
   long prof_tag;
 
-  if (argc == 1) {
-      disp_nodes = 20;
-  } else {
-      disp_nodes = atoi(argv[1]);
-  }
+  disp_nodes = (argc > 1 ? atoi(argv[1]) : 20);
 
   mytid = pvm_mytid();
   fprintf(stderr, "Rmonitor Tid is %x\n", mytid);
 
   for (;;) {
-      buf_id = pvm_recv(-1,-1);
-      if (buf_id < 0 ){
-	  fprintf(stderr, "Error in pvm_recv\n");
-      }
-      info = pvm_bufinfo(buf_id,&bufsize,&msgtag,&histid);
-      if (info < 0 ){
-	  fprintf(stderr, "Error in pvm_bufinfo\n");
-      }
-
-      pvm_upklong(&prof_tag, 1, 1);
-      switch(prof_tag){
-	case SHOEN_START_TAG:
-	  for (j = 0; j < disp_nodes; j++) {
-	      fprintf(stdout, " %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n",j);
-	  }	  
-	  fflush(stdout);
-	  break;
-
-	case SHOEN_OUTPUT_PROF_TAG:
-
-	  pvm_upklong(&nodes, 1, 1);
-	  if(nodes > disp_nodes){
-	      fprintf(stderr, "Please restart : rmon_server %d\n", nodes);
-	      exit();
-	  }
-
-	  pvm_upklong(ibuf, nodes*5, 1);
-
-	  fprintf(stdout, "CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl\n");
-	  n = 0;
-
-	  for (j = 0; j<nodes; j++) {
-	      s_times = ibuf[n];
-	      i_times = ibuf[n+1];
-	      gc_times = ibuf[n+2];
-	      sm_times = ibuf[n+3];
-	      rm_times = ibuf[n+4];
-	      
-	      fprintf(stdout, " %d    0   0    0    0    0    0    0    0    0    0     0 ",j);
-	      if (s_times) { 
-		  fprintf(stdout, " %d 0 0 %d\n",
-			  s_times - (i_times + sm_times + rm_times),
-			  i_times + sm_times + rm_times);
-	      } else {
-		  fprintf(stdout, " 0 0 0 100\n");
-	      }
-	      n+=5;
-	  }
-
-	  for(j = nodes ; j < disp_nodes ;j++){
-	      fprintf(stdout, " %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n",j);
-	  }
-	  fflush(stdout);
-	  break;
-
-	case SHOEN_TERMINATE_TAG:
-	  for(i = 0; i < 2 ; i++){
-	      fprintf(stdout, "CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl\n");	  
-	      for (j = 0; j < disp_nodes; j++) {
-		  fprintf(stdout, " %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n",j);
-	      }	  
-	      fflush(stdout);
-	      sleep(2);
-	    }
-	  break;
-
-	default:
-	  fprintf(stderr, "rmon_server invalid msg from shoen\n");
-	  exit();
-	  break;
+    buf_id = pvm_recv(-1, -1);
+    if (buf_id < 0 ){
+      fprintf(stderr, "Error in pvm_recv\n");
+    }
+    info = pvm_bufinfo(buf_id, &bufsize, &msgtag, &histid);
+    if (info < 0 ){
+      fprintf(stderr, "Error in pvm_bufinfo\n");
+    }
+
+    pvm_upklong(&prof_tag, 1, 1);
+    switch(prof_tag){
+    case SHOEN_START_TAG:
+      for (j = 0; j < disp_nodes; j++) {
+	fprintf(stdout, " %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n", j);
+      }
+      fflush(stdout);
+      break;
+
+    case SHOEN_OUTPUT_PROF_TAG:
+
+      pvm_upklong(&nodes, 1, 1);
+      if(nodes > disp_nodes){
+	fprintf(stderr, "Please restart : rmon_server %d\n", nodes);
+	exit(1);
       }
+
+      pvm_upklong(ibuf, nodes*5, 1);
+
+      fprintf(stdout, "CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl\n");
+      n = 0;
+
+      for (j = 0; j<nodes; j++) {
+	s_times = ibuf[n];
+	i_times = ibuf[n+1];
+	gc_times = ibuf[n+2];
+	sm_times = ibuf[n+3];
+	rm_times = ibuf[n+4];
+
+	fprintf(stdout, " %d    0   0    0    0    0    0    0    0    0    0     0 ", j);
+	if (s_times) {
+	  fprintf(stdout, " %d 0 0 %d\n",
+		  s_times - (i_times + sm_times + rm_times),
+		  i_times + sm_times + rm_times);
+	} else {
+	  fprintf(stdout, " 0 0 0 100\n");
+	}
+	n += 5;
+      }
+
+      for(j = nodes ; j < disp_nodes; j++){
+	fprintf(stdout, " %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n", j);
+      }
+      fflush(stdout);
+      break;
+
+    case SHOEN_TERMINATE_TAG:
+      for(i = 0; i < 2 ; i++){
+	fprintf(stdout, "CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl\n");
+	for (j = 0; j < disp_nodes; j++) {
+	  fprintf(stdout, " %d    0   0    0    0    0    0    0    0    0    0     0   0   0  0  100\n", j);
+	}
+	fflush(stdout);
+	sleep(2);
+      }
+      break;
+
+    default:
+      fprintf(stderr, "rmon_server invalid msg from shoen\n");
+      exit(1);
+      break;
+    }
   }
 }
-#endif
+#endif /* not VPPAP */
diff -ruN klic-3.003-2002-01-12a/runtime/datamsg.c klic-3.003-2002-01-13/runtime/datamsg.c
--- klic-3.003-2002-01-12a/runtime/datamsg.c	Fri Jan 11 10:02:56 2002
+++ klic-3.003-2002-01-13/runtime/datamsg.c	Sun Jan 13 13:03:18 2002
@@ -4,6 +4,18 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
+
+/*
+  public entry point
+  DATA ENCODER			void encode_data(buffer, data, depth)
+
+  specially defined as extern for reference from exref generic object;
+  EXREF DECODER			q* decode_exref(inbuf, allocp)
+  decode atomic or const	static q* decode_atomic_or_const(inbuf, allocp)
+  decode list			static q* decode_list(inbuf, allocp)
+  decode funct			static q* decode_funct(inbuf, allocp)
+  */
+
 #include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/primitives.h>
@@ -32,43 +44,36 @@
 
 extern const long initial_atoms;
 extern const long initial_functors;
-q search_exptbl();
-extern q exref_g_new();
-/* 
-  public entry point
-  DATA ENCODER			void encode_data(buffer, data, depth)
 
-  specially defined as extern for reference from exref generic object;
-  EXREF DECODER			q* decode_exref(inbuf, allocp)
-  decode atomic or const	static q* decode_atomic_or_const(inbuf, allocp)
-  decode list			static q* decode_list(inbuf, allocp)
-  decode funct			static q* decode_funct(inbuf, allocp)
-  */
+extern q search_exptbl();
+extern q exref_g_new();
 
-void push_decode_stack();
-q pop_decode_stack();
+extern void push_decode_stack();
+extern q pop_decode_stack();
 
 /* decoding data */
 /*
   LEVEL0 OBJECTS encoding
   e.g. const, atomic and ref
   */
-static q* decode_atomic_or_const(inbuf, allocp)
-     combuf *inbuf;
-     q *allocp;
+static q*
+decode_atomic_or_const(inbuf, allocp)
+  combuf* inbuf;
+  q* allocp;
 {
   declare_globals;
 
   INT_CL_DEBUG_X(ioprintf("%d:decode_const_or_atomic\n", my_node));
 
-  decode_data = (q)GET_BUFFER(inbuf);
+  decode_data = (q) GET_BUFFER(inbuf);
   push_decode_stack(decode_data);
-  return(allocp);
+  return allocp;
 }
 
-q* decode_exref(inbuf, allocp)
-     combuf *inbuf;
-     q *allocp;
+extern q*
+decode_exref(inbuf, allocp)
+  combuf* inbuf;
+  q* allocp;
 {
   declare_globals;
   long node;
@@ -77,67 +82,66 @@
 
   node = GET_BUFFER(inbuf);
   if(node == my_node) {
-      /* If the data is data exported by myself */
+    /* If the data is data exported by myself */
     long index = GET_BUFFER(inbuf);
     long wec   = GET_BUFFER(inbuf);
 
-    decode_data = (q)search_exptbl(index, wec);
+    decode_data = (q) search_exptbl(index, wec);
     push_decode_stack(decode_data);
-    return(allocp);
+    return allocp;
 
   } else {
-      /* If the data is others data */
+    /* If the data is other's data */
     generic_arg[0] = makeint(node);  /* PE number */
     generic_arg[1] = makeint(GET_BUFFER(inbuf));  /* exp_table index */
     generic_arg[2] = makeint(GET_BUFFER(inbuf));  /* WEC */
 
-    new_generic(exref_g_new, 3L, decode_data, 0); 
+    new_generic(exref_g_new, 3L, decode_data, 0);
     push_decode_stack(decode_data);
-    return(allocp);
+    return allocp;
   }
 }
+
 /*
   decode  STRUCTURED VALUE
   e.g. lists and functors
  */
-static q* decode_list(inbuf, allocp)
-     combuf *inbuf;
-     q *allocp;
+static q*
+decode_list(inbuf, allocp)
+  combuf* inbuf;
+  q* allocp;
 {
   declare_globals;
   q list;
-  module decoder;
 
   INT_CL_DEBUG_X(ioprintf("%d:decode_list\n", my_node));
 
- loop:
   heapalloc(list, sizeof(struct cons)/sizeof(q), makecons);
 
   cdr_of(list) = pop_decode_stack();
   car_of(list) = pop_decode_stack();
   push_decode_stack(list);
-  return(allocp);
+  return allocp;
 }
 
-static q* decode_funct(inbuf, allocp)
-     combuf *inbuf;
-     q *allocp;
+static q*
+decode_funct(inbuf, allocp)
+  combuf* inbuf;
+  q* allocp;
 {
   declare_globals;
   q funct, p_funct;
-  module decoder;
   int i;
 
   INT_CL_DEBUG_X(ioprintf("%d:decode_funct\n", my_node));
 
-  p_funct = (q)GET_BUFFER(inbuf);
+  p_funct = (q) GET_BUFFER(inbuf);
 
-
-  if (( real_heaplimit - allocp ) < ( arityof(p_funct) + 1 )) {
+  if ( real_heaplimit - allocp  <  arityof(p_funct) + 1 ) {
     inbuf->rd_index -= 2;
     heaplimit = 0;
     this_more_space += arityof(p_funct)+1;
-    return (allocp);
+    return allocp;
   }
 
   heapalloc(funct, arityof(p_funct)+1, makefunctor);
@@ -147,7 +151,7 @@
     arg(funct, i-1) = pop_decode_stack();
   }
   push_decode_stack(funct);
-  return(allocp);
+  return allocp;
 }
 
 /*
@@ -156,136 +160,132 @@
   if depth is zero, only one word structures are encoded.
   */
 
-#define   END_ENCODE_DATA()\
-{\
-    int i;\
-    for(i = 0 ; i < cdrlist ; i++){\
-	PUT_BUFFER(buffer, decode_list);\
-    }\
-}
-
-void encode_data(buffer, data, depth)
-combuf *buffer;
-q data;
-long depth;
+#define END_ENCODE_DATA() \
+do{ \
+  int i; \
+  for(i = 0 ; i < cdrlist ; i++){ \
+    PUT_BUFFER(buffer, decode_list); \
+  } \
+}while(0)
+
+extern void
+encode_data(buffer, data, depth)
+  combuf* buffer;
+  q data;
+  long depth;
 {
-  int i,depth_org;
   declare_globals;
+  int i;
   int cdrlist = 0;
-/*  depth_org = depth;*/
-  
+
  again:
   switch (ptagof(data)){
-    case ATOMIC:
-      if (issym(data) &&
-	  symval(data) >= initial_atoms+ATOMNUMBERBASE) {
-	ioeprintf("initial_atoms %d\n",initial_atoms);
-	ioeprintf("symval(data) %d\n",symval(data));
-	fatal("cannot send a newly created atom in this version.");
-      } else {
-	  goto Atomic_case;
-      } 
-      break;
-    case CONS:
-      if ((q*)data < heaptop ||
-	  (q*)data >= heaptop+heapsize+incrementsize) {
-	  goto Const_case;
-      } else if (depth == 0) {
+  case ATOMIC:
+    if (issym(data) && symval(data) >= initial_atoms+ATOMNUMBERBASE) {
+      ioeprintf("initial_atoms %d\n", initial_atoms);
+      ioeprintf("symval(data) %d\n", symval(data));
+      fatal("cannot send a newly created atom in this version.");
+    } else {
+      goto Atomic_case;
+    }
+    break;
+  case CONS:
+    if ((q*)data < heaptop || heaptop+heapsize+incrementsize <= (q*)data) {
+      goto Const_case;
+    } else if (depth == 0) {
+      goto Make_exref;
+    } else {
+      if (depth > 0)
+	depth--;
+      encode_data(buffer, car_of(data), depth);
+      data = cdr_of(data);
+      cdrlist++;
+      goto again;
+    }
+    break;
+  case FUNCTOR:
+    if ((q*)data < heaptop || heaptop+heapsize+incrementsize <= (q*)data) {
+      goto Const_case;
+    } else {
+      q f = functor_of(data);
+      if (isref(f)) { /* data_object */
+	if(depth == 0){
 	  goto Make_exref;
-      } else {
-	  if (depth > 0)
-	    depth--;
-	  encode_data(buffer, car_of(data), depth);
-          data = cdr_of(data);
-	  cdrlist++;
-          goto again;
-
-/*	  encode_data(buffer, cdr_of(data), depth);	      
-	  PUT_BUFFER(buffer, decode_list);*/
-      }
-      break;
-    case FUNCTOR:
-      if ((q*)data < heaptop ||
-	  (q*)data >= heaptop+heapsize+incrementsize) {
-	  goto Const_case;
-      } else {
-	q f = functor_of(data);
-	if (isref(f)) { /* data_object */
-	  if(depth == 0){
-	    goto Make_exref;
-	  } else {
-	    if ( generic_encode((struct data_object *)functorp(data),
-                                                        buffer, depth) ) {
-	      fatal("Encode method is not defined in Data Object");
-	    }
+	} else {
+	  if ( generic_encode((struct data_object*) functorp(data),
+			      buffer, depth) ) {
+	    fatal("Encode method is not defined in Data Object");
 	  }
-	} else {      /* functor */
-	  if((symval(f) - FUNCTORNUMBERBASE) >= initial_functors){
-	    ioeprintf("initial_functors %d\nsymval(data) %d\n",
+	}
+      } else {      /* functor */
+	if(symval(f) - FUNCTORNUMBERBASE >= initial_functors){
+	  ioeprintf("initial_functors %d\nsymval(data) %d\n",
 		    initial_functors, symval(f));
-	    fatal("cannot send a newly created functor in this version.");
-	  } else if (depth == 0) {
-	      goto Make_exref;
-	  } else {
-	    int arity1 = arityof(functor_of(data));
-	    if (depth > 0)
-	      depth--;
-	    for (i = 0; i < arity1; i++) {
-		encode_data(buffer, arg(data, i), depth);
-	    }
-	    PUT2_BUFFER(buffer, decode_funct, functor_of(data));  
+	  fatal("cannot send a newly created functor in this version.");
+	} else if (depth == 0) {
+	  goto Make_exref;
+	} else {
+	  int arity1 = arityof(functor_of(data));
+	  if (depth > 0)
+	    depth--;
+	  for (i = 0; i < arity1; i++) {
+	    encode_data(buffer, arg(data, i), depth);
 	  }
+	  PUT2_BUFFER(buffer, decode_funct, functor_of(data));
 	}
       }
-      break;	   
-      case VARREF:
-      {
-	q temp = derefone(data);
-      deref_x:
-	if (data != temp){
-	  if (isref(temp)) {
-	    q temp1 = derefone(temp);
-	    if (temp1 == data) {
-	      struct susprec *sdata = (struct susprec *)temp;
-	      if(is_generator_susp(sdata->u)){
-		/* generator */
-		struct generator_susp *genobj = generator_suspp(sdata);
-
-		if(generic_encode(untag_generator_susp(genobj->u.o), buffer, depth)){
-		  goto Make_exref;
-		}
+    }
+    break;
+  case VARREF:
+    {
+      q temp = derefone(data);
+    deref_x:
+      if (data != temp){
+	if (isref(temp)) {
+	  q temp1 = derefone(temp);
+	  if (temp1 == data) {
+	    struct susprec* sdata = (struct susprec*) temp;
+	    if(is_generator_susp(sdata->u)){
+	      /* generator */
+	      struct generator_susp* genobj = generator_suspp(sdata);
 
-	      } else {
-		/* consumer, goal */
+	      if(generic_encode(untag_generator_susp(genobj->u.o), buffer, depth)){
 		goto Make_exref;
 	      }
+
 	    } else {
-		/* REF chain continued */
-	      data = temp;
-	      temp = temp1;
-	      goto deref_x;
+	      /* consumer, goal */
+	      goto Make_exref;
 	    }
 	  } else {
-	    /* Already instantiated */
+	    /* REF chain continued */
 	    data = temp;
-	    goto again;
+	    temp = temp1;
+	    goto deref_x;
 	  }
 	} else {
-	  /* Simple variable */
-	  goto Make_exref;
+	  /* Already instantiated */
+	  data = temp;
+	  goto again;
 	}
+      } else {
+	/* Simple variable */
+	goto Make_exref;
       }
-      break;
     }
+    break;
+  }
   END_ENCODE_DATA();
   return;
+
  Make_exref:
   {
-      long index = regist_exptbl(data);
-      PUT4_BUFFER(buffer, decode_exref, my_node, index, EXPORT_UNIT_WEC);
-      END_ENCODE_DATA();
-      return;
+    long index = regist_exptbl(data);
+    PUT4_BUFFER(buffer, decode_exref, my_node, index, EXPORT_UNIT_WEC);
+    END_ENCODE_DATA();
+    return;
   }
+
  Atomic_case:
  Const_case:
   PUT2_BUFFER(buffer, decode_atomic_or_const, data);
diff -ruN klic-3.003-2002-01-12a/runtime/debug.c klic-3.003-2002-01-13/runtime/debug.c
--- klic-3.003-2002-01-12a/runtime/debug.c	Sat Jan  5 12:30:48 2002
+++ klic-3.003-2002-01-13/runtime/debug.c	Sun Jan 13 12:30:53 2002
@@ -45,9 +45,15 @@
 
 extern jmp_buf klic_topmost;
 
-extern void
+#ifdef DECL_FPRINTF
+extern int fprintf VA_ARGS((FILE* out, char* format, ...));
+#endif
+
+typedef void (*FPRINTF) VA_ARGS((FILE* out, char* format, ...));
+
+extern NeverReturn void
 fatal(message)
-     char *message;
+  char* message;
 {
   declare_globals;
 
@@ -56,11 +62,11 @@
 #ifdef DIST
   /* klic_fprintf(stderr, "Node %d Going to dump core\n", my_node); */
 
-  /*  ERROR_STOP; */
+  /* ERROR_STOP; */
 
   DetachIO();
   EmergencyStop();
-#endif
+#endif /* DIST */
 
   if (postmortem_pred !=0 && postmortem_args !=0) {
     longjmp(klic_topmost, 1);
@@ -74,61 +80,47 @@
   exit(-1);
 }
 
-klic_exit(N)
-int N;
-{
-#ifdef DIST
-  kill_child();
-#endif
-#ifdef SHM
-  abend("");
-#endif
-  exit(N);
-}
-
-extern void
+extern NeverReturn void
 fatalf(format, a0, a1, a2, a3, a4, a5, a6, a7)
-     char *format;
-     long a0, a1, a2, a3, a4, a5, a6, a7;
+  char* format;
+  long a0, a1, a2, a3, a4, a5, a6, a7;
 {
   char buf[4096];
-  (void) sprintf(buf, format, a0, a1, a2, a3, a4, a5, a6, a7);
+  sprintf(buf, format, a0, a1, a2, a3, a4, a5, a6, a7);
   fatal(buf);
 }
 
-extern void
+extern NeverReturn void
 fatalp(where, format, a0, a1, a2, a3, a4, a5, a6, a7)
-     char *where, *format;
-     long a0, a1, a2, a3, a4, a5, a6, a7;
+  char* where;
+  char* format;
+  long a0, a1, a2, a3, a4, a5, a6, a7;
 {
 #ifdef DIST
   char buf[4096];
-  char *bufp;
-#ifdef DECL_SYS_ERRLIST
-  extern char *sys_errlist[];
-#endif
-  (void) sprintf(buf, "%s: %s\n", where, strerror(errno));
+  char* bufp;
+  sprintf(buf, "%s: %s\n", where, strerror(errno));
   bufp = buf + strlen(buf);
-  (void) sprintf(bufp, format, a0, a1, a2, a3, a4, a5, a6, a7);
+  sprintf(bufp, format, a0, a1, a2, a3, a4, a5, a6, a7);
   fatal(buf);
-#else
+#else /* not DIST */
   perror(where);
   fatalf(format, a0, a1, a2, a3, a4, a5, a6, a7);
-#endif
+#endif /* not DIST */
 }
 
 #ifdef DIST
 /* inner functions for DISTRIBUTED version */
-void 
+static void
 iofprintf_inner(out, format, args)
-FILE *out;
-char *format;
-va_list args;
+  FILE* out;
+  char* format;
+  va_list args;
 {
   char io_buf[2048];
   declare_globals;
   vsprintf(io_buf, format, args);
-  
+
   if ( Node_type() ) {
     if(out == stdout)
       Print(io_buf);
@@ -137,91 +129,95 @@
     else
       fputs(io_buf, out);
   } else {
-    fputs(io_buf, out );
+    fputs(io_buf, out);
   }
   va_end(args);
 }
 
-void
+static void
 #ifdef USE_STDARG
-iofprintf(FILE *out, char *format, ...)
+iofprintf(FILE* out, char* format, ...)
 #else
 iofprintf(out, format, va_alist)
-FILE *out;
-char *format;
-va_dcl
+  FILE* out;
+  char* format;
+  va_dcl
 #endif
 {
-    va_list args;
-    char io_buf[2048];
-    declare_globals;
+  va_list args;
+  char io_buf[2048];
+  declare_globals;
 
-    VA_START(args, format);
-    iofprintf_inner(out, format, args);
-    va_end(args);
+  VA_START(args, format);
+  iofprintf_inner(out, format, args);
+  va_end(args);
 }
 
 
-void
+extern void
 #ifdef USE_STDARG
-ioprintf(char *format, ...)
+ioprintf(char* format, ...)
 #else
 ioprintf(format, va_alist)
-char *format;
-va_dcl
+  char* format;
+  va_dcl
 #endif
 {
-    va_list args;
-    char io_buf[2048];
-    declare_globals;
+  va_list args;
+  char io_buf[2048];
+  declare_globals;
 
-    VA_START(args, format);
-    iofprintf_inner(stdout, format, args);
-    va_end(args);
+  VA_START(args, format);
+  iofprintf_inner(stdout, format, args);
+  va_end(args);
 }
 
-void
+extern void
 #ifdef USE_STDARG
-ioeprintf(char *format, ...)
+ioeprintf(char* format, ...)
 #else
 ioeprintf(format, va_alist)
-char *format;
-va_dcl
+  char* format;
+  va_dcl
 #endif
 {
-    va_list args;
-    char io_buf[2048];
-    declare_globals;
+  va_list args;
+  char io_buf[2048];
+  declare_globals;
 
-    VA_START(args, format);
-    iofprintf_inner(stderr, format, args);
-    va_end(args);
+  VA_START(args, format);
+  iofprintf_inner(stderr, format, args);
+  va_end(args);
 }
 
-void
+extern void
 #ifdef USE_STDARG
-iosprintf(char *format, ...)
+iosprintf(char* format, ...)
 #else
 iosprintf(format, va_alist)
-char *format;
-va_dcl
+  char* format;
+  va_dcl
 #endif
 {
-    va_list args;
-    char io_buf[2048];
-    declare_globals;
+  va_list args;
+  char io_buf[2048];
+  declare_globals;
 
-    VA_START(args, format);
-    iofprintf_inner(stderr, format, args);
-    va_end(args);
+  VA_START(args, format);
+  iofprintf_inner(stderr, format, args);
+  va_end(args);
 }
+#endif /* DIST */
+
 
-static char *putbuf_fordist(redirect, bufp, buf, out)
-int redirect;
-char *bufp;
-char *buf;
-FILE *out;
+static char*
+putbuf_fordist(redirect, bufp, buf, out)
+  int redirect;
+  char* bufp;
+  char* buf;
+  FILE* out;
 {
+#ifdef DIST
   if(bufp != buf) {
     *bufp = '\0';
     if(redirect) {
@@ -242,30 +238,26 @@
     }
     bufp = buf;
   }
+#endif /* DIST */
+
   return bufp;
 }
-#endif  /* DIST */
 
-#ifdef DECL_FPRINTF
-extern int fprintf VA_ARGS((FILE *out, char *format, ...));
-#endif
 
-static Inline void 
+static Inline void
 klic_inner_fprintf(redirect, out, format,
 		   a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab)
-     int redirect; /* if redirect != 0 -> redirect stdout/err */
-     FILE *out;
-     char *format;
-     long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab;
+  int redirect; /* if redirect != 0 -> redirect stdout/err */
+  FILE* out;
+  char* format;
+  long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab;
 {
-  char *f;
-#ifdef DIST
+  char* f;
   char buf[4096];
-  char *bufp = buf;
+  char* bufp = buf;
   declare_globals;
-#endif
 
-  void (*fprintf_func) VA_ARGS((FILE *out, char *format, ...));
+  FPRINTF fprintf_func;
 
   long args[12], *argp;
   args[0] = a0; args[1] = a1; args[2] = a2; args[3] = a3;
@@ -279,80 +271,79 @@
   } else
 #endif
   {
-    fprintf_func = (void (*) VA_ARGS((FILE *, char *, ...))) (fprintf);
+    fprintf_func = (FPRINTF) fprintf;
   }
 
   for (f = format; *f != '\0'; f++) {
     if (*f == '%') {
-#ifdef DIST
       bufp = putbuf_fordist(redirect, bufp, buf, out);
-#endif
       f++;
       switch (*f) {
       case 'k':
 #ifdef DEBUGLIB
-	fprint_partially(out, (q)*argp, 3, 10);
+	fprint_partially(out, (q) *argp, 3, 10);
 #else
 	fprintf_func(out, "???");
 #endif
 	argp++;
 	break;
       case 'F':
+	fprintf_func(out, "%s/%d",
 #ifdef DEBUGLIB
-	(*fprintf_func)(out, "%s/%d",
-			atomname[functors[*argp-FUNCTORNUMBERBASE]-
-			      ATOMNUMBERBASE],
-			arities[*argp++ -FUNCTORNUMBERBASE]);
+		atomname[functors[*argp-FUNCTORNUMBERBASE] - ATOMNUMBERBASE],
 #else
-	(*fprintf_func)(out, "???/%d",
-			arities[*argp++ -FUNCTORNUMBERBASE]);
+		"???",
 #endif
+		arities[*argp -FUNCTORNUMBERBASE] );
+	argp++;
 	break;
       default:
 	{
 	  int k;
 	  char fmtbuf[1024];
 	  fmtbuf[0] = '%';
-	  k=1;
-	  while ((!isalpha(*f) || *f == 'l') && *f != 0) {
+	  for (k=1;  (!isalpha(*f) && *f != '\0') || *f == 'l';  k++, f++) {
 	    if (k>=1022) {
 	      fatal("Too complicated format string for debug_printf");
 	    }
-	    fmtbuf[k++] = *f++;
+	    fmtbuf[k] = *f;
 	  }
-	  fmtbuf[k++] = *f;
-	  fmtbuf[k] = 0;
-	  (*fprintf_func)(out, fmtbuf, *argp++);
+	  fmtbuf[k] = *f;
+	  k++;
+	  fmtbuf[k] = '\0';
+	  fprintf_func(out, fmtbuf, *argp);
+	  argp++;
 	}
       }
     } else {
 #ifdef DIST
-      *bufp++ = *f;
+      *bufp = *f;
+      bufp++;
 #else
       klic_putc(*f, out);
 #endif
     }
   }
-#ifdef DIST
   bufp = putbuf_fordist(redirect, bufp, buf, out);
-#endif
 }
 
+
 extern void
 klic_fprintf(out, format,
-		  a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab)
-     FILE *out;
-     char *format;
-     long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab;
+	     a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab)
+  FILE* out;
+  char* format;
+  long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab;
 {
   klic_inner_fprintf(1, out, format,
 		     a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab);
 }
 
+extern void
 klic_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;
+  char* format;
+  long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab;
 {
   klic_inner_fprintf(1, stdout, format,
 		     a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab);
@@ -360,10 +351,10 @@
 
 extern void
 debug_fprintf(out, format,
-		  a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab)
-     FILE *out;
-     char *format;
-     long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab;
+	      a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab)
+  FILE* out;
+  char* format;
+  long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab;
 {
   klic_inner_fprintf(0, out, format,
 		     a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab);
@@ -372,9 +363,9 @@
 
 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;
+	     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;
 {
   debug_fprintf(stderr, format,
 		a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab);
diff -ruN klic-3.003-2002-01-12a/runtime/export_table.c klic-3.003-2002-01-13/runtime/export_table.c
--- klic-3.003-2002-01-12a/runtime/export_table.c	Mon Jan  7 14:36:52 2002
+++ klic-3.003-2002-01-13/runtime/export_table.c	Sun Jan 13 11:26:48 2002
@@ -19,6 +19,8 @@
 #define EXP_TABLE_INC_SIZE	0x1000
 #define UNUSED_EXPREC  0xf0f0f0ff  /* This value is curious!! */
 
+extern q general_gc();
+
 struct exp_entry{
   long index;
   long wec;
@@ -30,46 +32,49 @@
 static struct exp_entry* top_of_exp_freelist;
 static long current_exp_size;
 
-static void initiate_allocated_exp_table()
+static void
+initiate_allocated_exp_table()
 {
   int i;
 
   top_of_exp_freelist = &exp_table[current_exp_size];
 
-  for(i = current_exp_size ; i < (current_exp_size+EXP_TABLE_INC_SIZE); i++){
+  for(i = current_exp_size ; i < current_exp_size+EXP_TABLE_INC_SIZE; i++){
     exp_table[i].index = i;            /* for getting index from address */
     exp_table[i].wec   = 0;            /* for getting index from address */
     exp_table[i].next = &exp_table[i+1];
-    exp_table[i].data = (q)UNUSED_EXPREC;
+    exp_table[i].data = (q) UNUSED_EXPREC;
   }
   exp_table[current_exp_size+EXP_TABLE_INC_SIZE-1].next = 0;
 
   current_exp_size += EXP_TABLE_INC_SIZE;
 }
 
-static struct exp_entry *pop_exp_table_entry()
+static struct exp_entry*
+pop_exp_table_entry()
 {
-  struct exp_entry *poped_exp_entry;
+  struct exp_entry* poped_exp_entry;
 
-  if (!top_of_exp_freelist){
+  if (top_of_exp_freelist == NULL){
     /*** for Debug ***
-    for(i=0; i<current_exp_size-1; i++){
-      if(exp_table[i].wec == 0){
-	ioeprintf("Export table reclaim error in entry %d\n",i);
-      }
-    }
-    *** for Debug ***/
+     * int i;
+     * for( i=0; i<current_exp_size-1; i++ ){
+     *   if( exp_table[i].wec == 0 ){
+     *     ioeprintf("Export table reclaim error in entry %d\n", i);
+     *   }
+     * }
+     *** for Debug ***/
 
     {
-      char *exp_alloc;
+      char* exp_alloc;
 
-      exp_alloc = (char *) realloc((char *)exp_table, 
-	  (current_exp_size+EXP_TABLE_INC_SIZE)*sizeof(struct exp_entry));
+      exp_alloc = (char*) realloc((char*) exp_table,
+	(current_exp_size+EXP_TABLE_INC_SIZE)*sizeof(struct exp_entry));
       if(exp_alloc == NULL){
 	fatal("realloc failed in pop_exp_table_entry");
       }
-      
-      exp_table = (struct exp_entry*)exp_alloc;
+
+      exp_table = (struct exp_entry*) exp_alloc;
 
       initiate_allocated_exp_table();
     }
@@ -78,78 +83,47 @@
   poped_exp_entry = top_of_exp_freelist;
   top_of_exp_freelist = top_of_exp_freelist->next;
 
-  if(poped_exp_entry->data != (q)UNUSED_EXPREC){
+  if(poped_exp_entry->data != (q) UNUSED_EXPREC){
     ioeprintf("export_entry doubly used\n");
     ERROR_STOP;
     fatal("export_entry doubly used");
   }
-  return(poped_exp_entry);
+  return poped_exp_entry;
 }
 
-static void push_exp_table_entry(push_exp_entry)
-     struct exp_entry *push_exp_entry;
+static void
+push_exp_table_entry(push_exp_entry)
+  struct exp_entry* push_exp_entry;
 {
-  push_exp_entry->data = (q)UNUSED_EXPREC;
+  push_exp_entry->data = (q) UNUSED_EXPREC;
   push_exp_entry->next = top_of_exp_freelist;
   top_of_exp_freelist = push_exp_entry;
 }
 
-#ifdef I_think_this_is_for_debug /* kumon */
-static void check_exp_table_data(data)
-     q data;
-{
- TOP:
-  switch(ptagof(data)){
-  case ATOMIC:
-    return;
-  case CONS:
-    check_exp_table_data(car_of(data));
-    check_exp_table_data(cdr_of(data));    
-    return;
-  case FUNCTOR:
-    fatal("not appear yet\n");
-    return;
-  case VARREF:
-    deref_and_switch(data, VAR, TOP, TOP, TOP);
-  VAR:
-    return;
-  default:
-    fatal("invalid data\n");    
-  }
-}
-void check_exp_table()
-{
-  int i;
-  for(i=0;i<current_exp_size;i++){
-    if(exp_table[i].data != (q)UNUSED_EXPREC){
-      check_exp_table_data(exp_table[i].data);
-    }
-  }
-}
-#endif /* I_think_this_is_for_debug kumon */
-
-long regist_exptbl(data)
-     q data;
+extern long
+regist_exptbl(data)
+  q data;
 {
-  struct exp_entry *exp_table_entry;
+  struct exp_entry* exp_table_entry;
 
   exp_table_entry = pop_exp_table_entry();
   active_exp_entry++;
 
-  exp_table_entry->wec = (long)EXPORT_UNIT_WEC;
+  exp_table_entry->wec = (long) EXPORT_UNIT_WEC;
 
   exp_table_entry->data = data;
-  return(exp_table_entry->index);
+  return exp_table_entry->index;
 }
 
-q search_exptbl(index, wec)
-     long index;
-     long wec;
+extern q
+search_exptbl(index, wec)
+  long index;
+  long wec;
 {
   q data;
 
   data = exp_table[index].data;
-  if((long)data == UNUSED_EXPREC){
+  if((long) data == UNUSED_EXPREC){
     ioeprintf("invalid exp record %d\n", index);
     ERROR_STOP;
   }
@@ -158,31 +132,30 @@
   if (exp_table[index].wec ==0){
     push_exp_table_entry(&exp_table[index]);
     active_exp_entry--;
-
   }
-  return(data);
+  return data;
 }
 
 
-void initiate_exp_table()
+extern void
+initiate_exp_table()
 {
-  char *exp_alloc;
+  char* exp_alloc;
 
-  current_exp_size = 0;
+  current_exp_size = 0L;
 
-  exp_alloc = (char *) malloc(EXP_TABLE_INC_SIZE*sizeof(struct exp_entry));
+  exp_alloc = (char*) malloc(EXP_TABLE_INC_SIZE*sizeof(struct exp_entry));
   if(exp_alloc == NULL){
     fatal("malloc failed in initiate_exp_table");
   }
-  exp_table = (struct exp_entry *)exp_alloc;
+  exp_table = (struct exp_entry*) exp_alloc;
 
   initiate_allocated_exp_table();
-
 }
 
-q general_gc();
 
-q* gc_exp_table(allocp, ntop, otop, nsize, osize)
+extern q*
+gc_exp_table(allocp, ntop, otop, nsize, osize)
      q *allocp, *ntop, *otop;
      unsigned long nsize, osize;
 {
@@ -192,8 +165,8 @@
   q newdata;
 
   j = 0;
-  for(i=0;i<current_exp_size;i++){
-    if(exp_table[i].data != (q)UNUSED_EXPREC){
+  for(i=0; i<current_exp_size; i++){
+    if(exp_table[i].data != (q) UNUSED_EXPREC){
       newdata = general_gc(&(exp_table[i].data), allocp, gcsp);
       exp_table[i].data = newdata;
       allocp = heapp;
@@ -202,7 +175,6 @@
     if(j == active_exp_entry){
       break;
     }
-    
   }
-  return(allocp);
+  return allocp;
 }
diff -ruN klic-3.003-2002-01-12a/runtime/faisus.c klic-3.003-2002-01-13/runtime/faisus.c
--- klic-3.003-2002-01-12a/runtime/faisus.c	Fri Jan 11 10:02:05 2002
+++ klic-3.003-2002-01-13/runtime/faisus.c	Sun Jan 13 11:09:27 2002
@@ -17,93 +17,109 @@
 
 #ifdef DEBUGLIB
 #include "trace.h"  /* trace_flag, trace_susp, trace_failure */
-
-extern int count_suspension;
 #endif
 
 #define generic_suspend(obj, ref, goal) \
   (method_table_of(obj)->suspend((ref), (goal)))
 
-static void do_fail(goal, reasonp)
-     struct goalrec *goal;
-     q *reasonp;
+extern struct predicate predicate_unify__term__dcode_xunify__goal_2;
+
+
+#ifdef DEBUGLIB
+extern int count_suspension;
+extern int stepping_flag;
+
+extern void record_suspended_pred();
+extern q* step_susp();
+#endif /* DEBUGLIB */
+
+
+static void
+do_fail(goal, reasonp)
+  struct goalrec* goal;
+  q* reasonp;
 {
 #ifdef DEBUGLIB
-  extern int stepping_flag;
   goal->next = 0;
   if (stepping_flag) {
     step_failure(goal);
     return;
   }
   trace_failure(goal);
-#endif
+#endif /* DEBUGLIB */
+
   fatal("Reduction Failure");
 }
 
-#ifdef DEBUGLIB
-static Inline q *record_susp(allocp, goal)
-     q *allocp;
-     struct goalrec *goal;
+
+static Inline q* record_susp(allocp, goal)
+  q* allocp;
+  struct goalrec* goal;
 {
+#ifdef DEBUGLIB
   declare_globals;
-  struct suspended_goal_rec *sm;
-  void record_suspended_pred();
+  struct suspended_goal_rec* sm;
   heapalloc(sm, sizeof(struct suspended_goal_rec)/sizeof(q),
-	    (struct suspended_goal_rec *));
+	    (struct suspended_goal_rec*));
   sm->goal = goal;
   sm->next = suspended_goal_list;
   suspended_goal_list = sm;
   if (count_suspension) {
     record_suspended_pred(goal);
   }
+#endif /* DEBUGLIB */
+
   return allocp;
 }
-#endif
 
-q *suspend_goal(allocp, goal, reason, spontaneous)
-     q *allocp;
-     struct goalrec *goal;
-     q reason;
-     int spontaneous;
+
+extern q*
+suspend_goal(allocp, goal, reason, spontaneous)
+  q* allocp;
+  struct goalrec* goal;
+  q reason;
+  int spontaneous;
 {
   declare_globals;
   int suspended = 0;
 
-  goal->next = (struct goalrec *)makeint(current_prio);
+  goal->next = (struct goalrec*) makeint(current_prio);
   if (derefone(reason) == reason) {
     /* no goals suspended yet on this variable */
-    struct susprec *susp;
+    struct susprec* susp;
     q newvar;
-    allocnewsusp(newvar,susp);
+    allocnewsusp(newvar, susp);
     susp->u.first_hook.u.g = goal;
     derefone(reason) = newvar;
     suspended = 1;
   } else {
     /* some goals already has suspended */
-    struct susprec *susp;
-    struct hook *newhook;
+    struct susprec* susp;
+    struct hook* newhook;
     susp = suspp(derefone(reason));  /* for shm implementation */
+
 #ifdef SHM
     /*
-       On shared memory implementation,
-       this `susp' may be instanciated by one of the other processors.
-       Thus, check again.
-       */
+     * On shared memory implementation,
+     * this `susp' may be instanciated by one of the other processors.
+     * Thus, check again.
+     */
     if ( !isref(susp) || reason != derefone(susp) ) {
       resume_same_prio(goal);
-      return(allocp);
+      return allocp;
     }
-#endif
+#endif /* SHM */
+
     /* generator object ? */
     if (!is_generator_susp(susp->u)) {
       /* then allocate new hook */
-      allochook(&susp->u.first_hook,newhook);
+      allochook(&susp->u.first_hook, newhook);
       newhook->u.g = goal;
       suspended = 1;
     } else {
-      struct generator_susp *gsusp = generator_suspp(susp);
+      struct generator_susp* gsusp = generator_suspp(susp);
       q ref = gsusp->backpt;
-      struct generator_object *gobj = untag_generator_susp(gsusp->u.o);
+      struct generator_object* gobj = untag_generator_susp(gsusp->u.o);
       q tmp = generic_generate(gobj, allocp);
       if (tmp != (q)0) {
 	if ( tmp == makecons(0) ) {
@@ -120,19 +136,18 @@
         }
       } else {
 	/* This case, the instanciation by generator object must
-	   postponed. Thus:
-	   1. ``goal'' is hooked on new variable ``newvar''.
-	   2. enqueue unification goal between ``newvar'' and ``ref'' */
-	struct susprec *susp;
+	 * postponed. Thus:
+	 * 1. ``goal'' is hooked on new variable ``newvar''.
+	 * 2. enqueue unification goal between ``newvar'' and ``ref'' */
+	struct susprec* susp;
 	q newvar;
-	struct goalrec *newgp = (struct goalrec *)allocp;
-	extern struct predicate predicate_unify__term__dcode_xunify__goal_2;
+	struct goalrec* newgp = (struct goalrec*) allocp;
 
 	suspended = 1;
 
-	allocnewsusp(newvar,susp);
+	allocnewsusp(newvar, susp);
 	susp->u.first_hook.u.g = goal;
-	newgp->next = (struct goalrec *)makeint(current_prio);
+	newgp->next = (struct goalrec*) makeint(current_prio);
 	newgp->pred = &predicate_unify__term__dcode_xunify__goal_2;
 	newgp->args[0] = reason;
 	newgp->args[1] = newvar;
@@ -143,15 +158,14 @@
     }
   }
   if (suspended) {
-#ifdef DEBUGLIB
     allocp = record_susp(allocp, goal);
-#endif
     suspensions++;
   }
 
-  return(allocp);
+  return allocp;
 }
 
+
 extern q*
 interrupt_goal(allocp, pred, reasonp)
   q* allocp;
@@ -159,17 +173,17 @@
   q* reasonp;
 {
   declare_globals;
-  struct goalrec *goal = (struct goalrec *)allocp;
+  struct goalrec* goal = (struct goalrec*) allocp;
   allocp += pred->arity + 2;
   goal->pred = pred;
 
-  if (reasonp == 0) {
+  if (reasonp == NULL) {
     /* Interrupt by some external event, such as: */
     /*   - A higher priority goal got ready for execution */
     /*   - Garbage collection required */
     /* In such cases, the interrupted goal is pushed down to the queue. */
-    struct goalrec *rsmg = resumed_goals;
-    if (rsmg == 0) {
+    struct goalrec* rsmg = resumed_goals;
+    if (rsmg == NULL) {
       goal->next = goal;
     } else {
       goal->next = rsmg->next;
@@ -182,7 +196,7 @@
   } else {
     /* First, try dereference */
     /* Compiled out code won't dereference more than one level */
-    q *rp;
+    q* rp;
     for (rp=reasons; rp<reasonp; rp++) {
       q v = *rp, iv = v, ov;
       do {
@@ -198,53 +212,44 @@
       } while (derefone(v) != ov);
     }
     /* OK, the goal should really be suspended */
+
 #ifdef DEBUGLIB
-    {
-      extern int stepping_flag;
-      q *step_susp();
-      if (reasonp > reasons) {
-	if (stepping_flag) {
-	  allocp = step_susp(allocp, goal, reasonp, 0);
-	  return allocp;
-	} else if (trace_flag) {
-	  goal = trace_susp(goal, reasonp, 0);
-	}
+    if (reasonp > reasons) {
+      if (stepping_flag) {
+	allocp = step_susp(allocp, goal, reasonp, 0);
+	return allocp;
+      } else if (trace_flag) {
+	goal = trace_susp(goal, reasonp, 0);
       }
     }
-#endif
+#endif /* DEBUGLIB */
 
-    goal->next = (struct goalrec *)makeint(current_prio);
+    goal->next = (struct goalrec*) makeint(current_prio);
     {
       int redo_request = 0;
       do {
 	q tmp, tmp1;
-/*
-	for (tmp = *(--reasonp), tmp1 = derefone(tmp);
-	     derefone(tmp1) != tmp;
-	     tmp = tmp1, tmp1 = derefone(tmp))
-	  ;
-*/
-	tmp = *(--reasonp);
-	while (1) {
+
+	reasonp--;
+	for (tmp = *reasonp; ; tmp = tmp1) {
 	  tmp1 = derefone(tmp);
 	  if ( !isref(tmp1) ) {
-		resume_same_prio(goal);
-		return allocp;
+	    resume_same_prio(goal);
+	    return allocp;
 	  }
-	  if (derefone(tmp1) == tmp ) break;
-	  tmp = tmp1;
+	  if (derefone(tmp1) == tmp) break;
 	}
 
 	if (tmp == tmp1) {
 	  /* no goals suspended yet on this variable */
-	  struct susprec *susp;
+	  struct susprec* susp;
 	  q newvar;
-	  makenewsusp(newvar,susp,allocp);
+	  makenewsusp(newvar, susp, allocp);
 	  susp->u.first_hook.u.g = goal;
 	  derefone(tmp) = newvar;
 	} else {
 	  /* some goals already has suspended */
-	  struct susprec *susp = suspp(tmp1);
+	  struct susprec* susp = suspp(tmp1);
 	  /* generator object ? */
 	  if(!is_generator_susp(susp->u)) {
 	    if (susp->u.first_hook.next->u.g == goal) {
@@ -252,15 +257,15 @@
 		 This includes the case where there's only one hook,
 		 because of the loop structure of the hook chain. */
 	    } else {
-	      struct hook *newhook;
-	      addhook(&susp->u.first_hook,newhook,allocp);
+	      struct hook* newhook;
+	      addhook(&susp->u.first_hook, newhook, allocp);
 	      newhook->u.g = goal;
 	    }
 	  } else {
 	    /* generator object */
-	    struct generator_susp *gsusp = generator_suspp(susp);
+	    struct generator_susp* gsusp = generator_suspp(susp);
 	    q ref = gsusp->backpt;
-	    struct generator_object *gobj = untag_generator_susp(gsusp->u.o);
+	    struct generator_object* gobj = untag_generator_susp(gsusp->u.o);
 	    q tmp = generic_generate(gobj, allocp);
 
 	    if(tmp == makecons(0)) {
@@ -271,7 +276,7 @@
 	    } else {
 	      redo_request = 1;
 	      if(tmp != makeref(0)) {
-		allocp = heapp; 
+		allocp = heapp;
 		derefone(ref) = tmp;
 	      } /* else GC request */
 	    }
@@ -281,9 +286,7 @@
       if (redo_request) {
 	resume_same_prio(goal);
       } else {
-#ifdef DEBUGLIB
 	allocp = record_susp(allocp, goal);
-#endif
 	suspensions++;
       }
     }
@@ -291,10 +294,11 @@
   }
 }
 
+
 extern int
 check_stack_for_alternatively(allocp, reasonp)
-     q *allocp;
-     q *reasonp;
+  q* allocp;
+  q* reasonp;
 {
   declare_globals;
 
@@ -303,10 +307,10 @@
     q tmp, tmp1;
     q var = *(--reasonp);
     q value;
-    struct susprec *susp;
+    struct susprec* susp;
     tmp = var;
     if (isref(tmp)) {
-      while (1) {
+      for (;;) {
         tmp1 = derefone(tmp);
         if (tmp == tmp1) goto fin;
         if (!isref(tmp1)) {
@@ -319,10 +323,9 @@
       susp = suspp(tmp1);
       /* generator object ? */
       if (is_generator_susp(susp->u)) {
-        struct generator_susp *gsusp = generator_suspp(susp);
+        struct generator_susp* gsusp = generator_suspp(susp);
         q ref = gsusp->backpt;
-        q tmp = generic_generate(untag_generator_susp(gsusp->u.o),
-                                 allocp);
+        q tmp = generic_generate(untag_generator_susp(gsusp->u.o), allocp);
         allocp = heapp;
         if (tmp == 0) goto fin;
         derefone(ref) = tmp;
diff -ruN klic-3.003-2002-01-12a/runtime/functt.kl1 klic-3.003-2002-01-13/runtime/functt.kl1
--- klic-3.003-2002-01-12a/runtime/functt.kl1	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2002-01-13/runtime/functt.kl1	Sun Jan 13 10:27:34 2002
@@ -4,7 +4,9 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
+
 :- inline:"extern unsigned long enter_functor();".
+
 :- module functor_table.
 
 new_functor(Funct,'.',2) :- Funct=[0|0].
@@ -12,9 +14,10 @@
 new_functor(Funct,Atom,0) :- atom(Atom) | Funct=Atom.
 new_functor(Funct,Atom,Arity):- 
 	Arity > 0,
-        inline:"{
+        inline:"
+{
   long i, arity = intval(%1);
-  allocp[0] = makesym(enter_functor(symval(%0),arity));
+  allocp[0] = makesym(enter_functor(symval(%0), arity));
   for (i=1; i<=arity; i++) allocp[i] = makeint(0);
   %2 = makefunctor(allocp);
   allocp += arity+1;
@@ -35,7 +38,7 @@
 fill_args([],_,F0,F) :- F=F0.
 fill_args([H|T],K,F0,F) :- inline:"
 {
-  struct functor *f = functorp(%0);
+  struct functor* f = functorp(%0);
   f->args[intval(%1)] = %2;
   %3 = makefunctor(f);
 }":[F0+functor,K+int,H+any,F1-functor] |
@@ -67,8 +70,10 @@
 setarg(N,[Car|_Cdr],NewCdr,NFunct) :- N=2 | NFunct=[Car|NewCdr].
 setarg(Index,Funct,Ele,NFunct) :- inline:"
 {
-  if (isfunctor(%0)) {
-    struct functor *f = functorp(%0);
+  if( !isfunctor(%0) ){
+    goto %f;
+  }else{
+    struct functor* f = functorp(%0);
     int index = intval(%1);
     q pf = f->functor;
     int size = arityof(pf);
@@ -79,6 +84,6 @@
     }
     %2 = makefunctor(allocp);
     allocp += size+1;
-  } else goto %f;
+  }
 }":[Funct+functor,Index+int,NF0-functor,Ele+any] |
     NFunct=NF0.
diff -ruN klic-3.003-2002-01-12a/runtime/gunix.kl1 klic-3.003-2002-01-13/runtime/gunix.kl1
--- klic-3.003-2002-01-12a/runtime/gunix.kl1	Mon Jan  7 16:41:19 2002
+++ klic-3.003-2002-01-13/runtime/gunix.kl1	Sun Jan 13 11:43:32 2002
@@ -62,6 +62,19 @@
 extern q gd_new_pointer();
 extern char* getenv();
 
+static NeverReturn void
+klic_exit(N)
+  int N;
+{
+#ifdef DIST
+  kill_child();
+#endif
+#ifdef SHM
+  abend(\"\");
+#endif
+  exit(N);
+}
+
 #define FilePointer(x) \\
   ((FILE*) ((struct pointer_object*) data_objectp(x))->pointer)
 
@@ -300,7 +313,7 @@
 :- module unix.
 
 exit(Stat) :- inline:"
-klic_exit(intval(%0));
+  klic_exit(intval(%0));
 ":[Stat+int] | true.
 
 unix([]).
diff -ruN klic-3.003-2002-01-12a/runtime/runtime.h klic-3.003-2002-01-13/runtime/runtime.h
--- klic-3.003-2002-01-12a/runtime/runtime.h	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2002-01-13/runtime/runtime.h	Sun Jan 13 13:44:44 2002
@@ -6,6 +6,8 @@
 #ifndef RUNTIME_H
 #define RUNTIME_H
 
+#include <klic/struct.h>
+
 /* cmphsh.c */
 extern q hash_kl1_term(q x, long l);
 
@@ -17,5 +19,10 @@
 extern struct goalrec*
   send_throw_goal(long node, struct goalrec* goal, struct goalrec* oldqp);
 extern void terminate_all_node(void);
+
+/* debug.c */
+extern void ioprintf VA_ARGS((char* format, ...));
+extern void ioeprintf VA_ARGS((char* format, ...));
+extern void iosprintf VA_ARGS((char* format, ...));
 
 #endif  /* RUNTIME_H */
