Index: ChangeLog
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/ChangeLog,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 ChangeLog
--- ChangeLog	2000/07/28 02:01:40	1.1.1.1
+++ ChangeLog	2001/08/16 09:57:35
@@ -1,3 +1,37 @@
+Thu May  3 23:06:39 2001  Hiroshi IGARASHI  <iga@ruby-lang.org>
+
+	* Makefile.tail, compiler/Makefile: specify -L../runtime via
+	LD_LIBRARY_OPTIONS when compiler is compiled.
+
+Thu Oct 12 18:16:32 2000  Hiroshi IGARASHI  <iga@ruby-lang.org>
+
+	* Configure, Makefile.tail: specify runpath by ld option `-R'
+	for Solaris.
+
+Thu Oct 12 14:54:17 2000  Hiroshi IGARASHI  <iga@ruby-lang.org>
+
+	* Makefile.tail (clean): pass value of variable DLLIBS.
+
+Thu Oct 12 14:50:34 2000  Hiroshi IGARASHI  <iga@ruby-lang.org>
+
+	* runtime/trace.c (get_mte): should be independent of dynamic location
+	of functions.
+
+Wed Oct 11 16:33:41 2000  Yusuke TAKAGI  <takagi@ueda.info.waseda.ac.jp>
+
+	* runtime/termio.kl1: support prolog-like IO for socket stream.
+
+Wed Oct 11 16:31:13 2000  Hiroshi IGARASHI  <iga@ruby-lang.org>
+
+	* runtime/asyncio.c, runtime/gunix.kl1, runtime/signal.c:
+	support full-duplex IO for socket stream.
+
+Mon Jul 31 05:04:10 2000  Hiroshi IGARASHI  <iga@ruby-lang.org>
+
+	* Configure, Makefile.tail, compiler/Makefile, disttest/Makefile,
+	runtime/Makefile.head, runtime/Makefile.tail, shmtest/Makefile,
+	test/Makefile: add shared library support(Linux/Solaris only).
+
 Sat Mar 27 11:14:18 1999  Sekita Daigo  <sekita@mri.co.jp>
 
 	* macro.kl1: fix the bug in replaceClase for the :- Dec form clause.
Index: Configure
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/Configure,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Configure
--- Configure	2000/07/28 02:01:40	1.1.1.1
+++ Configure	2001/08/16 09:57:36
@@ -357,6 +357,7 @@ fi
 
 if $CROSS; then
 ARCHIVES="libklicd.a"
+DLLIBS="libklicd\$(DLLEXT)"
 
 cat <<GAZONK
 # You specified to build the cross system.   To build the cross system,
@@ -386,6 +387,7 @@ cat <<GAZONK
 GAZONK
 
 ARCHIVES="libklic.a libklict.a"
+DLLIBS="libklic\$(DLLEXT) libklict\$(DLLEXT)"
 fi
 
 : ::: CPU Type
@@ -403,6 +405,7 @@ echo $n "Configure for distributed memor
 if ask_yes_or_no no DEF_DISTSYSTEM; then
 DISTSYSTEM=true
 ARCHIVES="$ARCHIVES libklicd.a"
+DLLIBS="$DLLIBS libklicd\$(DLLEXT)"
 else
 disttype=pvm
 #INCLUDESH=runtime/config/$disttype/config.h.sh
@@ -461,6 +464,7 @@ if ask_yes_or_no no DEF_SHMSYSTEM; then
   guess_arch
   if [ $CPU != "Unknown_cpu" ]; then
      ARCHIVES="$ARCHIVES libklics.a"
+     DLLIBS="$DLLIBS libklics$(DLLEXT)"
   else 
     cat <<GAZONK
 # I do not know this machine.
@@ -629,6 +633,37 @@ GAZONK
 fi
 echo ' '
 
+DLTYPE="linux"
+echo $n "May I build shared library too? "$c
+if ask_yes_or_no yes DEF_BUILD_DLL; then
+  ask_with_default "shared library type (linux,solaris)" DLTYPE
+  echo " "
+  case $DLTYPE in
+    linux)
+      EXTFLAGS="-fPIC"
+      KLICCFLAGS="$KLICCFLAGS -fPIC"
+      LDSHARED="gcc -shared"
+      DLLEXT=".so"
+      DLLTARGET="runtimedir-dll"
+      DLLINSTALLTARGET="install-runtime-dll";;
+    solaris)
+      EXTFLAGS="-fPIC"
+      KLICCFLAGS="$KLICCFLAGS -fPIC"
+      LDSHARED="gcc -Wl,-G"
+      DLLEXT=".so"
+      DLLTARGET="runtimedir-dll"
+      DLLINSTALLTARGET="install-runtime-dll";;
+    *)
+      echo "$DLTYPE is not supported type."
+      DLLTARGET=""
+      DLLINSTALLTARGET="";;
+  esac
+else
+  DLLTARGET=""
+  DLLINSTALLTARGET=""
+fi
+echo ' '
+
 if [ ! -z "$FORT" ]; then
   echo "May I use $FORT for linkage also "
   echo $n "when linking with Fortran code? "$c
@@ -738,6 +773,13 @@ check_writable "user command" KLICBIN
 check_writable "library" KLICLIB
 check_writable "include file" KLICINCLUDE
 echo " "
+case $DLTYPE in
+    solaris)
+      XLDFLAGS="-R$KLICLIB";;
+    *)
+      XLDFLAGS="";;
+esac
+KLICLDFLAGS="$KLICLDFLAGS $XLDFLAGS"
 
 LIBPATH=""
 for dir in /lib /usr/lib /usr/local/lib; do
@@ -1247,6 +1289,15 @@ LIBSWITCHES = $LIBSWITCHES
 
 # Library archive indexer
 RANLIB = $RANLIB
+
+# Shared Library
+XLDFLAGS = $XLDFLAGS
+EXTFLAGS = $EXTFLAGS
+LDSHARED = $LDSHARED
+DLLEXT = $DLLEXT
+DLLIBS = $DLLIBS
+DLLTARGET = $DLLTARGET
+DLLINSTALLTARGET = $DLLINSTALLTARGET
 
 # Make program
 MAKE = $MAKE
Index: Makefile.tail
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/Makefile.tail,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makefile.tail
--- Makefile.tail	2000/07/28 02:01:40	1.1.1.1
+++ Makefile.tail	2001/08/16 09:57:36
@@ -8,12 +8,12 @@
 # Site-specific definitions will be prepended to this
 # by the configuration script
 
-CFLAGS=$(OPTFLAGS) $(DEBUGFLAGS)
-LDFLAGS=$(LIBSWITCHES)
+CFLAGS=$(OPTFLAGS) $(DEBUGFLAGS) $(EXTFLAGS)
+LDFLAGS=$(LIBSWITCHES) $(XLDFLAGS)
 
-self:	version.sed compilerdir runtimedir
+self:	version.sed compilerdir runtimedir $(DLLTARGET)
 
-cross:	version.sed compilerdir.cross runtimedir
+cross:	version.sed compilerdir.cross runtimedir $(DLLTARGET)
 
 version.sed: version.sed.tmplt klic-version
 	sed -e "s%##TODAY%`date`%;s%##KLICVERSION%`cat klic-version`%" \
@@ -29,19 +29,41 @@ runtimedist:
 
 runtimedir: klic klicdb
 	cd runtime; \
+	LD_LIBRARY_PATH="../runtime:$(LD_LIBRARY_PATH)"; \
+	export LD_LIBRARY_PATH; \
 	$(MAKE) PARALLEL="$(PARALLEL)" \
 		CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		LDFLAGS="$(LDFLAGS)" KL1CMP="$(KL1CMP)" \
 		KLICOPT="$(KLICOPT)" \
 		ARCHIVES="$(ARCHIVES)" LN="$(LN)" DISTTYPE="$(DISTTYPE)"\
-		CC="$(CC)" LD="$(LD)" RANLIB=$(RANLIB) all
+		CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" RANLIB=$(RANLIB) \
+		all
+
+runtimedir-dll: klic klicdb
+	cd runtime; \
+	LD_LIBRARY_PATH="../runtime:$(LD_LIBRARY_PATH)"; \
+	export LD_LIBRARY_PATH; \
+	$(MAKE) PARALLEL="$(PARALLEL)" \
+		CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
+		LDFLAGS="$(LDFLAGS)" KL1CMP="$(KL1CMP)" \
+		KLICOPT="$(KLICOPT)" \
+		ARCHIVES="$(ARCHIVES)" LN="$(LN)" DISTTYPE="$(DISTTYPE)"\
+		CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" DLLIBS="$(DLLIBS)" \
+		LDSHARED="$(LDSHARED)" RANLIB=$(RANLIB) \
+		dll
 
 verify-runtime: klic klicdb
 	cd runtime; \
+	LD_LIBRARY_PATH="../runtime:$(LD_LIBRARY_PATH)"; \
+	export LD_LIBRARY_PATH; \
 	$(MAKE) PARALLEL="$(PARALLEL)" \
 		CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		KL1CMP="$(KL1CMP)" \
-		CC="$(CC)" LD="$(LD)" RANLIB=$(RANLIB) verify
+		CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" RANLIB=$(RANLIB) \
+		verify
 
 compilerdist: runtimedist
 	cd compiler; \
@@ -49,28 +71,46 @@ compilerdist: runtimedist
 		CC="$(CC)" LD="$(LD)" \
 		KL1CMP="$(KL1CMP)" dist
 
-compilerdir: runtimedir
+compilerdir: runtimedir $(DLLTARGET)
 	cd compiler; \
+	LD_LIBRARY_PATH="../runtime:$(LD_LIBRARY_PATH)"; \
+	export LD_LIBRARY_PATH; \
+	KLIC_LD_OPTIONS="-L../runtime $(LDFLAGS)"; \
+	export KLIC_LD_OPTIONS; \
 	$(MAKE) PARALLEL="$(PARALLEL)" \
 		CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		KL1CMP="$(KL1CMP)" KL1SELFCOMP="$(KL1SELFCOMP)" \
 		KLICOPT="$(KLICOPT)" \
-		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" all
+		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" \
+		all
 
 compilerdir.cross:
 	cd compiler; \
+	LD_LIBRARY_PATH="../runtime:$(LD_LIBRARY_PATH)"; \
+	export LD_LIBRARY_PATH; \
+	KLIC_LD_OPTIONS="$(LDFLAGS)"; \
+	export KLIC_LD_OPTIONS; \
 	$(MAKE) PARALLEL="$(PARALLEL)" \
 		CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		KL1CMP="$(KL1CMP)" KL1SELFCOMP="$(KL1SELFCOMP)" \
 		KLICOPT="$(KLICOPT)" \
-		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" klicdb klic
+		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" \
+		klicdb klic
 verify-compiler:
 	cd compiler; \
+	LD_LIBRARY_PATH="../runtime:$(LD_LIBRARY_PATH)"; \
+	export LD_LIBRARY_PATH; \
+	KLIC_LD_OPTIONS="$(LDFLAGS)"; \
+	export KLIC_LD_OPTIONS; \
 	$(MAKE) PARALLEL="$(PARALLEL)" \
 		CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		KL1CMP="$(KL1CMP)" KL1SELFCOMP="$(KL1SELFCOMP)" \
 		KLICOPT="$(KLICOPT)" \
-		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" verify
+		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" \
+		verify
 
 #klic:
 #	cd compiler; \
@@ -82,15 +122,25 @@ verify-compiler:
 
 klic:
 	cd compiler; \
+	LD_LIBRARY_PATH=../runtime:${LD_LIBRARY_PATH}; \
+	export LD_LIBRARY_PATH; \
+	KLIC_LD_OPTIONS="$(LDFLAGS)"; \
+	export KLIC_LD_OPTIONS; \
 	$(MAKE) CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		KL1CMP="$(KL1CMP)" KL1SELFCOMP="$(KL1SELFCOMP)" \
-		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" klic
+		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" klic
 
 klicdb:
 	cd compiler; \
+	LD_LIBRARY_PATH=../runtime:${LD_LIBRARY_PATH}; \
+	export LD_LIBRARY_PATH; \
+	KLIC_LD_OPTIONS="$(LDFLAGS)"; \
+	export KLIC_LD_OPTIONS; \
 	$(MAKE) CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		KL1CMP="$(KL1CMP)" KL1SELFCOMP="$(KL1SELFCOMP)" \
-		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" klicdb
+		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" klicdb
 
 rmonitor:
 	cd rmon; \
@@ -98,48 +148,69 @@ rmonitor:
 
 kl1pp:
 	cd compiler; \
+	LD_LIBRARY_PATH=../runtime:${LD_LIBRARY_PATH}; \
+	export LD_LIBRARY_PATH; \
 	$(MAKE) CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		KL1CMP="$(KL1CMP)" KL1SELFCOMP="$(KL1SELFCOMP)" \
-		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" kl1pp
+		LDFLAGS="$(LDFLAGS)" CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" kl1pp
 
 documentdist:
 	cd documents; $(MAKE) dist
 
-tests:	compilerdir runtimedir
+tests:	compilerdir runtimedir $(DLLTARGET)
 	echo 'Seq. impl.: NG' >tests.log
 	cd test; \
+	LD_LIBRARY_PATH=../runtime:${LD_LIBRARY_PATH}; \
+	export LD_LIBRARY_PATH; \
 	$(MAKE) PARALLEL="$(PARALLEL)" \
 		distclean tests;
 	echo 'Seq. impl.: OK' >tests.log
 
-disttests:	compilerdir runtimedir
+disttests:	compilerdir runtimedir $(DLLTARGET)
 	echo 'Distributed mem. imp.: NG' >disttests.log
 	cd disttest; \
+	LD_LIBRARY_PATH=../runtime:${LD_LIBRARY_PATH}; \
+	export LD_LIBRARY_PATH; \
 	$(MAKE) PARALLEL="$(PARALLEL)" KLICOPT="$(KLICOPT)" NODES="$(NODES)" \
 		distclean all-test;
 	echo 'Distributed mem. imp.: OK' >disttests.log
 
-shmtests:	compilerdir runtimedir
+shmtests:	compilerdir runtimedir $(DLLTARGET)
 	cd shmtest; \
+	LD_LIBRARY_PATH=../runtime:${LD_LIBRARY_PATH}; \
+	export LD_LIBRARY_PATH; \
 	$(MAKE) PARALLEL="$(PARALLEL)" KLICOPT="$(KLICOPT)" NODES="$(NODES)" \
 		distclean all-test
 
-install-basics: all install-compiler install-runtime install-include
+install-basics: all install-compiler install-runtime $(DLLINSTALLTARGET) install-include
 
 install-compiler: compilerdir
 	cd compiler; \
 	$(MAKE) install INSTALL="$(INSTALL)" INSTDIR="$(INSTDIR)" \
 		KL1CMP="$(KL1CMP)" KL1SELFCOMP="$(KL1SELFCOMP)" \
 		KLICLIB="$(KLICLIB)" KLICBIN="$(KLICBIN)" \
-		KLICINCLUDE="$(KLICINCLUDE)"
+		KLICINCLUDE="$(KLICINCLUDE)" DLLEXT="$(DLLEXT)"
 
 install-runtime: runtimedir
 	cd runtime; \
 	$(MAKE) install INSTALL="$(INSTALL)" INSTDIR="$(INSTDIR)" \
 		KL1CMP="$(KL1CMP)" \
 		KLICLIB="$(KLICLIB)" KLICBIN="$(KLICBIN)" \
+		ARCHIVES="$(ARCHIVES)" \
+		KLICINCLUDE="$(KLICINCLUDE)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" RANLIB="$(RANLIB)"
+
+install-runtime-dll: runtimedir-dll
+	cd runtime; \
+	$(MAKE) install-dll INSTALL="$(INSTALL)" INSTDIR="$(INSTDIR)" \
+		KL1CMP="$(KL1CMP)" \
+		KLICLIB="$(KLICLIB)" KLICBIN="$(KLICBIN)" \
 		ARCHIVES="$(ARCHIVES)" \
-		KLICINCLUDE="$(KLICINCLUDE)" RANLIB="$(RANLIB)"
+		KLICINCLUDE="$(KLICINCLUDE)" \
+		DLLEXT="$(DLLEXT)" DLLIBS="$(DLLIBS)" \
+		LDSHARED="$(LDSHARED)" RANLIB="$(RANLIB)" \
+		install-dll
 
 install-include:
 	cd include; \
@@ -154,7 +225,8 @@ install-rmon_server:
 		INSTDIR="$(INSTDIR)" KL1CMP="$(KL1CMP)" \
 		KLICLIB="$(KLICLIB)" KLICBIN="$(KLICBIN)" \
 		ARCHIVES="$(ARCHIVES)" \
-		KLICINCLUDE="$(KLICINCLUDE)" RANLIB="$(RANLIB)"
+		KLICINCLUDE="$(KLICINCLUDE)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" RANLIB="$(RANLIB)"
 
 install-rmonitor: install-rmon_server rmonitor
 	cd rmon; \
@@ -166,7 +238,8 @@ depend:
 		KLICOPT="$(KLICOPT)" PVMDIR="$(PVM_ROOT)"\
 		ARCHIVES="$(ARCHIVES)" LN="$(LN)" \
 		KLICLIB="$(KLICLIB)" KLICBIN="$(KLICBIN)" \
-		KLICINCLUDE="$(KLICINCLUDE)" RANLIB="$(RANLIB)"
+		KLICINCLUDE="$(KLICINCLUDE)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" RANLIB="$(RANLIB)"
 	cd compiler; $(MAKE) depend CFLAGS="$(CFLAGS)" \
 		CC="$(CC)" LD="$(LD)" KLICINCLUDE="$(KLICINCLUDE)" \
 		KLICLIB="$(KLICLIB)" KLICBIN="$(KLICBIN)"
@@ -174,12 +247,13 @@ depend:
 		CFLAGS="$(CFLAGS)" OPTLEVEL="$(OPTLEVEL)" \
 		PVMDIR="$(PVM_ROOT)" PVMLIBDIR="$(PVMLIBDIR)" \
 		PVMLIB="$(PVMLIB)" LDFLAGS="$(LDFLAGS)"\
-		CC="$(CC)" LD="$(LD)" RANLIB=$(RANLIB)
+		CC="$(CC)" LD="$(LD)" \
+		DLLEXT="$(DLLEXT)" LDSHARED="$(LDSHARED)" RANLIB=$(RANLIB)
 
 clean:
 	cd compiler; $(MAKE) clean
 	cd include; $(MAKE) clean
-	cd runtime; $(MAKE) clean LN="$(LN)"
+	cd runtime; $(MAKE) clean LN="$(LN)" DLLIBS="$(DLLIBS)"
 	cd test; $(MAKE) clean
 	cd disttest; $(MAKE) clean
 	cd shmtest; $(MAKE) clean
Index: compiler/Makefile
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/compiler/Makefile,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makefile
--- compiler/Makefile	2000/07/28 02:01:40	1.1.1.1
+++ compiler/Makefile	2001/08/16 09:57:37
@@ -46,7 +46,7 @@ OBJECTS = bb.o gb.o normalize.o version.
 KL1PPOBJS = kl1pp.o cmacro.o macropp.o \
 	msg.o macro.o extern.o obj.o util.o write.o
 
-KLIC = ../compiler/klic -P$(PARALLEL) $(KLICOPT) \
+KLIC =  ../compiler/klic -P$(PARALLEL) $(KLICOPT) \
 	-R -I../include -X. -D../compiler/klicdb -v 
 
 all: klicdb klic $(KL1SELFCOMP)
@@ -104,9 +104,10 @@ funct.c: klicdb $(EXT) klicdb.init libkl
 predicates.c: klicdb $(EXT) libklic.db
 	./klicdb -X. $(EXT)
 
-kl1cmp: klic klicdb klicdb.init libklic.db $(KL1SRC) ../runtime/libklict.a
+kl1cmp: klic klicdb klicdb.init libklic.db $(KL1SRC) \
+	../runtime/libklict.a
 	./klic -P$(PARALLEL) -K $(KL1CMP) -D./klicdb -v \
-		-X. -I../include -L../runtime \
+		-X. -I../include \
 		$(KLICOPT) -o kl1cmp $(KL1SRC)
 
 klicdb.init: ../runtime/klic.db
@@ -135,7 +136,7 @@ verify: verifydir kl1cmp $(CSRC)
 	  diff /tmp/$$file.old /tmp/$$file.new; \
 	  /bin/rm -f /tmp/$$file.old /tmp/$$file.new; \
 	done
-	
+
 depend:
 
 clean:
Index: disttest/Makefile
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/disttest/Makefile,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makefile
--- disttest/Makefile	2000/07/28 02:01:40	1.1.1.1
+++ disttest/Makefile	2001/08/16 09:57:37
@@ -23,7 +23,7 @@ NODES = 10
 PARALLEL = $(NODES)
 
 # KLIC compiler to compile test progs.
-KLIC=$(TOP)/compiler/klic -K$(TOP)/compiler/kl1cmp \
+KLIC= $(TOP)/compiler/klic -K$(TOP)/compiler/kl1cmp \
 	-D$(TOP)/compiler/klicdb -X. -I$(TOP)/include -L$(TOP)/runtime
 
 # options to compiler KLIC programs
Index: runtime/Makefile.head
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/runtime/Makefile.head,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makefile.head
--- runtime/Makefile.head	2000/07/28 02:01:41	1.1.1.1
+++ runtime/Makefile.head	2001/08/16 09:57:37
@@ -10,9 +10,9 @@ SHELL = /bin/sh
 .SUFFIXES: $(SUFFIXES) .kl1 .ext
 DISTTYPE = pvm
 PARALLEL = 0
-ARCHIVES= libklics.a libklicd.a libklic.a libklict.a
+ARCHIVES = libklics.a libklicd.a libklic.a libklict.a
 KLICDB= klic.db
-TARGETS = $(KLICDB) $(ARCHIVES) pipedio $(EXTENSION)
+TARGETS = $(KLICDB) $(ARCHIVES) $(DLLIBS) pipedio $(EXTENSION)
 COMPILEINC = ../include/klic
 EXTCOMPILEINC = ../include/klic
 EXTENSION =
Index: runtime/Makefile.tail
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/runtime/Makefile.tail,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makefile.tail
--- runtime/Makefile.tail	2000/07/28 02:01:41	1.1.1.1
+++ runtime/Makefile.tail	2001/08/16 09:57:38
@@ -7,7 +7,7 @@
 
 SHMCFLAGS = $(CFLAGS) -DDEBUGLIB -DSHM -I../include
 DEFINITIONS=$(DISTCFLAGS) -I../include 
-KLIC = ../compiler/klic -P$(PARALLEL) $(KLICOPT) \
+KLIC =  ../compiler/klic -P$(PARALLEL) $(KLICOPT) \
 	-R -I../include -X. -K$(KL1CMP) -D../compiler/klicdb -v 
 
 HEADERS = $(COMPILEINC)/config.h $(COMPILEINC)/alloc.h \
@@ -157,6 +157,8 @@ uplevel:
 	cd ..;make runtimedir
 all: $(TARGETS) $(EXTENSION)
 
+dll: $(DLLIBS)
+
 dist: $(COMMONKL1CSRCS) $(KL1NODCSRCS) \
 	atom.h funct.h atom.c funct.c predicates.c version.c
 
@@ -174,11 +176,28 @@ libklicd.a: $(COMMONOBJS) $(KL1DOBJS) $(
 	$(DDEBUGOBJS) $(DOBJS) $(DISTOBJS)
 	ar rcv $@ $?
 	$(RANLIB) $@
+
 libklics.a: $(COMMONOBJS) $(KL1SOBJS) $(SDEBUGOBJS) \
 	$(GENERIC_SOBJS) $(SHMOBJS)
 	ar rcv $@ $?
 	$(RANLIB) $@
 
+libklic$(DLLEXT): $(COMMONOBJS) $(KL1NODOBJS) $(NODEBUGOBJS) \
+	$(NODNODEBUGOBJS) $(NODOBJS)
+	$(LDSHARED) -o $@ $?
+
+libklict$(DLLEXT): $(COMMONOBJS) $(KL1NODOBJS) $(DEBUGOBJS) \
+	$(NODDEBUGOBJS) $(NODOBJS)
+	$(LDSHARED) -o $@ $?
+
+libklicd$(DLLEXT): $(COMMONOBJS) $(KL1DOBJS) $(DEBUGOBJS) \
+	$(DDEBUGOBJS) $(DOBJS) $(DISTOBJS)
+	$(LDSHARED) -o $@ $?
+
+libklics$(DLLEXT): $(COMMONOBJS) $(KL1SOBJS) $(SDEBUGOBJS) \
+	$(GENERIC_SOBJS) $(SHMOBJS)
+	$(LDSHARED) -o $@ $?
+
 kmain-t.c: kmain.c
 	rm -f $@; $(LN) $? $@
 debug-t.c: debug.c
@@ -410,7 +429,7 @@ verify: verifydir ../compiler/kl1cmp $(C
 clean:
 	/bin/rm -r -f verifydir core $(ALLOBJS) Makefile.bak \
 		atom.o funct.o predicates.o \
-		$(ARCHIVES) pipedio \
+		$(ARCHIVES) $(DLLIBS) pipedio \
 		rmon_server \
 		*-t.c *-d.c \
 		*~ \#*\#
@@ -447,7 +466,11 @@ install: all $(INSTALL_EXTENSION)
 	/bin/cp -p pipedio $(KLICLIB)/klic/pipedio
 	/bin/cp -p klic.db $(KLICLIB)/klicdb.init
 	/bin/cp -p libklic.db $(KLICLIB)/libklic.db
-	cd $(KLICLIB); $(RANLIB) $(ARCHIVES)
+
+install-dll: all $(INSTALL_EXTENSION)
+	- $(INSTDIR) $(KLICLIB)
+	if (test `pwd` != $(KLICLIB)) then \
+		($(INSTALL) $(DLLIBS) $(KLICLIB)) fi
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 alloc.o: alloc.c \
Index: runtime/asyncio.c
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/runtime/asyncio.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 asyncio.c
--- runtime/asyncio.c	2000/07/28 02:01:41	1.1.1.1
+++ runtime/asyncio.c	2001/08/16 09:57:38
@@ -263,6 +263,7 @@ void close_asynchronous_io_stream(fd)
 {
 #ifdef USESIG
   add_sigio_handler(fd, 0, KLIC_SIGIO_NONE);
+  asyncio_streams[fd] = 0;
 #endif
 }
 void register_asynchronous_io_stream(fd, stream)
Index: runtime/gunix.kl1
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/runtime/gunix.kl1,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 gunix.kl1
--- runtime/gunix.kl1	2000/07/28 02:01:41	1.1.1.1
+++ runtime/gunix.kl1	2001/08/16 09:57:39
@@ -81,8 +81,6 @@ extern q gd_new_pointer();
   MakeFilePointer(F, file); \\
 }
 
-static char buffer[4096];
-
 struct iobuf {
   unsigned char *ptr, *lim, *buf;
   int fd;
@@ -105,6 +103,33 @@ static struct iobuf *make_iobuf(fd, size
   return iob;
 }
 
+struct biobuf {
+  struct iobuf ibuf;
+  struct iobuf obuf;
+};
+
+static struct biobuf *make_biobuf(ifd, ofd, size)
+     int ifd, ofd, size;
+{
+  struct biobuf *biob = (struct biobuf *)malloc_check(sizeof(struct biobuf));
+  struct iobuf *ibuf = &(biob->ibuf);
+  struct iobuf *obuf = &(biob->obuf);
+
+  ibuf->fd = ifd;
+  ibuf->bufsize = size;
+  ibuf->buf = (unsigned char *)malloc_check(ibuf->bufsize);
+  ibuf->ptr = ibuf->buf;
+  ibuf->lim = ibuf->buf;
+
+  obuf->fd = ofd;
+  obuf->bufsize = size;
+  obuf->buf = (unsigned char *)malloc_check(obuf->bufsize);
+  obuf->ptr = obuf->buf;
+  obuf->lim = obuf->buf+size;
+
+  return biob;
+}
+
 #define MakeInBuf(klicvar, fd, size) \\
 { \\
   klicvar = gd_new_pointer((q)make_iobuf(fd,size,0), allocp); \\
@@ -120,6 +145,15 @@ static struct iobuf *make_iobuf(fd, size
 #define IOBuf(x) \\
   ((struct iobuf*)((struct pointer_object *)(data_objectp(x)))->pointer)
 
+#define MakeBIOBuf(klicvar, ifd, ofd, size) \\
+{ \\
+  klicvar = gd_new_pointer((q)make_biobuf(ifd,ofd,size), allocp); \\
+  allocp = heapp; \\
+}
+
+#define BIOBuf(x) \\
+  ((struct biobuf*)((struct pointer_object *)(data_objectp(x)))->pointer)
+
 static int fill_buf(iob)
      struct iobuf *iob;
 {
@@ -128,6 +162,10 @@ static int fill_buf(iob)
     if (result < 0) {
       switch (errno) {
       case EINTR: continue;
+#ifdef EPIPE
+      case EPIPE:
+        return -2;
+#endif /* EPIPE */
 #ifdef ASYNCIO
       case EAGAIN:
 #ifdef EWOULDBLOCK
@@ -159,6 +197,10 @@ static int write_buf(iob)
     if (result < 0) {
       switch (errno) {
       case EINTR: continue;
+#ifdef EPIPE
+      case EPIPE:
+        return -2;
+#endif /* EPIPE */
 #ifdef ASYNCIO
       case EAGAIN:
 #ifdef EWOULDBLOCK
@@ -203,7 +245,7 @@ static int write_buf(iob)
 /* End of Patch */
 #endif
       default:
-	fatalp(\"write\", \"Error in asynchronous input\");
+	fatalp(\"write\", \"Error in asynchronous output\");
       }
     } else {
       wp += result;
@@ -259,6 +301,7 @@ unix([append_open(P,R)|Cmnds])	:- append
 unix([update_open(P,R)|Cmnds])	:- update_open(P,R0), cont(R0,R,Cmnds).
 unix([signal_stream(S,R)|Cmnds]):- signal_stream(S,R0), cont(R0,R,Cmnds).
 unix([connect(A,R)|Cmnds])	:- connect(A,R0), cont(R0,R,Cmnds).
+unix([connect2(A,R)|Cmnds])	:- connect2(A,R0), cont(R0,R,Cmnds).
 unix([bind(A,R)|Cmnds])		:- bind(A,R0), cont(R0,R,Cmnds).
 unix([pipe(R)|Cmnds])		:- pipe(R0),	cont(R0,R,Cmnds).
 unix([system(S,R)|Cmnds])	:- system(S,R0), cont(R0,R,Cmnds).
@@ -488,6 +531,72 @@ alternatively.
 connect_sub(FD,Addr,Async,[],R) :-
     connect_sub(FD,Addr,Async,R).
 
+connect2(Spec,R) :-
+    net_convert(Spec,Fam,Addr),
+    connect2(Fam,Addr,_Async,R).
+
+connect2(Fam,Addr,Async,R) :- inline:"
+{
+#ifndef NO_USESOCKET
+  int family = intval(%0);
+  int sock = socket(family, SOCK_STREAM, 0);
+
+  if (sock < 0) { fatalp(\"socket\", \"Socket creation error\"); }
+#ifdef ASYNCIO
+  init_asynchronous_io();
+  setasync(sock, \"connection\");
+  register_asynchronous_io_stream(sock, %1);
+#endif
+  %2 = makeint(sock);
+#else
+  goto %f;
+#endif
+}":[Fam+int,Async+any,FD-int] |
+    connect2_sub(FD,Addr,Async,R).
+
+connect2_sub(FD,Addr,Async,R) :- inline:"
+{
+#ifndef NO_USESOCKET
+  int sock = intval(%0);
+  struct sockaddr *addr = (struct sockaddr*)
+    ((struct pointer_object *)(data_objectp(%1)))->pointer;
+
+ again2:
+  if (connect(sock, addr, sizeof(struct sockaddr)) < 0) {
+#ifdef ASYNCIO
+    if (errno == EINTR) goto again2;
+    if (errno != EISCONN) {
+      if (errno == EINPROGRESS || errno == EALREADY) goto %f;
+#endif
+      fatalp(\"connect\", \"Socket connection error\");
+#ifdef ASYNCIO
+    }
+#endif
+  }
+  free(addr);
+  MakeBIOBuf(%2, sock, sock, 4096);
+#else
+  goto %f;
+#endif
+}":[FD+int,Addr+object(pointer),IOB-object(pointer)] |
+    R=normal(SIn,SOut),
+    async_input(SIn,Async,IOB,0),
+    async_output(SOut,Async,IOB,0).
+otherwise.
+connect2_sub(FD,Addr,Async,R) :- inline:"{
+#ifdef NO_USE_SOCKET
+  goto %f;
+#endif
+}":[] |
+    timer:instantiate_after(time(0,3,0), Timer),
+    connect2_sub(FD, Addr, Async, Timer, R).
+
+connect2_sub(FD,Addr,[_|Async],_,R) :-
+    connect2_sub(FD,Addr,Async,R).
+otherwise.
+connect2_sub(FD,Addr,Async,[],R) :-
+    connect2_sub(FD,Addr,Async,R).
+
 bind(unix(Path),R) :-
     net_convert(unix(Path),Fam,Addr),
     bind(Fam,Addr,_Async,R).
@@ -590,6 +699,37 @@ bound_sock([accept(R)|S],FD,Async,Async1
 bound_sock(S,FD,[_|Async],Async1) :-
     bound_sock(S,FD,Async,Async1).
 
+bound_sock([accept2(R)|S],FD,Async,Async1) :- inline:"
+{
+#ifndef NO_USESOCKET
+  int sock;
+  struct sockaddr addr;
+  int socklen = sizeof(addr);
+#ifdef ASYNCIO
+  if (!poll_read_available(intval(%0))) goto %f;
+#endif
+  while (1) {
+    if ((sock = accept(intval(%0), &addr, &socklen)) > 0) break;
+    if (errno != EINTR) {
+      fatalp(\"accept\", \"Error in accept\");
+    }
+  }
+#ifdef ASYNCIO
+  setasync(sock, \"accepted socket\");
+  register_asynchronous_io_stream(sock,%1);
+#endif
+  MakeBIOBuf(%2, sock, sock, 4096);
+#else
+  goto %f;
+#endif
+}":[FD+int,Async1+any,IOB-object(pointer)] |
+    R=normal(SIn,SOut),
+    async_input(SIn,Async1,IOB,0),
+    async_output(SOut,Async1,IOB,0),
+    bound_sock(S,FD,Async,_).
+bound_sock(S,FD,[_|Async],Async1) :-
+    bound_sock(S,FD,Async,Async1).
+
 pipe(R) :- inline:"
 {
   int fd[2];
@@ -650,6 +790,7 @@ async_io([getc(C)|S],Async,InB,OutB,LC0)
   if (iob->ptr == iob->lim) {
     switch (fill_buf(iob)) {
     case -1: goto %f;
+    case -2: goto %f;
     case 0: c = -1; break;
     case 1: c = *iob->ptr++; break;
     }
@@ -674,7 +815,8 @@ async_io([fread(N,R)|S],Async,InB,OutB,L
   q str;
   if (ready_bytes==0) {
     switch (fill_buf(iob)) {
-    case -1:
+    case -1: goto %f;
+    case -2: goto %f;
     case 0: goto %f;
     case 1: break;
     }
@@ -713,6 +855,7 @@ async_io([feof(R)|S],Async,InB,OutB,LC) 
   if (iob->ptr == iob->lim) {
     switch (fill_buf(iob)) {
     case -1: goto %f;
+    case -2: goto %f;
     case 0: %1 = makeint(1); break;
     case 1: %1 = makeint(0); break;
     }
@@ -789,6 +932,252 @@ async_io([sync(R)|S],Async,InB,OutB,LC) 
 alternatively.
 async_io(S,[_|Async],InB,OutB,LC) :-
     async_io(S,Async,InB,OutB,LC).
+
+async_input([],_Async,IOB,_LC) :- inline:"
+{
+#ifdef ASYNCIO
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *inb = &(biob->ibuf);
+  struct iobuf *outb = &(biob->obuf);
+  if (inb->fd != outb->fd) {
+    if (close(inb->fd) != 0) {
+      fatalp(\"close\", \"Error in closing asynchronous input\");
+    }
+    close_asynchronous_io_stream(inb->fd);
+  }
+  if (outb->fd == -1) {
+    free(inb->buf);
+    free(outb->buf);
+  }
+  inb->fd = -1;
+#else
+  goto %f;
+#endif
+}":[IOB+object(pointer)] | true.
+async_input([getc(C)|S],Async,IOB,LC0) :- inline:"
+{
+#ifdef ASYNCIO
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *iob = &(biob->ibuf);
+  int c;
+  if (iob->ptr == iob->lim) {
+    switch (fill_buf(iob)) {
+    case -1: goto %f;
+    case -2: goto %f;
+    case 0: c = -1; break;
+    case 1: c = *iob->ptr++; break;
+    }
+  } else {
+    c = *iob->ptr++;
+  }
+  %3 = makeint(intval(%2) + ( c=='\\n' ? 1 : 0 ));
+  %1 = makeint(c);
+#else
+  goto %f;
+#endif
+}":[IOB+object(pointer),C0-int,LC0+int,LC-int] |
+    C=C0,
+    async_input(S,Async,IOB,LC).
+async_input([fread(N,R)|S],Async,IOB,LC0) :- inline:"
+{
+#ifdef ASYNCIO
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *iob = &(biob->ibuf);
+  int toread = intval(%1);
+  int k, nnl;
+  int ready_bytes = iob->lim - iob->ptr;
+  q str;
+  if (ready_bytes==0) {
+    switch (fill_buf(iob)) {
+    case -1: goto %f;
+    case -2: goto %f;
+    case 0: goto %f;
+    case 1: break;
+    }
+  }
+  if (toread > iob->lim - iob->ptr) toread = iob->lim - iob->ptr;
+  if ((char *)allocp+
+      sizeof(struct byte_string_object)+toread+sizeof(long) >=
+      (char *)real_heaplimit) {
+    allocp = real_heaplimit;
+    goto async__input_4_ext_interrupt;
+  }
+  for (k=0, nnl=0; k<toread; k++) {
+    if (iob->ptr[k] == '\\n') nnl++;
+  }
+  str = BC2KLIC(iob->ptr, toread, allocp);
+  if (isref(str)) {
+    fatal(\"internal error: string allocation failure for fread\");
+  }
+  %2 = str;
+  allocp = heapp;
+  iob->ptr += toread;
+  %4 = makeint(intval(%3)+nnl);
+#else
+  goto %f;
+#endif
+}":[IOB+object(pointer),N+int,R0-object(byte_string),LC0+int,LC-int] |
+    R=R0,
+    async_input(S,Async,IOB,LC).
+async_input([linecount(N)|S],Async,IOB,LC) :-
+    N=LC,
+    async_input(S,Async,IOB,LC).
+async_input([feof(R)|S],Async,IOB,LC) :- inline:"
+{
+#ifdef ASYNCIO
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *iob = &(biob->ibuf);
+  if (iob->ptr == iob->lim) {
+    switch (fill_buf(iob)) {
+    case -1: goto %f;
+    case -2: goto %f;
+    case 0: %1 = makeint(1); break;
+    case 1: %1 = makeint(0); break;
+    }
+  } else {
+    %1 = makeint(0);
+  }
+#else
+  goto %f;
+#endif
+}":[IOB+object(pointer),R0-int] |
+    R=R0,
+    async_input(S,Async,IOB,LC).
+alternatively.
+async_input(S,[_|Async],IOB,LC) :-
+    async_input(S,Async,IOB,LC).
+
+async_output([],_Async,IOB,_LC) :- inline:"
+{
+#ifdef ASYNCIO
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *inb = &(biob->ibuf);
+  struct iobuf *outb = &(biob->obuf);
+  if (outb->ptr != outb->buf) {
+    switch (write_buf(outb)) {
+    case -1: goto %f;
+    case -2: break;
+    case 1: break;
+    }
+  }
+  if (inb->fd != outb->fd) {
+    if (close(outb->fd) != 0) {
+      fatalp(\"close\", \"Error in closing asynchronous output\");
+    }
+    close_asynchronous_io_stream(outb->fd);
+  }
+  if (inb->fd == -1) {
+    free(inb->buf);
+    free(outb->buf);
+  }
+  outb->fd = -1;
+#else
+  goto %f;
+#endif
+}":[IOB+object(pointer)] | true.
+async_output([C|S],Async,IOB,LC) :- integer(C), inline:"
+{
+#ifdef ASYNCIO
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *iob = &(biob->obuf);
+  if (iob->ptr == iob->lim) {
+    switch (write_buf(iob)) {
+    case -1: goto %f;
+    case -2: goto %f;
+    case 1: break;
+    }
+  }
+  *iob->ptr++ = intval(%1);
+#else
+  goto %f;
+#endif
+}":[IOB+object(pointer),C+int] |
+    async_output(S,Async,IOB,LC).
+async_output([linecount(N)|S],Async,IOB,LC) :-
+    N=LC,
+    async_output(S,Async,IOB,LC).
+async_output([putc(C)|S],Async,IOB,LC) :- inline:"
+#ifndef ASYNCIO
+#endif
+":[] |
+    async_output([C|S],Async,IOB,LC).
+async_output([fwrite(X,R)|S],Async,IOB,LC) :- string(X,L,8), inline:"
+{
+#ifdef ASYNCIO
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *iob = &(biob->obuf);
+  char *str = KLIC2C(%1);
+  int len =intval(%2);
+  int room = iob->lim - iob->ptr;
+  while (iob->ptr + len >= iob->lim) {
+    BCOPY(str, iob->ptr, room);
+    len -= room;
+    str += room;
+    iob->ptr += room;
+    switch (write_buf(iob)) {
+    case -1: goto %f;
+    case -2: goto %f;
+    case 1: break;
+    }
+  }
+  BCOPY(str, iob->ptr, len);
+  iob->ptr += len;
+#else
+  goto %f;
+#endif
+}":[IOB+object(pointer),X+object(byte_string),L+int] |
+    R=L,
+    async_output(S,Async,IOB,LC).
+otherwise.
+async_output([fwrite(X,R)|S],Async,IOB,LC) :- true |
+    R = -1,
+    async_output(S,Async,IOB,LC).
+async_output([fwrite(X)|S],Async,IOB,LC) :-
+    async_output([fwrite(X,_)|S],Async,IOB,LC).
+async_output([fflush(R)|S],Async,IOB,LC) :- inline:"
+{
+#ifdef ASYNCIO
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *iob = &(biob->obuf);
+  if (iob->ptr != iob->buf) {
+    switch (write_buf(iob)) {
+    case -1: goto %f;
+    case -2: goto %f;
+    case 1: break;
+    }
+  }
+#else
+  goto %f;
+#endif
+}":[IOB+object(pointer)] |
+    R = 0,
+    async_output(S,Async,IOB,LC).
+otherwise.
+async_output([fflush(R)|S],Async,IOB,LC) :- true |
+    R = -1,
+    async_output(S,Async,IOB,LC).
+async_output([sync(R)|S],Async,IOB,LC) :- inline:"
+#ifdef ASYNCIO
+{
+  struct biobuf *biob = BIOBuf(%0);
+  struct iobuf *outb = &(biob->obuf);
+  switch (write_buf(outb)) {
+  case -1: goto %f;
+  case -2: goto %f;
+  case 1: break;
+  }
+}
+#endif
+":[IOB+object(pointer)] |
+    R=0,
+    async_output(S,Async,IOB,LC).
+otherwise.
+async_output([sync(R)|S],Async,IOB,LC) :- true |
+    R = -1,
+    async_output(S,Async,IOB,LC).
+alternatively.
+async_output(S,[_|Async],IOB,LC) :-
+    async_output(S,Async,IOB,LC).
 
 /****************************************
 	SYSTEM CALLS, etc
@@ -905,12 +1294,12 @@ fork_with_pipes(R) :- inline:"
     In1-object(pointer),Out1-object(pointer),
     In2-object(pointer),Out2-object(pointer)] |
     (
-	PID=:=0 ->
+	PID=\=0 ->
 	R=parent(PID,In,Out),
 	generic:new(file_io,In,In1,"pipe-input",[],""),
     	generic:new(file_io,Out,[],"",Out2,"pipe-output")
     ;
-	PID=\=0 ->
+	PID=:=0 ->
 	R=child(In,Out),
 	generic:new(file_io,In,In2,"pipe-input",[],""),
     	generic:new(file_io,Out,[],"",Out1,"pipe-output")
Index: runtime/signal.c
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/runtime/signal.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 signal.c
--- runtime/signal.c	2000/07/28 02:01:41	1.1.1.1
+++ runtime/signal.c	2001/08/16 09:57:40
@@ -190,6 +190,18 @@ static void init_streamed_signal_handlin
   register_gc_hook(gc_signal_streams);
 }
 
+/****************************************
+  DEFAULT SIGPIPE HANDLER
+****************************************/
+
+static int default_sigpipe_handler(allocp, sig)
+     q *allocp;
+     int sig;
+{
+  declare_globals;
+  return 0;
+}
+
 /*
   GENERAL INITIATION
 */
@@ -199,6 +211,7 @@ void init_klic_signal_handling()
   init_general_signal_handling();
   init_streamed_signal_handling();
   add_signal_handler(SIGINT, default_sigint_handler);
+  add_signal_handler(SIGPIPE, default_sigpipe_handler);
 }
 
 #endif
Index: runtime/termio.kl1
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/runtime/termio.kl1,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 termio.kl1
--- runtime/termio.kl1	2000/07/28 02:01:41	1.1.1.1
+++ runtime/termio.kl1	2001/08/16 09:57:40
@@ -29,6 +29,10 @@ klicio([update_open(Path,R)|S],U) :-
     send_unix(update_open(Path,RU),U,UT), termupdt(RU,R), klicio(S,UT).
 klicio([connect(What,R)|S],U) :-
     send_unix(connect(What,RU),U,UT), termupdt(RU,R), klicio(S,UT).
+klicio([connect2(What,R)|S],U) :-
+    send_unix(connect2(What,RU),U,UT), termupdt(RU,R), klicio(S,UT).
+klicio([bind(What,R)|S],U) :-
+    send_unix(bind(What,RU),U,UT), bind(RU,R), klicio(S,UT).
 otherwise.
 klicio([Msg|S],U) :-
     send_unix(Msg,U,UT), klicio(S,UT).
@@ -59,6 +63,18 @@ termupdt(normal(SU),R) :-
     updt(SI,SU,s(Ops,0)).
 otherwise.
 termupdt(R0,R) :- R=R0.
+
+bind(normal(SU),R) :-
+    R=normal(SI),
+    bound_sock(SI,SU).
+otherwise.
+bind(R0,R) :- R=R0.
+
+bound_sock([],U) :- U=[].
+bound_sock([accept(R)|S],U) :-
+    U=[accept(RU)|UT], termupdt(RU,R), bound_sock(S,UT).
+bound_sock([accept2(R)|S],U) :-
+    U=[accept2(RU)|UT], termupdt(RU,R), bound_sock(S,UT).
 
 in([],U,_Ops) :- U=[].
 in([gett(Term)|S],U,Stat) :-
Index: runtime/trace.c
===================================================================
RCS file: /home/igarashi/kl1/cvsroot/klic/runtime/trace.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 trace.c
--- runtime/trace.c	2000/07/28 02:01:41	1.1.1.1
+++ runtime/trace.c	2001/08/16 09:57:41
@@ -150,17 +150,13 @@ static struct mod_table_entry *get_mte(p
 {
   module mod = (module)pred->func;
   unsigned int low = 0, high = n_mod, mid;
-  while (low != high) {
-    mid = ((high+low) >> 1);
-    if ((module)mod_index[mid]->func == mod) {
-      return mod_index[mid];
-    } else if ((unsigned long)mod_index[mid]->func > (unsigned long)mod) {
-      high = mid;
-    } else {
-      low = mid + 1;
-    }
+  for (mid = low; mid < high; mid++) {
+    if ((module)mod_index[mid]->func == mod) break;
   }
-  return 0;
+  if (mid == high) {
+    fprintf(stderr, "get_mte(): not found(bug).\n");  /* for debug */
+    return 0;
+  } else return mod_index[mid];
 }
 
 static struct pred_hash_entry {
