OSDN Git Service

* Chill runtime moved into toplevel libchill.
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Sep 1998 01:11:54 +0000 (01:11 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Sep 1998 01:11:54 +0000 (01:11 +0000)
        * Makefile.in Revamped due to move.  Add multilib support.
        * configure.in: Similarly.  Use autoconf.
        * powerset.h: Do not depend on BITS_PER_UNIT.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@22238 138bc75d-0d04-0410-961f-82ee72b054a4

88 files changed:
libchill/ChangeLog [new file with mode: 0644]
libchill/Makefile.in [new file with mode: 0644]
libchill/abstime.c [new file with mode: 0644]
libchill/allgmem.c [new file with mode: 0644]
libchill/allmem.c [new file with mode: 0644]
libchill/allocate.c [new file with mode: 0644]
libchill/andps.c [new file with mode: 0644]
libchill/auxtypes.h [new file with mode: 0644]
libchill/basicio.c [new file with mode: 0644]
libchill/bitstring.h [new file with mode: 0644]
libchill/cardps.c [new file with mode: 0644]
libchill/cause.c [new file with mode: 0644]
libchill/checkcycle.c [new file with mode: 0644]
libchill/chillrt0.c [new file with mode: 0644]
libchill/chillstdio.c [new file with mode: 0644]
libchill/concatps.c [new file with mode: 0644]
libchill/concatstr.c [new file with mode: 0644]
libchill/configure [new file with mode: 0755]
libchill/configure.in [new file with mode: 0644]
libchill/continue.c [new file with mode: 0644]
libchill/convdurrtstime.c [new file with mode: 0644]
libchill/copyps.c [new file with mode: 0644]
libchill/delaycase.c [new file with mode: 0644]
libchill/delete.c [new file with mode: 0644]
libchill/diffps.c [new file with mode: 0644]
libchill/eoln.c [new file with mode: 0644]
libchill/eqps.c [new file with mode: 0644]
libchill/eqstr.c [new file with mode: 0644]
libchill/exh.c [new file with mode: 0644]
libchill/exhstack.c [new file with mode: 0644]
libchill/existing.c [new file with mode: 0644]
libchill/ffsetclrps.c [new file with mode: 0644]
libchill/ffsetps.c [new file with mode: 0644]
libchill/fileio.h [new file with mode: 0644]
libchill/flsetclrps.c [new file with mode: 0644]
libchill/flsetps.c [new file with mode: 0644]
libchill/format.c [new file with mode: 0644]
libchill/format.h [new file with mode: 0644]
libchill/getassoc.c [new file with mode: 0644]
libchill/gettextaccess.c [new file with mode: 0644]
libchill/gettextindex.c [new file with mode: 0644]
libchill/gettextrecord.c [new file with mode: 0644]
libchill/getusage.c [new file with mode: 0644]
libchill/inbitstr.c [new file with mode: 0644]
libchill/indexable.c [new file with mode: 0644]
libchill/inps.c [new file with mode: 0644]
libchill/inttime.c [new file with mode: 0644]
libchill/ioerror.c [new file with mode: 0644]
libchill/ioerror.h [new file with mode: 0644]
libchill/iomodes.h [new file with mode: 0644]
libchill/isassociated.c [new file with mode: 0644]
libchill/leps.c [new file with mode: 0644]
libchill/ltps.c [new file with mode: 0644]
libchill/ltstr.c [new file with mode: 0644]
libchill/memmove.c [new file with mode: 0644]
libchill/neps.c [new file with mode: 0644]
libchill/notps.c [new file with mode: 0644]
libchill/orps.c [new file with mode: 0644]
libchill/outoffile.c [new file with mode: 0644]
libchill/powerset.h [new file with mode: 0644]
libchill/printbuffer.c [new file with mode: 0644]
libchill/printevent.c [new file with mode: 0644]
libchill/queuelength.c [new file with mode: 0644]
libchill/readable.c [new file with mode: 0644]
libchill/readrecord.c [new file with mode: 0644]
libchill/remaintime.c [new file with mode: 0644]
libchill/retmem.c [new file with mode: 0644]
libchill/rtltypes.h [new file with mode: 0644]
libchill/rts.c [new file with mode: 0644]
libchill/rts.h [new file with mode: 0644]
libchill/rtsdummy.c [new file with mode: 0644]
libchill/sendbuffer.c [new file with mode: 0644]
libchill/sequencible.c [new file with mode: 0644]
libchill/setbitps.c [new file with mode: 0644]
libchill/setbits.c [new file with mode: 0644]
libchill/settextaccess.c [new file with mode: 0644]
libchill/settextindex.c [new file with mode: 0644]
libchill/settextrecord.c [new file with mode: 0644]
libchill/sliceps.c [new file with mode: 0644]
libchill/terminate.c [new file with mode: 0644]
libchill/unhex.c [new file with mode: 0644]
libchill/unhex1.c [new file with mode: 0644]
libchill/variable.c [new file with mode: 0644]
libchill/waitbuffer.c [new file with mode: 0644]
libchill/waituntil.c [new file with mode: 0644]
libchill/writeable.c [new file with mode: 0644]
libchill/writerecord.c [new file with mode: 0644]
libchill/xorps.c [new file with mode: 0644]

diff --git a/libchill/ChangeLog b/libchill/ChangeLog
new file mode 100644 (file)
index 0000000..ea62d6e
--- /dev/null
@@ -0,0 +1,742 @@
+Sat Sep  5 02:09:42 1998  Jeffrey A Law  (law@cygnus.com)
+
+       * Chill runtime moved into toplevel libchill.
+       * Makefile.in Revamped due to move.  Add multilib support.
+       * configure.in: Similarly.  Use autoconf.
+       * powerset.h: Do not depend on BITS_PER_UNIT.
+
+Fri Apr 24 16:12:40 1998  Dave Brolley  <brolley@cygnus.com>
+
+       * writerecord.c (sys/types.h): #included to pick up off_t.
+
+Tue Nov 26 01:56:03 1996  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * memmove.c (memmove): If nor overlapping use memcpy instead of
+        byte copy.
+
+Tue May 14 21:26:52 1996  Per Bothner  <bothner@deneb.cygnus.com>
+
+       * gestr.c, gtstr.c, lestr.c, nestr.c:  Removed - no longer used.
+       * Makefile.in (STROBJS)  Removed gestr.o, gtstr.o, lestr.o, nestr.o.
+
+Thu May  9 06:59:23 1996  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * basicio.c (__connect): In case of Same, fix condition for
+       exception.
+
+Thu Feb 29 10:55:01 1996  Per Bothner  <bothner@kalessin.cygnus.com>
+
+       * format.c:  Use ANSI-standard float.h, rather than old values.h.
+
+Mon Jan 15 06:16:22 1996  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * sendbuffer.c (__send_buffer): Take care of possibly unaligned
+       pointers.
+
+       * waitbuffer.c (__wait_buffer): Ditto.
+
+Thu Nov 30 03:49:58 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * format.c (inpioctrl): Process NOTCONNECTED.
+       (outioctrl): Deto.
+       (scanformcont): Fix processing of %% in format string.
+
+Mon Nov 27 05:27:14 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * chillrt0.c (main): Pass argc & argv to __RTS_INIT__.
+
+Thu Nov 23 05:15:05 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * ioerror.h (io_info_word_t): Make value of first entry compile time
+       comfigurable.
+
+Tue Nov  7 22:52:24 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * format.c: Rename ultoa to myultoa cause of conflicting types
+       on some systems.
+
+Mon Nov  6 03:17:50 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * chillrt0.c: Move definition of chill_stdin, chill_stdout,
+       chill_stderr ...
+
+       * chillstdio.c: ... to here.
+
+       * delete.c, eoln.c, existing.c, getusage.c, indexable.c,
+       isassociated.c, outoffile.c, readable.c, sequencible.c,
+       variable.c, writeable.c: Modified for new implementation of
+       chill file i/o.
+
+       * basicio.c, format.c, getassoc.c, gettextaccess.c, gettextindex.c,
+       gettextrecord.c, ioerror.c, readrecord.c, settextaccess.c,
+       settextindex.c, settextrecord.c, writerecord.c: New files to 
+       implement chill file i/o.
+
+       * allocate.c, terminate.c: New files to implement chill's
+       ALLOCATE and TERMINATE built-in's.
+
+       * associate.c, checksum.c, connect.c, create.c, disconnect.c,
+       dissociate.c, findfile.c, findnextfile.c, fstable.c, getass.c,
+       getdir.c, gettxtacc.c, gettxtidx.c, gettxtrec.c, iostatus.c,
+       lowlevelio.c, modify.c, rdformat.c, rdrecord.c, rdstring.c,
+       rdtext.c, rdunixstd.c, readlen.c, regexp.h, setdir.c, settxtacc.c,
+       settxtidx.c, settxtrec.c, skiprec.c, wrformat.c, wrrecord.c,
+       wrstring.c, wrtext.c, wrunixstd.c: Removed.
+
+Tue Sep 12 04:27:47 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * Makefile.in (Makefile): Add rule for Makefile.
+       OBJS depends on ../../cc1 to build a new library when cc1 have
+       changed.
+       
+Mon Jul 31 15:04:04 1995  Per Bothner  <bothner@kalessin.cygnus.com>
+
+       * ffsetclrps.c, flsetclrps.c:  Completely different interface,
+       * storeoutps.c:  Remove, no longer needed.
+       * Makefile.in (PSOBJS):  Take out storeoutps.o.
+
+Mon Jun 19 05:23:35 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * exh.c (__cause_exception): New argument. 
+       (__cause_ex1): New function. This function will get called
+       now by the compiler when an exception should be raised.
+
+       * abstime.c, allgmem.c, allmem.c, checkcycle.c, delaycase.c,
+       ffsetps.c, flsetps.c, inbitstr.c, sendbuffer.c, waitbuffer.c:
+       Change calls to __cause_exception to calls to __cause_ex1.
+
+       * unhex.c (unhandled_exception), 
+       cause.c (cause_exception): New argument.
+
+       * rts.h: Add prototypes for __delay_this and __continue_that.
+
+       * ffsetclrps.c, flsetclrps.c, inps.c, rtltypes.h, setbitps.c:
+       Remove prototype for __cause_exception (not needed).
+
+       * rdstring.c (_readstring), wrstring.c (_writestring): Add argument
+       to call to __cause_exception.
+
+       * Makefile.in, unhex1.c: New file. Function __unhandled_ex
+       is defined here. This gets called when the compiler doesn't
+       find a handler when causing an exception.
+
+Tue Apr 11 16:01:02 1995  Per Bothner  <bothner@kalessin.cygnus.com>
+
+       * iomodes.h (__tmp_WIO_union, __tmp_RIO_union):  Make __forbyte
+       be explicitly signed, for the sake of systems where char is unsigned.
+
+Wed Mar 22 06:10:18 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * setbitps.c (__setbitpowerset): Change definition of new_value 
+       to char, cause booleans are represented as 8 bit values by the 
+       compiler. Use only least significant bit of new_value.
+
+Tue Jan 17 07:32:17 1995  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * inps.c (__inpowerset): Don't do rangecheck. Return 0
+       if value not in range.
+
+       * Makefile.in, inbitstr.c (__inbitstring): New file and
+       function for accessing single elements in a bitstring.
+
+Tue Dec  6 02:35:00 1994  Wilfried Moser  <moser@rtl.cygnus.com>
+
+       * rdformat.c (rf_parse_iolist): In case of __IO_set and
+       __IO_SetRange process the ignore_case flag.
+
+       * iomodes.h: Change definition of __tmp_RIO_forset and 
+       __tmp_RIO_forsetrange.
+
+Fri Nov  4 12:04:16 1994  Per Bothner  <bothner@kalessin.cygnus.com>
+
+       * concatstr.c (__concatstring):  Add support for input strings
+       to overlap target.
+       * setbits.c (__setbits):  Fix function name passed
+       to __cause_exception.
+
+Wed Nov  2 05:02:59 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * Makefile.in (TIMEOBJS): Add new files.
+
+       * checkcycle.c (__check_cycle): New file and function for 
+       CYCLE statement.
+
+       * convdurrtstime.c (__convert_duration_rtstime): New file
+       and function for conversion of DURATION (unsigned long) to
+       RtsTime format.
+
+       * delaycase.c (__delay_event): Implement processing of
+       timesupervision.
+
+       * remaintime.c (__remaintime): New file and function to 
+       calculate the remaining time of a duration (used for 
+       timesupervision).
+
+       * rts.h: New definitions and prototypes.
+
+       * sendbuffer.c (__send_buffer): Implement processing of
+        timesupervision.
+
+       * waitbuffer.c (__wait_buffer): Implement processing of
+        timesupervision.
+
+       * waituntil.c (__wait_until): Changed due to implementation
+       of timesupervision.
+
+Thu Oct  6 06:41:02 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * wrformat.c (default_conv): Remove processing of 
+       POWERSET's.
+
+       * rdformat.c (rf_parse_iolist): Remove processing of
+       POWERSET's.
+
+       * iomodes.h: Remove definition for POWERSET's.
+
+Fri Sep 30 01:52:25 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * rdformat.c (rf_parse_iolist): Fix processing of BITSTRINGs.
+
+Mon Sep 26 16:10:47 1994  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * copyps.c (__pscpy):  Add missing 'const'.
+
+       * wrformat.c (default_conv):  Replace memcpy by explicit loop,
+       since memcpy can get mis-optimized when we have unaligned data.
+
+       * wrformat.c (__write_format):  Don't alloca an extra copy of
+       the format string.
+
+Mon Sep 26 08:54:03 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * wrformat.c (default_conv): Remove formating of nonprintable
+       characters (ESC-sequences wouldn't work).
+
+Fri Sep 23 00:48:28 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * copyps.c (__pscpy): Fix masking out unused bits.
+
+       * fileio.h: Fix prototype.
+
+Tue Sep 13 04:54:45 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * rdformat.c (__read_format): Remove end-of-input string 
+       check.
+
+Thu Sep  8 17:20:07 1994  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * setbits.c (__setbits):  New function, based on __setpowersetbits,
+       but with 4 instead of 5 parameters.
+       * setpsbits.c:  Removed.  No longer used.
+       * Makefile (PSOBJS):  Update accordingly.
+
+Mon Sep  5 08:03:46 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * queuelength.c (__queue_length): New file and function
+       to implement QUEUE_LENGTH built-in.
+       * Makefile.in (TASKOBJS): Add queuelength.o.
+
+Fri Aug 26 16:27:21 1994  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * Makefile.in (INCLUDES):  Add  -I../../include.
+
+Wed Aug 24 01:12:32 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * sendbuffer.c, waitbuffer.c, delaycase.c, printbuffer.c,
+       printevent.c: Be careful with addresses of data from the
+       application,they may be unaligned (-fpack).
+
+Fri Aug 19 07:16:15 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * wrformat.c (default_conv), rdformat.c (rf_parse_iolist): Be
+       careful with addresses of data from the application, they may 
+       be unaligned (-fpack).
+
+Fri Aug 12 20:31:47 1994  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * eqps.c (__eqpowerset):  Calculate number of full words
+       as floor, not ceiling of bitslength/SET_WORD_SIZE.
+
+Fri Aug  5 17:25:48 1994  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * eqps.c (__eqpowerset):   Revert Wilfried's fix, and fix
+       the problem in a slightly different way (which is simpler
+       and will also work for 0-length bitstrings).
+       * neps.c (__nepowerset):  Simplify - just call __eqpowerset.
+
+Fri Jul 29 04:06:56 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * neps.c (__nepowerset): Correct processing of powerset
+       in case of USE_CHARS defined.
+
+Wed Jul 27 05:27:06 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * eqps.c (__eqpowerset): Correct processing of powerset
+       in case of USE_CHARS defined.
+
+Mon Jun 27 01:17:09 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * iomodes.h: Change layout of __tmp_WIO_list that it is always
+       the same, regardless if compiled with -fpack or not.
+
+Tue May 31 04:54:48 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * printbuffer.c, printevent.c, rts.h, sendbuffer.c,
+       waitbuffer.c: Finish the implementation of BUFFER's
+       and EVENT's.
+
+Tue May 10 05:17:43 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * iomodes.h: Change names of __access, __association and 
+       __text to __access_type, __association_type and
+       __text_type. __access is already defined in one of the
+       linux header files.
+
+Wed May  4 15:37:22 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * Makefile.in (clean): Add chillrt0.o
+       * continue.c (__continue): Implement the function.
+       * delaycase.c (__delay_event): Implement the function.
+       * printbuffer.c (__print_buffer): Implement the function.
+       * printevent.c (__print_event.c): Implement the function.
+       * rts.h: Change datatypes used for EVENT's and BUFFER's.
+       * sendbuffer.c (__send_buffer): Implement the function.
+         FIXME: not completely done.
+       * waitbuffer.c (__wait_buffer): Implement the function.
+         FIXME: not completely done.
+
+Thu Apr 28 14:39:06 1994  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * Makefile.in (TASKOBJS): New variable for tasking related
+         objects files.
+       * Makefile.in (TIMEOBJS): New object file added.
+       * rts.h: Add definitions for BUFFER's and EVENT's.
+       * waituntil.c (__wait_until): New file and new function.
+         Implements the AT action.
+       * delaycase.c (__delay_event): New file and new function.
+         Implements the DELAY and DELAY CASE action. FIXME: not yet done.
+       * continue.c (__continue): New file and new function.
+         Implements the CONTINUE action. FIXME: not yet done.
+       * sendbuffer.c (__send_buffer): New file and new function.
+         Implements the SEND buffer action. FIXME: not yet done.
+       * waitbuffer.c (__wait_buffer): New file and new function.
+         Implements the RECEIVE buffer CASE action. FIXME: not yet done.
+       * printevent.c (__print_event): New file and new function.
+         Prints an event queue. FIXME: not yet done.
+       * printbuffer.c (__print_buffer): New file and new function.
+         Prints a buffer queue. FIXME: not yet done.
+
+Fri Apr  1 10:59:55 1994  Wilfried Moser  (fs_moser at rcsw47)
+
+       * wrformat.c (default_conv): Change output of characters in the
+       range 0 to 31 (control characters now printed as ^C).
+
+Fri Apr 15 16:29:21 1994  Ian Lance Taylor  (ian@tweedledumb.cygnus.com)
+
+       * Makefile.in: XTRAFLAGS is no longer need, since -Bdir now
+       implies -Idir/include.
+       (XTRAFLAGS): Don't define.
+       (ALL_CFLAGS): Don't include $(XTRAFLAGS).
+
+Thu Apr 14 13:44:31 1994  Wilfried Moser  (moser@phishhead.cygnus.com)
+
+       * Makefile.in (TIMEOBJS): New variable for time related stuff.
+       * Makefile.in (OBJS): Add TIMEOBJS.
+       * abstime.c (_abstime): New file and new function to handle
+       ABSTIME builtin.
+       * inttime.c (_inttime): New file and new function to handle
+       INTTIME builtin.
+
+Tue Mar 29 13:11:37 1994  Wilfried Moser  (fs_moser at rcsw1h)
+
+       * Makefile.in (LIBOBJS2): Add new modules rdformat.o rdstring.o
+         rdunixstd.o 
+       * iomodes.h: Remove unnecessary definitions. Redefine interface to
+         READTEXT/WRITETEXT functions.
+       * rdstring.c (_readstring): Rework function.
+       * rdformat.c: Rework functionality.
+       * rdunixstd.d: New module. This is designed to implement
+          READTEXT (stdin...). 
+       * wrformat.c (copy_text): Change return value of function. In case
+         of an empty string this function has failed.
+       * wrformat.c: Change formating of a NULL pointer to NULL instead
+         of 0.
+       * wrformat.c (PUT_CHARS): Change macro according to new return
+         value of function copy_text.
+
+Sun Mar 20 21:11:35 1994  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * powerset.h:  Bitstrings are now allocated in units
+       of (unsigned char), rather than words.
+       * eqps.c (__eqpowerset):  Optimize slighly for above change.
+
+       * setbitps.c (__setbitpowerset):  Clean up parameter list.
+
+Thu Mar 10 11:10:32 1994  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in: Add standard gcc Makefile stuff.  Move
+         chillcrt0 and libchill.a to all.indirect from all target.
+
+Tue Mar  1 17:01:32 1994  Wilfried Moser  (fs_moser at rcsw1h)
+
+       * iomodes.h: Add definition for POWERSET's
+       * wrunixstd.c: Change the write call to an fprintf cause a system
+         we have doesn't support write.
+       * wrformat.c: Add processing of SET's and POWERSET's
+
+Sat Jan 29 13:32:52 1994  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in: Add new files copyps.c and concatps.c.
+       * copyps.c: New function with functionality from sliceps.c,
+       * sliceps.c: Change to call copyps now from here.
+       * concatps.c: New function - call copyps from here.
+       * powerset.h: Fix CLEAR_BIT_IN_CHAR macro.
+
+Wed Jan 26 12:30:48 1994  Mike Stump  (mrs@cygnus.com)
+
+       * Makefile.in: Don't echo ranlib command.
+
+Wed Jan 26 12:21:11 1994  Mike Stump  (mrs@cygnus.com)
+
+       * Makefile.in: Make sure cross builds work.  AR, and RANLIB now
+         used properly.  Make sure we can reconfigure if Makefile.in
+         changes.  Use GCC_FOR_TARGET, not CC to compile libchill.a.
+
+Fri Jan 21 15:30:31 1994  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * allgmem.c:  Make prototype K&R-compatible.
+
+Sat Jan 15 10:04:08 1994  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in: Remove unused install code.
+         (Install will happen from devo/gcc).  Add
+         rules for cleaning up.
+
+Fri Jan 14 21:43:45 1994  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * chillrt0.c (__init_list):  Renamed to _ch_init_list, to
+       avoid a conflict on the Alpha.
+
+Tue Jan 25 13:28:15 1994  Wilfried Moser  (fs_moser at rcsw1j)
+
+       * Makefile.in: clean up for cross compilation. Remove a lot of
+         functions (file-io) which are not used at the moment.
+       * iomodes.h: clean up the datatypes passed to the writetext
+         functions. 
+       * unhex.c: Comment out include of gvarargs.h (not needed).
+       * rtsdummy.c: Comment out include of gvarargs.h (not needed).
+       * wrformat.c: change various procedure arguments according to the
+         new type passed by the compiler. Remove include of fcntl.h and
+         sys/stat.h (not needed).
+       * wrformat.c (default_conv): Change formatting of integers in case
+         of %O, %H, %B to unsigned. (PR-4395)
+       * wrstring.c: change various procedure arguments according to the
+         new type passed by the compiler. Remove include of fcntl.h and
+         sys/stat.h (not needed).
+       * wrtext.c: change various procedure arguments according to the
+         new type passed by the compiler.
+       * wrunixstd.c: change various procedure arguments according to the
+         new type passed by the compiler. Remove include of fcntl.h and
+         sys/stat.h (not needed).
+       * wrunixstd.c (_writeunixstd): Change the fwrite call to fprintf.
+         This is necessary due to a port to a system which does not
+         support fwrite.
+
+Sun Jan  2 14:40:32 1994  Bill Cox  (bill@cygnus.com)
+
+       * Makefile.in: Clean out obsolete .c286 suffix references.
+
+Sat Jan  1 16:51:22 1994  Bill Cox  (bill@cygnus.com)
+
+       * Makefile.in: Add dependencies on fileio.h
+
+Sat Jan  1 12:31:22 1994  Bill Cox  (bill@cygnus.com)
+
+       * Reorganize the whole directory and the Makefile.  Now you
+         can recompile a single function and not have to recompile
+         a whole file full of them.
+       * eqps.c, neps.c: Fix handling of a one-word set. (PR-4077).
+
+Thu Dec 16 10:19:00 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * fileio.c (default_conv): Changes to support all basic CHILL types.
+         Standardize function header formats.
+
+Tue Dec 14 14:36:27 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * fileio.c (writeunixstd): Call _allocate_memory and
+         _return_memory, so we'll get appropriate exceptions.  
+       * powerset.c: Ensure a space between each macro name and the
+         parameters.
+
+Mon Nov 22 10:42:37 1993  Wilfried Moser  (moser@rtl.cygnus.com)
+
+       * Makefile.in: Add functions to LIBFUNCS1
+       * chillrt0.c (main): Clear the exception stack.
+       * libchill.c (__setexceptionStack, __getexceptionStack): New
+         functions according to allow one exceptionStack per thread.
+
+Sat Nov 20 17:45:52 1993  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * libchill.c (__ch_link_handler, __ch_unlink_handler):  New functions.
+
+Fri Nov 19 14:37:12 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in, string.c: Add memmove function (PR-3937).
+
+Wed Nov 17 17:07:46 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * fileio.c (_writestring): Add parameters for the source file
+         and line number where it was called, for way better error
+         messages.
+       * powerset.c: Make all length and count variables longs.
+         Allows much larger powersets.
+
+Mon Nov 15 14:59:47 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * fileio.c (writestring): Changed interface.
+       * iomodes.h: New structures for above interface.
+       * libchill.c: Delete bunch of powerset-related cruft.
+          (cause_exception): Empty it out.
+       * powerset.c: Call correct exception causer.
+       * string.c: Rewrite string comparisons from scratch.  They
+         were bad...
+
+Sat Oct 30 14:54:39 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in: Change paths to executables.
+
+Thu Oct 28 16:38:34 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * powerset.c (__inpowerset, __setbitpowerset): Correct error checking.
+         These were throwing false exceptions.
+          (__setpowersetbits): Add check for null output set ptr.
+
+Wed Oct 27 16:45:29 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * powerset.c (__diffpowerset): Check for SET_SHORT_SIZE, not
+         SET_CHAR_SIZE twice.
+          (__ffsetpowerset, __flsetpowerset): Add code for CHAR and SHORT sets.
+       * libchill.c (cause_exception): Output a message to stderr, and
+         abort, as a default exception action.
+
+Thu Oct 21 16:04:09 1993  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * fileio.c (__write_format): Add missing increment of fstr.
+
+Thu Sep 30 20:11:34 1993  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * powerset.c (__psslice):  Take length, rather than upper bound.
+
+Sun Sep 19 23:14:57 1993  Per Bothner  (bothner@kalessin.cygnus.com)
+
+       * chillrt0.c, fileio.c (_writeunixstd): Change a standard Unix file
+       from (long*) to (long).  Use fwrite rather than write.
+       * fileio.c (PUT_CHARS, PUT_CHAR):  New macros.
+       * fileio.c (__write_format):  Use them.
+       * fileio.c (__write-format):  Handle "%/" format even if
+       not io_ctrl_allowed (by emitting '\n').
+
+Fri Sep 10 12:15:51 1993  Wilfried Moser  (fs_moser at rcsw1j)
+
+       * chillrt0.c: Make stdin, stdout, stderr available to chill
+         programs. This is done by setting the apropriate file handles
+          to chill_stdin, chill_stdout, chill_stderr.
+       * fileio.c: Add a new function (_writeunixstd) to the 
+         chill library. This function will be called when the compiler
+         detects a WRITETEXT action to one of the above mentioned
+         file handles.
+       * Makefile.in: Add _writeunixstd to LIBFUNCS3.
+
+Sat Aug 21 17:17:53 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+        * Makefile.in: Add psset to list of powerset stuff.
+       * powerset.c: Standardize (and correct) for loops.  Fix
+         comments.
+
+Mon Jul  5 09:48:06 1993  Wilfried Moser  (fs_moser at rcsw1j)
+
+       * rtltypes.h: Change layout of struct __ch_handler. The entry
+         jmp_buf is moved to the end of the structure.
+
+Mon Jun 14 12:17:53 1993  david d `zoo' zuhn  (zoo at rtl.cygnus.com)
+
+       * Makefile.in: rename INSTALLDIR to libdir; remove parentdir
+       support; update definition of INSTALL
+
+Thu Jun 10 18:14:41 1993  Wilfried Moser  (moser@deneb.cygnus.com)
+
+       * libchill.c: (vector): This entry was removed. It is no
+         longer neccessary.
+       * Makefile.in: Change due to the remove of vector.
+
+Wed Jun  9 10:39:25 1993  Wilfried Moser  (moser@deneb.cygnus.com)
+
+       * chillrt0.c (main): Change processing of constructors
+         according to the new design made for tasking.
+       * libchill.c (__rts_main_loop, __rts_init): Don't do an
+         abort () there.
+
+Mon May 31 08:24:51 1993  Ian Lance Taylor  (ian@cygnus.com)
+
+       * Makefile.in (install): Create directory if necessary.
+
+Sun May 30 15:57:05 1993  Per Bothner  (bothner@cygnus.com)
+
+       * powerset.c (__eqpowerset, _newpowerset):  Don't call
+       MASK_UNUSED_{CHAR,SHORT}_BITS on input operand
+       (which might be in read-only memory).
+       * powerset.c (SET_CHAR, SET_SHORT):  Make unsigned.
+
+Fri May 21 10:45:07 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+        * Makefile.in, chillrt0.c, fileio.c, libchill.c, 
+         powerset.c, rtltypes.h: Wilfried's changes checked
+         in at Cygnus.     
+
+Tue May 18 09:21:56 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * powerset.c, Makefile.in: Add psslice routine.
+         Change function name from bitsetpowerset to
+          setpowersetbits.  Drop build of I/O library
+          stuff, per Wilfried's request.
+
+Tue May 18 07:55:25 1993  Wilfried Moser  (fs_moser at rcsw1j)
+
+       * Makefile.in: clean up directory. Remove chillrt0.c 
+          from libchill.a, this will be linked separately.
+         Remove librmt.a from Makefile, this is application
+          dependent.
+
+Fri May  7 10:45:09 1993  Ian Lance Taylor  (ian@cygnus.com)
+
+       * Makefile.in (tooldir): Define.
+       * configure.in: If cross-compilation, install in $(tooldir)/lib
+       rather than in $(exec_prefix)/lib.
+
+Sat May  1 11:43:44 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in: Add store_output to lists.
+       * powerset.c: Add char- and short-length set handling
+          across the board.
+
+Thu Apr  8 17:43:33 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * powerset.c (nepowerset): Return TRUE for non-equal comparison.
+       * string.c (eqstring, nestring): Call memcmp for the real work.
+
+Mon Mar 22 23:22:53 1993  david d `zoo' zuhn  (zoo at cirdan.cygnus.com)
+
+       * Makefile.in: add dvi, check and installcheck targets
+
+Fri Mar 12 10:59:31 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * string.c (nestring): Fix return status - was completely bogus.
+
+Fri Mar  5 18:34:15 1993  Per Bothner  (bothner@rtl.cygnus.com)
+
+       * powerset.c:  Re-name INT_TYPE_SIZE to SET_WORD_SIZE.
+       * powerset.c:  Use SET_WORD instead of (unsigned int).
+       * powerset.c (__eqpowerset, __nepowerset):  Fix masking
+       of final word to not trash memory.
+
+Fri Mar  5 07:55:13 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in, powerset.c (__nepowerset): add psne for powerset
+          inequality test.
+        * string.c: fix comment.
+
+Sat Feb 20 08:07:21 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in, libchill.c, powerset.c: split out powerset stuff.
+       * powerset.c: fix __ffsetpowerset and __flsetpowerset.
+
+Fri Feb 19 11:00:10 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in: add psmax and psmin to LIBFUNCS1, so the 
+         ffsetpowerset and flsetpowerset functions get into the library.
+
+Sat Feb 13 15:43:21 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in, string.c: cleanup
+
+Sat Feb 13 13:52:20 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * Makefile.in: Add LIBFUNC4, and loop for it.  Builds
+         string-related runtime functions, adds them to libchill.a.
+
+Wed Feb 10 09:45:29 1993  Bill Cox  (bill@rtl.cygnus.com)
+
+       * rtltypes.h: added missing TExceptionDefinition.
+
+       * libchill.c: add GNU comment header, various new powerset
+         support routines.  Change function declarations for K&R
+         compatibility.
+       * string.c: added - runtime string routines (relationals and
+         concat).
+
+Tue Feb  9 16:17:35 1993  Per Bothner  (bothner@rtl.cygnus.com)
+
+       * libchill.c, rtltypes.h:  Replace exceptions-handling code.
+       * fileio.c:  Comment out non-working pseudo-exception-handlers.
+
+Fri Feb  5 07:38:39 1993  Fred Fish  (fnf@cygnus.com)
+
+       * Makefile.in (RANLIB_TEST, INSTALL, INSTALL_PROGRAM,
+       INSTALL_DATA):  Supply default definitions.
+
+Sat Jan 30 13:57:09 1993  Per Bothner  (bothner@rtl.cygnus.com)
+
+       * libchill.c:  Change exception to be plain (char*).
+       (This is a simplification, at the cost of needing strcmp's.)
+       * Makefile.in:  Move install actions over form ../gcc/Makefile.in.
+
+Wed Jan 27 23:22:44 1993  Per Bothner  (bothner@rtl.cygnus.com)
+
+       * libchill.c (__cause_exception):  Exception is (for now)
+       (char**), rather than short.
+       Also, add (commented-out) sketch of new exception implementation.
+
+Tue Jan 12 21:14:56 1993  Per Bothner  (bothner@cygnus.com)
+
+       * libchill.c:  Re-wrote bitstring/powerset code:  Each chunk is
+       now a (unsigned int), rather than a (char), and bit-order
+       depends on BITS_BIG_ENDIAN, rather than being always
+       litle-endian.  Other improvements here and there.
+       * libchill.c (__cardpowerset, __diffpowerset):  Faster code.
+       * libchill.c (__setbitinstring):  New routine, to assign
+       a single bit in a bitstring/powerset.
+       * Makefile.in (LIBFUNCS1):  Add psset for __setbitinstring().
+
+Tue Jan 12 00:10:46 1993  david d `zoo' zuhn  (zoo at cirdan.cygnus.com)
+
+       * Makefile.in: compile all files with ALL_CFLAGS instead of CFLAGS,
+       default ALL_CFLAGS to include CFLAGS,
+       default XTRAFLAGS which is used to find the C library (like libg++),
+       added dummy install-info target for devo builds,
+
+Wed Jan  6 08:03:46 1993  Fred Fish  (fnf@cygnus.com)
+
+       * Makefile.in (libchill.a):  Since libchill.a depends upon
+       chillrt0.o, don't remove chillrt0.o after adding to archive.
+       * config/mh-sysv4:  Add SVR4 configuration file.
+       * Makefile.in (GCC_MAKEFILE):  Define to point to gcc/chill
+       compiler Makefile, which contains the actual makefile fragments
+       to do the install, since it knows where gcc/chill is installed.
+       * Makefile.in:  Add lines that configure looks for to insert
+       host, target, and site specific Makefile fragments.
+       * Makefile.in (install):  New target that invokes make on the
+       gcc/chill makefile to do the actual install.
+       * configure.in (*-*-sysv4):  Use mh-sysv4 as host_makefile_frag.
+
+Sun Jan  3 16:47:25 1993  Per Bothner  (bothner@cygnus.com)
+
+       * chillrt0.c:  Comment out for now the non-portable
+       kludge for adding build_exceptions to the C++ initialision list.
+
+Sat Jan  2 15:51:43 1993  Per Bothner  (bothner@rtl.cygnus.com)
+
+       * New directory.  Moved files from ../gcc/chillrt.
+       * configure.in:  New file.
+       * Makefile.in:  Modified from old Makefile to fit into standard
+       directory structure.
diff --git a/libchill/Makefile.in b/libchill/Makefile.in
new file mode 100644 (file)
index 0000000..68f9218
--- /dev/null
@@ -0,0 +1,166 @@
+# Makefile for GNU CHILL compiler runtime library.
+#   Copyright (C) 1987, 88, 90-94, 1998 Free Software Foundation, Inc.
+
+#This file is part of GNU CC.
+
+#GNU CC is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 2, or (at your option)
+#any later version.
+
+#GNU CC is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with GNU CC; see the file COPYING.  If not, write to
+#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# This was cribbed from the libf2c, libiberty and libstdc++ Makefile.in
+# files.  Some of this stuff may be unnecessary and worthless.
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+target_alias = @target_alias@
+gcc_version = @gcc_version@
+gcc_version_trigger = @gcc_version_trigger@
+
+libdir = $(exec_prefix)/lib
+libsubdir = $(libdir)/gcc-lib/$(target_alias)/$(gcc_version)
+
+# Multilib support variables.
+MULTISRCTOP =
+MULTIBUILDTOP =
+MULTIDIRS =
+MULTISUBDIR =
+MULTIDO = true
+MULTICLEAN = true
+
+# Not configured per top-level version, since that doesn't get passed
+# down at configure time, but overrridden by the top-level install
+# target.
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+AR = @AR@
+AR_FLAGS = rc
+
+RANLIB = @RANLIB@
+
+CC = @CC@
+CFLAGS = @CFLAGS@
+ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS)
+
+.SUFFIXES:
+.SUFFIXES: .c .o
+
+.c.o:
+       $(CC) -c $(ALL_CFLAGS) $(INCLUDES) $<
+
+# Lists of required functions for each archive.
+
+LIBOBJS1 = allgmem.o allmem.o allocate.o cause.o exhstack.o exh.o retmem.o \
+          unhex.o unhex1.o rtsdummy.o terminate.o
+
+IOOBJS = basicio.o chillstdio.o delete.o eoln.o existing.o format.o getassoc.o \
+        gettextaccess.o gettextindex.o gettextrecord.o getusage.o \
+        indexable.o ioerror.o isassociated.o outoffile.o readable.o \
+        readrecord.o sequencible.o settextaccess.o settextindex.o \
+        settextrecord.o variable.o writeable.o writerecord.o
+
+PSOBJS = andps.o cardps.o concatps.o copyps.o diffps.o eqps.o ffsetclrps.o \
+       ffsetps.o flsetclrps.o flsetps.o inbitstr.o inps.o leps.o ltps.o \
+       neps.o notps.o orps.o setbitps.o setbits.o sliceps.o xorps.o
+
+STROBJS = concatstr.o eqstr.o ltstr.o memmove.o
+
+TIMEOBJS = abstime.o inttime.o waituntil.o remaintime.o convdurrtstime.o \
+          checkcycle.o
+
+TASKOBJS = continue.o delaycase.o printbuffer.o printevent.o queuelength.o \
+          sendbuffer.o waitbuffer.o
+
+OBJS = $(LIBOBJS1) $(IOOBJS) $(PSOBJS) $(STROBJS) $(TIMEOBJS) $(TASKOBJS)
+
+libchill.a: $(OBJS)
+       $(AR) $(AR_FLAGS) $@ $(OBJS)
+       $(RANLIB) $@
+
+$(PSOBJS): $(srcdir)/powerset.h
+librmt.o: $(srcdir)/rtltypes.h
+chillrt0.o: $(srcdir)/rtltypes.h $(srcdir)/iomodes.h $(srcdir)/auxtypes.h
+$(LIBOBJS1): $(srcdir)/rtltypes.h
+$(TIMEOBJS): $(srcdir)/rtltypes.h $(srcdir)/rts.h
+$(TASKOBJS): $(srcdir)/rts.h $(srcdir)/rtltypes.h
+$(IOOBJS): $(srcdir)/fileio.h $(srcdir)/bitstring.h $(srcdir)/auxtypes.h \
+          $(srcdir)/iomodes.h $(srcdir)/format.h $(srcdir)/ioerror.h
+
+# Flags to pass to a recursive make.
+FLAGS_TO_PASS = \
+       "AR=$(AR)" \
+       "AR_FLAGS=$(AR_FLAGS)" \
+       "CC=$(CC)" \
+       "CFLAGS=$(CFLAGS)" \
+       "LIBCFLAGS=$(LIBCFLAGS)" \
+       "EXTRA_OFILES=$(EXTRA_OFILES)" \
+       "HDEFINES=$(HDEFINES)" \
+       "INSTALL=$(INSTALL)" \
+       "INSTALL_DATA=$(INSTALL_DATA)" \
+       "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
+       "LDFLAGS=$(LDFLAGS)" \
+       "LOADLIBES=$(LOADLIBES)" \
+       "PICFLAG=$(PICFLAG)" \
+       "RANLIB=$(RANLIB)" \
+       "SHELL=$(SHELL)"
+
+all: chillrt0.o libchill.a
+       @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
+
+Makefile: Makefile.in config.status
+       $(SHELL) config.status
+
+config.status: configure
+       rm -f config.cache
+       CONFIG_SITE=no-such-file CC='$(CC)' AR='$(AR)' CFLAGS='$(CFLAGS)' \
+       CPPFLAGS='$(CPPFLAGS)' $(SHELL) config.status --recheck
+
+${srcdir}/configure: configure.in
+       rm -f config.cache
+       cd ${srcdir} && autoconf
+
+install: all
+       $(INSTALL_DATA) libchill.a $(libsubdir)$(MULTISUBDIR)/libchill.a.n
+       $(RANLIB) $(libsubdir)$(MULTISUBDIR)/libchill.a.n
+       mv $(libsubdir)$(MULTISUBDIR)/libchill.a.n $(libsubdir)$(MULTISUBDIR)/libchill.a
+       $(INSTALL_DATA) chillrt0.o $(libsubdir)$(MULTISUBDIR)/chillrt0.o
+       @rootme=`pwd`/ ; export rootme ; \
+       $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
+
+
+check uninstall install-strip dist installcheck installdirs:
+
+mostlyclean:
+       rm -f *.o
+       @$(MULTICLEAN) multi-clean DO=mostlyclean
+
+clean: mostlyclean
+       rm -f config.log
+       @$(MULTICLEAN) multi-clean DO=clean
+
+distclean: clean
+       @$(MULTICLEAN) multi-clean DO=distclean
+       rm -f config.cache config.status Makefile configure
+
+maintainer-clean realclean: distclean
+
+.PHONY: mostlyclean clean distclean maintainer-clean all check uninstall \
+       install-strip dist installcheck installdirs 
+
diff --git a/libchill/abstime.c b/libchill/abstime.c
new file mode 100644 (file)
index 0000000..2933fa8
--- /dev/null
@@ -0,0 +1,131 @@
+/* Implement timing-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <time.h>
+#include "rtltypes.h"
+
+EXCEPTION (rangefail);
+
+#define SECOND_VALID         1
+#define MINUTE_VALID         2
+#define HOUR_VALID           4
+#define DAY_VALID            8
+#define MONTH_VALID         16
+#define YEAR_VALID          32
+
+extern void __cause_ex1 (char *ex, char *file, int lineno);
+
+#define CAUSE_RANGEFAIL     __cause_ex1 ("rangefail", filename, lineno)
+
+/*
+ * function _abstime
+ *
+ * parameters:
+ *     mask - mask of valid values
+ *     year
+ *     month
+ *     day
+ *     hour
+ *     minute
+ *     second
+ *
+ * returns:
+ *     unsigned long
+ *
+ * exceptions:
+ *     rangefail
+ *
+ * abstract:
+ *     perform the ABSTIME builtin call
+ *
+ */
+
+unsigned long
+_abstime (mask, year, month, day, hour, minute, second,
+         filename, lineno)
+     int  mask, year, month, day, hour, minute, second;
+     char *filename;
+     int  lineno;
+{
+  struct tm   *time_str;
+  time_t      result, current_time;
+
+  /* first of all get current time */
+  if ((current_time = time (0)) == (time_t)-1)
+    /* FIXME: what excpetion ?? */
+    CAUSE_RANGEFAIL;
+
+  /* if we just have to determine the current time, we are ready.
+     This is shown by mask == 0. */
+  if (mask == 0)
+    return (unsigned long)current_time;
+
+  /* convert current time to struct tm */
+  time_str = localtime (&current_time);
+
+  if (mask & YEAR_VALID)
+    {
+      if (year < 1900)
+       CAUSE_RANGEFAIL;
+      time_str->tm_year = year - 1900;
+    }
+
+  if (mask & MONTH_VALID)
+    {
+      if (month < 1 || month > 12)
+       CAUSE_RANGEFAIL;
+      time_str->tm_mon = month - 1;
+    }
+
+  if (mask & DAY_VALID)
+    {
+      if (day < 1 || day > 31)
+       CAUSE_RANGEFAIL;
+      time_str->tm_mday = day;
+    }
+
+  if (mask & HOUR_VALID)
+    {
+      if (hour < 0 || hour > 23)
+       CAUSE_RANGEFAIL;
+      time_str->tm_hour = hour;
+    }
+
+  if (mask & MINUTE_VALID)
+    {
+      if (minute < 0 || minute > 59)
+       CAUSE_RANGEFAIL;
+      time_str->tm_min = minute;
+    }
+
+  if (mask & SECOND_VALID)
+    {
+      if (second < 0 || second > 59)
+       CAUSE_RANGEFAIL;
+      time_str->tm_sec = second;
+    }
+
+  /* do it */
+  time_str->tm_isdst = -1;
+  if ((result = mktime (time_str)) == (time_t)-1)
+    CAUSE_RANGEFAIL;
+
+  return (unsigned long)result;
+}
diff --git a/libchill/allgmem.c b/libchill/allgmem.c
new file mode 100644 (file)
index 0000000..b0d91ed
--- /dev/null
@@ -0,0 +1,61 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "config.h"
+#include <stdlib.h>
+#include "rtltypes.h"
+
+extern void __cause_ex1 (char *ex, char *filename, int lineno);
+
+EXCEPTION (notimplemented);
+
+/*
+ * function _allocate_global_memory
+ *
+ * parameters:
+ *  ptr                        pointer to location where pointer should be written
+ *  size               number of bytes to allocate
+ *  filename            source file which issued the call
+ *  linenumber          line number of the call within that file
+ *
+ * returns:
+ *  void
+ *
+ * exceptions:
+ *  spacefail
+ *  protectionfail
+ *  rangefail
+ *
+ * abstract:
+ *  allocate global memory. At the moment we dont know how to realize this,
+ *  therefore cause NotImplemented.
+ *
+*/
+
+void
+_allocate_global_memory (ptr, size, filename, linenumber)
+     void **ptr;
+     int size;
+     char *filename;
+     int linenumber;
+{
+    __cause_ex1 ("notimplemented", filename, linenumber);
+}
+
diff --git a/libchill/allmem.c b/libchill/allmem.c
new file mode 100644 (file)
index 0000000..8cf2be5
--- /dev/null
@@ -0,0 +1,73 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include <stdlib.h>
+#include "config.h"
+#include "rtltypes.h"
+
+extern void __cause_ex1 (char *exname, char *file, int lineno);
+
+/* define needed exceptions */
+EXCEPTION (protectionfail);
+EXCEPTION (rangefail);
+EXCEPTION (spacefail);
+
+/*
+ * function _allocate_memory
+ *
+ * parameters:
+ *  ptr                        pointer to location where pointer should be written
+ *  size               number of bytes to allocate
+ *  filename            source file which issued the call
+ *  linenumber          line number within that source file
+ *
+ * returns:
+ *  void
+ *
+ * exceptions:
+ *  spacefail
+ *  protectionfail
+ *  rangefail
+ *
+ * abstract:
+ *  allocate memory from heap
+ *
+*/
+
+void
+_allocate_memory (ptr, size, filename, linenumber)
+     void **ptr;
+     int size;
+     char *filename;
+     int   linenumber;
+{
+  void *tmp;
+    
+  if (!ptr)
+    __cause_ex1 ("protectionfail", filename, linenumber);
+  if (size < 0)
+    __cause_ex1 ("rangefail", filename, linenumber);
+  tmp = malloc (size);
+  if (!tmp)
+    __cause_ex1 ("spacefail", filename, linenumber);
+  *ptr = tmp;
+}
diff --git a/libchill/allocate.c b/libchill/allocate.c
new file mode 100644 (file)
index 0000000..66c22ea
--- /dev/null
@@ -0,0 +1,67 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include <stdlib.h>
+#include "config.h"
+#include "rtltypes.h"
+
+extern void __cause_ex1 (char *exname, char *file, int lineno);
+
+/* define needed exceptions */
+EXCEPTION (allocatefail)
+EXCEPTION (rangefail)
+
+/*
+ * function __allocate
+ *
+ * parameters:
+ *  size               number of bytes to allocate
+ *  filename            source file which issued the call
+ *  linenumber          line number within that source file
+ *
+ * returns:
+ *  void *
+ *
+ * exceptions:
+ *  allocatefail
+ *  rangefail
+ *
+ * abstract:
+ *  allocate memory from heap
+ *
+*/
+
+void *
+__allocate (size, filename, linenumber)
+     int size;
+     char *filename;
+     int   linenumber;
+{
+  void *tmp;
+    
+  if (size < 0)
+    __cause_ex1 ("rangefail", filename, linenumber);
+  tmp = malloc (size);
+  if (!tmp)
+    __cause_ex1 ("allocatefail", filename, linenumber);
+  return tmp;
+}
diff --git a/libchill/andps.c b/libchill/andps.c
new file mode 100644 (file)
index 0000000..fd7d609
--- /dev/null
@@ -0,0 +1,76 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __andpowerset
+ *
+ * parameters:
+ *     out             return from __andpowerset
+ *     left            left powerset
+ *     right           right powerset
+ *     bitlength       length of powerset in bits
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  and's two powersets
+ *
+ */
+
+void
+__andpowerset (out, left, right, bitlength)
+     SET_WORD      *out;
+     SET_WORD      *left;
+     SET_WORD      *right;
+     unsigned long  bitlength;
+{
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      *((SET_CHAR *)out) = *((SET_CHAR *)left) &
+                           *((SET_CHAR *)right);
+      MASK_UNUSED_CHAR_BITS((SET_CHAR *)out, bitlength);
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      *((SET_SHORT *)out) = *((SET_SHORT *)left) &
+                            *((SET_SHORT *)right);
+      MASK_UNUSED_SHORT_BITS((SET_SHORT *)out, bitlength);
+    }
+  else
+    {
+      unsigned long len = BITS_TO_WORDS (bitlength);
+      register unsigned long i;
+    
+      for (i = 0; i < len; i++)
+       out[i] = left[i] & right[i];
+      MASK_UNUSED_WORD_BITS ((out + len - 1), 
+                            bitlength % SET_WORD_SIZE);
+    }
+}
diff --git a/libchill/auxtypes.h b/libchill/auxtypes.h
new file mode 100644 (file)
index 0000000..627da11
--- /dev/null
@@ -0,0 +1,45 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef _auxtypes_h_
+#define _auxtypes_h_
+
+
+typedef enum { False, True } Boolean;
+
+#define VARYING_STRING(strlen) \
+  struct { unsigned short len; char body[strlen]; }
+
+typedef struct {
+  unsigned short len;
+  char           body[1];
+} VarString; 
+
+/* Macros for moving an (U)INT and (U)LONG without alignment worries */
+#define MOV2(tgt,src) \
+  *((char*)(tgt)  ) = *((char*)(src)  ), \
+  *((char*)(tgt)+1) = *((char*)(src)+1)
+#define MOV4(tgt,src) \
+  *((char*)(tgt)  ) = *((char*)(src)  ), \
+  *((char*)(tgt)+1) = *((char*)(src)+1), \
+  *((char*)(tgt)+2) = *((char*)(src)+2), \
+  *((char*)(tgt)+3) = *((char*)(src)+3)
+
+#endif
diff --git a/libchill/basicio.c b/libchill/basicio.c
new file mode 100644 (file)
index 0000000..b13b0b8
--- /dev/null
@@ -0,0 +1,467 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+   
+   This file is part of GNU CC.
+   
+   GNU CC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+   
+   GNU CC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with GNU CC; see the file COPYING.  If not, write to
+   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <errno.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "fileio.h"
+
+#ifndef PATH_MAX
+#define PATH_MAX _POSIX_PATH_MAX
+#endif
+
+static
+void
+GetSetAttributes( Association_Mode* the_assoc )
+{
+  struct stat statbuf;
+  int retco;
+
+  if( (retco = stat( the_assoc->pathname, &statbuf )) )
+    return;
+
+  if( S_ISREG(statbuf.st_mode) )
+    {
+      SET_FLAG( the_assoc, IO_EXISTING );
+      if( !TEST_FLAG( the_assoc, IO_VARIABLE ) )
+        SET_FLAG( the_assoc, IO_INDEXABLE );
+    }
+  else
+    if( S_ISCHR(statbuf.st_mode) || S_ISFIFO(statbuf.st_mode) )
+      {
+       SET_FLAG( the_assoc, IO_EXISTING );
+       CLR_FLAG( the_assoc, IO_INDEXABLE );
+      }
+  SET_FLAG( the_assoc, IO_SEQUENCIBLE );
+
+  /* FIXME: File size and computation of number of records for outoffile ? */
+
+  if( !access( the_assoc->pathname, R_OK ) )
+    SET_FLAG( the_assoc, IO_READABLE );
+  if( !access( the_assoc->pathname, W_OK ) )
+    SET_FLAG( the_assoc, IO_WRITEABLE );
+}
+
+static
+void 
+makeName( Association_Mode* the_assoc, char* the_path, int the_path_len,
+        char* file, int line)
+{
+  int namlen;
+  if( ! the_assoc->pathname && 
+      ! (the_assoc->pathname = (char*)malloc( PATH_MAX )) )
+    CHILLEXCEPTION( file, line, SPACEFAIL, PATHNAME_ALLOC );
+
+  if( the_path[0] != DIRSEP )
+    {
+      if( !getcwd( the_assoc->pathname, PATH_MAX ) )
+       {
+         the_assoc->syserrno = errno;
+         CHILLEXCEPTION( file, line, ASSOCIATEFAIL, GETCWD_FAILS );
+       }
+      namlen = strlen( the_assoc->pathname );
+      the_assoc->pathname[namlen++] = DIRSEP;  
+    }
+  else
+    namlen = 0;
+
+  strncpy( the_assoc->pathname + namlen, the_path, the_path_len );
+  the_assoc->pathname[namlen+the_path_len] = '\0';
+}
+
+/*
+ * ASSOCIATE
+ */
+/* Caution: returns an Association mode location (!) */
+Association_Mode*
+__associate( Association_Mode* the_assoc,
+            char*             the_path,
+            int               the_path_len,
+            char*             the_mode,
+            int               the_mode_len,
+            char*             file,
+            int               line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+
+  if( TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
+    CHILLEXCEPTION( file, line, ASSOCIATEFAIL, IS_ASSOCIATED );
+
+  /* clear all flags */
+  the_assoc->flags = 0;
+
+  if( ! the_path_len )
+    CHILLEXCEPTION( file, line, ASSOCIATEFAIL, NO_PATH_NAME );
+
+  makeName( the_assoc, the_path, the_path_len, file, line );
+  GetSetAttributes( the_assoc );
+
+  CLR_FLAG( the_assoc, IO_VARIABLE );
+  if ( the_mode )
+    {
+      if( !strncmp( the_mode, "VARIABLE", 8 ) )
+       {
+         SET_FLAG( the_assoc, IO_VARIABLE );
+         CLR_FLAG( the_assoc, IO_INDEXABLE );
+       }
+      else
+       if( strlen( the_mode ) )
+         CHILLEXCEPTION( file, line, ASSOCIATEFAIL, INVALID_ASSOCIATION_MODE );
+    }
+
+  SET_FLAG( the_assoc, IO_ISASSOCIATED );
+  return the_assoc;
+}
+
+/*
+ *  DISSOCIATE
+ */
+void
+__dissociate( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+
+  if( !TEST_FLAG( the_assoc, IO_ISASSOCIATED ) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+
+  if( the_assoc->access )
+    __disconnect( the_assoc->access, file, line );
+
+  the_assoc->access = NULL;
+  CLR_FLAG( the_assoc, IO_ISASSOCIATED );
+
+  /* free allocated memory */
+  if (the_assoc->pathname)
+    {
+      free (the_assoc->pathname);
+      the_assoc->pathname = 0;
+    }
+  if (the_assoc->bufptr)
+    {
+      free (the_assoc->bufptr);
+      the_assoc->bufptr = 0;
+    }
+}
+
+/*
+ * CREATE
+ */
+void __create( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+
+  if( !TEST_FLAG( the_assoc, IO_ISASSOCIATED ) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+
+  if( TEST_FLAG( the_assoc, IO_EXISTING ) )
+    CHILLEXCEPTION( file, line, CREATEFAIL, FILE_EXISTING );
+
+  if( (the_assoc->handle = open( the_assoc->pathname, O_CREAT+O_TRUNC+O_WRONLY, 0666 ))
+      == -1 )
+      CHILLEXCEPTION( file, line, CREATEFAIL, CREATE_FAILS );
+
+  the_assoc->usage = ReadWrite;
+  GetSetAttributes( the_assoc );
+
+  close( the_assoc->handle );
+}
+
+/*
+ * MODIFY
+ */
+void
+__modify( Association_Mode* the_assoc,
+         char*             the_path,
+         int               the_path_len,
+         char*             the_mode,
+         int               the_mode_len,
+         char*             file,
+         int               line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+
+  if( !TEST_FLAG( the_assoc, IO_ISASSOCIATED ) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+
+  if( the_path_len )
+    {
+      char* oldname;
+
+      if( ! (oldname = (char*)malloc( PATH_MAX )) )
+       CHILLEXCEPTION( file, line, SPACEFAIL, PATHNAME_ALLOC );
+      strcpy( oldname, the_assoc->pathname );
+
+      makeName( the_assoc, the_path, the_path_len, file, line );
+
+      if( rename( oldname, the_assoc->pathname ) )
+       {
+         free( oldname );
+         CHILLEXCEPTION( file, line, MODIFYFAIL, RENAME_FAILS );
+       }
+      free( oldname );
+    }
+  else
+    {
+      /* FIXME: other options? */
+    }
+}
+
+static
+/*** char* DirMode[] = { "rb", "r+b", "r+b" }; ***/
+int DirMode[] = { O_RDONLY, O_RDWR, O_RDWR };
+
+static
+/*** char* SeqMode [] = { "rb", "r+b", "r+b" }; ***/
+int SeqMode[] = { O_RDONLY, O_RDWR, O_RDWR };
+
+/*
+ * CONNECT
+ */
+void
+__connect( void*             the_transfer,
+          Association_Mode* the_assoc,
+          Usage_Mode        the_usage,
+          Where_Mode        the_where,
+          Boolean           with_index,
+          signed long       the_index,
+          char*             file,
+          int               line )
+{
+  Access_Mode*  the_access;
+  off_t         filepos;
+  off_t         savepos;
+  char          dummy;
+  unsigned long nbytes;
+  int           oflag;
+
+  if( !the_transfer )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS );
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+
+  if( TEST_FLAG((Text_Mode*)the_transfer, IO_TEXTLOCATION ))
+    {
+      if( ! ((Text_Mode*)the_transfer)->access_sub )
+       CHILLEXCEPTION( file, line, EMPTY, NO_ACCESS_SUBLOCATION );
+      the_access = ((Text_Mode*)the_transfer)->access_sub;
+      SET_FLAG( the_access, IO_TEXTIO );
+    }
+  else
+    {
+      the_access = (Access_Mode*)the_transfer;
+      CLR_FLAG( the_access, IO_TEXTIO );
+    }
+
+  /* FIXME: This should be an (implementation-dependent) static check
+     if( with_index && the_access->rectype > Fixed )
+     CHILLEXCEPTION( file, line, CONNECTFAIL, IMPL_RESTRICTION );
+     */
+
+  if( ! TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+
+  if( ! TEST_FLAG( the_assoc, IO_EXISTING ) )
+    CHILLEXCEPTION( file, line, CONNECTFAIL, NOT_EXISTING );
+
+  if( ! TEST_FLAG( the_assoc, IO_READABLE ) &&
+      ( the_usage = ReadOnly || the_usage == ReadWrite ) )    
+    CHILLEXCEPTION( file, line, CONNECTFAIL, NOT_READABLE );
+
+  if( ! TEST_FLAG( the_assoc, IO_WRITEABLE ) &&
+      ( the_usage = WriteOnly || the_usage == ReadWrite ) )    
+    CHILLEXCEPTION( file, line, CONNECTFAIL, NOT_WRITEABLE );
+
+  if( ! TEST_FLAG( the_assoc, IO_INDEXABLE ) 
+      && TEST_FLAG( the_access, IO_INDEXED ) )
+    CHILLEXCEPTION( file, line, CONNECTFAIL, NOT_INDEXABLE );
+
+  if( ! TEST_FLAG( the_assoc, IO_SEQUENCIBLE ) 
+      && ! TEST_FLAG( the_access, IO_INDEXED ) )
+    CHILLEXCEPTION( file, line, CONNECTFAIL, NOT_SEQUENCIBLE );
+
+  if( the_where == Same && the_assoc->access == NULL )
+    CHILLEXCEPTION( file, line, CONNECTFAIL, NO_CURRENT_POS );
+
+  /* This dynamic condition is not checked for text connections. */
+  if( ! TEST_FLAG( the_access, IO_TEXTIO ) )
+    if( ! TEST_FLAG( the_assoc, IO_VARIABLE ) 
+       && the_access->rectype > Fixed 
+       && ( the_usage == WriteOnly || the_usage == ReadWrite ) )
+      CHILLEXCEPTION( file, line, CONNECTFAIL, NOT_VARIABLE );
+  if( TEST_FLAG( the_assoc, IO_VARIABLE )
+      && the_access->rectype == Fixed 
+      && ( the_usage == ReadOnly || the_usage == ReadWrite ) )
+    CHILLEXCEPTION( file, line, CONNECTFAIL, NOT_FIXED );
+  if( ! TEST_FLAG( the_access, IO_INDEXED ) && the_usage == ReadWrite )
+    CHILLEXCEPTION( file, line, CONNECTFAIL, NOT_INDEXED );
+
+  /* Access location may be connected to a different association. */
+  if( the_access->association && the_access->association != the_assoc )
+    __disconnect( the_access, file, line );
+
+  /* Is the association location already connected? */
+  if( the_assoc->access )
+    {
+      /* save position just in case we need it for the_where == Same */
+      if( (savepos = lseek( the_assoc->handle, 0L, SEEK_CUR )) == -1L )
+       CHILLEXCEPTION( file, line, CONNECTFAIL, LSEEK_FAILS );
+
+      /* text: read correction, flush buffer */
+      if( the_assoc->bufptr ){
+       savepos -= the_assoc->bufptr->len - the_assoc->bufptr->cur;
+       the_assoc->bufptr->len = the_assoc->bufptr->cur = 0;
+      }
+
+      /* implicit disconnect */
+      __disconnect( the_assoc->access, file, line );
+    }
+
+  the_assoc->usage = the_usage;
+  CLR_FLAG( the_access, IO_OUTOFFILE );
+  if( TEST_FLAG( the_access, IO_INDEXED ) )
+    {
+      if( (the_assoc->handle = open( the_assoc->pathname, DirMode[the_usage] )) == -1 )
+       CHILLEXCEPTION( file, line, CONNECTFAIL, OPEN_FAILS );
+
+      /* Set base index. */
+      switch( the_where )
+       {
+       case First: 
+         filepos = 0;
+         break;
+       case Same: 
+         filepos = savepos;
+         break;
+       case Last: 
+         if( lseek( the_assoc->handle, 0L, SEEK_END ) == -1L )
+           CHILLEXCEPTION( file, line, CONNECTFAIL, LSEEK_FAILS );
+         filepos = lseek( the_assoc->handle, 0L, SEEK_CUR );
+         break;
+       }
+
+      /* Set current index */
+      if( with_index )
+       {
+         if( the_index < the_access->lowindex
+             || the_access->highindex < the_index )
+           CHILLEXCEPTION( file, line, RANGEFAIL, BAD_INDEX );
+         filepos += (the_index - the_access->lowindex) * the_access->reclength;
+       }
+      if( lseek( the_assoc->handle, filepos, SEEK_SET ) == -1L )
+       CHILLEXCEPTION( file, line, CONNECTFAIL, LSEEK_FAILS );
+      the_access->base = filepos;
+    }
+  else
+    {
+      /* for association to text for reading: allocate buffer */
+      if( TEST_FLAG((Text_Mode*)the_transfer, IO_TEXTLOCATION ) &&
+         the_usage == ReadOnly &&
+         !the_assoc->bufptr )
+       {
+         if( ! (the_assoc->bufptr = (readbuf_t*)malloc( sizeof(readbuf_t) )) )
+           CHILLEXCEPTION( file, line, CONNECTFAIL, BUFFER_ALLOC ); 
+         memset (the_assoc->bufptr, 0, sizeof (readbuf_t));
+       }
+      if( (the_assoc->handle = open( the_assoc->pathname, SeqMode[the_usage] )) == -1 )
+       CHILLEXCEPTION( file, line, CONNECTFAIL, OPEN_FAILS );
+
+      /* Set base index. */
+      switch( the_where )
+       {
+       case First: 
+         filepos = 0;
+         break;
+       case Same: 
+         filepos = savepos;
+         break;
+       case Last:
+         if( lseek( the_assoc->handle, 0L, SEEK_END ) == -1L )
+           CHILLEXCEPTION( file, line, CONNECTFAIL, LSEEK_FAILS );
+         filepos = lseek( the_assoc->handle, 0L, SEEK_CUR );
+         break;
+       }
+
+      /* file truncation for sequential, Write Only */
+      /***************************** FIXME: cannot truncate at Same
+       if( the_usage == WriteOnly )
+       {
+       if( fseek( the_assoc->file_ptr, filepos, SEEK_SET ) == -1L )
+        CHILLEXCEPTION( file, line, CONNECTFAIL, FSEEK_FAILS );
+       fclose( the_assoc->file_ptr );
+       if( !(the_assoc->file_ptr = fopen( the_assoc->pathname, "ab" )) )
+        CHILLEXCEPTION( file, line, CONNECTFAIL, OPEN_FAILS );
+       }
+       else
+       ***************************/
+      if( (filepos = lseek( the_assoc->handle, filepos, SEEK_SET )) == -1L )
+       CHILLEXCEPTION( file, line, CONNECTFAIL, LSEEK_FAILS );
+    }
+
+  the_access->association = the_assoc;
+  the_assoc->access = the_access;
+  /* for text: set carriage control default */
+  if( TEST_FLAG((Text_Mode*)the_transfer, IO_TEXTLOCATION ) ){
+    the_assoc->ctl_pre  = '\0';
+    the_assoc->ctl_post = '\n';
+  }
+}
+
+void
+__disconnect( void* the_transfer, char* file, int line )
+{
+  Access_Mode* the_access;
+
+  if( !the_transfer )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS );
+
+  if( TEST_FLAG((Text_Mode*)the_transfer, IO_TEXTLOCATION ))
+    {
+      the_access = ((Text_Mode*)the_transfer)->access_sub;
+      CLR_FLAG( the_access, IO_TEXTIO );
+    }
+  else
+    the_access = (Access_Mode*)the_transfer;
+
+  if( !the_access->association )
+    CHILLEXCEPTION( file, line, NOTCONNECTED, IS_NOT_CONNECTED );
+
+  close( the_access->association->handle );
+  /* FIXME: check result */
+
+  if( the_access->store_loc )
+    free( the_access->store_loc );
+  the_access->store_loc           = NULL;
+  the_access->association->access = NULL;
+  the_access->association         = NULL;
+}
diff --git a/libchill/bitstring.h b/libchill/bitstring.h
new file mode 100644 (file)
index 0000000..0a8ce62
--- /dev/null
@@ -0,0 +1,29 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef _bitstring_h_
+#define _bitstring_h_
+
+int __inpowerset( int i, char* string, int strlen, int dummy );
+void __setbitpowerset (char *powerset, unsigned long bitlength,
+                      long minval, long bitno, char newval,
+                      char *filename, int lineno);
+                      
+#endif
diff --git a/libchill/cardps.c b/libchill/cardps.c
new file mode 100644 (file)
index 0000000..261241d
--- /dev/null
@@ -0,0 +1,99 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+
+/*
+ * function __cardpowerset
+ *
+ * parameters:
+ *     ps              powerset
+ *     bitlength       length of powerset
+ *
+ * returns:
+ *     long            number of set bits
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  returns the number of set bit's in a powerset
+ *
+ */
+
+/* bit_count[I] is number of '1' bits in I. */
+static
+const unsigned char __four_bit_count[16] = {
+    0, 1, 1, 2,
+    1, 2, 2, 3,
+    1, 2, 2, 3,
+    2, 3, 3, 4 };
+
+long
+__cardpowerset (ps, bitlength)
+     SET_WORD      *ps;
+     unsigned long  bitlength;
+{
+  unsigned long        count = 0;
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      register SET_CHAR        c = *((SET_CHAR *)ps);
+      /* count 4 bits at a time. */
+      while (c > 0)
+       {
+         count += __four_bit_count[c & 15];
+         c >>= 4;
+       }
+      return count;
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      register SET_SHORT c = *((SET_SHORT *)ps);
+      /* count 4 bits at a time. */
+      while (c > 0)
+       {
+         count += __four_bit_count[c & 15];
+         c >>= 4;
+       }
+      return count;
+    }
+  else
+    {
+      register SET_WORD        *p = ps;
+      SET_WORD *endp = p + BITS_TO_WORDS(bitlength);
+    
+      while (p < endp)
+       {
+         register SET_WORD c = *p++;
+         /* count 4 bits at a time. */
+         while (c > 0)
+           {
+             count += __four_bit_count[c & 15];
+             c >>= 4;
+           }
+       }
+      return (count);
+    }
+}
diff --git a/libchill/cause.c b/libchill/cause.c
new file mode 100644 (file)
index 0000000..d4d0794
--- /dev/null
@@ -0,0 +1,48 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+
+/*
+ * function cause_exception
+ *
+ * parameters:
+ *  exname             exception name
+ *  file               file name
+ *  lineno             line number
+ *   user_arg          user specified argument
+ *
+ * returns:
+ *  void
+ *
+ * abstract:
+ *  dummy for ChillLib but may be overwritten by the user
+ *
+ */
+void
+cause_exception (exname, file, lineno, user_arg)
+     char *exname;
+     char *file;
+     int lineno;
+     int user_arg;
+{
+}
diff --git a/libchill/checkcycle.c b/libchill/checkcycle.c
new file mode 100644 (file)
index 0000000..571884a
--- /dev/null
@@ -0,0 +1,65 @@
+/* Implement timing-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rtltypes.h"
+#include "rts.h"
+
+EXCEPTION (cyclefail);
+
+/*
+ * function __check_cycle
+ *
+ * parameters:
+ *      t         pointer to initial time
+ *      dur       duration
+ *      filename  filename of call
+ *      lineno    linenumber of call
+ *
+ * returns:
+ *      void
+ *
+ * exceptions:
+ *      cyclefail
+ *
+ * abstract:
+ *      Function checks if cycle is possible (there is time left) and wait the
+ *      remaining time.
+ *
+ */
+
+extern int __remaintime (RtsTime *since, unsigned long dur, RtsTime *remain);
+extern int __cause_ex1 (char *ex, char *file, int lineno);
+    
+void
+__check_cycle (t, dur, fname, lineno)
+    RtsTime       *t;
+    unsigned long  dur;
+    char          *fname;
+    int            lineno;
+{
+  RtsTime remain;
+  
+  if (__remaintime (t, dur, &remain) != 0)
+    /* no time left -- cause exception */
+    __cause_ex1 ("cyclefail", fname, lineno);
+  
+  /* delay the process */
+  __delay_this (wait_wait, &remain, fname, lineno);
+}
diff --git a/libchill/chillrt0.c b/libchill/chillrt0.c
new file mode 100644 (file)
index 0000000..b549602
--- /dev/null
@@ -0,0 +1,147 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#include "rtltypes.h"
+#include "iomodes.h"
+\f
+/* type definitions */
+typedef void (*init_ptr) ();
+typedef void (*rts_init_ptr) (int *argc, char *argv []);
+
+typedef struct INIT_LIST
+{
+  init_ptr             code;
+  struct INIT_LIST     *forward;
+} InitList;
+
+InitList    *_ch_init_list = 0;
+
+/* force linker to get correct RTS functions */
+extern rts_init_ptr    __RTS_INIT__;
+extern init_ptr                __RTS_MAIN_LOOP__;
+extern init_ptr                __RTS_FETCH_NUMBERS__;
+extern init_ptr                __RTS_FETCH_NAMES__;
+static init_ptr                *rts_dummies[4] = 
+{
+  &__RTS_INIT__,
+  &__RTS_MAIN_LOOP__,
+  &__RTS_FETCH_NUMBERS__,
+  &__RTS_FETCH_NAMES__,
+};
+
+/* chill argc and argv */
+int                    chill_argc = 0;
+TVaryingCharType       **chill_argv = NULL;
+
+/* the program name for debugging purpose */
+char                   *progname = 0;
+\f
+extern void *__xmalloc_ ();
+
+/*
+ * function __xrealloc_
+ *
+ * parameter:
+ *   ptr               pointer to reallocate
+ *   size              new number of bytes
+ *
+ * returns:
+ *  void*
+ *
+ * abstract:
+ *  This is the general reallocation routine for libchill
+ *
+ */
+
+void *
+__xrealloc_ (ptr, size)
+void *ptr;
+int size;
+{
+  void *tmp = realloc (ptr, size);
+  
+  if (!tmp)
+    {
+      fprintf (stderr, "ChillLib: Out of heap space.\n");
+      fflush (stderr);
+      exit (ENOMEM);
+    }
+  return (tmp);
+} /* __xrealloc_ */
+\f
+static void
+setup_argc_argv (argc, argv)
+int argc;
+char *argv[];
+{
+  int          i;
+  
+  chill_argv = __xmalloc_ ((argc + 1) * sizeof (TVaryingCharType *));
+  for (i = 0; i < argc; i++)
+    {
+      chill_argv[i] = __xmalloc_ (sizeof (TVaryingCharType) + strlen (argv[i]) + 1);
+      chill_argv[i]->len = strlen (argv[i]);
+      strcpy (chill_argv[i]->body, argv[i]);
+    }
+  chill_argv[chill_argc = argc] = NULL;
+  
+  if ((progname = strrchr (argv[0], '/')) == 0)
+    progname = argv[0];
+  else
+    progname++;
+  
+} /* setup_argc_argv */
+
+extern void __setexceptionStack ();
+
+/*--------- main entry for each CHILL - program ----------*/
+int
+main (argc, argv)
+     int argc;
+     char *argv [];
+{
+  /* call look up for tasking */
+  (*__RTS_INIT__) (&argc, argv);
+
+  /* setup argc and argv */
+  setup_argc_argv (argc, argv);
+
+  /* clear exception stack */
+  __setexceptionStack (0);
+
+  /* now call code at module level */
+  while (_ch_init_list)
+    {
+      if (_ch_init_list->code)
+       (*(_ch_init_list->code)) ();
+      _ch_init_list = _ch_init_list->forward;
+    }
+
+  /* if we have rts linked, something will be done, else just return */
+  (*__RTS_MAIN_LOOP__) ();
+  
+  return (0);
+  
+} /* main */
diff --git a/libchill/chillstdio.c b/libchill/chillstdio.c
new file mode 100644 (file)
index 0000000..a7e2a7b
--- /dev/null
@@ -0,0 +1,210 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#include "iomodes.h"
+
+/* predefined associations, accesses, and text for stdin, stdout, stderr */
+/* stdin */
+#define STDIO_TEXT_LENGTH 1024
+#define STDIN_TEXT_LENGTH STDIO_TEXT_LENGTH
+
+static Access_Mode stdin_access;
+
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+
+static
+Association_Mode stdin_association =
+{
+  IO_EXISTING | IO_READABLE | IO_SEQUENCIBLE | IO_ISASSOCIATED,
+  NULL,
+  &stdin_access,
+  STDIN_FILENO,
+  NULL,
+  0,
+  ReadOnly
+};
+
+static Access_Mode stdin_access = 
+{
+  IO_TEXTIO,
+  STDIN_TEXT_LENGTH + 2,
+  0,
+  0,
+  &stdin_association,
+  0,
+  NULL,
+  VaryingChars
+};
+
+static
+VARYING_STRING(STDIN_TEXT_LENGTH) stdin_text_record;
+
+Text_Mode chill_stdin =
+{
+  IO_TEXTLOCATION,
+  (VarString *)&stdin_text_record,
+  &stdin_access,
+  0
+};
+
+/* stdout */
+#define STDOUT_TEXT_LENGTH STDIO_TEXT_LENGTH
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+static Access_Mode stdout_access;
+
+static
+Association_Mode stdout_association =
+{
+  IO_EXISTING | IO_WRITEABLE | IO_SEQUENCIBLE | IO_ISASSOCIATED,
+  NULL,
+  &stdout_access,
+  STDOUT_FILENO,
+  NULL,
+  0,
+  WriteOnly
+};
+
+static Access_Mode stdout_access = 
+{
+  IO_TEXTIO,
+  STDOUT_TEXT_LENGTH + 2,
+  0,
+  0,
+  &stdout_association,
+  0,
+  NULL,
+  VaryingChars
+};
+
+static
+VARYING_STRING(STDOUT_TEXT_LENGTH) stdout_text_record;
+
+Text_Mode chill_stdout =
+{
+  IO_TEXTLOCATION,
+  (VarString *)&stdout_text_record,
+  &stdout_access,
+  0
+};
+
+/* stderr */
+#define STDERR_TEXT_LENGTH STDIO_TEXT_LENGTH
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+
+static Access_Mode stderr_access;
+
+static
+Association_Mode stderr_association =
+{
+  IO_EXISTING | IO_WRITEABLE | IO_SEQUENCIBLE | IO_ISASSOCIATED,
+  NULL,
+  &stderr_access,
+  STDERR_FILENO,
+  NULL,
+  0,
+  WriteOnly
+};
+
+static Access_Mode stderr_access = 
+{
+  IO_TEXTIO,
+  STDERR_TEXT_LENGTH + 2,
+  0,
+  0,
+  &stderr_association,
+  0,
+  NULL,
+  VaryingChars
+};
+
+static
+VARYING_STRING(STDIN_TEXT_LENGTH) stderr_text_record;
+
+Text_Mode chill_stderr =
+{
+  IO_TEXTLOCATION,
+  (VarString *)&stderr_text_record,
+  &stderr_access,
+  0
+};
+
+/*
+ * function __xmalloc_
+ *
+ * parameter:
+ *   size              number of bytes to allocate
+ *
+ * returns:
+ *  void*
+ *
+ * abstract:
+ *  This is the general allocation routine for libchill
+ *
+ */
+
+void *
+__xmalloc_ (size)
+int size;
+{
+  void *tmp = malloc (size);
+  
+  if (!tmp)
+    {
+      fprintf (stderr, "ChillLib: Out of heap space.\n");
+      fflush (stderr);
+      exit (ENOMEM);
+    }
+  return (tmp);
+} /* __xmalloc_ */
+
+static char *
+newstring (char *str)
+{
+  char *tmp = __xmalloc_ (strlen (str) + 1);
+  strcpy (tmp, str);
+  return tmp;
+}
+
+static void setup_stdinout (void) __attribute__((constructor));
+
+static void
+setup_stdinout ()
+{
+  /* allocate the names */
+  stdin_association.pathname = newstring ("stdin");
+  stdout_association.pathname = newstring ("stdout");
+  stderr_association.pathname = newstring ("stderr");
+
+  /* stdin needs a readbuffer */
+  stdin_association.bufptr = __xmalloc_ (sizeof (readbuf_t));
+  memset (stdin_association.bufptr, 0, sizeof (readbuf_t));
+}
diff --git a/libchill/concatps.c b/libchill/concatps.c
new file mode 100644 (file)
index 0000000..4dacda6
--- /dev/null
@@ -0,0 +1,93 @@
+/* Implement powerset-related runtime actions for CHILL.
+   Copyright (C) 1992, 93, 1994 Free Software Foundation, Inc.
+   Author: Bill Cox
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "powerset.h"
+
+extern void cause_exception (char *exname, char *file, int lineno);
+
+/*
+ * function __concatps
+ *
+ * parameters:
+ *     OUT      - pointer to output PS
+ *     LEFT     - pointer to left PS
+ *     LEFTLEN  - length of left PS in bits
+ *     RIGHT    - pointer to right PS
+ *     RIGHTLEN - length of right PS in bits
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     concatenates two powersets into the output powerset.
+ *
+ */
+
+extern void
+__pscpy (SET_WORD      *dps,
+        unsigned long  dbl,
+        unsigned long  doffset,
+        SET_WORD      *sps,
+        unsigned long  sbl,
+        unsigned long  start,
+        unsigned long  length);
+
+void
+__concatps (out, left, leftlen, right, rightlen)
+     SET_WORD      *out;
+     SET_WORD      *left;
+     unsigned long  leftlen;
+     SET_WORD      *right;
+     unsigned long  rightlen;
+{
+  /* allocated sizes for each set involved */
+  unsigned long outall, leftall, rightall;
+
+  if (!out)
+    {
+      /* FIXME: cause an exception */
+    }
+  else if (leftlen == 0 || !left)
+    {
+      if (rightlen == 0 || !right)
+       return;               /* no work to do */
+      __pscpy (out, rightlen, (unsigned long)0,
+              right, rightlen, (unsigned long)0, rightlen);
+    }
+  else if (rightlen == 0 || !right)
+    {
+      if (leftlen == 0 || !left)
+       return;               /* no work to do */
+      __pscpy (out, leftlen, (unsigned long)0,
+              left, leftlen, (unsigned long)0, leftlen);
+    }
+  /* copy the left powerset into bits 0..leftlen - 1 */
+  __pscpy (out, leftlen + rightlen, (unsigned long)0,
+          left, leftlen, (unsigned long)0, leftlen);
+
+  /* copy the right powerset into bits leftlen..leftlen+rightlen-1 */
+  __pscpy (out, leftlen + rightlen, leftlen,
+          right, rightlen, (unsigned long)0, rightlen);
+}
diff --git a/libchill/concatstr.c b/libchill/concatstr.c
new file mode 100644 (file)
index 0000000..e4105d6
--- /dev/null
@@ -0,0 +1,69 @@
+/* Implement string-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Bill Cox
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define MIN(a, b)  ((a) < (b) ? (a) : (b))
+
+extern void cause_exception (char *exname, char *file, int lineno);
+
+/*
+ * function __concatstring 
+ *
+ * parameters:
+ *     OUT  - pointer to output string
+ *     S1   - pointer to left string
+ *     LEN1 - length of left string
+ *     S2   - pointer to right string
+ *     LEN2 - length of right string
+ *
+ * returns:
+ *     pointer to OUT string
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     concatenates two character strings into the output string
+ *
+ */
+
+char *
+__concatstring (out, s1, len1, s2, len2)
+     char *out, *s1;
+     int   len1;
+     char *s2;
+     int   len2;
+{
+  if (out)
+    {
+      if (s2 /* Check for overlap between s2 and out. */
+         && ((s2 >= out && s2 < (out + len1 + len2))
+             || (s2 + len2 > out && s2 <= out + len1)))
+       {
+         char *tmp = alloca (len2);
+         memcpy (tmp, s2, len2);
+         s2 = tmp;
+       }
+      if (s1)
+       memmove (out, s1, len1);
+      if (s2)
+       memcpy (&out[len1], s2, len2);
+    }
+  return out;
+}
diff --git a/libchill/configure b/libchill/configure
new file mode 100755 (executable)
index 0000000..c486b4a
--- /dev/null
@@ -0,0 +1,1474 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.12.1 
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval "$ac_prev=\$ac_option"
+    ac_prev=
+    continue
+  fi
+
+  case "$ac_option" in
+  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) ac_optarg= ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case "$ac_option" in
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir="$ac_optarg" ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build="$ac_optarg" ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file="$ac_optarg" ;;
+
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir="$ac_optarg" ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    eval "enable_${ac_feature}=no" ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix="$ac_optarg" ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he)
+    # Omit some internal or obsolete options to make the list less imposing.
+    # This message is too long to be a string in the A/UX 3.1 sh.
+    cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+  --cache-file=FILE       cache test results in FILE
+  --help                  print this message
+  --no-create             do not create output files
+  --quiet, --silent       do not print \`checking...' messages
+  --version               print the version of autoconf that created configure
+Directory and file names:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [same as prefix]
+  --bindir=DIR            user executables in DIR [EPREFIX/bin]
+  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
+  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
+  --datadir=DIR           read-only architecture-independent data in DIR
+                          [PREFIX/share]
+  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
+                          [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
+  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
+  --includedir=DIR        C header files in DIR [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
+  --infodir=DIR           info documentation in DIR [PREFIX/info]
+  --mandir=DIR            man documentation in DIR [PREFIX/man]
+  --srcdir=DIR            find the sources in DIR [configure dir or ..]
+  --program-prefix=PREFIX prepend PREFIX to installed program names
+  --program-suffix=SUFFIX append SUFFIX to installed program names
+  --program-transform-name=PROGRAM
+                          run sed PROGRAM on installed program names
+EOF
+    cat << EOF
+Host type:
+  --build=BUILD           configure for building on BUILD [BUILD=HOST]
+  --host=HOST             configure for HOST [guessed]
+  --target=TARGET         configure for TARGET [TARGET=HOST]
+Features and packages:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --x-includes=DIR        X include files are in DIR
+  --x-libraries=DIR       X library files are in DIR
+EOF
+    if test -n "$ac_help"; then
+      echo "--enable and --with options recognized:$ac_help"
+    fi
+    exit 0 ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host="$ac_optarg" ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir="$ac_optarg" ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir="$ac_optarg" ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir="$ac_optarg" ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir="$ac_optarg" ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir="$ac_optarg" ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir="$ac_optarg" ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir="$ac_optarg" ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix="$ac_optarg" ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix="$ac_optarg" ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix="$ac_optarg" ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name="$ac_optarg" ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir="$ac_optarg" ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir="$ac_optarg" ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site="$ac_optarg" ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir="$ac_optarg" ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir="$ac_optarg" ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target="$ac_optarg" ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers)
+    echo "configure generated by autoconf version 2.12.1"
+    exit 0 ;;
+
+  -with-* | --with-*)
+    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "with_${ac_package}='$ac_optarg'" ;;
+
+  -without-* | --without-*)
+    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    eval "with_${ac_package}=no" ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes="$ac_optarg" ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries="$ac_optarg" ;;
+
+  -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+    ;;
+
+  *)
+    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+      echo "configure: warning: $ac_option: invalid host type" 1>&2
+    fi
+    if test "x$nonopt" != xNONE; then
+      { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+    fi
+    nonopt="$ac_option"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+  exec 6>/dev/null
+else
+  exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+  case "$ac_arg" in
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c) ;;
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+  *" "*|*"     "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+  *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+  esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set.  These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=chillrt0.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then its parent.
+  ac_prog=$0
+  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  srcdir=$ac_confdir
+  if test ! -r $srcdir/$ac_unique_file; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+  if test "$ac_srcdir_defaulted" = yes; then
+    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+  else
+    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+  fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+  if test "x$prefix" != xNONE; then
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+  else
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+  fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+  if test -r "$ac_site_file"; then
+    echo "loading site script $ac_site_file"
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  echo "loading cache $cache_file"
+  . $cache_file
+else
+  echo "creating cache $cache_file"
+  > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+    ac_n= ac_c='
+' ac_t='       '
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+if  "${srcdir}" = "."  ; then
+  if  "${with_target_subdir}" != "."  ; then
+    topsrcdir=${with_multisrctop}../..
+  else
+    topsrcdir=${with_multisrctop}..
+  fi
+else
+  topsrcdir=${srcdir}/..
+fi
+
+# For chill we'll set CC to point at the built gcc, but this will get it into
+# the makefiles
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:539: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="gcc"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:568: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  ac_prog_rejected=no
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+        ac_prog_rejected=yes
+       continue
+      fi
+      ac_cv_prog_CC="cc"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# -gt 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    set dummy "$ac_dir/$ac_word" "$@"
+    shift
+    ac_cv_prog_CC="$@"
+  fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:616: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext <<EOF
+#line 626 "configure"
+#include "confdefs.h"
+main(){return(0);}
+EOF
+if { (eval echo configure:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  ac_cv_prog_cc_works=yes
+  # If we can't run a trivial program, we are probably using a cross compiler.
+  if (./conftest; exit) 2>/dev/null; then
+    ac_cv_prog_cc_cross=no
+  else
+    ac_cv_prog_cc_cross=yes
+  fi
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+  { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:650: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:655: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.c <<EOF
+#ifdef __GNUC__
+  yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:664: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+  ac_cv_prog_gcc=yes
+else
+  ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+  GCC=yes
+  ac_test_CFLAGS="${CFLAGS+set}"
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS=
+  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:679: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+  ac_cv_prog_cc_g=yes
+else
+  ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+  if test "$ac_test_CFLAGS" = set; then
+    CFLAGS="$ac_save_CFLAGS"
+  elif test $ac_cv_prog_cc_g = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-O2"
+  fi
+else
+  GCC=
+  test "${CFLAGS+set}" = set || CFLAGS="-g"
+fi
+
+
+test "$AR" || AR=ar
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:710: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftestmake <<\EOF
+all:
+       @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+  eval ac_cv_prog_make_${ac_make}_set=yes
+else
+  eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  SET_MAKE=
+else
+  echo "$ac_t""no" 1>&6
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+
+# Sanity check for the cross-compilation case:
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:740: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+    # This must be in double quotes, not single quotes, because CPP may get
+  # substituted into the Makefile and "${CC-cc}" will confuse make.
+  CPP="${CC-cc} -E"
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp.
+  cat > conftest.$ac_ext <<EOF
+#line 755 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:761: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -E -traditional-cpp"
+  cat > conftest.$ac_ext <<EOF
+#line 772 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:778: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+  ac_cv_prog_CPP="$CPP"
+fi
+  CPP="$ac_cv_prog_CPP"
+else
+  ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+ac_safe=`echo "stdio.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for stdio.h""... $ac_c" 1>&6
+echo "configure:802: checking for stdio.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 807 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:812: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  :
+else
+  echo "$ac_t""no" 1>&6
+{ echo "configure: error: Can't find stdio.h.
+You must have a usable C system for the target already installed, at least
+including headers and, preferably, the library, before you can configure
+the Chill runtime system.  If necessary, install gcc now with \`LANGUAGES=c',
+then the target library, then build with \`LANGUAGES=chill'." 1>&2; exit 1; }
+fi
+
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:840: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 845 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  ac_cv_header_stdc=yes
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 870 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "memchr" >/dev/null 2>&1; then
+  :
+else
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 888 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "free" >/dev/null 2>&1; then
+  :
+else
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+  :
+else
+  cat > conftest.$ac_ext <<EOF
+#line 909 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+  :
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+  cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+
+echo $ac_n "checking for posix""... $ac_c" 1>&6
+echo "configure:945: checking for posix" >&5
+if eval "test \"`echo '$''{'chill_cv_header_posix'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 950 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <unistd.h>
+#ifdef _POSIX_VERSION
+  yes
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "yes" >/dev/null 2>&1; then
+  rm -rf conftest*
+  chill_cv_header_posix=yes
+else
+  rm -rf conftest*
+  chill_cv_header_posix=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$chill_cv_header_posix" 1>&6
+
+# We can rely on the GNU library being posix-ish.  I guess checking the 
+# header isn't actually like checking the functions, though...
+echo $ac_n "checking for GNU library""... $ac_c" 1>&6
+echo "configure:976: checking for GNU library" >&5
+if eval "test \"`echo '$''{'chill_cv_lib_gnu'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 981 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+#ifdef __GNU_LIBRARY__
+  yes
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "yes" >/dev/null 2>&1; then
+  rm -rf conftest*
+  chill_cv_lib_gnu=yes
+else
+  rm -rf conftest*
+  chill_cv_lib_gnu=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$chill_cv_lib_gnu" 1>&6
+
+echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
+echo "configure:1004: checking return type of signal handlers" >&5
+if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1009 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+#ifdef __cplusplus
+extern "C" void (*signal (int, void (*)(int)))(int);
+#else
+void (*signal ()) ();
+#endif
+
+int main() {
+int i;
+; return 0; }
+EOF
+if { (eval echo configure:1026: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_type_signal=void
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_type_signal=int
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_type_signal" 1>&6
+cat >> confdefs.h <<EOF
+#define RETSIGTYPE $ac_cv_type_signal
+EOF
+
+
+# we'll get atexit by default
+if test $ac_cv_header_stdc != yes; then
+echo $ac_n "checking for atexit""... $ac_c" 1>&6
+echo "configure:1047: checking for atexit" >&5
+if eval "test \"`echo '$''{'ac_cv_func_atexit'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1052 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char atexit(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char atexit();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_atexit) || defined (__stub___atexit)
+choke me
+#else
+atexit();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_func_atexit=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_atexit=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'atexit`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<\EOF
+#define onexit atexit
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+  cat >> confdefs.h <<\EOF
+#define NO_ONEXIT 1
+EOF
+
+  echo $ac_n "checking for onexit""... $ac_c" 1>&6
+echo "configure:1100: checking for onexit" >&5
+if eval "test \"`echo '$''{'ac_cv_func_onexit'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1105 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char onexit(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char onexit();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_onexit) || defined (__stub___onexit)
+choke me
+#else
+onexit();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1128: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_func_onexit=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_onexit=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'onexit`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  :
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for on_exit""... $ac_c" 1>&6
+echo "configure:1146: checking for on_exit" >&5
+if eval "test \"`echo '$''{'ac_cv_func_on_exit'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1151 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char on_exit(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char on_exit();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_on_exit) || defined (__stub___on_exit)
+choke me
+#else
+on_exit();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1174: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_func_on_exit=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_on_exit=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'on_exit`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<\EOF
+#define onexit on_exit
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+fi
+
+else true
+fi
+
+# We need multilib support, but only if configuring for the target.
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs.  It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already.  You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+  case `(ac_space=' '; set) 2>&1 | grep ac_space` in
+  *ac_space=\ *)
+    # `set' does not quote correctly, so add quotes (double-quote substitution
+    # turns \\\\ into \\, and sed turns \\ into \).
+    sed -n \
+      -e "s/'/'\\\\''/g" \
+      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+    ;;
+  *)
+    # `set' quotes correctly as required by POSIX, so do not add quotes.
+    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+    ;;
+  esac >> confcache
+if cmp -s $cache_file confcache; then
+  :
+else
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[        ]*VPATH[        ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+cat > conftest.defs <<\EOF
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
+s%[    `~#$^&*(){}\\|;'"<>?]%\\&%g
+s%\[%\\&%g
+s%\]%\\&%g
+s%\$%$$%g
+EOF
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+rm -f conftest.defs
+
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+  case "\$ac_option" in
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+    exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+    echo "$CONFIG_STATUS generated by autoconf version 2.12.1"
+    exit 0 ;;
+  -help | --help | --hel | --he | --h)
+    echo "\$ac_cs_usage"; exit 0 ;;
+  *) echo "\$ac_cs_usage"; exit 1 ;;
+  esac
+done
+
+ac_given_srcdir=$srcdir
+
+trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@CC@%$CC%g
+s%@AR@%$AR%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@CPP@%$CPP%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+  if test $ac_beg -gt 1; then
+    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+  else
+    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+  fi
+  if test ! -s conftest.s$ac_file; then
+    ac_more_lines=false
+    rm -f conftest.s$ac_file
+  else
+    if test -z "$ac_sed_cmds"; then
+      ac_sed_cmds="sed -f conftest.s$ac_file"
+    else
+      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+    fi
+    ac_file=`expr $ac_file + 1`
+    ac_beg=$ac_end
+    ac_end=`expr $ac_end + $ac_max_sed_cmds`
+  fi
+done
+if test -z "$ac_sed_cmds"; then
+  ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case "$ac_file" in
+  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+  *) ac_file_in="${ac_file}.in" ;;
+  esac
+
+  # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+  # Remove last slash and all that follows it.  Not all systems have dirname.
+  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+    # The file is in a subdirectory.
+    test ! -d "$ac_dir" && mkdir "$ac_dir"
+    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+    # A "../" for each directory in $ac_dir_suffix.
+    ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+  else
+    ac_dir_suffix= ac_dots=
+  fi
+
+  case "$ac_given_srcdir" in
+  .)  srcdir=.
+      if test -z "$ac_dots"; then top_srcdir=.
+      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+  *) # Relative path.
+    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+    top_srcdir="$ac_dots$ac_given_srcdir" ;;
+  esac
+
+
+  echo creating "$ac_file"
+  rm -f "$ac_file"
+  configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+  case "$ac_file" in
+  *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+  *) ac_comsub= ;;
+  esac
+
+  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+  sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+srcdir=${srcdir}
+host=${host}
+target=${target}
+with_target_subdir=${with_target_subdir}
+with_multisubdir=${with_multisubdir}
+ac_configure_args="--enable-multilib ${ac_configure_args}"
+CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+topsrcdir=${topsrcdir}
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+if test -n "$CONFIG_FILES"; then
+  if test -n "${with_target_subdir}"; then
+    # FIXME: We shouldn't need to set ac_file
+    ac_file=Makefile
+    . ${topsrcdir}/config-ml.in
+  fi
+fi
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
+
+
+
diff --git a/libchill/configure.in b/libchill/configure.in
new file mode 100644 (file)
index 0000000..e4d2cb5
--- /dev/null
@@ -0,0 +1,121 @@
+# Process this file with autoconf to produce a configure script.
+#   Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+#   Contributed by Dave Love (d.love@dl.ac.uk).
+#
+#This file is part of GNU CC.
+#
+#GNU Fortran is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 2, or (at your option)
+#any later version.
+#
+#GNU Fortran is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#along with GNU Fortran; see the file COPYING.  If not, write to
+#the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+#02111-1307, USA.
+
+AC_INIT(chillrt0.c)
+
+if [ "${srcdir}" = "." ] ; then
+  if [ "${with_target_subdir}" != "." ] ; then
+    topsrcdir=${with_multisrctop}../..
+  else
+    topsrcdir=${with_multisrctop}..
+  fi
+else
+  topsrcdir=${srcdir}/..
+fi
+
+dnl Checks for programs.
+# For chill we'll set CC to point at the built gcc, but this will get it into
+# the makefiles
+AC_PROG_CC
+
+test "$AR" || AR=ar
+AC_SUBST(AR)
+AC_PROG_MAKE_SET
+
+dnl Checks for libraries.
+
+dnl Checks for header files.
+# Sanity check for the cross-compilation case:
+AC_CHECK_HEADER(stdio.h,:,
+  [AC_MSG_ERROR([Can't find stdio.h.
+You must have a usable C system for the target already installed, at least
+including headers and, preferably, the library, before you can configure
+the Chill runtime system.  If necessary, install gcc now with \`LANGUAGES=c',
+then the target library, then build with \`LANGUAGES=chill'.])])
+
+AC_HEADER_STDC
+
+AC_MSG_CHECKING(for posix)
+AC_CACHE_VAL(chill_cv_header_posix,
+  AC_EGREP_CPP(yes,
+  [#include <sys/types.h>
+#include <unistd.h>
+#ifdef _POSIX_VERSION
+  yes
+#endif
+], 
+  chill_cv_header_posix=yes,
+  chill_cv_header_posix=no))
+AC_MSG_RESULT($chill_cv_header_posix)
+
+# We can rely on the GNU library being posix-ish.  I guess checking the 
+# header isn't actually like checking the functions, though...
+AC_MSG_CHECKING(for GNU library)
+AC_CACHE_VAL(chill_cv_lib_gnu,
+  AC_EGREP_CPP(yes,
+    [#include <stdio.h>
+#ifdef __GNU_LIBRARY__
+  yes
+#endif
+], 
+  chill_cv_lib_gnu=yes, chill_cv_lib_gnu=no))
+AC_MSG_RESULT($chill_cv_lib_gnu)
+
+dnl Checks for library functions.
+AC_TYPE_SIGNAL
+# we'll get atexit by default
+if test $ac_cv_header_stdc != yes; then
+AC_CHECK_FUNC(atexit,
+  AC_DEFINE(onexit,atexit),dnl just in case
+  [AC_DEFINE(NO_ONEXIT)
+  AC_CHECK_FUNC(onexit,,
+    [AC_CHECK_FUNC(on_exit,
+     AC_DEFINE(onexit,on_exit),)])])
+else true
+fi
+
+# We need multilib support, but only if configuring for the target.
+AC_OUTPUT(Makefile,
+[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
+if test -n "$CONFIG_FILES"; then
+  if test -n "${with_target_subdir}"; then
+    # FIXME: We shouldn't need to set ac_file
+    ac_file=Makefile
+    . ${topsrcdir}/config-ml.in
+  fi
+fi],
+srcdir=${srcdir}
+host=${host}
+target=${target}
+with_target_subdir=${with_target_subdir}
+with_multisubdir=${with_multisubdir}
+ac_configure_args="--enable-multilib ${ac_configure_args}"
+CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+topsrcdir=${topsrcdir}
+)
+
+
+
+dnl Local Variables:
+dnl comment-start: "dnl "
+dnl comment-end: ""
+dnl comment-start-skip: "\\bdnl\\b\\s *"
+dnl End:
diff --git a/libchill/continue.c b/libchill/continue.c
new file mode 100644 (file)
index 0000000..76d457d
--- /dev/null
@@ -0,0 +1,83 @@
+/* Implement tasking-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rtltypes.h"
+#include "rts.h"
+
+/*
+ * function __continue
+ *
+ * parameters:
+ *     evaddr     pointer to Eventlocation
+ *     filename   source file name where function gets called
+ *     lineno     linenumber in source file
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     implement the CHILL CONTINUE action.
+ */
+
+void
+__continue (evaddr, filename, lineno)
+     Event_Queue   **evaddr;
+     char           *filename;
+     int             lineno;
+{
+  Event_Queue  *ev = *evaddr;
+  Event_Queue  *wrk;
+
+  if (ev == 0)
+    /* nothing to do */
+    return;
+
+  /* search for 1st one is not already continued */
+  while (ev && ev->is_continued)
+    ev = ev->forward;
+  if (!ev)
+    /* all have been continued in that queue, do nothing */
+    return;
+
+  wrk = ev->startlist;
+  while (wrk)
+    {
+      Event_Queue     *tmp = (Event_Queue *)wrk->listhead;
+      
+      while (tmp->forward != wrk)
+       tmp = tmp->forward;
+      tmp->forward = wrk->forward;
+      wrk = wrk->chain;
+    }
+
+  /* so far so good, continue this one */
+  ev->is_continued = 1;
+  ev->who_continued = THIS;
+
+  /* tell the runtime system to activate the process */
+  __continue_that (ev->this, ev->priority, filename, lineno);
+}
+
+/* force function print_event to be linked */
+extern void __print_event ();
+static EntryPoint pev = __print_event;
diff --git a/libchill/convdurrtstime.c b/libchill/convdurrtstime.c
new file mode 100644 (file)
index 0000000..f56fc3a
--- /dev/null
@@ -0,0 +1,52 @@
+/* Implement timing-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rts.h"
+
+/*
+ * function __convert_duration_rtstime
+ *
+ * parameters:
+ *      dur     the duration value
+ *      t       pointer to the duration value converted to RtsTime
+ *
+ * returns:
+ *      void
+ *
+ * exceptions:
+ *      none
+ *
+ * abstract:
+ *      converts a duration value (unsigned long in millisecs) to RtsTime
+ *      format.
+ *
+ */
+
+void
+__convert_duration_rtstime (dur, t)
+     unsigned long  dur;
+     RtsTime       *t;
+{
+  unsigned long tmp;
+    
+  t->secs = dur / 1000;
+  tmp = dur - (t->secs * 1000);
+  t->nanosecs = tmp * 1000000;
+}
diff --git a/libchill/copyps.c b/libchill/copyps.c
new file mode 100644 (file)
index 0000000..226f429
--- /dev/null
@@ -0,0 +1,111 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __powerset_copy
+ *    This is more general than __psslice, since it
+ *    can be told where in the destination powerset (DOFFSET
+ *    parameter) to start storing the slice.
+ *
+ * parameters:
+ *      dps             dest powerset
+ *      dbl             destination bit length
+ *      doffset         offset bit number (zero origin)
+ *     sps             sourcepowerset
+ *     sbl             source powerset length in bits
+ *      start           starting bit number
+ *      end             ending bit number
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  Extract into a powerset a slice of another powerset.
+ *
+ */
+void
+__pscpy (dps, dbl, doffset, sps, sbl, start, length)
+     SET_WORD      *dps;
+     unsigned long  dbl;
+     unsigned long  doffset;
+     const SET_WORD*sps;
+     unsigned long  sbl;
+     unsigned long  start;
+     unsigned long  length;
+{
+  unsigned long end = start + length - 1;
+  unsigned long src, dst;
+
+  /* assert end >= start;
+     assert end - start + 1 <= dbl;
+     assert "the sets don't overlap in memory" */
+
+  /* assert doffset >= 0 and < dbl */
+
+  for (src = start, dst = doffset; src <= end; src++, dst++)
+    {
+      char tmp;
+
+      if (sbl <= SET_CHAR_SIZE)                /* fetch a bit */
+       tmp = GET_BIT_IN_CHAR (*((SET_CHAR *)sps), src);
+      else if (sbl <= SET_SHORT_SIZE)
+       tmp = GET_BIT_IN_SHORT (*((SET_SHORT *)sps), src);
+      else
+       tmp = GET_BIT_IN_WORD (sps[src / SET_WORD_SIZE], src % SET_WORD_SIZE);
+
+      if (tmp & 1)
+       {
+         if (dbl <= SET_CHAR_SIZE)            /* store a 1-bit */
+           SET_BIT_IN_CHAR (*((SET_CHAR *)dps), dst);
+         else if (dbl <= SET_SHORT_SIZE)
+           SET_BIT_IN_SHORT (*((SET_SHORT *)dps), dst);
+         else
+           SET_BIT_IN_WORD (dps[dst / SET_WORD_SIZE], dst % SET_WORD_SIZE);
+       }
+      else
+       {
+         if (dbl <= SET_CHAR_SIZE)            /* store a 0-bit */
+           CLEAR_BIT_IN_CHAR (*((SET_CHAR *)dps), dst);
+         else if (dbl <= SET_SHORT_SIZE)
+           CLEAR_BIT_IN_SHORT (*((SET_SHORT *)dps), dst);
+         else
+           CLEAR_BIT_IN_WORD (dps[dst / SET_WORD_SIZE], dst % SET_WORD_SIZE);
+       }
+    }
+  if (dbl <= SET_CHAR_SIZE)         /* clear unused bits in output bitstring */
+    {
+      MASK_UNUSED_CHAR_BITS ((SET_CHAR *)dps, dbl);
+    }
+  else if (dbl <= SET_SHORT_SIZE)
+    {
+      MASK_UNUSED_SHORT_BITS ((SET_SHORT *)dps, dbl);
+    }
+  else
+    {
+      MASK_UNUSED_WORD_BITS ((SET_WORD *)(dps + (dbl/SET_WORD_SIZE)), 
+                            dbl % SET_WORD_SIZE);
+    }
+}
diff --git a/libchill/delaycase.c b/libchill/delaycase.c
new file mode 100644 (file)
index 0000000..22db534
--- /dev/null
@@ -0,0 +1,220 @@
+/* Implement tasking-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rtltypes.h"
+#include "rts.h"
+
+extern void __cause_ex1 (char *ex, char *file, int lineno);
+
+EXCEPTION (delayfail);
+#define CAUSE_DELAYFAIL     __cause_ex1 ("delayfail", filename, lineno)
+
+EXCEPTION (notyetimplemented);
+#define CAUSE_NOTIMPLEMENTED   __cause_ex1 ("notyetimplemeyed", filename, lineno)
+
+/*
+ * function __delay_event
+ *
+ * parameters:
+ *     ev_got      pointer to location where to write the event got.
+ *     nevents     number of events in list
+ *     evptrs      array of event descriptors
+ *     priority    specified priority
+ *     insloc      pointer to resulting instance location
+ *     to          timeout value
+ *     filename    filename of caller
+ *     lineno      linenumber of caller
+ *
+ * returns:
+ *     int         0 .. success
+ *                 1 .. timed out
+ *
+ * exceptions:
+ *     delayfail
+ *
+ * abstract:
+ *     implement the CHILL DELAY and DELAY CASE actions.
+ *
+ */
+
+int
+__delay_event (ev_got, nevents, evptrs, priority, to, insloc, filename, lineno)
+     void         **ev_got;
+     int            nevents;
+     Event_Descr   *evptrs;
+     int            priority;
+     void          *to;
+     INSTANCE      *insloc;
+     char          *filename;
+     int            lineno;
+{
+  int             i, already_done = 0;
+  Event_Queue    *start_list = 0;
+  Event_Queue   **retval = 0;
+  Event_Queue    *wrk;
+  int            timed_out = 0;
+  
+  /* check if all specified event queues have enough space left
+     to perform the delay */
+  for (i = 0; i < nevents; i++)
+    {
+      Event_Queue  *e;
+      unsigned long cnt = 0;
+      int j, have_done = 0;
+
+      if (evptrs[i].maxqueuelength == 0)
+       CAUSE_DELAYFAIL;
+      else if (evptrs[i].maxqueuelength == (unsigned long)-1L)
+       /* infinite length */
+       continue;
+
+      /* check if we already have processed this one, that means, this
+         event is mentioned more then once */
+      for (j = 0; j < i; j++)
+        {
+          if (evptrs[i].ev == evptrs[j].ev)
+           {
+              have_done = 1;
+              break;
+           }
+        }
+      if (have_done)
+       continue;
+      
+      memcpy (&e, evptrs[i].ev, sizeof (Event_Queue *));
+      while (e)
+       {
+         cnt++;
+         e = e->forward;
+       }
+      if (cnt >= evptrs[i].maxqueuelength)
+       CAUSE_DELAYFAIL;
+    }
+
+  for (i = 0; i < nevents; i++)
+    {
+      /* queue that stuff on each event */
+      Event_Queue      *wrk;
+      Event_Queue      *ev;
+      Event_Queue      *prev_queue_entry = 0;
+      Event_Queue      *prev_list_entry;
+      int               j, have_done = 0;
+      
+      /* check for this event already processed */
+      for (j = 0; j < i; j++)
+       {
+          if (evptrs[i].ev == evptrs[j].ev)
+           {
+              have_done = 1;
+              break;
+           }
+       }
+      if (have_done)
+       continue;
+
+      memcpy (&ev, &evptrs[i].ev, sizeof (Event_Queue *));
+      MALLOC (wrk, sizeof (Event_Queue));
+      memset (wrk, 0, sizeof (Event_Queue));
+
+      wrk->priority = priority;
+      wrk->this = THIS;
+      wrk->listhead = evptrs[i].ev;
+
+      /* search for the place to queue this entry in */
+      while (ev->forward != 0 && ev->priority >= priority)
+       {
+         prev_queue_entry = ev;
+         ev = ev->forward;
+       }
+
+      /* ready to put entry into queue */
+      if (ev->forward == 0 || prev_queue_entry == 0)
+       {
+         /* beginning or end of the list */
+         wrk->forward = ev->forward;
+         ev->forward = wrk;
+       }
+      else
+       {
+         /* this is somewhere in the middle */
+         wrk->forward = prev_queue_entry->forward;
+         prev_queue_entry->forward = wrk;
+       }
+
+      /* queue it into list */
+      wrk->startlist = start_list;
+      if (! start_list)
+       {
+         /* we are the first in the list */
+         start_list = wrk;
+         prev_list_entry = wrk;
+         wrk->startlist = start_list;
+       }
+      else
+       {
+         prev_list_entry->chain = wrk;
+         prev_list_entry = wrk;
+       }
+    }
+
+  /* tell runtime system to delay that process */
+  timed_out = __delay_this (wait_event_delay, to, filename, lineno);
+  if (timed_out)
+    {
+      /* we have to remove the entries from the queue's */
+      wrk = start_list;
+      while (wrk)
+        {
+         Event_Queue *tmp = (Event_Queue *)wrk->listhead;
+         
+         while (tmp->forward != wrk)
+           tmp = tmp->forward;
+         tmp->forward = wrk->forward;
+         wrk = wrk->chain;
+        }
+    }
+  
+  wrk = start_list;
+  while (wrk)
+    {
+      Event_Queue  *tmp;
+
+      if (wrk->is_continued && ! already_done)
+       {
+         already_done = 1;
+         retval = wrk->listhead;
+         if (insloc && !timed_out)
+           {
+             insloc->ptype = wrk->who_continued.ptype;
+             insloc->pcopy = wrk->who_continued.pcopy;
+           }
+       }
+      tmp = wrk->chain;
+      FREE (wrk);
+      wrk = tmp;
+    }
+  if (!timed_out && ev_got)
+    *ev_got = (void *)retval;
+  return timed_out;
+}
+
+/* force function print_event to be linked */
+extern void __print_event ();
+static EntryPoint pev = __print_event;
diff --git a/libchill/delete.c b/libchill/delete.c
new file mode 100644 (file)
index 0000000..3945a82
--- /dev/null
@@ -0,0 +1,42 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+   
+   This file is part of GNU CC.
+   
+   GNU CC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+   
+   GNU CC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with GNU CC; see the file COPYING.  If not, write to
+   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <unistd.h>
+
+#include "fileio.h"
+
+void __delete( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+
+  if( !TEST_FLAG( the_assoc, IO_ISASSOCIATED ) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+
+  /* forced dissociate */
+  if( the_assoc->access )
+    __disconnect( the_assoc->access, file, line );
+
+  /* delete */
+  if( unlink( the_assoc->pathname ) )
+    CHILLEXCEPTION( file, line, DELETEFAIL, DELETE_FAILS );
+
+  CLR_FLAG( the_assoc, IO_EXISTING );
+}
diff --git a/libchill/diffps.c b/libchill/diffps.c
new file mode 100644 (file)
index 0000000..2e760b0
--- /dev/null
@@ -0,0 +1,74 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __diffpowerset
+ *
+ * parameters:
+ *     out             result of __diffpowerset
+ *     left            powerset
+ *     right           powerset
+ *     bitlength       length of powerset
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  makes a difference of 2 powersets (out = left - right)
+ *
+ */
+void
+__diffpowerset (out, left, right, bitlength)
+     SET_WORD      *out;
+     SET_WORD      *left;
+     SET_WORD      *right;
+     unsigned long  bitlength;
+{
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      *((SET_CHAR *)out) = *((SET_CHAR *)left) & ~
+                           *((SET_CHAR *)right);
+      MASK_UNUSED_CHAR_BITS ((SET_CHAR *)out, bitlength);
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      *((SET_SHORT *)out) = *((SET_SHORT *)left) & ~
+                            *((SET_SHORT *)right);
+      MASK_UNUSED_SHORT_BITS ((SET_SHORT *)out, bitlength);
+    }
+  else
+    {
+      unsigned long len = BITS_TO_WORDS(bitlength);
+      register unsigned long i;
+    
+      for (i = 0; i < len; i++)
+       out[i] = left[i] & ~right[i];
+      MASK_UNUSED_WORD_BITS ((out + len - 1), bitlength % SET_WORD_SIZE);
+    }
+}
diff --git a/libchill/eoln.c b/libchill/eoln.c
new file mode 100644 (file)
index 0000000..60bb0f0
--- /dev/null
@@ -0,0 +1,30 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__eoln( Text_Mode* the_text, char* file, int line )
+{
+  if( !the_text )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_TEXT );
+
+  return the_text->actual_index == the_text->access_sub->reclength - 2;
+}
diff --git a/libchill/eqps.c b/libchill/eqps.c
new file mode 100644 (file)
index 0000000..4ac002d
--- /dev/null
@@ -0,0 +1,88 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __eqpowerset
+ *
+ * parameters:
+ *     left            left powerset
+ *     right           right powerset
+ *     bitlength       length of powerset in bits
+ *
+ * returns:
+ *    1 if powersets are equal, bit for bit
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  compares two powersets for equality
+ *
+ */
+int
+__eqpowerset (left, right, bitlength)
+     SET_WORD *left;
+     SET_WORD *right;
+     unsigned long bitlength;
+{
+#ifndef USE_CHARS
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      SET_CHAR c = *(SET_CHAR *)left ^ *(SET_CHAR *)right;
+      MASK_UNUSED_CHAR_BITS (&c, bitlength);
+      return (c == 0) ? 1 : 0;
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      SET_SHORT c = *(SET_SHORT *)left ^ *(SET_SHORT *)right;
+      MASK_UNUSED_SHORT_BITS (&c, bitlength);
+      return (c == 0) ? 1 : 0;
+    }
+  else if (bitlength <= SET_WORD_SIZE)
+    {
+      SET_WORD c = *(SET_WORD *)left ^ *(SET_WORD *)right;
+      MASK_UNUSED_WORD_BITS (&c, bitlength % SET_WORD_SIZE);
+      return (c == 0) ? 1 : 0;
+    }
+  else
+#endif
+    {
+      SET_WORD c;
+      register unsigned long i;
+      unsigned long len = bitlength / SET_WORD_SIZE;
+
+      for (i = 0; i < len; i++) /* a word-oriented memcmp */
+       if (left[i] != right[i])
+         return 0;
+      /* do the last (possibly partial) word */
+      bitlength %= SET_WORD_SIZE;
+      if (bitlength == 0)
+       return 1;
+      c = left[i] ^ right[i];
+      MASK_UNUSED_WORD_BITS (&c, bitlength);
+      return (c == 0) ? 1 : 0;
+    }
+}
diff --git a/libchill/eqstr.c b/libchill/eqstr.c
new file mode 100644 (file)
index 0000000..0b94665
--- /dev/null
@@ -0,0 +1,54 @@
+/* Implement string-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Bill Cox
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+extern void cause_exception (char *exname, char *file, int lineno);
+
+/*
+ * function __eqstring
+ *
+ * parameters:
+ *     S1 - pointer to left string
+ *     LEN1 - length of left string
+ *     S2 - pointer to right string
+ *     LEN2 - length of right string
+ *
+ * returns:
+ *     1 if strings equal, 0 if not
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     compares two character strings for equality
+ *
+ */
+
+int
+__eqstring (s1, len1, s2, len2)
+     char *s1;
+     int len1;
+     char *s2;
+     int len2;
+{
+  if (len1 != len2)
+    return 0;
+
+  return ! memcmp (s1, s2, len1);
+}
diff --git a/libchill/exh.c b/libchill/exh.c
new file mode 100644 (file)
index 0000000..59f7434
--- /dev/null
@@ -0,0 +1,152 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include <setjmp.h>
+#include "rtltypes.h"
+
+extern void cause_exception (char *exname, char *file, int lineno, int user_arg);
+extern void unhandled_exception (char *exname, char *file, int lineno, int user_arg);
+
+/* An action with a handler:
+       BODY ON (e1, e2): H12; (e3): H3; ELSE HE; END;
+   is translated into:
+
+    struct __ch_handler __tmp;
+    static struct __ch_handler_excepts _H[4] =
+      {
+        { <<e1>>, 1 },
+        { <<e2>>, 1 },
+        { <<e3>>, 2 },
+        { __ch_else_except, 3 },
+      };
+    __ch_link_handler(&__tmp);
+    __tmp.handlers = _H;
+    switch (setmp(&__tmp.jbuf))
+      {        
+      case 0:  BODY; __ch_unlink_handler(&__tmp); break;
+      case 1:  H12; break;
+      case 2:  H3; break;
+      case 3:  HE; break;
+      }
+*/
+
+/* this part contains all neccessary functions to handle exceptions in CHILL */
+
+/* These two trivial function aren't inlines, to allow for
+   more flexibility (e.g. a per-thread exception stack). */
+
+extern void __setexceptionStack (TExceptionHandlerStack *new);
+extern TExceptionHandlerStack * __getexceptionStack (void);
+
+void
+__ch_link_handler (handler)
+     struct __ch_handler *handler;
+{
+  handler->prev = __getexceptionStack ();
+  __setexceptionStack (handler);
+}
+
+ void
+__ch_unlink_handler (handler)
+     struct __ch_handler *handler;
+{
+  __setexceptionStack (handler->prev);
+}
+
+/*
+ * function __cause_exception
+ *
+ * parameters:
+ *  exnum              name string of exception to raise
+ *  file               filename of CAUSE statement
+ *  lineno             linenumber of CAUSE statement
+ *  user_arg           user specified argument
+ *
+ * returns:
+ *  never              leave function with longjmp or abort
+ *
+ * abstract:
+ *  search exceptionstack for last handler of caused exception,
+ *  call userdefined function to signal exception,
+ *  jump to handler with longjmp or call unhandled_exception
+ *
+ */
+
+void
+__cause_exception  (ex, file, lineno, user_arg)
+     char *ex;
+     char *file;
+     int  lineno;
+     int user_arg;
+{
+  register struct __ch_handler *handler = __getexceptionStack();
+
+  /* call user defined cause function */
+  cause_exception (ex, file, lineno, user_arg);
+  
+  for ( ; handler != NULL; handler = handler->prev)
+    {
+      register struct __ch_handled_excepts *list = handler->handlers;
+      for ( ; list->code != 0; list++ )
+       {
+         if (list->ex == __ch_else_except || EX_EQ(list->ex, ex)) /* found */
+           {
+             __setexceptionStack (handler->prev);
+             longjmp(handler->jbuf, list->code);         
+           }
+       }
+    }
+
+  /* no handler found -- call unhandled_exception */
+  unhandled_exception (ex, file, lineno, user_arg);
+  abort ();
+}
+
+/*
+ * function __cause_ex1
+ *
+ * parameters:
+ *  exnum              name string of exception to raise
+ *  file               filename of CAUSE statement
+ *  lineno             linenumber of CAUSE statement
+ *
+ * returns:
+ *  never              leave function with longjmp or abort
+ *
+ * abstract:
+ *  This is the function the compiler generated code calls.
+ *  Search exceptionstack for last handler of caused exception,
+ *  call userdefined function to signal exception,
+ *  jump to handler with longjmp or call unhandled_exception
+ *
+ */
+
+void
+__cause_ex1  (ex, file, lineno)
+     char *ex;
+     char *file;
+     int  lineno;
+{
+  __cause_exception (ex, file, lineno, 0);
+}
diff --git a/libchill/exhstack.c b/libchill/exhstack.c
new file mode 100644 (file)
index 0000000..ed3c514
--- /dev/null
@@ -0,0 +1,40 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <setjmp.h>
+#include "rtltypes.h"
+
+typedef void (*init_ptr) ();
+typedef int * tasking_ptr;
+
+static TExceptionHandlerStack  *__exceptionStack;
+
+TExceptionHandlerStack * __getexceptionStack ()
+{
+  return __exceptionStack;
+}
+
+void __setexceptionStack (TExceptionHandlerStack *new)
+{
+  __exceptionStack = new;
+}
diff --git a/libchill/existing.c b/libchill/existing.c
new file mode 100644 (file)
index 0000000..93d9eb5
--- /dev/null
@@ -0,0 +1,31 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__existing( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+  if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+  return TEST_FLAG(the_assoc, IO_EXISTING ) ? True : False;
+}
diff --git a/libchill/ffsetclrps.c b/libchill/ffsetclrps.c
new file mode 100644 (file)
index 0000000..bb5b965
--- /dev/null
@@ -0,0 +1,102 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __ffsetclrpowerset
+ *
+ * parameters:
+ *     ps              powerset
+ *     bitlength       length of powerset
+ *
+ * returns:
+ *     int             -1 .. nothing found
+ *                     >=0 .. index of first true bit found
+ * exceptions:
+ *  none
+ */
+
+int
+__ffsetclrpowerset (ps, bitlength, first_bit)
+     SET_WORD      *ps;
+     unsigned long  bitlength;
+     int first_bit;
+{
+  register int bitno;
+
+  if (first_bit >= bitlength)
+    return -1;
+
+#ifndef USE_CHARS
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      for (bitno = first_bit; bitno < bitlength; bitno++)
+       if (GET_BIT_IN_CHAR (*((SET_CHAR *)ps), bitno))
+         break;
+      return bitno == bitlength ? -1 : bitno;
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      for (bitno = first_bit; bitno < bitlength; bitno++)
+       if (GET_BIT_IN_SHORT (*((SET_SHORT *)ps), bitno))
+         break;
+      return bitno == bitlength ? -1 : bitno;
+    }
+  else
+#endif
+    {
+      unsigned int words_to_skip = (unsigned) first_bit / SET_WORD_SIZE;
+      unsigned long cnt = words_to_skip * SET_WORD_SIZE;
+      SET_WORD *p = ps + words_to_skip;
+      SET_WORD *endp = ps + BITS_TO_WORDS(bitlength);
+      SET_WORD c;
+      first_bit = (unsigned) first_bit % (unsigned) SET_WORD_SIZE;
+
+      c = *p++;
+      if (c)
+       {
+         for (bitno = first_bit; bitno < SET_WORD_SIZE; bitno++)
+           if (GET_BIT_IN_WORD(c, bitno))
+             goto found;
+       }
+      cnt += SET_WORD_SIZE;
+
+      while (p < endp)
+       {
+         if ((c = *p++))
+           {
+             /* found a bit set .. calculate which */
+             for (bitno = 0; bitno < SET_WORD_SIZE; bitno++)
+               if (GET_BIT_IN_WORD(c, bitno))
+                 goto found;
+           }
+         cnt += SET_WORD_SIZE;
+       }
+      return -1;
+    found:
+      bitno += cnt;
+      return bitno >= bitlength ? -1 : bitno;
+    }
+}
diff --git a/libchill/ffsetps.c b/libchill/ffsetps.c
new file mode 100644 (file)
index 0000000..c17cd59
--- /dev/null
@@ -0,0 +1,109 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+extern void __cause_ex1 (char *exname, char *file, int lineno);
+
+/*
+ * function __ffsetpowerset
+ *
+ * parameters:
+ *     ps              powerset
+ *     bitlength       length of powerset
+ *      minval          set low bound
+ *      filename        caller's file name
+ *      lineno          caller's line number
+ *
+ * returns:
+ *     int             enum value of lowest member of powerset
+ *
+ * exceptions:
+ *      "empty" if the set is empty
+ *
+ * abstract:
+ *  Find first bit set in a powerset and return the corresponding value.
+ *
+ */
+long
+__ffsetpowerset (ps, bitlength, minval, filename, lineno)
+     SET_WORD      *ps;
+     unsigned long  bitlength;
+     long           minval;
+     char          *filename;
+     int            lineno;
+{
+  unsigned long bitno;
+
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      SET_CHAR cset = *((SET_CHAR *)ps);
+      if (cset != 0)
+       {
+         /* found a bit set .. calculate which */
+         for (bitno = 0; bitno < SET_CHAR_SIZE; bitno++)
+           if (GET_BIT_IN_CHAR (cset, bitno))
+             break;
+         /* return its index */
+         return bitno + minval;
+       }
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      SET_SHORT sset = *((SET_SHORT *)ps);
+      if (sset != 0)
+       {
+         /* found a bit set .. calculate which */
+         for (bitno = 0; bitno < SET_SHORT_SIZE; bitno++)
+           if (GET_BIT_IN_SHORT (sset, bitno))
+             break;
+         /* return its index */
+         return bitno + minval;
+       }
+    }
+  else /* set composed of array of one or more WORDs */
+    {
+      SET_WORD *p    = ps;
+      SET_WORD *endp = ps + BITS_TO_WORDS(bitlength);
+      unsigned long    cnt;
+      
+      /* FIXME: bitorder problems? */
+      for (cnt = 0; p < endp; p++, cnt += SET_WORD_SIZE)
+       {
+         SET_WORD c = *p;
+
+         if (c)
+           {
+             /* found a bit set .. calculate which */
+             for (bitno = 0; bitno < SET_WORD_SIZE; bitno++)
+               if (GET_BIT_IN_WORD (c, bitno))
+                 break;
+             /* return its index */
+             return cnt + bitno + minval;
+           }
+       }
+    }
+  /* no bits found - raise exception */
+  __cause_ex1 ("empty", filename, lineno);
+}
diff --git a/libchill/fileio.h b/libchill/fileio.h
new file mode 100644 (file)
index 0000000..fb15b8f
--- /dev/null
@@ -0,0 +1,153 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef _fileio_h_
+#define _fileio_h_
+
+#include <stdio.h>
+
+#include "auxtypes.h"
+#include "ioerror.h"
+#include "iomodes.h"
+
+#define DIRSEP '/'
+
+#define TEST_FLAG(Xloc,Flag) (((Xloc)->flags) & (Flag))
+#define SET_FLAG(Xloc,Flag)  (Xloc)->flags |= (Flag)
+#define CLR_FLAG(Xloc,Flag)  (Xloc)->flags = ((Xloc)->flags & ~(Flag))
+
+Boolean
+__isassociated( Association_Mode* the_assoc, char* file, int line );
+
+Boolean
+__existing( Association_Mode* the_assoc, char* file, int line );
+
+Boolean
+__readable( Association_Mode* the_assoc, char* file, int line );
+
+Boolean
+__writeable( Association_Mode* the_assoc, char* file, int line );
+
+Boolean
+__indexable( Association_Mode* the_assoc, char* file, int line );
+
+Boolean
+__sequencible( Association_Mode* the_assoc, char* file, int line );
+
+Boolean
+__variable( Association_Mode* the_assoc, char* file, int line );
+
+typedef signed long int Index_t;
+
+Association_Mode*
+__associate( Association_Mode* the_assoc,
+             char*             the_path,
+             int               the_path_len,
+             char*             the_mode,
+             int               the_mode_len,
+             char*             file,
+             int               line );
+
+void
+__dissociate( Association_Mode* the_assoc, char* file, int line );
+
+void
+__create( Association_Mode* the_assoc, char* file, int line );
+
+void
+__delete( Association_Mode* the_assoc, char* file, int line );
+
+void
+__modify( Association_Mode* the_assoc,
+          char*             the_path,
+          int               the_path_len,
+          char*             the_mode,
+          int               the_mode_len,
+          char*             file,
+          int               line );
+
+void
+__connect( void*             the_transfer, 
+           Association_Mode* the_assoc,
+           Usage_Mode        the_usage,
+           Where_Mode        the_where,
+           Boolean           with_index,
+           signed long       the_index,
+           char*             file,
+           int               line );
+
+void
+__disconnect( void* the_transfer, char* file, int line );
+
+Association_Mode*
+__getassociation( void* the_transfer, char* file, int line );
+
+Usage_Mode
+__getusage( void* the_transfer, char* file, int line );
+
+Boolean
+__outoffile( void* the_transfer, char* file, int line );
+
+void*
+__readrecord( Access_Mode*  the_access,
+              signed long   the_index,
+              char*         the_buf_addr,
+              char*         file,
+              int           line );
+
+void
+__writerecord( Access_Mode*  the_access,
+               signed long   the_index,
+               char*         the_val_addr,
+               unsigned long the_val_len,
+               char*         file,
+               int           line );
+
+VarString*
+__gettextrecord( Text_Mode* the_text, char* file, int line );
+
+unsigned long
+__gettextindex( Text_Mode* the_text, char* file, int line );
+
+Access_Mode*
+__gettextaccess( Text_Mode* the_text, char* file, int line );
+
+Boolean
+__eoln( Text_Mode* the_text, char* file, int line );
+
+void
+__settextrecord( Text_Mode* the_text,
+                 VarString* the_text_rec,
+                 char*      file,
+                 int        line );
+
+void
+__settextindex( Text_Mode*  the_text,
+                signed long the_text_index, 
+                char*       file,
+                int         line );
+
+void
+__settextaccess( Text_Mode*   the_text,
+                 Access_Mode* the_access,
+                 char*        file,
+                 int          line );
+
+#endif
diff --git a/libchill/flsetclrps.c b/libchill/flsetclrps.c
new file mode 100644 (file)
index 0000000..e768a47
--- /dev/null
@@ -0,0 +1,99 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __flsetclrpowerset
+ *
+ * parameters:
+ *     ps              powerset
+ *     bitlength       length of powerset
+ *
+ * returns:
+ *     int             -1 .. nothing found
+ *                     >= 0 .. index of last set bit
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  Find last bit set in a powerset and return the corresponding value
+ *  in *out and clear this bit. Return 0 for no more found, else 1.
+ *
+ */
+int
+__flsetclrpowerset (ps, bitlength, first_bit)
+     SET_WORD      *ps;
+     unsigned long  bitlength;
+     int first_bit;
+{
+  register int bitno;
+
+#ifndef USE_CHARS
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      for (bitno = bitlength - 1; bitno >= first_bit; bitno--)
+       if (GET_BIT_IN_CHAR (*((SET_CHAR *)ps), bitno))
+         break;
+      return bitno < first_bit ? -1 : bitno;
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      for (bitno = bitlength - 1; bitno >= first_bit; bitno--)
+       if (GET_BIT_IN_SHORT (*((SET_SHORT *)ps), bitno))
+         break;
+      return bitno < first_bit ? -1 : bitno;
+    }
+  else
+#endif
+    {
+      SET_WORD *p, c;
+      bitno = bitlength - 1;
+      if (bitno < first_bit)
+       return -1;
+      p = &ps[(unsigned) bitno / SET_WORD_SIZE];
+      c = *p;
+      if (((unsigned) bitlength % SET_WORD_SIZE) != 0)
+       MASK_UNUSED_WORD_BITS(&c, (unsigned) bitlength % SET_WORD_SIZE);
+      if (c)
+       goto found;
+      else
+       bitno -= ((unsigned) bitno % SET_WORD_SIZE) + 1;
+      while (bitno >= first_bit)
+       {
+         c = *--p;
+         if (c)
+           goto found;
+         bitno -= SET_WORD_SIZE;
+       }
+      return -1;
+    found:
+      for (; bitno >= first_bit; bitno--)
+       {
+         if (GET_BIT_IN_WORD (c, (unsigned) bitno % SET_WORD_SIZE))
+           return bitno;
+       }
+      return -1;
+    }
+}
diff --git a/libchill/flsetps.c b/libchill/flsetps.c
new file mode 100644 (file)
index 0000000..1a79076
--- /dev/null
@@ -0,0 +1,107 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+extern void __cause_ex1 (char *exname, char *file, int lineno);
+
+/*
+ * function __flsetpowerset
+ *
+ * parameters:
+ *     ps              powerset
+ *     bitlength       length of powerset
+ *      minval          set low bound
+ *      filename        caller's file name
+ *      lineno          caller's line number
+ *
+ * returns:
+ *     int             largest enumeration value
+ * exceptions:
+ *      "empty"         if set is empty
+ *
+ * abstract:
+ *  Find last bit set in a powerset and return the corresponding value.
+ *
+ */
+long
+__flsetpowerset (ps, bitlength, minval, filename, lineno)
+     SET_WORD      *ps;
+     unsigned long  bitlength;
+     long           minval;
+     char          *filename;
+     int            lineno;
+{
+  unsigned long bitno;
+
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      SET_CHAR cset = *((SET_CHAR *)ps);
+      if (cset != 0)
+       {
+         /* found a bit set .. calculate which */
+         for (bitno = SET_CHAR_SIZE; bitno >= 1; bitno--)
+           if (GET_BIT_IN_CHAR (cset, bitno - 1))
+             break;
+         /* return its index */
+         return bitno + minval - 1;
+       }
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      SET_SHORT sset = *((SET_SHORT *)ps);
+      if (sset != 0)
+       {
+         /* found a bit set .. calculate which */
+         for (bitno = SET_SHORT_SIZE; bitno >= 1; bitno--)
+           if (GET_BIT_IN_SHORT (sset, bitno - 1))
+             break;
+         /* return its index */
+         return bitno + minval - 1;
+       }
+    }
+  else /* set composed of array of one or more WORDs */
+    {
+      SET_WORD *endp = ps;
+      SET_WORD *p = ps + BITS_TO_WORDS(bitlength) - 1;
+      unsigned long cnt;
+      
+      /* FIXME: bitorder problems? */
+      for (cnt = ((bitlength - 1) / SET_WORD_SIZE) * SET_WORD_SIZE;
+          p >= endp; p--, cnt -= SET_WORD_SIZE)
+       {
+         SET_WORD c = *p;
+         if (c)
+           {
+             /* found a bit set .. calculate which */
+             for (bitno = SET_WORD_SIZE; bitno >= 1; bitno--)
+               if (GET_BIT_IN_WORD (c, bitno - 1))
+                 break;
+             return cnt + bitno + minval - 1;
+           }
+       }
+    }
+  /* no bits found - raise exception */
+  __cause_ex1 ("empty", filename, lineno);
+}
diff --git a/libchill/format.c b/libchill/format.c
new file mode 100644 (file)
index 0000000..b0d70af
--- /dev/null
@@ -0,0 +1,2186 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <limits.h>
+#include <string.h>
+#include <ctype.h>
+#include <setjmp.h>
+#include <float.h>
+#include <math.h>
+#include <stdlib.h>
+#if _TEXTIO_DEBUG_
+#include <stdio.h>
+#endif
+
+#include "bitstring.h"
+#include "auxtypes.h"
+#include "iomodes.h"
+#include "format.h"
+#include "fileio.h"
+#include "ioerror.h"
+
+#define CH_BYTE_MIN   0xffffff80L
+#define CH_BYTE_MAX   0x0000007fL
+#define CH_UBYTE_MAX  0x000000ffUL
+#define CH_INT_MIN    0xffff8000L
+#define CH_INT_MAX    0x00007fffL
+#define CH_UINT_MAX   0x0000ffffUL
+#define CH_LONG_MIN   0x80000000L
+#define CH_LONG_MAX   0x7fffffffL
+#define CH_ULONG_MAX  0xffffffffUL
+
+#ifndef M_LN2
+#define M_LN2   0.69314718055994530942
+#endif
+#ifndef M_LN10
+#define M_LN10          2.30258509299404568402
+#endif
+
+#define DMANTDIGS  (1 + (int)(DBL_MANT_DIG * M_LN2 / M_LN10))
+#define FMANTDIGS  (1 + (int)(FLT_MANT_DIG * M_LN2 / M_LN10))
+
+/* float register length */
+#define MAXPREC 40
+
+#define LET 0x0001
+#define BIN 0x0002
+#define DEC 0x0004
+#define OCT 0x0008
+#define HEX 0x0010
+#define USC 0x0020
+#define BIL 0x0040
+#define SPC 0x0080
+#define SCS 0x0100
+#define IOC 0x0200
+#define EDC 0x0400
+#define CVC 0x0800
+
+#define isDEC(c)  ( chartab[(c)] & DEC )
+#define isCVC(c)  ( chartab[(c)] & CVC )
+#define isEDC(c)  ( chartab[(c)] & EDC )
+#define isIOC(c)  ( chartab[(c)] & IOC )
+#define isUSC(c)
+#define isXXX(c,XXX)  ( chartab[(c)] & XXX )
+
+/*
+ *  local definitions
+ */
+
+static
+short int chartab[256] = {
+  0, 0, 0, 0, 0, 0, 0, 0, 
+  0, SPC, SPC, SPC, SPC, SPC, 0, 0, 
+
+  0, 0, 0, 0, 0, 0, 0, 0, 
+  0, 0, 0, 0, 0, 0, 0, 0, 
+
+  SPC, IOC, 0, 0, 0, 0, 0, 0, 
+  SCS, SCS, SCS, SCS+IOC, SCS, SCS+IOC, SCS, SCS+IOC, 
+  BIN+OCT+DEC+HEX, BIN+OCT+DEC+HEX, OCT+DEC+HEX, OCT+DEC+HEX, OCT+DEC+HEX,
+     OCT+DEC+HEX, OCT+DEC+HEX, OCT+DEC+HEX, 
+  DEC+HEX, DEC+HEX, SCS, SCS, SCS+EDC, SCS+IOC, SCS+EDC, IOC, 
+
+  0, LET+HEX+BIL, LET+HEX+BIL+CVC, LET+HEX+BIL+CVC, LET+HEX+BIL, LET+HEX, 
+     LET+HEX+CVC, LET, 
+  LET+BIL+CVC, LET, LET, LET, LET, LET, LET, LET+CVC, 
+
+  LET, LET, LET, LET, LET+EDC, LET, LET, LET,
+  LET+EDC, LET, LET, SCS, 0, SCS, 0, USC, 
+
+  0, LET+HEX, LET+HEX, LET+HEX, LET+HEX, LET+HEX, LET+HEX, LET, 
+  LET, LET, LET, LET, LET, LET, LET, LET, 
+
+  LET, LET, LET, LET, LET, LET, LET, LET,
+  LET, LET, LET, 0, 0, 0, 0, 0 
+};
+
+typedef enum {
+  FormatText, FirstPercent, RepFact, ConvClause, EditClause, ClauseEnd,
+  AfterWidth, FractWidth, FractWidthCont, ExpoWidth, ExpoWidthCont, 
+  ClauseWidth, CatchPadding, LastPercent
+} fcsstate_t;
+
+#define CONVERSIONCODES "CHOBF"
+typedef enum {
+  DefaultConv, HexConv, OctalConv, BinaryConv, ScientConv
+} convcode_t;
+
+static
+short int base[4] = { 10, 16, 8, 2 };
+
+static
+short int dset[4] = { DEC, HEX, OCT, BIN };
+
+#define EDITCODES "X<>T"
+typedef enum {
+  SpaceSkip, SkipLeft, SkipRight, Tabulation
+} editcode_t;
+
+#define IOCODES "/+-?!="
+typedef enum {
+  NextRecord, NextPage, CurrentLine, Prompt, Emit, EndPage
+} iocode_t;
+
+typedef enum { 
+  ConvAct, EditAct, IOAct
+} acttype_t;
+
+typedef enum {
+  NormalEnd, EndAtParen, TextFailEnd 
+} formatexit_t;
+
+static
+double ep_1[10] = {
+  1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9 };
+static
+double ep_10[10] = {
+  1e0, 1e10, 1e20, 1e30, 1e40, 1e50, 1e60, 1e70, 1e80, 1e90 };
+static
+double ep_100 = 1e100;
+
+/* float register */
+static
+unsigned char floatdig[MAXPREC];
+
+/*
+ *  global io variables
+ */
+
+static Text_Mode*      textptr = NULL;
+static VarString*      textrecptr;
+
+static int             actual_index;
+static int             maximum_index;
+static int             iolist_index;
+
+static __tmp_IO_list*  iolistptr;
+static int             iolistlen;
+static char*           iostrptr;
+static int             iostrlen;
+
+
+static convcode_t     convcode;
+static editcode_t     editcode;
+static iocode_t       iocode;
+static unsigned long  repetition;
+static Boolean        leftadjust;
+static Boolean        overflowev;
+static Boolean        dynamicwid;
+static Boolean        paddingdef;
+static char           paddingchar;
+static Boolean        fractiondef;
+static unsigned long  fractionwidth;
+static Boolean        exponentdef;
+static unsigned long  exponentwidth;
+static unsigned long  clausewidth;
+static signed long    textindex;
+  
+static
+__tmp_IO_enum_table_type bool_tab[] = 
+   { { 0, "FALSE" }, 
+     { 1, "TRUE"  },
+     { 0 , NULL   }  };
+
+/*
+ * case insensitive compare: s1 is zero delimited, s2 has n chars
+ */
+static
+int casncmp( const char* s1, const char* s2, int n )
+{
+  int res = 0;
+  while( n-- )
+  {
+    if( (res = toupper(*s1++) - toupper(*s2++)) ) 
+      return res;
+  }
+  return *s1;
+}
+
+/*
+ * skip spaces with blank equal to tab
+ */
+static
+int skip_space( int limit )
+{
+  int skipped = 0;
+  while( actual_index < limit &&
+         (iostrptr[actual_index] == ' ' || iostrptr[actual_index] == '\t' ) )
+  {
+    actual_index++;
+    skipped++;
+  }
+  return skipped;
+}
+
+/*
+ * skip leading pad characters
+ */
+static
+int skip_pad( int limit )
+{
+  int skipped = 0;
+  while( actual_index < limit && iostrptr[actual_index] == paddingchar )
+  {
+    actual_index++;
+    skipped++;
+  }
+#if _TEXTIO_DEBUG_
+  printf( "skipping '%c' until %d: %d\n", paddingchar, limit, skipped );
+#endif
+  return skipped;
+}
+
+/*
+ * backup trailing pad characters
+ */
+static
+int piks_pad( int start, int limit )
+{
+  int skipped = 0;
+  while( start >/***=*/ limit && iostrptr[--start] == paddingchar )
+  {
+    skipped++;
+  }
+#if _TEXTIO_DEBUG_
+  printf( "piksing '%c' from %d until %d: %d\n", 
+          paddingchar, start, limit, skipped );
+#endif
+  return skipped;
+}
+
+/*
+ * parse an integer
+ */
+static
+int parse_int( int limit, int SET, int base, 
+               unsigned long* valptr, int* signptr )
+{
+  int           parsed = actual_index;
+  Boolean       digits = False;
+  unsigned long value  = 0;
+  char          curr;
+  int           dig;
+
+  if( actual_index >= limit )
+    IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_INT );
+  *signptr = +1;
+  if( iostrptr[actual_index] == '+' )
+    actual_index++;
+  else
+    if( iostrptr[actual_index] == '-' )
+    {  *signptr = -1;
+       actual_index++;
+    }
+
+  for( ; actual_index < limit; actual_index++ )
+  {
+    curr = iostrptr[actual_index];
+    if( curr == '_' ) continue;
+    if( isXXX(curr,SET) )
+    {
+      digits = True;
+      dig = curr <= '9' ? curr - '0' : toupper(curr) - 'A' + 10;
+      if( value > (ULONG_MAX - dig)/base )
+        IOEXCEPTION( TEXTFAIL, INT_VAL_OVERFLOW );
+      value = value*base + dig;
+      continue;
+    }
+    break;
+  }
+  if( !digits )
+    IOEXCEPTION( TEXTFAIL, NO_DIGITS_FOR_INT );
+
+  *valptr = value;
+#if _TEXTIO_DEBUG_
+  printf( "parsing for int until %d, base %d: %u\n", limit, base, value );
+#endif
+  return actual_index - parsed;
+}
+
+static
+double
+make_float( int dexp, int sign )
+{
+  double value = atof( floatdig );
+#if _TEXTIO_DEBUG_
+  printf( " value = %25.20e, dexp = %d\n", value, dexp );
+#endif
+  while( dexp >= 100 )
+    value *= ep_100, dexp -= 100;
+  if( dexp >= 10 )
+    value *= ep_10[dexp/10], dexp %= 10;
+  if( dexp > 0 )
+    value *= ep_1[dexp];
+
+  while( dexp <= -100 )
+    value /= ep_100, dexp += 100;
+  if( dexp <= -10 )
+    value /= ep_10[-dexp/10], dexp %= 10;
+  if( dexp < 0 )
+    value /= ep_1[-dexp];
+
+  return  sign ? -value : value;
+}
+
+/* %C -> fixed point   [+|-]<digit>+[.<digit>*]  */
+static
+int parse_fixedpoint( int limit, double* valptr )
+{
+  int           parsed = actual_index;
+  Boolean       digits = False;
+  int           sdig = 0;
+  double        value;
+  char          curr;
+  int           sign = False;
+  int           expo = 0;
+
+  if( actual_index >= limit )
+    IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_FLOAT );
+  if( iostrptr[actual_index] == '+' )
+    actual_index++;
+  else
+    if( iostrptr[actual_index] == '-' )
+    {
+       sign = True;
+       actual_index++;
+    }
+
+  floatdig[0] = '.';
+  for( ; actual_index < limit; actual_index++ )
+  {
+    curr = iostrptr[actual_index];
+    if( ! isDEC(curr) )
+      break;
+    digits = True;
+    if( sdig < MAXPREC - 1 )
+    {
+      if( sdig || curr != '0' )
+      {
+        floatdig[++sdig] = curr;
+        expo++;
+      }
+    }
+    else
+      if( sdig )
+        expo++;
+  }
+  if( digits && curr == '.' )
+  { 
+    actual_index++;
+    for( ; actual_index < limit; actual_index++ )
+    {
+      curr = iostrptr[actual_index];
+      if( !isDEC(curr) )
+        break;
+      if( sdig < MAXPREC - 1 )
+      {
+        if( sdig || curr != '0' )
+          floatdig[++sdig] = curr;
+        else
+          expo--;
+      }
+    }
+  }
+  floatdig[++sdig] = '\0';
+
+  if( !digits )
+    IOEXCEPTION( TEXTFAIL, NO_DIGITS_FOR_FLOAT );
+
+  *valptr = make_float( expo, sign);
+  return actual_index - parsed;
+}
+
+
+typedef enum {
+  s_sign, s_dig, s_period, s_fraca, s_fracb, s_expo, s_exposign, 
+  s_expoa, s_expob }
+scient_t;
+
+/* %C -> scientific   [+|-]<digit>[.<digit>*]E[=|-]<digit>+  */
+static
+int parse_scientific( int limit, double* valptr, double dmin, double dmax )
+{
+  int           parsed = actual_index;
+  int           sdig = 0;
+  char          curr;
+  double        value;
+  int           sign = False;
+  int           expo = 0;           
+  int           expo_sign = +1;
+
+  scient_t      state = s_sign;  
+
+  if( actual_index >= limit )
+    IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_FLOAT );
+
+  floatdig[0] = '.';
+  for( ; actual_index < limit; actual_index++ )
+  {
+    curr = iostrptr[actual_index];
+    switch( state )
+    {
+    case s_sign:
+      if( iostrptr[actual_index] == '+' )
+      {
+        state = s_dig;
+        break;
+      }
+      if( iostrptr[actual_index] == '-' )
+      {
+        sign = True;
+        state = s_dig;
+        break;
+      }
+      /* fall through - no break */
+    case s_dig:
+      if( isDEC(curr) && curr > '0' )
+      {
+        floatdig[++sdig] = curr;
+        state = s_period;
+        break;
+      }
+      IOEXCEPTION( TEXTFAIL, NO_DIGITS_FOR_FLOAT );
+    case s_period:
+      if( curr == '.' )
+      {
+        state = s_fraca;
+        break;
+      }
+      if( curr == 'E' )
+      {
+        state = s_exposign;
+        break;
+      }
+      IOEXCEPTION( TEXTFAIL, NO_EXPONENT );
+    case s_fraca:
+      if( isDEC(curr) )
+      {
+        floatdig[++sdig] = curr;
+        state = s_fracb;
+        break;
+      }
+      IOEXCEPTION( TEXTFAIL, NO_DIGITS_FOR_FLOAT );
+    case s_fracb:
+      if( isDEC(curr) )
+      {
+        if( sdig < MAXPREC - 1 )
+          floatdig[++sdig] = curr;
+        break;
+      }
+      if( curr == 'E' )
+      {
+        state = s_exposign;
+        break;
+      }
+      IOEXCEPTION( TEXTFAIL, NO_EXPONENT );
+    case s_exposign:
+      if( iostrptr[actual_index] == '+' )
+      {
+        state = s_expoa;
+        break;
+      }
+      if( iostrptr[actual_index] == '-' )
+      {
+        expo_sign = -1;
+        state = s_expoa;
+        break;
+      }
+    case s_expoa:
+      if( isDEC(curr) )
+      {
+        expo = curr - '0';
+        state = s_expob;
+        break;
+      }
+      IOEXCEPTION( TEXTFAIL, NO_EXPONENT );
+    case s_expob:
+      expo = expo*10 + (curr - '0');
+      if( expo > 1000 )
+        IOEXCEPTION( TEXTFAIL, REAL_OVERFLOW );
+    }
+  }
+  if( state != s_expob ) 
+    IOEXCEPTION( TEXTFAIL, NO_EXPONENT );
+
+  expo *= expo_sign;
+  expo++;
+
+  floatdig[++sdig] = '\0';
+
+  *valptr = make_float( expo, sign );
+  return actual_index - parsed;
+}
+
+
+static
+int parse_set( int limit, __tmp_IO_enum_table_type* tabptr, 
+               unsigned long* valptr )
+{
+  int    parsed = actual_index;
+  char   curr;
+  __tmp_IO_enum_table_type* etptr;
+
+  if( actual_index >= limit )
+    IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_SET );
+
+  curr = iostrptr[actual_index];
+  if( isXXX(curr,LET+USC) )
+    actual_index++;
+  else
+    IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_SET );
+
+  for( ; actual_index < limit; actual_index++ )
+  {    
+    if( ! isXXX(iostrptr[actual_index],LET+DEC+USC) )
+      break;
+  }
+
+  if( tabptr )
+     while( tabptr->name )
+     {
+       if( !casncmp( tabptr->name, &iostrptr[parsed], actual_index-parsed ) )
+       {
+         *valptr = tabptr->value;
+#if _TEXTIO_DEBUG_
+         printf( "parsing set value until %d: %u\n", limit, tabptr->value );
+#endif
+         return actual_index - parsed;         
+       }
+       tabptr++;
+     }
+  IOEXCEPTION( TEXTFAIL, SET_CONVERSION_ERROR ); 
+}
+
+static
+int parse_bit( int limit, char* bitptr )
+{
+  int parsed = actual_index;
+  int i = 0;
+  char curr;
+
+  if( actual_index >= limit )
+    IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_BOOLS );
+
+  for( ; actual_index < limit; actual_index++ )
+  {
+    curr = iostrptr[actual_index] - '0';
+    if( curr == 0 || curr == 1 )
+      /* __setbitinset( i++, bitptr, limit, curr ); */
+      __setbitpowerset (bitptr, limit, 0, i++, curr, __FILE__, __LINE__);
+    else
+      break;
+  }
+  return actual_index - parsed;
+}
+
+static
+char* myultoa( unsigned long ul, char* buf, int base )
+{
+  char*         res = buf;
+  unsigned long h = ul/base;
+  unsigned long q = 1;
+
+  while( h >= q ) q *= base;
+  while( q > 0 )
+  {
+    *buf++ = "0123456789ABCDEF"[ul/q];
+    ul %= q;
+    q /= base;
+  }
+  *buf++ = '\0';
+  return res;
+}
+
+/*
+ *  convert a bit string from src, bit offset up to len
+ */
+static
+char* bitput( char* dst, char* src, int offset, int len )
+{
+  char* res = dst;
+  int i;
+  for( i = offset; i < len; i++ )
+  {
+    *dst++ = __inpowerset( i, src, len, 0 ) ? '1' : '0';
+  }
+  return res;
+}
+
+/*
+ * dround: round decimal register *digptr starting at digit mdigs,
+ *         on carry advance begin of digit sequence and bump exponent
+ */ 
+static
+char*
+dround( char* digptr, int mdigs, int* deptr )
+{
+  int carry;
+#if _TEXTIO_DEBUG_
+  printf( "Rounding from %d\n", mdigs );
+#endif
+  if( digptr[mdigs] >= 5 )
+  {
+    carry = 1;
+    while( carry )
+    {
+      digptr[--mdigs]++;
+      if( digptr[mdigs] >= 10 )
+        digptr[mdigs] = 0;
+      else
+        carry = 0;
+    }
+  }
+  if( mdigs < 0 )
+  {
+    digptr[--mdigs] = 1;
+    (*deptr)++;
+    return digptr - 1;
+  }
+  else
+    return digptr;
+}
+
+/*
+ * mydtoa: convert val with a precision of mantdigs to a decimal fraction
+ *         first digit is at **fstdiptr, decimal exponent is at *deptr
+ */
+static
+char*
+mydtoa( double val, int mantdigs, int* deptr, int* sgnptr )
+{
+  double m;
+  int be;
+  int de = -1;
+  int fstdig = 0;
+  int idig; 
+  char* digptr = floatdig+2;
+
+  floatdig[0] = floatdig[1] = 0;
+
+  if( val < 0 ) 
+    *sgnptr = -1, val = fabs( val );
+  else
+    *sgnptr = +1;
+
+  /* split the value */
+  m = frexp( val, &be ) * 10.0;
+
+  /* 5.0 <= m < 10.0 */
+  while( be > 0 )
+  {
+    de++; be--; m /= 5.0;
+    if( m < 1.0 )
+      m *= 10.0, de--;
+  }
+  while( be < 0 )
+  {
+    de--; be++; m *= 5.0;
+    if( m >= 10.0 )
+      m /= 10.0, de++;
+  }
+
+  for( idig = 0; idig < mantdigs; idig++ )
+  {
+    digptr[idig] = (int)m;
+    m = (m - digptr[idig])*10.0;
+  }
+  digptr[idig] = (int)m;
+
+  *deptr = de;
+  return dround( digptr, mantdigs, deptr );
+}
+
+#define PUT(c) \
+  { if( ifst <= ++iprt && iprt <= ilst ) *dst++ = c; }
+
+static
+char*
+fixput( char* dst, char* src, 
+        int ifst, int ilst, 
+        int sign, int fst, int lst, 
+        int nid, int nfd )
+{
+  char* dstsav = dst;
+  int idig;
+  int iprt = 0;
+
+  if( sign < 0 )
+    PUT( '-' );
+  for( idig = nid; idig >= -nfd; idig-- )
+  {
+    if (idig == -1)
+      PUT( '.' );
+    PUT( idig > fst || lst >= idig ? '0': '0' + *src++ );
+  }
+  return dstsav;
+}
+
+static
+char*
+sciput( char* dst, char* src, char* expbeg,
+        int ifst, int ilst, 
+        int sign, int de, int expwid )
+{
+  char* dstsav = dst;
+  int iprt = 0;
+  int nfd = fractionwidth;
+  int explen = strlen( expbeg );
+
+  if( sign < 0 )
+    PUT( '-' );
+  PUT( '0' + *src++ );
+  PUT( '.' );
+
+  while( nfd-- )
+    PUT( '0' + *src++ );
+  PUT( 'E' );
+  PUT( de >= 0 ? '+' : '-' );
+  while( expwid > explen )
+  {
+    PUT( '0' );
+    expwid--;
+  }
+  while( explen-- )
+    PUT( *expbeg++ );
+  return dstsav;
+}
+
+/*
+ *  handle dynamic field width
+ */ 
+static
+get_field_width( void )
+{
+  unsigned long  width;
+  unsigned long  ulongval;
+           long  longval;
+  __tmp_IO_list  io;
+   
+
+  if( ++iolist_index > iolistlen )
+    IOEXCEPTION( TEXTFAIL, IOLIST_EXHAUSTED );  
+
+  io = *iolistptr++;
+
+  /* must be integer, >= 0 */
+  switch( io.__descr )
+  {
+  case __IO_ByteVal:
+    longval = io.__t.__valbyte; 
+    goto signed_fieldwidth;
+  case __IO_UByteVal:
+    width = io.__t.__valubyte; 
+    goto unsigned_fieldwidth;
+  case __IO_IntVal:
+    longval = io.__t.__valint; 
+    goto signed_fieldwidth;
+  case __IO_UIntVal:
+    width = io.__t.__valuint; 
+    goto unsigned_fieldwidth;
+  case __IO_LongVal:
+    longval = io.__t.__vallong; 
+    goto signed_fieldwidth;
+  case __IO_ULongVal:
+    width = io.__t.__valulong; 
+    goto unsigned_fieldwidth;
+  case __IO_ByteLoc:
+    longval = *(signed char*)io.__t.__locint; 
+    goto signed_fieldwidth;
+  case __IO_UByteLoc:
+    width = *(unsigned char*)io.__t.__locint; 
+    goto unsigned_fieldwidth;
+  case __IO_IntLoc:
+    longval = *(signed short*)io.__t.__locint; 
+    goto signed_fieldwidth;
+  case __IO_UIntLoc:
+    width = *(unsigned short*)io.__t.__locint; 
+    goto unsigned_fieldwidth;
+  case __IO_LongLoc:
+    longval = *(signed long*) io.__t.__locint; 
+    goto signed_fieldwidth;
+  case __IO_ULongLoc:
+    width = *(unsigned long*)io.__t.__locint; 
+    goto unsigned_fieldwidth;
+  default:
+    IOEXCEPTION( TEXTFAIL, NON_INT_FIELD_WIDTH );
+  }
+
+signed_fieldwidth: ;
+  if( longval < 0 )
+    IOEXCEPTION( TEXTFAIL, NEGATIVE_FIELD_WIDTH );
+  width = longval;
+
+unsigned_fieldwidth: ;
+  return width;
+}
+
+
+static
+void inpconv( void )
+{
+  __tmp_IO_list  io;
+  int            width;
+  int            limit;
+  int            skiplim;
+  int            skipped;
+  int            bypass;
+  int            parsed;
+  Boolean        fixedchars;
+  int            fixedlen;
+  unsigned char  curr;
+  double         dval;
+  float          fval;
+
+  __tmp_IO_long  lval;
+  int            sign;
+  unsigned long  umin;
+  unsigned long  umax;
+    signed long  smin;
+    signed long  smax;
+  int            ilen;
+  short unsigned slen;
+  __tmp_IO_enum_table_type* settabptr; 
+
+  while( repetition-- )
+  {
+    if( ++iolist_index > iolistlen )
+      IOEXCEPTION( TEXTFAIL, IOLIST_EXHAUSTED );  
+
+    io = *iolistptr++;
+
+    if( dynamicwid )
+      width = get_field_width();
+    else
+      width = clausewidth;
+
+    bypass = skipped = 0;
+    if( width )
+    {
+      if( actual_index + width > iostrlen )
+        IOEXCEPTION( TEXTFAIL, NOT_ENOUGH_CHARS );
+
+      switch(io.__descr)
+      {
+      case __IO_CharLoc:
+      case __IO_CharRangeLoc:
+        fixedchars = True;
+        fixedlen = 1;
+        break;
+      case __IO_CharStrLoc:
+        fixedchars = True;
+        fixedlen = io.__t.__loccharstring.string_length;
+        break;
+      default:
+        fixedchars = False;
+        break;
+      }
+         
+      if( leftadjust )
+      {
+        skiplim = fixedchars ? actual_index + fixedlen
+                             : actual_index;
+        bypass = skipped = piks_pad( actual_index + width, skiplim );
+      }
+      else
+      {
+        skiplim = fixedchars ? actual_index + width - fixedlen
+                             : actual_index + width;
+        skipped = skip_pad( skiplim );
+      }
+      width -= skipped;
+      limit = actual_index + width;
+    }
+    else
+    { /* free format */
+      if( paddingdef || !( io.__descr == __IO_CharLoc ||
+                           io.__descr == __IO_CharRangeLoc || 
+                           io.__descr == __IO_CharStrLoc ||
+                           io.__descr == __IO_CharVaryingLoc ) )
+        if( paddingchar == ' ' || paddingchar == '\t' )
+          skip_space( iostrlen );
+        else
+          skip_pad( iostrlen );
+      limit = iostrlen;
+    }
+
+    switch( io.__descr )
+    {
+    case __IO_ByteLoc:
+      ilen = 1;
+      smin = CH_BYTE_MIN;
+      smax = CH_BYTE_MAX;
+      goto parse_signed_int;
+    case __IO_UByteLoc:
+      ilen = 1;
+      umin = 0;
+      umax = CH_UBYTE_MAX;
+      goto parse_unsigned_int;
+    case __IO_IntLoc:
+      ilen = 2;
+      smin = CH_INT_MIN;
+      smax = CH_INT_MAX;
+      goto parse_signed_int;
+    case __IO_UIntLoc:
+      ilen = 2;
+      umin = 0;
+      umax = CH_UINT_MAX;
+      goto parse_unsigned_int;
+    case __IO_LongLoc:
+      ilen = 4;
+      smin = CH_LONG_MIN;
+      smax = CH_LONG_MAX;
+      goto parse_signed_int;
+    case __IO_ULongLoc:
+      ilen = 4;
+      umin = 0;
+      umax = CH_ULONG_MAX;
+      goto parse_unsigned_int;
+
+    case __IO_ByteRangeLoc:
+      ilen = 1;
+      smin = io.__t.__locintrange.lower.slong;
+      smax = io.__t.__locintrange.upper.slong;
+      goto parse_signed_int;
+    case __IO_UByteRangeLoc:
+      ilen = 1;
+      umin = io.__t.__locintrange.lower.ulong;
+      umax = io.__t.__locintrange.upper.ulong;
+      goto parse_unsigned_int;
+    case __IO_IntRangeLoc:
+      ilen = 2;
+      smin = io.__t.__locintrange.lower.slong;
+      smax = io.__t.__locintrange.upper.slong;
+      goto parse_signed_int;
+    case __IO_UIntRangeLoc:
+      ilen = 2;
+      umin = io.__t.__locintrange.lower.ulong;
+      umax = io.__t.__locintrange.upper.ulong;
+      goto parse_unsigned_int;
+    case __IO_LongRangeLoc:
+      ilen = 4;
+      smin = io.__t.__locintrange.lower.slong;
+      smax = io.__t.__locintrange.upper.slong;
+      goto parse_signed_int;
+    case __IO_ULongRangeLoc:
+      ilen = 4;
+      umin = io.__t.__locintrange.lower.ulong;
+      umax = io.__t.__locintrange.upper.ulong;
+      goto parse_unsigned_int;
+
+    case __IO_BoolLoc:
+      ilen = 1;
+      umin = 0;
+      umax = 1;
+      settabptr = bool_tab;
+      goto parse_set;
+    case __IO_BoolRangeLoc:
+      ilen = 1;
+      umin = io.__t.__locboolrange.lower;
+      umax = io.__t.__locboolrange.upper;
+      settabptr = bool_tab;
+      goto parse_set;
+
+    case __IO_SetLoc:
+      ilen = io.__t.__locsetrange.length;
+      settabptr = io.__t.__locsetrange.name_table;
+      umin = 0;
+      umax = CH_ULONG_MAX;
+      goto parse_set;
+    case __IO_SetRangeLoc:
+      ilen = io.__t.__locsetrange.length;
+      settabptr = io.__t.__locsetrange.name_table;
+      umin = io.__t.__locsetrange.lower;
+      umax = io.__t.__locsetrange.upper;
+      goto parse_set;
+
+    case __IO_CharLoc:
+      umin = 0;
+      umax = 0xff;
+      goto parse_char;
+    case __IO_CharRangeLoc:
+      umin = io.__t.__loccharrange.lower;
+      umax = io.__t.__loccharrange.upper;
+      goto parse_char;
+
+    case __IO_CharVaryingLoc:
+      if( convcode != DefaultConv )
+        IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+      slen = io.__t.__loccharstring.string_length;
+      if( (parsed = limit - actual_index) < slen )
+        slen = parsed;
+      else
+        parsed = slen;  
+      memcpy( io.__t.__loccharstring.string + 2, 
+              &iostrptr[actual_index], parsed );
+      MOV2(io.__t.__loccharstring.string,&slen);
+      actual_index += parsed;
+      goto check_field_complete;
+
+
+    case __IO_CharStrLoc:
+      if( convcode != DefaultConv )
+        IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+      if( actual_index + io.__t.__loccharstring.string_length > limit )
+        IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_CHARS );
+      memcpy( io.__t.__loccharstring.string,
+              &iostrptr[actual_index],
+              parsed = io.__t.__loccharstring.string_length );
+      actual_index += parsed;
+      goto check_field_complete;
+
+    case __IO_BitStrLoc:
+      if( convcode != DefaultConv )
+        IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+      parsed = parse_bit( limit, io.__t.__loccharstring.string );
+      if( parsed < io.__t.__loccharstring.string_length )
+        IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_BOOLS );
+      goto check_field_complete;
+
+    case __IO_LongRealLoc:
+    case __IO_RealLoc:
+      switch( convcode )
+      {
+      case ScientConv:
+        parse_scientific( limit, &dval, DBL_MIN, DBL_MAX );
+        break;
+      case DefaultConv:
+        parse_fixedpoint( limit, &dval );
+        break;
+      default:
+        IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+      }
+      if( io.__descr == __IO_LongRealLoc )
+        memcpy( io.__t.__loclongreal, &dval, sizeof(double) );
+      else
+      {
+        fval = (float)dval;
+        MOV4(io.__t.__locreal,&fval);
+      }
+      goto check_field_complete;
+    default:
+      IOEXCEPTION( TEXTFAIL, INVALID_IO_LIST );
+    }
+
+
+parse_signed_int: ;
+    if( convcode == ScientConv )
+      IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+    parsed = parse_int( limit, dset[convcode], base[convcode], 
+                        &lval.ulong, &sign );
+    if( sign < 0 )
+    {
+      if( lval.ulong > (unsigned long)CH_LONG_MIN )
+        IOEXCEPTION( TEXTFAIL, INTEGER_RANGE_ERROR );
+      lval.slong = -lval.ulong;
+    }
+    else
+    {
+      /* not needed: lval.slong = lval.ulong; */
+      /* Hack: sign extension for bin/oct/dec if no sign present */
+      if( convcode != DefaultConv && lval.ulong & (1 << (ilen*8-1)) )
+      {
+        if( ilen < 4 )
+          lval.ulong |= 0xFFFFFFFF << ilen*8;
+      }
+      else
+        if( lval.ulong > (unsigned long)CH_LONG_MAX )
+          IOEXCEPTION( TEXTFAIL, INTEGER_RANGE_ERROR );
+    }
+    if( lval.slong < smin || smax < lval.slong )
+      IOEXCEPTION( TEXTFAIL, INTEGER_RANGE_ERROR );
+    goto store_int;
+
+parse_unsigned_int: ;
+    if( convcode == ScientConv )
+      IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+    parsed = parse_int( limit, dset[convcode], base[convcode],
+                        &lval.ulong, &sign );
+    if( sign < 0 ||  lval.ulong < umin || umax < lval.ulong )
+      IOEXCEPTION( TEXTFAIL, INTEGER_RANGE_ERROR );
+    goto store_int;
+
+parse_set: ;
+    if( convcode != DefaultConv )
+      IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+    parsed = parse_set( limit, settabptr, &lval.ulong );
+    if( lval.ulong < umin || umax < lval.ulong )
+      IOEXCEPTION( TEXTFAIL, SET_RANGE_ERROR );
+    goto store_int;
+
+store_int: ;
+    switch( ilen )
+    {
+    case 1:
+      *(unsigned char*)io.__t.__locint = lval.ulong;
+      break;
+    case 2:
+      slen = lval.ulong;
+      MOV2(io.__t.__locint,&slen);
+      break;
+    case 4:
+      MOV4(io.__t.__locint,&lval.ulong);
+      break;
+    default:
+      IOEXCEPTION( TEXTFAIL, INTERNAL_ERROR );
+    }
+    goto check_field_complete;
+
+parse_char: ;
+    if( convcode != DefaultConv )
+      IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+    if( actual_index >= limit )
+      IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_CHARS );
+    curr = iostrptr[actual_index++];
+    parsed = 1;
+    if( curr < umin || umax < curr )
+      IOEXCEPTION( TEXTFAIL, CHAR_RANGE_ERROR );
+    *io.__t.__locchar = curr;
+    goto check_field_complete;
+
+check_field_complete: ;
+    actual_index += bypass;    
+    if( width > parsed )
+      IOEXCEPTION( TEXTFAIL, INVALID_CHAR );
+  }
+}
+
+static
+void inpedit( void )
+{
+  int           nchars;
+
+  if( dynamicwid ) 
+    clausewidth = get_field_width();
+
+  switch( editcode )
+  { 
+  case SpaceSkip:
+    nchars = repetition*clausewidth;
+    if( actual_index + nchars > iostrlen )
+      IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_EDIT );
+    for( ; nchars ; nchars-- )
+      if( iostrptr[actual_index++] != ' ' )
+        IOEXCEPTION( TEXTFAIL, NO_SPACE_TO_SKIP );
+    break; 
+
+  case SkipLeft:
+    nchars = repetition*clausewidth;
+    if( (actual_index -= nchars) < 0 )
+      IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_EDIT );
+    break;
+
+  case SkipRight:
+    nchars = repetition*clausewidth;
+    if( (actual_index += nchars) > iostrlen )
+      IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_EDIT );
+    break;
+  
+  case Tabulation:
+    if( (actual_index = clausewidth) > iostrlen )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+    break;
+  }
+}
+
+static
+void outconv( void )
+{
+  unsigned long             width;
+  char                      itembuf[33]; 
+  unsigned long             ulongval;
+           long             longval;
+  __tmp_IO_list             io;
+  __tmp_IO_enum_table_type* etptr;
+  char*                     itembeg;
+  unsigned long             itemlen;
+  double                    doubleval;
+  int                       de;
+  int                       sign;
+  int                       mantdigs;
+  int                       nid;
+  int                       nfd;
+  char*                     expbeg;
+  int                       explen;
+  unsigned int              expwid;
+
+  while( repetition-- )
+  {
+    if( ++iolist_index > iolistlen )
+      IOEXCEPTION( TEXTFAIL, IOLIST_EXHAUSTED );  
+
+    io = *iolistptr++;
+    width =  dynamicwid ? get_field_width() : clausewidth;
+
+    switch( convcode )
+    {
+    case DefaultConv:
+      switch( io.__descr )
+      {
+      case __IO_ByteVal:
+        longval = io.__t.__valbyte; 
+        goto signed_conversion;
+      case __IO_UByteVal:
+        ulongval = io.__t.__valubyte; 
+        goto unsigned_conversion;
+      case __IO_IntVal:
+        longval = io.__t.__valint; 
+        goto signed_conversion;
+      case __IO_UIntVal:
+        ulongval = io.__t.__valuint; 
+        goto unsigned_conversion;
+      case __IO_LongVal:
+        longval = io.__t.__vallong; 
+        goto signed_conversion;
+      case __IO_ULongVal:
+        ulongval = io.__t.__valulong; 
+        goto unsigned_conversion;
+
+      case __IO_BoolVal:
+        switch( io.__t.__valbool )
+        {
+        case 0:
+          itembeg = "FALSE";
+          itemlen = 5;
+          goto move_item;
+        case 1:
+          itembeg = "TRUE";
+          itemlen = 4;
+          goto move_item;
+        default:
+          IOEXCEPTION( TEXTFAIL, BOOL_CONVERSION_ERROR );
+        }
+      case __IO_CharVal:
+        itembeg = &io.__t.__valchar;
+        itemlen = 1;
+        goto move_item;
+  
+      case __IO_SetVal:
+        /* locate name string using set mode name table */
+        itembeg = 0;
+        
+        if( (etptr = io.__t.__valset.name_table) )
+          while( etptr->name )
+         {
+            if( etptr->value == io.__t.__valset.value )
+           {
+              itembeg = etptr->name;
+              itemlen = strlen( itembeg );
+              goto move_item;
+            }
+            etptr++;
+          }
+       IOEXCEPTION( TEXTFAIL, SET_CONVERSION_ERROR ); 
+
+      case __IO_CharVaryingLoc:
+        {
+          unsigned short l;
+          itembeg = (char*)io.__t.__loccharstring.string;
+          MOV2(&l,itembeg);
+          itembeg += 2;
+          itemlen = l;
+          goto move_item;
+        }
+
+      case __IO_CharStrLoc:
+        itembeg = io.__t.__loccharstring.string;
+        itemlen = io.__t.__loccharstring.string_length;
+        goto move_item;
+
+      case __IO_BitStrLoc:
+        itemlen = io.__t.__loccharstring.string_length;
+        itembeg = io.__t.__loccharstring.string;
+
+        if( !width )
+          width = itemlen;
+
+        /* check remaining space */
+        if( actual_index + width > iostrlen )
+          IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+
+        if( itemlen == width )
+          bitput( iostrptr + actual_index, itembeg, 0, itemlen );
+        else
+          if( itemlen < width )
+            if( leftadjust )
+              memset( bitput( iostrptr + actual_index, itembeg, 0, itemlen )
+                      + itemlen,
+                      paddingchar, width - itemlen );
+            else
+              bitput( memset( iostrptr + actual_index, 
+                              paddingchar, width - itemlen )
+                      + width - itemlen,
+                      itembeg, itemlen - width, itemlen );
+          else
+            if( overflowev )
+              memset( iostrptr + actual_index, '*', width );
+            else
+              if( leftadjust )
+                bitput( iostrptr + actual_index, itembeg, 0, width );
+              else
+                bitput( iostrptr + actual_index, itembeg, 
+                        itemlen - width, itemlen );
+        goto adjust_index;
+
+      case __IO_RealVal:
+        doubleval = io.__t.__valreal;
+        mantdigs = FMANTDIGS;
+        goto fixed_point_conversion;
+      case __IO_LongRealVal:
+        doubleval = io.__t.__vallongreal;
+        mantdigs = DBL_DIG;
+        goto fixed_point_conversion;
+        break;
+
+      default:
+        IOEXCEPTION( TEXTFAIL, INVALID_IO_LIST );
+      }
+
+    case HexConv:
+    case OctalConv:
+    case BinaryConv:
+      switch( io.__descr )
+      {
+      case __IO_ByteVal:
+      case __IO_UByteVal:
+        ulongval = io.__t.__valubyte; 
+        break;
+      case __IO_IntVal:
+      case __IO_UIntVal:
+        ulongval = io.__t.__valuint; 
+        break;
+      case __IO_LongVal:
+      case __IO_ULongVal:
+        ulongval = io.__t.__valulong; 
+        break;
+      default:
+        IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+      }
+      itembeg = myultoa( ulongval, itembuf, base[convcode] );
+      itemlen = strlen( itembeg );
+      goto move_item;
+  
+    case ScientConv:
+      switch( io.__descr )
+      {
+      case __IO_RealVal:
+        doubleval = io.__t.__valreal;
+        mantdigs = FMANTDIGS;
+        if( !fractiondef )
+          fractionwidth = FMANTDIGS - 1;
+        goto scientific_conversion;
+      case __IO_LongRealVal:
+        doubleval = io.__t.__vallongreal;
+        mantdigs = DBL_DIG;
+        if( !fractiondef )
+          fractionwidth = DBL_DIG - 1;
+        goto scientific_conversion;
+        break;
+      default:
+        IOEXCEPTION( TEXTFAIL, CONVCODE_MODE_MISFIT );
+      }
+    }
+
+fixed_point_conversion: ;
+    itembeg = mydtoa( doubleval, mantdigs, &de, &sign );
+    if( fractiondef && de >= -fractionwidth - 1
+        && -fractionwidth > de - mantdigs )
+      itembeg = dround( itembeg, de + fractionwidth + 1, &de );
+
+    nid = de >= 0 ? de : 0;
+    nfd = fractiondef ? fractionwidth 
+                      : ( de + 1 - mantdigs > 0 ? 0 : mantdigs - de - 1 );
+    itemlen = ( sign < 0 ? 1 : 0 ) + 2 + nid + nfd;
+#if _TEXTIO_DEBUG_
+printf( "fixed item length %d\n", itemlen );
+#endif
+    if( !width )
+      width = itemlen;
+#if _TEXTIO_DEBUG_
+printf( "fixed item width %d\n", width );
+#endif
+    /* check remaining space */
+    if( actual_index + width > iostrlen )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+
+    if( itemlen == width )
+      fixput( iostrptr + actual_index, itembeg, 
+              1, itemlen, sign, de, de - mantdigs, nid, nfd );
+    else
+      if( itemlen < width )
+        if( leftadjust )
+          memset( fixput( iostrptr + actual_index, itembeg, 
+                          1, itemlen, sign, de, de - mantdigs, nid, nfd )
+                  + itemlen,
+                  paddingchar, width - itemlen );
+        else
+          fixput( memset( iostrptr + actual_index, 
+                          paddingchar, width - itemlen )
+                  + width - itemlen,
+                  itembeg, 1, itemlen, sign, de, de - mantdigs, nid, nfd );
+      else
+        if( overflowev )
+          memset( iostrptr + actual_index, '*', width );
+        else
+          if( leftadjust )
+            fixput( iostrptr + actual_index, itembeg, 
+                    1, width, sign, de, de - mantdigs, nid, nfd );
+          else
+            fixput( iostrptr + actual_index, itembeg, 
+                    itemlen - width + 1, itemlen,
+                    sign, de, de - mantdigs, nid, nfd );
+    goto adjust_index;
+
+scientific_conversion: ;
+    itembeg = mydtoa( doubleval, mantdigs, &de, &sign );
+
+    if( fractiondef && fractionwidth < mantdigs )
+      itembeg = dround( itembeg, fractionwidth + 1, &de );
+
+    expbeg = myultoa( abs(de), itembuf, 10 );
+    explen = strlen( expbeg );
+
+    expwid = explen > exponentwidth ? explen : exponentwidth;
+    itemlen = ( sign < 0 ? 1 : 0 ) + 2 + fractionwidth + 2 + expwid;
+#if _TEXTIO_DEBUG_
+printf( "floating item length %d, fraction %d, exponent %d\n", 
+        itemlen, fractionwidth, expwid );
+#endif
+    if( width == 0 )
+      width = itemlen;
+#if _TEXTIO_DEBUG_
+printf( "floating item width %d\n", width );
+#endif
+    /* check remaining space */
+    if( actual_index + width > iostrlen )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+
+    if( itemlen == width )
+      sciput( iostrptr + actual_index, itembeg, expbeg, 
+              1, itemlen, sign, de, expwid );
+    else
+      if( itemlen < width )
+        if( leftadjust )
+          memset( sciput( iostrptr + actual_index, itembeg, expbeg,
+                          1, itemlen, sign, de, expwid )
+                  + itemlen,
+                  paddingchar, width - itemlen );
+        else
+          sciput( memset( iostrptr + actual_index, 
+                          paddingchar, width - itemlen )
+                  + width - itemlen,
+                  itembeg, expbeg, 1, itemlen, sign, de, expwid );
+      else
+        if( overflowev )
+          memset( iostrptr + actual_index, '*', width );
+        else
+          if( leftadjust )
+            sciput( iostrptr + actual_index, itembeg, expbeg,
+                    1, width, sign, de, expwid );
+          else
+            sciput( iostrptr + actual_index, itembeg, expbeg,
+                    itemlen - width + 1, itemlen,
+                    sign, de, expwid );
+    goto adjust_index;
+
+signed_conversion: ;   
+    if( longval >= 0 )
+      itembeg = myultoa( longval, itembuf, 10 );
+    else
+    {
+      itembuf[0] = '-';
+      myultoa( -longval, itembuf+1, 10 );
+      itembeg = itembuf;
+    }  
+    itemlen = strlen( itembeg );
+    goto move_item;
+
+unsigned_conversion: ;
+    itembeg = myultoa( ulongval, itembuf, 10 );
+    itemlen = strlen( itembeg );
+    goto move_item;
+
+move_item: ;
+    if( !width )
+      width = itemlen;
+
+    /* check remaining space */
+    if( actual_index + width > iostrlen )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+
+    /* move item, filling or truncating or overflow-evidencing */
+    if( itemlen == width )
+      memcpy( iostrptr + actual_index, itembeg, itemlen );
+    else
+      if( itemlen < width )
+        if( leftadjust )
+          memset( memcpy( iostrptr + actual_index, itembeg, itemlen )
+                  + itemlen,
+                  paddingchar, width - itemlen );
+        else
+          memcpy( memset( iostrptr + actual_index, 
+                          paddingchar, width - itemlen )
+                  + width - itemlen,
+                  itembeg, itemlen );
+      else
+        if( overflowev )
+          memset( iostrptr + actual_index, '*', width );
+        else
+          if( leftadjust )
+            memcpy( iostrptr + actual_index, itembeg, width );
+          else
+            memcpy( iostrptr + actual_index, 
+                    itembeg + itemlen - width, width );
+
+  /*
+   *  adjust.
+   */
+adjust_index: ;
+  actual_index += width;
+  if( actual_index > maximum_index )
+    maximum_index = actual_index;
+  }
+}
+
+static
+void outedit( void )
+{
+  int nchars;
+
+  if( dynamicwid )
+    clausewidth = get_field_width();
+  switch( editcode )
+  { 
+  case SpaceSkip:
+    nchars = repetition*clausewidth;
+    if( actual_index + nchars > iostrlen )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+    memset( iostrptr + actual_index, ' ', nchars );
+    actual_index += nchars;
+    if( actual_index > maximum_index )
+      maximum_index = actual_index;
+    break;
+
+  case SkipLeft:
+    nchars = repetition*clausewidth;
+    if(  actual_index - nchars < 0 )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+    actual_index -= nchars;
+    break;
+
+  case SkipRight:
+    nchars = repetition*clausewidth;
+    if( actual_index + nchars > iostrlen )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+    actual_index += nchars;
+    if( actual_index > maximum_index )
+    {
+      memset( iostrptr + maximum_index, ' ', actual_index - maximum_index );
+      maximum_index = actual_index;
+    }
+    break;
+  
+  case Tabulation:
+    if( clausewidth >= iostrlen )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+    actual_index = clausewidth;
+    if( actual_index > maximum_index )
+    {
+      memset( iostrptr + maximum_index, ' ', actual_index - maximum_index );
+      maximum_index = actual_index;
+    }  
+    break;
+  }
+}
+
+
+static
+void inpioctrl( void )
+{
+  unsigned short hlen;
+  if( !textptr )
+    IOEXCEPTION( TEXTFAIL, IO_CONTROL_NOT_VALID );
+  if( iocode != EndPage )
+  {
+    jmp_buf ioerror;
+    unsigned long info;
+
+    if (textptr->access_sub->association)
+      {
+       if( (info = setjmp( ioerror )) )
+         IOEXCEPTION( info>>16, info & 0xffff );    
+       while( repetition-- )
+         {
+           __readrecord( textptr->access_sub, textindex,
+                        (char*)textptr->text_record, 
+                        __FILE__, __LINE__ );
+           actual_index = 0;
+           MOV2(&hlen,&textptr->text_record->len);
+           iostrlen = hlen;
+         }
+      }
+    else
+      IOEXCEPTION (NOTCONNECTED, IS_NOT_CONNECTED);
+  }
+}
+
+/* specify pre/post in the order "/+-?!" */
+static
+char* pre_char =  "\0\f\0\r\0"; /* Z.200: "\n\f\0\n\0" */
+static
+char* post_char = "\n\n\r\0\0"; /* Z.200: "\r\r\r\0\0" */
+
+static
+void outioctrl( void )
+{
+  Association_Mode* assoc;
+  unsigned short hlen;
+  if( !textptr )
+    IOEXCEPTION( TEXTFAIL, IO_CONTROL_NOT_VALID );
+  if( (assoc = textptr->access_sub->association) )
+  {
+    jmp_buf ioerror;
+    unsigned long info;
+    if( (info = setjmp( ioerror )) )
+      IOEXCEPTION( info>>16, info & 0xffff );    
+
+    while( repetition-- )
+    {
+      if( iocode != EndPage )
+      {
+        if( TEST_FLAG( assoc, IO_FIRSTLINE ) )
+        {
+          CLR_FLAG( assoc, IO_FIRSTLINE );
+          assoc->ctl_pre = '\0';
+        }
+        else
+        {
+          if( TEST_FLAG( assoc, IO_FORCE_PAGE ) )
+          {
+            CLR_FLAG( assoc, IO_FORCE_PAGE );
+            assoc->ctl_pre = '\f';
+         }
+          else
+            assoc->ctl_pre = pre_char[iocode];
+        }
+        assoc->ctl_post = post_char[iocode];
+        hlen = actual_index;
+        MOV2(&textptr->text_record->len,&hlen);
+        __writerecord( textptr->access_sub, textindex,
+                       (char*)textptr->text_record,
+                       textptr->text_record->len,
+                       __FILE__, __LINE__ );
+        hlen = actual_index = 0;
+        MOV2(&textptr->text_record->len,&hlen);
+      }
+      else if( !TEST_FLAG( textptr, IO_FIRSTLINE ) )
+       SET_FLAG( textptr, IO_FORCE_PAGE );
+      assoc->ctl_pre = assoc->ctl_post = '\0';
+    }
+  }
+  else
+    IOEXCEPTION (NOTCONNECTED, IS_NOT_CONNECTED);
+}
+
+static
+void (**actionptr)( void );
+static
+void (*readactions[])( void ) = { inpconv, inpedit, inpioctrl };
+static
+void (*writeactions[])( void ) = { outconv, outedit, outioctrl };
+
+
+static
+void emitstr( char* begtxt, char* endtxt )
+{  
+  char c;
+  int  nchars = endtxt - begtxt;
+  if( actual_index + nchars > iostrlen )
+      IOEXCEPTION( TEXTFAIL, TEXT_LOC_OVERFLOW );
+  memcpy( iostrptr + actual_index, begtxt, nchars );
+  actual_index += nchars;
+  if( actual_index > maximum_index )
+    maximum_index = actual_index;
+}
+
+static
+void scanstr( char* begtxt, char* endtxt )
+{  
+  int  nchars = endtxt - begtxt;
+  if( actual_index + nchars > iostrlen )
+    IOEXCEPTION( TEXTFAIL, NO_CHARS_FOR_TEXT );
+  if( strncmp( iostrptr + actual_index, begtxt, nchars ) )
+    IOEXCEPTION( TEXTFAIL, FORMAT_TEXT_MISMATCH );
+  actual_index += nchars;
+}
+
+void (*ftextptr) ( char*, char* );
+
+static
+formatexit_t scanformcont( char* fcs, int len,
+                           char** fcsptr, int* lenptr )
+{
+  char          curr; 
+  fcsstate_t    state  = FormatText;
+  unsigned long buf;
+  int           dig;
+  acttype_t     action;
+  char*         begtxt = fcs;
+
+  while( len-- )
+  {
+    curr = *fcs++;
+    switch( state )
+    {
+    case FormatText: 
+      if( curr == '%' )
+      {
+        ftextptr( begtxt, fcs-1 );
+        state = FirstPercent;
+      }
+      break;
+
+after_first_percent: ;
+    case FirstPercent: 
+      if( curr == '%' )
+      {
+        state = FormatText;
+        begtxt = fcs - 1;
+        break;
+      }
+      if( curr == ')' )
+      {
+        *lenptr = len;
+        *fcsptr = fcs;
+        return EndAtParen;
+      }
+      if( isDEC(curr) )
+      {
+        state = RepFact;
+        repetition = curr - '0';
+        break;
+      }
+
+      repetition = 1; 
+
+test_for_control_codes: ;
+      if( isCVC(curr) )
+      {
+        state = ConvClause;
+        action = ConvAct;
+        convcode = strchr( CONVERSIONCODES, curr ) - CONVERSIONCODES;
+        leftadjust = False;
+        overflowev = False;
+        dynamicwid = False;
+        paddingdef = False;
+        paddingchar = ' ';
+        fractiondef = False;
+        /* fractionwidth = 0; default depends on mode ! */
+        exponentdef = False;
+        exponentwidth = 3;
+        clausewidth = 0;        
+        break;        
+      }
+      if( isEDC(curr) )
+      {
+        state = EditClause;
+        action = EditAct;
+        editcode = strchr( EDITCODES, curr ) - EDITCODES;
+        dynamicwid = False;
+        clausewidth = editcode == Tabulation ? 0 : 1;        
+        break;        
+      }
+      if( isIOC(curr) )
+      {
+        state = ClauseEnd;
+        action = IOAct;
+        iocode = strchr( IOCODES, curr ) - IOCODES;
+        break;        
+      }
+      if( curr == '(' )
+      {
+        unsigned long times = repetition;
+        int  cntlen;
+        char* cntfcs;         
+        while( times-- )
+        {        
+          if( scanformcont( fcs, len, &cntfcs, &cntlen ) != EndAtParen )
+            IOEXCEPTION( TEXTFAIL, UNMATCHED_OPENING_PAREN );
+        }
+        fcs = cntfcs;
+        len = cntlen;
+        state  = FormatText;
+        begtxt = fcs;
+        break;
+      }
+      IOEXCEPTION( TEXTFAIL, BAD_FORMAT_SPEC_CHAR );
+
+    case RepFact:
+      if( isDEC(curr) )
+      {
+        dig = curr - '0';
+        if( repetition > (ULONG_MAX - dig)/10 )
+          IOEXCEPTION( TEXTFAIL, REPFAC_OVERFLOW );
+        repetition = repetition*10 + dig;
+        break;
+      }
+      goto test_for_control_codes;
+
+    case ConvClause:
+      if( isDEC(curr) )
+      {
+        state = ClauseWidth;
+        clausewidth = curr - '0';
+        break;
+      }
+      if( curr == 'L' )  
+      {
+        if( leftadjust ) 
+          IOEXCEPTION( TEXTFAIL, DUPLICATE_QUALIFIER );
+        leftadjust = True;
+        break;
+      }
+      if( curr == 'E' )
+      {
+        if( overflowev ) 
+          IOEXCEPTION( TEXTFAIL, DUPLICATE_QUALIFIER );
+        overflowev = True;
+        break;
+      }
+      if( curr == 'P' )
+      {
+        if( paddingdef ) 
+          IOEXCEPTION( TEXTFAIL, DUPLICATE_QUALIFIER );
+        paddingdef = True;
+        state = CatchPadding;
+        break;
+      }
+
+test_for_variable_width: ;
+      if( curr == 'V' )
+      {
+        dynamicwid = True;
+        state = AfterWidth;
+        break;
+      }
+      goto test_for_fraction_width;
+
+    case ClauseWidth:
+      if( isDEC(curr) )
+      {
+        dig = curr - '0';
+        if( clausewidth > (ULONG_MAX - dig)/10 )
+          IOEXCEPTION( TEXTFAIL, CLAUSE_WIDTH_OVERFLOW );
+        clausewidth = clausewidth*10 + dig;
+        break;
+      }
+      /* fall through */
+
+test_for_fraction_width: ;
+    case AfterWidth:
+      if( curr == '.' )
+      {
+        if( convcode != DefaultConv && convcode != ScientConv )
+          IOEXCEPTION( TEXTFAIL, NO_FRACTION );
+        fractiondef = True;
+        state = FractWidth;
+        break;
+      }
+      goto test_for_exponent_width;
+
+    case FractWidth:
+      if( isDEC( curr ) )
+      {
+        state = FractWidthCont;
+        fractionwidth = curr - '0';
+        break;
+      }
+      else
+        IOEXCEPTION( TEXTFAIL, NO_FRACTION_WIDTH );
+
+    case FractWidthCont:
+      if( isDEC( curr ) )
+      {
+        dig = curr - '0';
+        if( fractionwidth > (ULONG_MAX - dig)/10 )
+          IOEXCEPTION( TEXTFAIL, FRACTION_WIDTH_OVERFLOW );
+        fractionwidth = fractionwidth*10 + dig;
+        break;
+      }
+             
+test_for_exponent_width: ;
+      if( curr == ':' )
+      {
+        if( convcode != ScientConv )
+          IOEXCEPTION( TEXTFAIL, NO_EXPONENT );
+        exponentdef = True;
+        state = ExpoWidth;
+        break;
+      }
+      goto test_for_final_percent;
+
+    case ExpoWidth:
+      if( isDEC( curr ) )
+      {
+        state = ExpoWidthCont;
+        exponentwidth = curr - '0';
+        break;
+      }
+      else
+        IOEXCEPTION( TEXTFAIL, NO_EXPONENT_WIDTH );
+
+    case ExpoWidthCont:
+      if( isDEC( curr ) )
+      {
+        dig = curr - '0';
+        if( exponentwidth > (ULONG_MAX - dig)/10 )
+          IOEXCEPTION( TEXTFAIL, EXPONENT_WIDTH_OVERFLOW );
+        exponentwidth = exponentwidth*10 + dig;
+        break;
+      }
+      /* fall through  */
+
+test_for_final_percent: ;
+    case ClauseEnd:
+      if( curr == '%' )
+      {
+        state = LastPercent;
+        break;
+      }
+  do_the_action: ;
+      actionptr[action]();
+      state = FormatText;
+      begtxt = fcs - 1;
+      break;
+
+    case CatchPadding:
+      paddingchar = curr;
+      state = ConvClause;
+      break;
+
+    case EditClause:
+      if( isDEC(curr) )
+      {
+        state = ClauseWidth;
+        clausewidth = curr - '0';
+        break;
+      }
+      goto test_for_variable_width; 
+
+    case LastPercent:
+      actionptr[action]();
+      if( curr == '.' )
+      {
+        state = FormatText;
+        begtxt = fcs;
+        break;
+      }
+      goto after_first_percent;
+
+    default:
+      IOEXCEPTION( TEXTFAIL, INTERNAL_ERROR );
+    }
+  }
+  switch( state )
+  {
+  case FormatText:
+    ftextptr( begtxt, fcs );
+    break;
+  case FirstPercent: 
+  case LastPercent:
+  case RepFact:
+  case FractWidth:
+  case ExpoWidth:
+    IOEXCEPTION( TEXTFAIL, BAD_FORMAT_SPEC_CHAR );
+  case CatchPadding:
+    IOEXCEPTION( TEXTFAIL, NO_PAD_CHAR );
+  default:
+    actionptr[action]();
+  }
+
+  *lenptr = len;
+  *fcsptr = fcs;
+  return NormalEnd;
+}
+
+static
+void
+__read_format (char*           fmtptr,
+               int             fmtlen,
+               __tmp_IO_list*  ioptr,
+               int             iolen,
+               void*           inpptr,
+               int             inplen )
+{
+  formatexit_t res;
+  unsigned short l;
+
+  iostrptr = (char*)inpptr;
+  iostrlen = inplen;
+
+  /* initialisation */
+  iolist_index = 0;
+  iolistptr    = ioptr; 
+  iolistlen    = iolen;
+  
+  actionptr = readactions;
+  ftextptr = scanstr;
+     
+  if( (res = scanformcont( fmtptr, fmtlen, &fmtptr, &fmtlen )) == EndAtParen )
+    IOEXCEPTION( TEXTFAIL, UNMATCHED_CLOSING_PAREN );
+
+  if( iolist_index != iolen )
+    IOEXCEPTION( TEXTFAIL, EXCESS_IOLIST_ELEMENTS );
+
+  return;
+}
+
+void
+__readtext_f( Text_Mode*      the_text_loc,
+              signed long     the_index,
+              char*           fmtptr,
+              int             fmtlen,
+              __tmp_IO_list*  ioptr,
+              int             iolen,
+              char*           file,
+              int             line )
+{
+  unsigned long info;
+
+  if( (info = setjmp( __io_exception )) )
+    CHILLEXCEPTION( file, line, info>>16, info & 0xffff );
+
+  textptr       = the_text_loc;
+  textrecptr    = textptr->text_record;
+  actual_index  = textptr->actual_index;
+  textindex     = the_index;
+
+  __read_format ( fmtptr, fmtlen, ioptr, iolen,
+                  (char*)textrecptr + 2, textptr->text_record->len );
+  textptr->actual_index = actual_index;
+}
+
+void
+__readtext_s( void*           string_ptr,
+              int             string_len,
+              char*           fmtptr,
+              int             fmtlen,
+              __tmp_IO_list*  ioptr,
+              int             iolen,
+              char*           file,
+              int             line )
+{
+  int info;
+
+  if( (info = setjmp( __io_exception )) )
+    CHILLEXCEPTION( file, line, info>>16, info & 0xffff );
+
+  textptr      = NULL;
+  actual_index = 0;
+
+  __read_format ( fmtptr, fmtlen,  ioptr, iolen, string_ptr, string_len );
+}
+
+static
+void
+__write_format (char*           fmtptr,
+                int             fmtlen,
+                __tmp_IO_list*  ioptr,
+                int             iolen,
+                void*           outptr,
+                int             outlen )
+{
+  formatexit_t res;
+  unsigned short l;
+
+  /* initialisation */
+  maximum_index = actual_index;
+  iolist_index = 0;
+  
+  actionptr = writeactions;
+  ftextptr  = emitstr;
+  iolistptr = ioptr; 
+  iolistlen = iolen;
+  iostrptr  = (char *)outptr + 2;
+  iostrlen  = outlen;
+
+  if( (res = scanformcont( fmtptr, fmtlen, &fmtptr, &fmtlen )) == EndAtParen )
+    IOEXCEPTION( TEXTFAIL, UNMATCHED_CLOSING_PAREN );
+
+  if( iolist_index != iolen )
+    IOEXCEPTION( TEXTFAIL, EXCESS_IOLIST_ELEMENTS );
+
+  /* set length of output string */
+#if _TEXTIO_DEBUG_
+  printf( "maximum index = %d\n", maximum_index );
+#endif
+  l = maximum_index;
+  MOV2(outptr,&l);
+  return;
+}
+
+void
+__writetext_f( Text_Mode*      the_text_loc,
+               signed long     the_index,
+               char*           fmtptr,
+               int             fmtlen,
+               __tmp_IO_list*  ioptr,
+               int             iolen,
+               char*           file,
+               int             line )
+{
+  int info;
+
+  if( (info = setjmp( __io_exception )) )
+    CHILLEXCEPTION( file, line, info>>16, info & 0xffff );
+
+  textptr       = the_text_loc;
+  textrecptr    = the_text_loc->text_record;
+  textindex     = the_index;
+  iolistptr     = ioptr; 
+  iolistlen     = iolen;
+
+  actual_index = textptr->actual_index;
+  __write_format ( fmtptr, fmtlen, ioptr, iolen,
+                   textrecptr, textptr->access_sub->reclength - 2 );
+  textptr->actual_index = actual_index;
+}
+
+void
+__writetext_s( void*           string_ptr,
+               int             string_len,
+               char*           fmtptr,
+               int             fmtlen,
+               __tmp_IO_list*  ioptr,
+               int             iolen,
+               char*           file,
+               int             line )
+{
+  int info;
+
+  if( (info = setjmp( __io_exception )) )
+    CHILLEXCEPTION( file, line, info>>16, info & 0xffff );
+
+  textptr      = NULL;
+  actual_index = 0;
+
+  __write_format ( fmtptr, fmtlen, ioptr, iolen, string_ptr, string_len );
+}
diff --git a/libchill/format.h b/libchill/format.h
new file mode 100644 (file)
index 0000000..8b554f4
--- /dev/null
@@ -0,0 +1,71 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef _format_h_
+#define _format_h_
+
+#include "iomodes.h"
+#include "fileio.h"
+
+extern Text_Mode __stdin_text;
+extern Text_Mode __stdout_text;
+extern Text_Mode __stderr_text;
+
+void
+__readtext_f( Text_Mode*      TextLoc,
+              signed long     Index,
+              char*           fmtptr,
+              int             fmtlen,
+              __tmp_IO_list*  ioptr,
+              int             iolen,
+              char*           file,
+              int             line );
+
+void
+__readtext_s( void*           string_ptr,
+              int             string_len,
+              char*           fmtptr,
+              int             fmtlen,
+              __tmp_IO_list*  ioptr,
+              int             iolen,
+              char*           file,
+              int             line );
+
+void
+__writetext_f( Text_Mode*      Text_Loc,
+               signed long     Index,
+               char*           fmtptr,
+               int             fmtlen,
+               __tmp_IO_list*  ioptr,
+               int             iolen,
+               char*           file,
+               int             line );
+
+void
+__writetext_s( void*           string_ptr,
+               int             string_len,
+               char*           fmtptr,
+               int             fmtlen,
+               __tmp_IO_list*  ioptr,
+               int             iolen,
+               char*           file,
+               int             line );
+
+#endif _format_h_
diff --git a/libchill/getassoc.c b/libchill/getassoc.c
new file mode 100644 (file)
index 0000000..1bc92aa
--- /dev/null
@@ -0,0 +1,37 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Association_Mode*
+__getassociation( void* the_transfer, char* file, int line )
+{
+  Access_Mode* the_access;
+
+  if( !the_transfer )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS );
+
+  if( TEST_FLAG((Text_Mode*)the_transfer, IO_TEXTLOCATION ))
+    the_access = ((Text_Mode*)the_transfer)->access_sub;
+  else
+    the_access = (Access_Mode*)the_transfer;
+
+  return the_access->association;
+}
diff --git a/libchill/gettextaccess.c b/libchill/gettextaccess.c
new file mode 100644 (file)
index 0000000..28f976d
--- /dev/null
@@ -0,0 +1,31 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Access_Mode*
+__gettextaccess( Text_Mode* the_text, char* file, int line )
+{
+  if( !the_text )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_TEXT );
+
+  return the_text->access_sub;
+}
+
diff --git a/libchill/gettextindex.c b/libchill/gettextindex.c
new file mode 100644 (file)
index 0000000..60fa703
--- /dev/null
@@ -0,0 +1,30 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+unsigned long
+__gettextindex( Text_Mode* the_text, char* file, int line )
+{
+  if( !the_text )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_TEXT );
+
+  return the_text->actual_index;
+}
diff --git a/libchill/gettextrecord.c b/libchill/gettextrecord.c
new file mode 100644 (file)
index 0000000..16934f5
--- /dev/null
@@ -0,0 +1,30 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+VarString*
+__gettextrecord( Text_Mode* the_text, char* file, int line )
+{
+  if( !the_text )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_TEXT );
+
+  return the_text->text_record;
+}
diff --git a/libchill/getusage.c b/libchill/getusage.c
new file mode 100644 (file)
index 0000000..2fcaf77
--- /dev/null
@@ -0,0 +1,40 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Usage_Mode
+__getusage( void* the_transfer, char* file, int line )
+{
+  Access_Mode* the_access;
+
+  if( !the_transfer )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS );
+
+  if( TEST_FLAG((Text_Mode*)the_transfer, IO_TEXTLOCATION ))
+    the_access = ((Text_Mode*)the_transfer)->access_sub;
+  else
+    the_access = (Access_Mode*)the_transfer;
+
+  if( !the_access->association )
+    CHILLEXCEPTION( file, line, NOTCONNECTED, IS_NOT_CONNECTED );
+  return the_access->association->usage;
+}
+
diff --git a/libchill/inbitstr.c b/libchill/inbitstr.c
new file mode 100644 (file)
index 0000000..dd3f127
--- /dev/null
@@ -0,0 +1,74 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+extern void __cause_ex1 (char *exname, char *file, int lineno);
+
+/*
+ * function __inbitstring
+ *
+ * parameters:
+ *     bitno           bit number within set
+ *     powerset        the powerset
+ *     bitlength       length of powerset in bits
+ *      minval          number of lowest bit stored
+ *     fname           filename of caller
+ *     lineno          linenumber of caller
+ *
+ * returns:
+ *     int             1 .. found
+ *                     0 .. not found
+ *
+ * exceptions:
+ *  rangefail
+ *
+ * abstract:
+ *  checks if a given value is included in a bitstring
+ *
+ */
+int
+__inbitstring (bitno, powerset, bitlength, minval, fname, lineno)
+     unsigned long  bitno;
+     SET_WORD      *powerset;
+     unsigned long  bitlength;
+     long           minval;
+     char          *fname;
+     int            lineno;
+    
+{
+  if (powerset == NULL
+      || bitno < minval 
+      || (bitno - minval) >= bitlength)
+    __cause_ex1 ("rangefail", fname, lineno);
+
+  bitno -= minval;
+  if (bitlength <= SET_CHAR_SIZE)
+    return GET_BIT_IN_CHAR (*((SET_CHAR *)powerset), bitno);
+  else if (bitlength <= SET_SHORT_SIZE)
+    return GET_BIT_IN_SHORT (*((SET_SHORT *)powerset), bitno);
+  else
+    return GET_BIT_IN_WORD (powerset[bitno / SET_WORD_SIZE],
+                           bitno % SET_WORD_SIZE);
+}
diff --git a/libchill/indexable.c b/libchill/indexable.c
new file mode 100644 (file)
index 0000000..dde2604
--- /dev/null
@@ -0,0 +1,31 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__indexable( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+  if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+  return TEST_FLAG(the_assoc, IO_INDEXABLE) ? True : False;
+}
diff --git a/libchill/inps.c b/libchill/inps.c
new file mode 100644 (file)
index 0000000..d01d76a
--- /dev/null
@@ -0,0 +1,65 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __inpowerset
+ *
+ * parameters:
+ *     bitno           bit number within set
+ *     powerset        the powerset
+ *     bitlength       length of powerset in bits
+ *      minval          number of lowest bit stored
+ *
+ * returns:
+ *     int             1 .. found
+ *                     0 .. not found
+ *
+ * exceptions:
+ *  rangefail
+ *
+ * abstract:
+ *  checks if a given value is included in a powerset
+ *
+ */
+int
+__inpowerset (bitno, powerset, bitlength, minval)
+     unsigned long  bitno;
+     SET_WORD      *powerset;
+     unsigned long  bitlength;
+     long           minval;
+{
+  if (bitno < minval || (bitno - minval) >= bitlength)
+    return 0;
+    
+  bitno -= minval;
+  if (bitlength <= SET_CHAR_SIZE)
+    return GET_BIT_IN_CHAR (*((SET_CHAR *)powerset), bitno);
+  else if (bitlength <= SET_SHORT_SIZE)
+    return GET_BIT_IN_SHORT (*((SET_SHORT *)powerset), bitno);
+  else
+    return GET_BIT_IN_WORD (powerset[bitno / SET_WORD_SIZE],
+                           bitno % SET_WORD_SIZE);
+}
diff --git a/libchill/inttime.c b/libchill/inttime.c
new file mode 100644 (file)
index 0000000..b82c5ec
--- /dev/null
@@ -0,0 +1,85 @@
+/* Implement timing-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <time.h>
+
+typedef struct
+{
+  void          *p;
+  unsigned long len;
+} Descr;
+
+typedef Descr   **Toutlist;
+
+#define ASSIGN_VALUE(OUT,VAL)          \
+do                                     \
+{                                      \
+  if (OUT)                             \
+    switch (OUT->len)                  \
+      {                                \
+      case 1:                          \
+       *(char *)((OUT)->p) = VAL;     \
+       break;                         \
+      case 2:                          \
+       *(short *)((OUT)->p) = VAL;    \
+       break;                         \
+      case 4:                          \
+       *(int *)((OUT)->p) = VAL;      \
+       break;                         \
+      }                                \
+} while (0)
+
+
+/*
+ * function _inttime
+ *
+ * parameters:
+ *     t    time_t
+ *     list the pointers to the results
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     perform the INTTIME builtin call
+ *
+ */
+
+void
+_inttime (timer, outlist)
+     time_t   timer;
+     Toutlist outlist;
+{
+  struct tm  *time_str;
+
+  /* get struct tm from time_t */
+  time_str = localtime (&timer);
+
+  /* assign the values */
+  ASSIGN_VALUE (outlist[0], time_str->tm_year + 1900);
+  ASSIGN_VALUE (outlist[1], time_str->tm_mon + 1);
+  ASSIGN_VALUE (outlist[2], time_str->tm_mday);
+  ASSIGN_VALUE (outlist[3], time_str->tm_hour);
+  ASSIGN_VALUE (outlist[4], time_str->tm_min);
+  ASSIGN_VALUE (outlist[5], time_str->tm_sec);
+}
diff --git a/libchill/ioerror.c b/libchill/ioerror.c
new file mode 100644 (file)
index 0000000..8c9fad4
--- /dev/null
@@ -0,0 +1,45 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <setjmp.h>
+
+/* define names of IO-exceptions */
+
+char * __IO_exception_names[] =
+{
+  "UNUSED",
+  "notassociated",
+  "associatefail",
+  "createfail",
+  "deletefail",
+  "modifyfail",
+  "connectfail",
+  "notconnected",
+  "empty",
+  "rangefail",
+  "spacefail",
+  "readfail",
+  "writefail",
+  "textfail",
+};
+
+jmp_buf __io_exception;
+
+jmp_buf __rw_exception;
diff --git a/libchill/ioerror.h b/libchill/ioerror.h
new file mode 100644 (file)
index 0000000..e2ddfe5
--- /dev/null
@@ -0,0 +1,161 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef _ioerror_h_
+#define _ioerror_h_
+
+#include <setjmp.h>
+
+/* Note: numbers must be in the same order as
+   strings in ioerror.c */
+typedef enum 
+{ NOTASSOCIATED = 1,
+  ASSOCIATEFAIL,
+  CREATEFAIL, 
+  DELETEFAIL,
+  MODIFYFAIL,
+  CONNECTFAIL,
+  NOTCONNECTED,
+  EMPTY,
+  RANGEFAIL,
+  SPACEFAIL,
+  READFAIL,
+  WRITEFAIL,
+  TEXTFAIL
+} io_exceptions_t;
+
+#ifndef FIRST_IO_ERROR_NUMBER
+#define FIRST_IO_ERROR_NUMBER 0
+#endif
+
+typedef enum {
+  FIRST_AND_UNUSED = FIRST_IO_ERROR_NUMBER,
+  INTERNAL_ERROR,
+  INVALID_IO_LIST,
+  REPFAC_OVERFLOW,
+  CLAUSE_WIDTH_OVERFLOW,
+  UNMATCHED_CLOSING_PAREN,
+  UNMATCHED_OPENING_PAREN,
+  BAD_FORMAT_SPEC_CHAR,
+  NO_PAD_CHAR,
+  IO_CONTROL_NOT_VALID,
+  DUPLICATE_QUALIFIER,
+  NO_FRACTION_WIDTH,
+  NO_EXPONENT_WIDTH,
+  FRACTION_WIDTH_OVERFLOW,
+  EXPONENT_WIDTH_OVERFLOW,
+  NO_FRACTION,
+  NO_EXPONENT,
+  NEGATIVE_FIELD_WIDTH,
+  TEXT_LOC_OVERFLOW,
+  IOLIST_EXHAUSTED,
+  CONVCODE_MODE_MISFIT,
+  SET_CONVERSION_ERROR,
+  BOOL_CONVERSION_ERROR,
+  NON_INT_FIELD_WIDTH,
+  EXCESS_IOLIST_ELEMENTS,
+  NOT_ENOUGH_CHARS,
+  NO_CHARS_FOR_INT,
+  NO_CHARS_FOR_FLOAT,
+  NO_EXPONENT_VAL,
+  INT_VAL_OVERFLOW,
+  REAL_OVERFLOW,
+  NO_DIGITS_FOR_INT,
+  NO_DIGITS_FOR_FLOAT,
+  NO_CHARS_FOR_SET,
+  NO_CHARS_FOR_CHAR,
+  NO_CHARS_FOR_BOOLS,
+  NO_CHARS_FOR_CHARS,
+  NO_CHARS_FOR_TEXT,
+  NO_CHARS_FOR_EDIT,
+  NO_SPACE_TO_SKIP,
+  FORMAT_TEXT_MISMATCH,
+  INTEGER_RANGE_ERROR,
+  SET_RANGE_ERROR,
+  CHAR_RANGE_ERROR,
+  INVALID_CHAR,
+/* end of formatting errors */
+  NULL_ASSOCIATION,
+  NULL_ACCESS,
+  NULL_TEXT,
+  IS_NOT_ASSOCIATED,
+  IS_ASSOCIATED,
+  GETCWD_FAILS,
+  INVALID_ASSOCIATION_MODE,
+  FILE_EXISTING,
+  CREATE_FAILS,
+  DELETE_FAILS,
+  RENAME_FAILS,
+  IMPL_RESTRICTION,
+  NOT_EXISTING,
+  NOT_READABLE,
+  NOT_WRITEABLE,
+  NOT_INDEXABLE,
+  NOT_SEQUENCIBLE,
+  NO_CURRENT_POS,
+  NOT_VARIABLE,
+  NOT_FIXED,
+  NOT_INDEXED, 
+  LENGTH_CHANGE,
+  LSEEK_FAILS,
+  BUFFER_ALLOC,
+  OPEN_FAILS,
+  NO_ACCESS_SUBLOCATION, 
+  BAD_INDEX,
+  IS_NOT_CONNECTED,
+  NO_PATH_NAME,
+  PATHNAME_ALLOC,
+  BAD_USAGE,
+  OUT_OF_FILE,
+  NULL_STORE_LOC,
+  STORE_LOC_ALLOC,
+  OS_IO_ERROR,
+  RECORD_TOO_LONG,
+  RECORD_TOO_SHORT,
+  BAD_TEXTINDEX,
+  NULL_TEXTREC
+} io_info_word_t;
+
+
+extern
+char* io_info_text [];
+
+extern
+char* exc_text [];
+extern 
+jmp_buf __io_exception;
+
+extern 
+jmp_buf __rw_exception;
+
+void __cause_exception (char *ex, char* f, int line, int info);
+extern char * __IO_exception_names[];
+
+#define IOEXCEPTION(EXC,INFO) \
+    longjmp( __io_exception, (EXC<<16) + INFO )
+
+#define RWEXCEPTION(EXC,INFO) \
+    longjmp( __rw_exception, (EXC<<16) + INFO )
+
+#define CHILLEXCEPTION(FILE,LINE,EXC,INFO) \
+    __cause_exception (__IO_exception_names[EXC], FILE, LINE, INFO);
+
+#endif
diff --git a/libchill/iomodes.h b/libchill/iomodes.h
new file mode 100644 (file)
index 0000000..8e254e2
--- /dev/null
@@ -0,0 +1,251 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef _iomodes_h_
+#define _iomodes_h_
+
+#include "auxtypes.h"
+
+typedef enum { ReadOnly, WriteOnly, ReadWrite
+} Usage_Mode;
+
+typedef enum { First, Same, Last
+} Where_Mode;
+
+typedef enum { None, Fixed, VaryingChars
+} Record_t;
+
+/* association flags */
+#define IO_ISASSOCIATED 0x00000001
+#define IO_EXISTING     0x00000002
+#define IO_READABLE     0x00000004
+#define IO_WRITEABLE    0x00000008
+#define IO_INDEXABLE    0x00000010
+#define IO_SEQUENCIBLE  0x00000020
+#define IO_VARIABLE     0x00000040
+#define IO_FIRSTLINE    0x00000100
+#define IO_FORCE_PAGE   0x00000200
+
+struct Access_Mode;
+
+#define READBUFLEN 512
+typedef struct
+{
+  unsigned long len;
+  unsigned long cur;
+  char buf[READBUFLEN];
+} readbuf_t;
+
+typedef struct Association_Mode {
+  unsigned long       flags;      /* INIT = 0 */
+  char*               pathname;
+  struct Access_Mode* access;
+  int                 handle;
+  readbuf_t*          bufptr;
+  long                syserrno;
+  char                usage;
+  char                ctl_pre;
+  char                ctl_post;
+} Association_Mode;
+
+/*
+   rectype   indexed   max. reclength    act. reclength
+   ---------------------------------------------------
+   None        T/F        0
+   Fixed       T/F     SIZE(recmode)  =  SIZE(recmode)
+   Varying       F     SIZE(recmode) >=  length
+*/
+
+/* access/text flags */
+#define IO_TEXTLOCATION 0x80000000
+#define IO_INDEXED      0x00000001
+#define IO_TEXTIO       0x00000002
+#define IO_OUTOFFILE    0x00010000
+
+typedef struct Access_Mode {
+  unsigned long     flags;     /* INIT */   
+  unsigned long     reclength; /* INIT */
+  signed long       lowindex;  /* INIT */
+  signed long       highindex; /* INIT */
+  Association_Mode* association;
+  unsigned long     base;
+  char*             store_loc;
+  Record_t          rectype;   /* INIT */
+} Access_Mode;
+
+typedef struct Text_Mode {
+  unsigned long flags;         /* INIT */
+  VarString*    text_record;   /* INIT */
+  Access_Mode*  access_sub;    /* INIT */
+  unsigned long actual_index;
+} Text_Mode;
+
+typedef enum
+{
+    __IO_UNUSED,
+
+    __IO_ByteVal,
+    __IO_UByteVal,
+    __IO_IntVal,
+    __IO_UIntVal,
+    __IO_LongVal,
+    __IO_ULongVal,
+
+    __IO_ByteLoc,
+    __IO_UByteLoc,
+    __IO_IntLoc,
+    __IO_UIntLoc,
+    __IO_LongLoc,
+    __IO_ULongLoc,
+
+    __IO_ByteRangeLoc,
+    __IO_UByteRangeLoc,
+    __IO_IntRangeLoc,
+    __IO_UIntRangeLoc,
+    __IO_LongRangeLoc,
+    __IO_ULongRangeLoc,
+
+    __IO_BoolVal,
+    __IO_BoolLoc,
+    __IO_BoolRangeLoc,
+
+    __IO_SetVal,
+    __IO_SetLoc,
+    __IO_SetRangeLoc,
+
+    __IO_CharVal,
+    __IO_CharLoc,
+    __IO_CharRangeLoc,
+
+    __IO_CharStrLoc,
+
+    __IO_CharVaryingLoc,
+
+    __IO_BitStrLoc,
+
+    __IO_RealVal,
+    __IO_RealLoc,
+    __IO_LongRealVal,
+    __IO_LongRealLoc
+} __tmp_IO_enum;
+
+typedef struct
+{
+    long        value;
+    char*       name;
+} __tmp_IO_enum_table_type;
+
+typedef struct
+{
+    long                      value;
+    __tmp_IO_enum_table_type* name_table;
+} __tmp_WIO_set;
+
+typedef struct
+{
+    char*       ptr;
+    long        lower;
+    long        upper;
+} __tmp_IO_charrange;
+
+typedef union
+{
+      signed long  slong;
+    unsigned long  ulong;
+}  __tmp_IO_long;
+
+typedef struct
+{
+    void*         ptr;
+    __tmp_IO_long lower;
+    __tmp_IO_long upper;
+} __tmp_IO_intrange;
+
+typedef struct
+{
+    void*           ptr;
+    unsigned long   lower;
+    unsigned long   upper;
+} __tmp_RIO_boolrange;
+
+typedef struct
+{
+    void*                     ptr;
+    long                      length;
+    __tmp_IO_enum_table_type* name_table;
+} __tmp_RIO_set;
+
+typedef struct
+{
+    void*                      ptr;
+    long                       length;
+    __tmp_IO_enum_table_type*  name_table;
+    unsigned long              lower;
+    unsigned long              upper;
+} __tmp_RIO_setrange;
+
+typedef struct
+{
+    char*       string;
+    long        string_length;
+} __tmp_IO_charstring;
+
+typedef union
+{
+    char                     __valbyte;
+    unsigned char            __valubyte;
+    short                    __valint;
+    unsigned short           __valuint;
+    long                     __vallong;
+    unsigned long            __valulong;
+    void*                    __locint;
+    __tmp_IO_intrange        __locintrange;
+
+    unsigned char            __valbool;
+    unsigned char*           __locbool;
+    __tmp_RIO_boolrange      __locboolrange;
+
+    __tmp_WIO_set            __valset;
+    __tmp_RIO_set            __locset;
+    __tmp_RIO_setrange       __locsetrange;
+
+    unsigned char            __valchar;
+    unsigned char*           __locchar;
+    __tmp_IO_charrange       __loccharrange;
+
+    __tmp_IO_charstring      __loccharstring;
+
+    float                    __valreal;
+    float*                   __locreal;
+    double                   __vallongreal;
+    double*                  __loclongreal;
+} __tmp_IO_union;
+
+/*
+ * CAUTION: The longest variant of __tmp_IO_union is 5 words long.
+ * Together with __descr this caters for double alignment where required.
+ */
+typedef struct
+{
+    __tmp_IO_union    __t;
+    __tmp_IO_enum     __descr;
+} __tmp_IO_list;
+
+#endif
diff --git a/libchill/isassociated.c b/libchill/isassociated.c
new file mode 100644 (file)
index 0000000..a3a4d49
--- /dev/null
@@ -0,0 +1,29 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__isassociated( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+  return TEST_FLAG(the_assoc, IO_ISASSOCIATED) ? True : False;
+}
diff --git a/libchill/leps.c b/libchill/leps.c
new file mode 100644 (file)
index 0000000..7c5231a
--- /dev/null
@@ -0,0 +1,76 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __lepowerset
+ *
+ * parameters:
+ *     left            powerset
+ *     right           powerset
+ *     bitlength       length of powerset
+ *
+ * returns:
+ *     int             1 .. left is included in right
+ *                     0 .. not
+ *
+ * abstract:
+ *  check if one powerset is included in another
+ *
+ */
+int
+__lepowerset (left, right, bitlength)
+     SET_WORD      *left;
+     SET_WORD      *right;
+     unsigned long  bitlength;
+{
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      if ((*((SET_CHAR *)left) & *((SET_CHAR *)right))
+         != *((SET_CHAR *)left))
+       return 0;
+      return 1;
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      if ((*((SET_SHORT *)left) & *((SET_SHORT *)right))
+         != *((SET_SHORT *)left))
+       return 0;
+      return 1;
+    }
+  else
+    {
+      SET_WORD *endp = left + BITS_TO_WORDS(bitlength);
+    
+      while (left < endp)
+       {
+         if ((*right & *left) != *left)
+           return 0;
+         left++;
+         right++;
+       }
+      return 1;
+    }
+}
diff --git a/libchill/ltps.c b/libchill/ltps.c
new file mode 100644 (file)
index 0000000..747be42
--- /dev/null
@@ -0,0 +1,86 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __ltpowerset
+ *
+ * parameters:
+ *     left            powerset
+ *     right           powerset
+ *     bitlength       length of powerset
+ *
+ * returns:
+ *     int             1 .. left is proper subset of right
+ *                           (excludes case where left == right)
+ *                     0 .. not
+ *
+ * abstract:
+ *  check if one powerset is included in another
+ *
+ */
+int
+__ltpowerset (left, right, bitlength)
+     SET_WORD      *left;
+     SET_WORD      *right;
+     unsigned long  bitlength;
+{
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      if ((*((SET_CHAR *)left) & *((SET_CHAR *)right))
+         != *((SET_CHAR *)left))
+       return 0;
+      if (*((SET_CHAR *)left) != *((SET_CHAR *)right))
+       return 1;
+      return 0;
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      if ((*((SET_SHORT *)left) & *((SET_SHORT *)right))
+         != *((SET_SHORT *)left))
+       return 0;
+      if (*((SET_SHORT *)left) != *((SET_SHORT *)right))
+       return 1;
+      return 0;
+    }
+  else
+    {
+      SET_WORD *endp = left + BITS_TO_WORDS(bitlength);
+      int all_equal = 1;              /* assume all bits are equal */
+    
+      while (left < endp)
+       {
+         if ((*right & *left) != *left)
+           return 0;
+         if (*left != *right)
+           all_equal = 0;
+         left++;
+         right++;
+       }
+      if (left == endp && all_equal)    /* exclude TRUE return for == case */
+       return 0;
+      return 1;
+    }
+}
diff --git a/libchill/ltstr.c b/libchill/ltstr.c
new file mode 100644 (file)
index 0000000..683a947
--- /dev/null
@@ -0,0 +1,55 @@
+/* Implement string-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Bill Cox
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define MIN(a, b)  ((a) < (b) ? (a) : (b))
+
+/*
+ * function __ltstring
+ *
+ * parameters:
+ *     S1 - pointer to left string
+ *     LEN1 - length of left string
+ *     S2 - pointer to right string
+ *     LEN2 - length of right string
+ *
+ * returns:
+ *     1 if left string is a proper subset of the right string, 0 otherwise
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     compares two character strings for subset relationship
+ *
+ */
+
+int __ltstring (s1, len1, s2, len2)
+     char *s1;
+     int len1;
+     char *s2;
+     int len2;
+{
+  int i;
+
+  i = memcmp (s1, s2, MIN (len1, len2));
+  if (i)
+    return (i < 0);
+  return (len1 < len2);
+}
diff --git a/libchill/memmove.c b/libchill/memmove.c
new file mode 100644 (file)
index 0000000..7622428
--- /dev/null
@@ -0,0 +1,63 @@
+/* Implement string-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Bill Cox
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define MIN(a, b)  ((a) < (b) ? (a) : (b))
+
+
+/*
+ * function memmove
+ *
+ * parameters:
+ *     S1 - pointer to destination string
+ *     S2 - pointer to source string
+ *     LEN - length of string
+ *
+ * returns:
+ *     pointer to destination string
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     copies a string safely, where the source and dest areas may overlap.
+ *
+ */
+
+void *
+memmove (s1, s2, n)
+     void *s1;
+     const void *s2;
+     int n;
+{
+  char *sc1 = s1;
+  const char *sc2 = s2;
+
+  if (sc2 < sc1 && (sc1 < sc2 + n))
+    for (sc1 += n, sc2 += n; 0 < n; --n)
+      *--sc1 = *--sc2;
+  else
+#if 0
+    for (; 0 < n; --n)
+      *sc1++ = *sc2++;
+#else
+    memcpy (sc1, sc2, n);
+#endif
+  return s1;
+}
diff --git a/libchill/neps.c b/libchill/neps.c
new file mode 100644 (file)
index 0000000..220577d
--- /dev/null
@@ -0,0 +1,52 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __nepowerset
+ *
+ * parameters:
+ *     left            left powerset
+ *     right           right powerset
+ *     bitlength       length of powerset in bits
+ *
+ * returns:
+ *    1 if powersets are not equal, bit for bit
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  compares two powersets for inequality
+ *
+ */
+int
+__nepowerset (left, right, bitlength)
+     SET_WORD *left;
+     SET_WORD *right;
+     unsigned long bitlength;
+{
+  return ! __eqpowerset (left, right, bitlength);
+}
diff --git a/libchill/notps.c b/libchill/notps.c
new file mode 100644 (file)
index 0000000..dd683ed
--- /dev/null
@@ -0,0 +1,81 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __notpowerset
+ *
+ * parameters:
+ *     out             output powerset
+ *     left            input powerset
+ *     bitlength       length of powerset in bits
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *
+ */
+
+void
+__notpowerset (out, left, bitlength)
+     SET_WORD      *out;
+     SET_WORD      *left;
+     unsigned long  bitlength;
+{
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      *((SET_CHAR *)out) = ~ (*((SET_CHAR *)left));
+#if 0
+      SET_CHAR tmp;
+      tmp = *((SET_CHAR *)left);
+      tmp = ~ tmp;
+      *((SET_CHAR *)out) = tmp;
+
+      MASK_UNUSED_CHAR_BITS((SET_CHAR *)out, bitlength);
+      *((SET_CHAR *)out) = ~ *((SET_CHAR *)left);
+      MASK_UNUSED_CHAR_BITS((SET_CHAR *)out, bitlength);
+      *((SET_CHAR *)out) = (~(0)) ^  (*((SET_CHAR *)left));
+      MASK_UNUSED_CHAR_BITS((SET_CHAR *)out, bitlength);
+#endif
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      *((SET_SHORT *)out) = ~  (*((SET_SHORT *)left));
+      MASK_UNUSED_SHORT_BITS((SET_SHORT *)out, bitlength);
+    }
+  else
+    {
+      unsigned long len = BITS_TO_WORDS(bitlength);
+      register unsigned long i;
+    
+      for (i = 0; i < len; i++)
+       out[i] = ~ left[i];
+      MASK_UNUSED_WORD_BITS((out + len - 1), bitlength % SET_WORD_SIZE);
+    }
+}
diff --git a/libchill/orps.c b/libchill/orps.c
new file mode 100644 (file)
index 0000000..79e6a8f
--- /dev/null
@@ -0,0 +1,75 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __orpowerset
+ *
+ * parameters:
+ *     out             return from __orpowerset
+ *     left            left powerset
+ *     right           right powerset
+ *     bitlength       length of powerset in bits
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  or's two powersets.
+ *
+ */
+
+void
+__orpowerset (out, left, right, bitlength)
+     SET_WORD      *out;
+     SET_WORD      *left;
+     SET_WORD      *right;
+     unsigned long  bitlength;
+{
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      *((SET_CHAR *)out) = *((SET_CHAR *)left) |
+                           *((SET_CHAR *)right);
+      MASK_UNUSED_CHAR_BITS((SET_CHAR *)out, bitlength);
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      *((SET_SHORT *)out) = *((SET_SHORT *)left) |
+                            *((SET_SHORT *)right);
+      MASK_UNUSED_SHORT_BITS((SET_SHORT *)out, bitlength);
+    }
+  else
+    {
+      register unsigned long i;
+      unsigned long len = BITS_TO_WORDS(bitlength);
+    
+      for (i = 0; i < len; i++)
+       out[i] = left[i] | right[i];
+      MASK_UNUSED_WORD_BITS ((out + len - 1), bitlength % SET_WORD_SIZE);
+    }
+}
diff --git a/libchill/outoffile.c b/libchill/outoffile.c
new file mode 100644 (file)
index 0000000..d81e955
--- /dev/null
@@ -0,0 +1,40 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__outoffile( void* the_transfer, char* file, int line )
+{
+  Access_Mode* the_access;
+
+  if( !the_transfer )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS );
+
+  if( TEST_FLAG((Text_Mode*)the_transfer, IO_TEXTLOCATION ))
+    the_access = ((Text_Mode*)the_transfer)->access_sub;
+  else
+    the_access = (Access_Mode*)the_transfer;
+
+  if( !the_access->association )
+    CHILLEXCEPTION( file, line, NOTCONNECTED, IS_NOT_CONNECTED );
+
+  return TEST_FLAG( the_access, IO_OUTOFFILE ) ? True : False;
+}
diff --git a/libchill/powerset.h b/libchill/powerset.h
new file mode 100644 (file)
index 0000000..ade9ec3
--- /dev/null
@@ -0,0 +1,106 @@
+/* Common macros for POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef _POWERSET_H
+#define _POWERSET_H
+
+#define USE_CHARS
+
+#ifdef USE_CHARS
+
+#define SET_WORD unsigned char
+#define SET_CHAR  unsigned char
+#define SET_SHORT unsigned char
+
+#else
+
+#ifndef SET_WORD
+#define SET_WORD unsigned int
+#endif
+#define SET_CHAR  unsigned char
+#define SET_SHORT unsigned short
+#endif
+
+#define SET_WORD_SIZE (sizeof (char) * sizeof (SET_WORD))
+#define SET_SHORT_SIZE (sizeof (char) * sizeof (SET_SHORT))
+#define SET_CHAR_SIZE sizeof (char)
+
+/* Powersets and bit strings are stored as arrays of SET_WORD.
+   if they are a word or longer.  Powersets and bit strings whic
+   fit in a byte or short are stored that way by the compiler.
+
+   The order of the bits follows native bit order:
+   If BITS_BIG_ENDIAN, bit 0 is the most significant bit (i.e. 0x80..00);
+   otherwise, bit 0 is the least significant bit (i.e. 0x1).
+
+   MASK_UNUSED_BITS masks out unused bits in powersets and bitstrings.
+   GET_BIT_IN_WORD(W,B) yields 1 (or 0) if the B'th bit if W is set (cleared).
+*/
+
+#if BITS_BIG_ENDIAN
+#define GET_BIT_IN_WORD(w,b) (((w) >> (SET_WORD_SIZE - 1 - (b))) & 1)
+#define GET_BIT_IN_SHORT(w,b) (((w) >> (SET_SHORT_SIZE - 1 - (b))) & 1)
+#define GET_BIT_IN_CHAR(w,b) (((w) >> (SET_CHAR_SIZE - 1 - (b))) & 1)
+
+#define SET_BIT_IN_WORD(w,b) ((w) |= 1 << ((SET_WORD_SIZE) - 1 - (b)))
+#define SET_BIT_IN_SHORT(w,b) ((w) |= 1 << ((SET_SHORT_SIZE) - 1 - (b)))
+#define SET_BIT_IN_CHAR(w,b) ((w) |= 1 << ((SET_CHAR_SIZE) - 1 - (b)))
+
+#define CLEAR_BIT_IN_WORD(w,b) ((w) &= ~(1 << ((SET_WORD_SIZE) - 1 - (b))))
+#define CLEAR_BIT_IN_SHORT(w,b) ((w) &= ~(1 << ((SET_SHORT_SIZE) - 1 - (b))))
+#define CLEAR_BIT_IN_CHAR(w,b) ((w) &= ~(1 << ((SET_CHAR_SIZE) - 1 - (b))))
+#define MASK_UNUSED_WORD_BITS(p,b)                \
+{ if (b) *(p) &= (~0) << (SET_WORD_SIZE - (b)); }
+#define MASK_UNUSED_SHORT_BITS(p,b)               \
+{ if (b) *(p) &= (~0) << (SET_SHORT_SIZE - (b)); }
+#define MASK_UNUSED_CHAR_BITS(p,b)                 \
+{ if (b) *(p) &= (~0) << (SET_CHAR_SIZE - (b)); }
+
+#else /* !BITS_BIG_ENDIAN */
+
+#define GET_BIT_IN_WORD(w,b) (((w) >> (b)) & 1)
+#define GET_BIT_IN_SHORT(w,b) GET_BIT_IN_WORD(w,b)
+#define GET_BIT_IN_CHAR(w,b) GET_BIT_IN_WORD(w,b)
+
+#define SET_BIT_IN_WORD(w,b) ((w) |= 1 << (b))
+#define SET_BIT_IN_SHORT(w,b) SET_BIT_IN_WORD(w,b)
+#define SET_BIT_IN_CHAR(w,b) SET_BIT_IN_WORD(w,b)
+
+#define CLEAR_BIT_IN_WORD(w,b) ((w) &= ~(1 << (b)))
+#define CLEAR_BIT_IN_SHORT(w,b) CLEAR_BIT_IN_WORD(w,b)
+#define CLEAR_BIT_IN_CHAR(w,b) CLEAR_BIT_IN_WORD(w,b)
+
+#define MASK_UNUSED_WORD_BITS(p,b)  \
+{ if (b) *(p) &= ~((~0) << (b)); }
+#define MASK_UNUSED_SHORT_BITS(p,b) MASK_UNUSED_WORD_BITS(p,b)
+#define MASK_UNUSED_CHAR_BITS(p,b) MASK_UNUSED_WORD_BITS(p,b)
+
+#endif
+
+
+/* Number of words needed for a bitstring/powerset of size BITLENGTH.
+   This definition handles the (BITLENGTH==0) by yielding 0. */
+
+#define BITS_TO_WORDS(BITLENGTH) \
+  (((BITLENGTH) + (SET_WORD_SIZE-1)) / SET_WORD_SIZE)
+#define BITS_TO_CHARS(BITLENGTH) \
+  (((BITLENGTH) + (SET_CHAR_SIZE-1)) / SET_CHAR_SIZE)
+
+#endif
diff --git a/libchill/printbuffer.c b/libchill/printbuffer.c
new file mode 100644 (file)
index 0000000..9dd9617
--- /dev/null
@@ -0,0 +1,116 @@
+/* Implement tasking-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <stdio.h>
+#include "rtltypes.h"
+#include "rts.h"
+
+typedef char *(*fetch_names) (int number);
+extern fetch_names     __RTS_FETCH_NAMES__;
+
+/*
+ * function print_instance
+ *
+ */
+
+static char *print_instance (ins)
+     INSTANCE ins;
+{
+  static char  buf[256];
+  char *f;
+
+  if (!__RTS_FETCH_NAMES__)
+    f = 0;
+  else
+    f = (*__RTS_FETCH_NAMES__) (ins.ptype);
+  if (!f)
+    sprintf (buf, "[%u;%u]", ins.ptype, ins.pcopy);
+  else
+    sprintf (buf, "[%s;%u]", f, ins.pcopy);
+  return buf;
+}
+
+/*
+ * function __print_buffer
+ *
+ * parameters:
+ *     buffer      buffer location
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     Function is used for debugging purposes only to print a
+ *     buffer queue
+ */
+
+void
+__print_buffer (buffer, name)
+     Buffer_Queue   **buffer;
+     char            *name;
+{
+  Buffer_Queue      *bq;
+  int                bsqcnt = 0, bwqcnt = 0;
+  Buffer_Send_Queue *bsq;
+  Buffer_Wait_Queue *bwq;
+
+  if (name)
+    printf ("Buffer %s:\n", name);
+  else
+    printf ("Buffer at address H'%X:\n", buffer);
+
+  memcpy (&bq, buffer, sizeof (Buffer_Queue *));
+  if (bq == 0)
+    {
+      printf ("EMPTY\n");
+      return;
+    }
+
+  bsq = bq->sendqueue;
+  if (bsq != 0)
+      printf ("Send Queue:\n");
+  while (bsq)
+    {
+      printf (" %3d: ", ++bsqcnt);
+      printf ("Process %s, ", print_instance (bsq->this));
+      printf ("Priority %d", bsq->priority);
+      if (bsq->is_delayed)
+       printf (", Delayed");
+      printf ("\n");
+      bsq = bsq->forward;
+    }
+  bwq = bq->waitqueue;
+  if (bwq != 0)
+      printf ("Wait Queue:\n");
+  while (bwq)
+    {
+      printf (" %3d: ", ++bwqcnt);
+      printf ("Process %s, ", print_instance (bwq->this));
+      if (bwq->is_sent)
+       printf (", Send by %s", print_instance (bwq->who_sent));
+      printf ("\n");
+      bwq = bwq->forward;
+    }
+  if (bsqcnt == 0 && bwqcnt == 0)
+    printf ("EMPTY\n");
+}
diff --git a/libchill/printevent.c b/libchill/printevent.c
new file mode 100644 (file)
index 0000000..c491a2c
--- /dev/null
@@ -0,0 +1,93 @@
+/* Implement tasking-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <stdio.h>
+#include "rtltypes.h"
+#include "rts.h"
+
+typedef char *(*fetch_names) (int number);
+extern fetch_names     __RTS_FETCH_NAMES__;
+
+/*
+ * function print_instance
+ *
+ */
+
+static char *print_instance (ins)
+     INSTANCE ins;
+{
+  static char  buf[256];
+  char *f;
+
+  if (!__RTS_FETCH_NAMES__)
+    f = 0;
+  else
+    f = (*__RTS_FETCH_NAMES__) (ins.ptype);
+  if (!f)
+    sprintf (buf, "[%u;%u]", ins.ptype, ins.pcopy);
+  else
+    sprintf (buf, "[%s;%u]", f, ins.pcopy);
+  return buf;
+}
+
+/*
+ * function __print_event
+ *
+ * parameters:
+ *     event      event location
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     Function is used for debugging purposes only to print an
+ *     event queue
+ */
+
+void
+__print_event (evaddr, name)
+     Event_Queue   **evaddr;
+     char           *name;
+{
+  Event_Queue    *ev;
+  int            cnt = 0;
+
+  if (name)
+    printf ("Event %s:\n", name);
+  else
+    printf ("Event at address H'%X:\n", evaddr);
+
+  memcpy (&ev, evaddr, sizeof (Event_Queue *));
+  while (ev)
+    {
+      printf (" %3d: ", ++cnt);
+      printf ("Process %s, ", print_instance (ev->this));
+      printf ("Priority %d", ev->priority);
+      if (ev->is_continued)
+       printf (" ,Continued by %s", print_instance (ev->who_continued));
+      printf ("\n");
+      ev = ev->forward;
+    }
+  if (!cnt)
+    printf ("EMPTY\n");
+}
diff --git a/libchill/queuelength.c b/libchill/queuelength.c
new file mode 100644 (file)
index 0000000..417d175
--- /dev/null
@@ -0,0 +1,79 @@
+/* Implement tasking-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rtltypes.h"
+#include "rts.h"
+
+/*
+ * function __queue_length
+ *
+ * parameters:
+ *     buf_ev      Buffer or event location
+ *     is_event    0 .. buf_ev is a buffer location
+ *                 1 .. buf_ev is an event location
+ *
+ * returns:
+ *     int         number of delayed processeson an event location
+ *                 or number of send delayed processes on a buffer
+ *
+ * exceptions:
+ *     none
+ *
+ * abstract:
+ *     implements the QUEUE_LENGTH built-in.
+ *
+ */
+
+int
+__queue_length (buf_ev, is_event)
+     void  *buf_ev;
+     int    is_event;
+{
+  int            retval = 0;
+  
+  /* if buf_ev == 0 then we don't have anything */
+  if (buf_ev == 0)
+    return 0;
+
+  if (is_event)
+    {
+      /* process an event queue */
+      Event_Queue   *ev = buf_ev;
+
+      while (ev)
+       {
+         retval++;
+         ev = ev->forward;
+       }
+    }
+  else
+    {
+      /* process a buffer queue */
+      Buffer_Queue *bq = buf_ev;
+      Buffer_Send_Queue *bsq = bq->sendqueue;
+
+      while (bsq)
+       {
+         retval++;
+         bsq = bsq->forward;
+       }
+    }
+  return retval;
+}
diff --git a/libchill/readable.c b/libchill/readable.c
new file mode 100644 (file)
index 0000000..ffed841
--- /dev/null
@@ -0,0 +1,32 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__readable( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+  if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+  return TEST_FLAG(the_assoc, IO_READABLE) ? True : False;
+}
+
diff --git a/libchill/readrecord.c b/libchill/readrecord.c
new file mode 100644 (file)
index 0000000..03641f9
--- /dev/null
@@ -0,0 +1,208 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <setjmp.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "fileio.h"
+
+#ifdef EOF
+#undef EOF
+#endif
+#define EOF -1
+
+static
+Boolean
+doRead( Access_Mode* the_access, void* buf, size_t nbyte )
+{
+  size_t nread;
+
+  nread = read( the_access->association->handle, buf, nbyte );
+  if( nread == nbyte )
+  {
+    CLR_FLAG( the_access, IO_OUTOFFILE );
+    return True;
+  }
+  if( nread == 0 )
+  {
+    SET_FLAG( the_access, IO_OUTOFFILE );
+    return False;
+  }
+  the_access->association->syserrno = errno;
+  RWEXCEPTION( READFAIL, OS_IO_ERROR );
+  /* no return */
+}
+
+static
+int bgetc( int handle, readbuf_t* rbptr )
+{
+  if( rbptr->cur >= rbptr->len )
+    {
+      rbptr->len = read( handle, rbptr->buf, READBUFLEN );
+      if( rbptr->len == 0 )
+       return EOF;
+      rbptr->cur = 0;
+    }
+  return rbptr->buf[rbptr->cur++];
+}
+
+static
+void bungetc( readbuf_t* rbptr, int c )
+{
+  rbptr->buf[--rbptr->cur] = c;
+}
+
+void*
+__readrecord( Access_Mode*  the_access,
+              signed long   the_index,
+              char*         the_buf_addr,
+              char*         file,
+              int           line )
+{
+  unsigned long  info;
+  char*          actaddr;
+  unsigned short actlen;
+  off_t          filepos;
+  unsigned short reclen;
+  unsigned long  readlen;
+
+  if( !the_access )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS );
+
+  if( !the_access->association )
+    CHILLEXCEPTION( file, line, NOTCONNECTED, IS_NOT_CONNECTED );
+
+  /* Usage must not be WriteOnly */
+  if( the_access->association->usage == WriteOnly )
+    CHILLEXCEPTION( file, line, READFAIL, BAD_USAGE );
+
+  /* OUTOFFILE must not be True when connected for sequential read */
+  if( !TEST_FLAG( the_access, IO_INDEXED )
+      && TEST_FLAG( the_access, IO_OUTOFFILE ) )
+    CHILLEXCEPTION( file, line, READFAIL, OUT_OF_FILE );
+
+  /*
+   *  Positioning
+   */
+  if( TEST_FLAG( the_access, IO_INDEXED ) )
+  {
+    /* index expression must be within bounds of index mode */
+    if( the_index < the_access->lowindex
+        || the_access->highindex < the_index ) 
+      CHILLEXCEPTION( file, line, RANGEFAIL, BAD_INDEX );
+
+    filepos = the_access->base + 
+              (the_index - the_access->lowindex) * the_access->reclength;
+
+    if( lseek( the_access->association->handle, filepos, SEEK_SET ) == -1L )
+      CHILLEXCEPTION( file, line, READFAIL, LSEEK_FAILS );
+  }
+
+  /* establish store loc */
+  if( !(actaddr = the_buf_addr ))
+  {
+    /* if not yet allocated, do it now */
+    if (!the_access->store_loc)
+      if( !(the_access->store_loc = (char*)malloc( the_access->reclength ) ) )
+       CHILLEXCEPTION( file, line, SPACEFAIL, STORE_LOC_ALLOC );
+    actaddr = the_access->store_loc;
+  }
+  actlen  = the_access->reclength;
+
+  if( (info = setjmp( __rw_exception )) )
+    CHILLEXCEPTION( file, line, info>>16, info & 0xffff );
+
+  if( TEST_FLAG( the_access, IO_TEXTIO ) )
+  {
+    readlen = actlen - 2;
+    if( TEST_FLAG( the_access, IO_INDEXED ) )
+    {
+      if( ! doRead( the_access, &reclen, sizeof(reclen) ) )
+        return NULL;
+      if( reclen > readlen )
+        CHILLEXCEPTION( file, line, RANGEFAIL, RECORD_TOO_LONG );
+      if( ! doRead( the_access, actaddr + 2, reclen ) )
+        CHILLEXCEPTION( file, line, READFAIL, RECORD_TOO_SHORT );
+    }
+    else
+    { 
+      Association_Mode *assoc = the_access->association;
+      int              handle = assoc->handle;
+      readbuf_t*       rbuf   = assoc->bufptr;
+      char* cptr = actaddr+2;
+      int   curr;
+
+      reclen = 0;
+      while( readlen-- )
+      {
+        curr = bgetc( handle, rbuf );
+        if( curr == '\n' )
+          goto end_of_line;
+        if( curr == EOF )
+       {
+          if( !reclen )
+            SET_FLAG( the_access, IO_OUTOFFILE );
+          goto end_of_line;
+       }
+        *cptr++ = curr;
+        reclen++;
+      }
+      if( (curr = bgetc( handle, rbuf )) != '\n' )
+       {
+         bungetc( rbuf, curr );
+         CHILLEXCEPTION( file, line, RANGEFAIL, RECORD_TOO_LONG );
+       }
+end_of_line: ;
+    }
+    MOV2(actaddr,&reclen);
+  }
+  else
+  {
+    switch( the_access->rectype )
+    {
+    case Fixed:
+      if( ! doRead( the_access, actaddr, actlen ) )
+        return NULL;
+      break;
+    case VaryingChars:
+      if( TEST_FLAG( the_access->association, IO_VARIABLE ) )
+      {
+        if( ! doRead( the_access, &reclen, sizeof(reclen) ) )
+          return NULL;
+        if( reclen > actlen - 2 )
+          CHILLEXCEPTION( file, line, RANGEFAIL, RECORD_TOO_LONG );
+        readlen = TEST_FLAG( the_access, IO_INDEXED ) ? actlen - 2 : reclen;
+        if( ! doRead( the_access, actaddr + 2, readlen ) )
+          CHILLEXCEPTION( file, line, READFAIL, RECORD_TOO_SHORT );
+      }
+      else
+      {
+        if( ! doRead( the_access, actaddr + 2, reclen = actlen - 2 ) )
+          CHILLEXCEPTION( file, line, READFAIL, RECORD_TOO_SHORT );
+      }
+      MOV2(actaddr,&reclen);
+      break;
+    }
+  }
+
+  return actaddr;
+}
diff --git a/libchill/remaintime.c b/libchill/remaintime.c
new file mode 100644 (file)
index 0000000..548911b
--- /dev/null
@@ -0,0 +1,83 @@
+/* Implement timing-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+   
+   This file is part of GNU CC.
+   
+   GNU CC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+   
+   GNU CC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with GNU CC; see the file COPYING.  If not, write to
+   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rts.h"
+
+/*
+ * function __remaintime
+ *
+ * parameters:
+ *      since   pointer to the  initial RtsTime
+ *      dur     the duration value
+ *      t       pointer to the remaining RtsTime
+ *
+ * returns:
+ *      int     0 .. there is a remaining time
+ *              1 .. there is no remaining time
+ *
+ * exceptions:
+ *      none
+ *
+ * abstract:
+ *      This function writes to t the remaining duration value in RtsTime format
+ *      from a given start (since) and the current RtsTime.
+ *
+ */
+
+extern void __convert_duration_rtstime (unsigned long dur, RtsTime *t);
+
+int
+  __remaintime (since, dur, t)
+RtsTime       *since;
+unsigned long  dur;
+RtsTime       *t;
+{
+  RtsTime now, dur_in_rtstime, tmp, diff;
+  
+  __rtstime (&now);
+  __convert_duration_rtstime (dur, &dur_in_rtstime);
+  
+  tmp.secs = since->secs;
+  tmp.nanosecs = since->nanosecs;
+  
+  /* calculate the difference of absolute times */
+  if (tmp.nanosecs > now.nanosecs)
+    {
+      tmp.secs--;
+      tmp.nanosecs += 1000000000;
+    }
+  diff.secs = now.secs - tmp.secs;
+  diff.nanosecs = now.nanosecs - tmp.nanosecs;
+  
+  /* substract diff from duration */
+  if (diff.nanosecs > dur_in_rtstime.nanosecs)
+    {
+      dur_in_rtstime.secs--;
+      dur_in_rtstime.nanosecs += 1000000000;
+    }
+  
+  t->secs = dur_in_rtstime.secs - diff.secs;
+  t->nanosecs = dur_in_rtstime.nanosecs - diff.nanosecs;
+  
+  if (t->secs > dur_in_rtstime.secs)
+    return 1;
+  else
+    return 0;
+}
diff --git a/libchill/retmem.c b/libchill/retmem.c
new file mode 100644 (file)
index 0000000..a17ef7b
--- /dev/null
@@ -0,0 +1,52 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdlib.h>
+
+/*
+ * function _return_memory
+ *
+ * parameter:
+ *  ptr                        pointer to memory to free
+ *  filename            source file which issued the call
+ *  linenumber          line number of the call within that file
+ *
+ * returns:
+ *  void
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  free memory previously allocated by _allocate_(global_)memory
+ *
+*/
+
+void
+_return_memory (ptr, filename, linenumber)
+     void *ptr;
+     char *filename;
+     int linenumber;
+{
+    free (ptr);
+}
diff --git a/libchill/rtltypes.h b/libchill/rtltypes.h
new file mode 100644 (file)
index 0000000..ed994f3
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef __rtltypes_h__
+#define __rtltypes_h__
+
+#include <setjmp.h>
+
+/* Add prototype support.  */
+#ifndef PROTO
+#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
+#define PROTO(ARGS) ARGS
+#else
+#define PROTO(ARGS) ()
+#endif
+#endif
+
+/* argc, argv */
+typedef struct
+{
+    unsigned short     len;
+    char               body[0];
+} TVaryingCharType;
+
+#ifndef __CHILL_LIB__
+extern TVaryingCharType        **chill_argv;
+extern int             chill_argc;
+#endif
+
+/* definitions for exceptions */
+typedef struct
+{
+    char       *exname;
+    short      exnumber;
+} TExceptionDefinition;
+
+#if 1
+typedef char *__ch_exception;
+#define EX_EQ(e1, e2) (strcmp(e1, e2)==0)
+#else
+typedef void *__ch_exception;
+#define EX_EQ(e1, e2) (e1 == e2)
+#endif
+#define __ch_else_except ((__ch_exception)0)
+
+struct __ch_handled_excepts
+{
+  /* List is ended by a code==0, or ex==__ch_else_except (ELSE handler). */
+  __ch_exception ex;
+  int code; /* Positive number indicating ordinal in handler list. */
+};
+
+/* definitions for exception handlers */
+typedef struct  __ch_handler
+{
+  struct __ch_handler *prev;
+  struct __ch_handled_excepts *handlers;
+  jmp_buf jbuf;
+} TExceptionHandlerStack;
+
+/* exceptions */
+#define EXCEPTION(x)   /* nothing */
+
+#endif /* __rtltypes_h__ */
diff --git a/libchill/rts.c b/libchill/rts.c
new file mode 100644 (file)
index 0000000..b7602e9
--- /dev/null
@@ -0,0 +1,655 @@
+/* GNU CHILL compiler regression test file
+ Copyright (C) 1992, 1993 Free Software Foundation, Inc.
+ This file is part of GNU CC.
+
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING.  If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <setjmp.h>
+#include <signal.h>
+
+#include "rts.h"
+
+
+/* some allocation/reallocation functions */
+
+static void *
+xmalloc (size)
+     int size;
+{
+  void *tmp = malloc (size);
+
+  if (!tmp)
+    {
+      fprintf (stderr, "Out of heap space.\n");
+      exit (1);
+    }
+  return (tmp);
+}
+
+static void *
+xrealloc (ptr, size)
+     void *ptr;
+     int size;
+{
+  void *tmp = realloc (ptr, size);
+
+  if (!tmp)
+    {
+      fprintf (stderr, "Out of heap space.\n");
+      exit (1);
+    }
+  return (tmp);
+}
+
+/* the necessary data */
+#define MAX_NUMBER 100
+typedef char UsedValues[MAX_NUMBER];
+
+#define MAX_COPIES 100
+
+#define MAX_PER_ITEM 20
+typedef struct TASKINGSTRUCTLIST
+{
+  struct TASKINGSTRUCTLIST *forward;
+  int    num;
+  TaskingStruct *data[MAX_PER_ITEM];
+  char copies[MAX_COPIES];
+  jmp_buf where;
+} TaskingStructList;
+
+static TaskingStructList *task_array[LAST_AND_UNUSED];
+static UsedValues used_values[LAST_AND_UNUSED];
+
+static short
+get_next_free_number (vals)
+     UsedValues vals;
+{
+  short  i;
+  for (i = 1; i < MAX_NUMBER; i++)
+    {
+      if (!vals[i])
+       {
+         vals[i] = 1;
+         return (i);
+       }
+    }
+  fprintf (stderr, "There are no more free numbers.\n");
+  exit (1);
+}
+
+/* function search for the next available copy number */
+static short
+get_next_copy_number (p)
+     TaskingStructList *p;
+{
+  short i;
+
+  for (i = 0; i < MAX_COPIES; i++)
+    {
+      if (!p->copies[i])
+       {
+         p->copies[i] = 1;
+         return (i);
+       }
+    }
+  fprintf (stderr, "No more copies available for \"%s\".\n",
+          p->data[0]->name);
+  exit (1);
+}
+
+/* function registers a tasking entry from a module and assign
+   a value to the type */
+
+void
+__register_tasking (t)
+     TaskingStruct *t;
+{
+  TaskingStructList *p;
+
+  /* check first if a value was provided and if it is in range */
+  if (t->value_defined && *t->value >= MAX_NUMBER)
+    {
+      fprintf (stderr, "Value %d out of range.\n", *t->value);
+      exit (1);
+    }
+
+  /* look for item defined */
+  p = task_array[t->type];
+  while (p)
+    {
+      if (!strcmp (p->data[0]->name, t->name))
+       /* have found it */
+       break;
+      p = p->forward;
+    }
+
+  if (!p)
+    {
+      TaskingStructList *wrk = (TaskingStructList *)&task_array[t->type];
+
+      /* this is a new one -- allocate space */
+      p = xmalloc (sizeof (TaskingStructList));
+      memset (p->copies, 0, sizeof (p->copies));
+      p->forward = 0;
+      p->num = 1;
+      p->data[0] = t;
+
+      /* queue it in */
+      while (wrk->forward)
+       wrk = wrk->forward;
+      wrk->forward = p;
+    }
+  else
+    {
+      if (p->num >= MAX_PER_ITEM)
+       {
+         fprintf (stderr, "Too many registrations of \"%s\".\n", t->name);
+         exit (1);
+       }
+      p->data[p->num++] = t;
+    }
+}
+\f
+/* define all the entries for the runtime system. They will be
+   needed by chillrt0.o */
+
+typedef char *(*fetch_names) ();
+typedef int (*fetch_numbers) ();
+
+static char tmp_for_fetch_name[100];
+
+char *
+__fetch_name (number)
+     int number;
+{
+  TaskingStructList *p = task_array[Process];
+
+  while (p)
+    {
+      if (*(p->data[0]->value) == number)
+       return (p->data[0]->name);
+      p = p->forward;
+    }
+  sprintf (tmp_for_fetch_name, "%d", number);
+  return (tmp_for_fetch_name);
+}
+fetch_names    __RTS_FETCH_NAMES__ = __fetch_name;
+
+static int 
+__fetch_number (name)
+     char *name;
+{
+  TaskingStructList *p = task_array[Process];
+
+  while (p)
+    {
+      if (!strcmp (p->data[0]->name, name))
+       return (*(p->data[0]->value));
+      p = p->forward;
+    }
+  return (-1);
+}
+fetch_numbers  __RTS_FETCH_NUMBERS__ = __fetch_number;
+
+
+/* here we go to check all registered items */
+static void
+ __rts_init ()
+{
+  int i;
+  TaskingStructList *p;
+
+  for (i = Process; i <= Event; i++)
+    {
+      p = task_array[i];
+      while (p)
+       {
+         TaskingStruct *t = 0;
+         int j;
+         short val;
+
+         for (j = 0; j < p->num; j++)
+           {
+             if (p->data[j]->value_defined)
+               {
+                 if (t)
+                   {
+                     if (*(t->value) != *(p->data[j]->value))
+                       {
+                         fprintf (stderr, "Different values (%d & %d) for \"%s\".",
+                                  *(t->value), *(p->data[j]->value), t->name);
+                         exit (1);
+                       }
+                   }
+                 else
+                   t = p->data[j];
+               }
+           }
+
+         if (t)
+           {
+
+             val = *(t->value);
+
+             if (used_values[t->type][val])
+               {
+                 fprintf (stderr, "Value %d for \"%s\" is already used.\n",
+                          val, t->name);
+                 exit (1);
+               }
+             used_values[t->type][val] = 1;
+           }
+         else
+           {
+             /* we have to create a new value */
+             val = get_next_free_number (used_values[p->data[0]->type]);
+           }
+             
+         for (j = 0; j < p->num; j++)
+           {
+             p->data[j]->value_defined = 1;
+             *(p->data[j]->value) = val;
+           }
+
+         p = p->forward;
+       }
+    }
+}
+EntryPoint     __RTS_INIT__ = __rts_init;
+\f
+/* define the start process queue */
+typedef struct STARTENTRY
+{
+  struct STARTENTRY *forward;
+  INSTANCE whoami;
+  EntryPoint entry;
+  void *data;
+  int datalen;
+} StartEntry;
+
+static StartEntry *start_queue = 0;
+static StartEntry *current_process = 0;
+
+/* the jump buffer for the main loop */
+static jmp_buf jump_buffer;
+static int jump_buffer_initialized = 0;
+
+/* look for entries in start_queue and start the process */
+static void
+__rts_main_loop ()
+{
+  StartEntry *s;
+
+  while (1)
+    {
+      if (setjmp (jump_buffer) == 0)
+       {
+         jump_buffer_initialized = 1;
+         s = start_queue;
+         while (s)
+           {
+             current_process = s;
+             start_queue = s->forward;
+             
+             /* call the process */
+             (*s->entry) (s->data);
+             s = start_queue;
+           }
+         /* when queue empty we have finished */
+         return;
+       }
+      else
+       {
+         /* stop executed */
+         if (current_process->data)
+           free (current_process->data);
+         free (current_process);
+         current_process = 0;
+       }
+    }
+}
+EntryPoint     __RTS_MAIN_LOOP__ = __rts_main_loop;
+
+
+void
+__start_process (ptype, pcopy, arg_size, args, ins)
+     short ptype;
+     short pcopy;
+     int arg_size;
+     void *args;
+     INSTANCE *ins;
+{
+  TaskingStructList *p = task_array[Process];
+  EntryPoint pc = 0;
+  int i;
+  short this_copy = pcopy;
+  StartEntry *s, *wrk;
+
+  /* search for the process */
+  while (p)
+    {
+      if (*(p->data[0]->value) == ptype)
+       break;
+      p = p->forward;
+    }
+  if (!p)
+    {
+      fprintf (stderr, "Cannot find a process with type %d.\n", ptype);
+      exit (1);
+    }
+  
+  /* search for the entry point */
+  for (i = 0; i < p->num; i++)
+    {
+      if (p->data[i]->entry)
+       {
+         pc = p->data[i]->entry;
+         break;
+       }
+    }
+  if (!pc)
+    {
+      fprintf (stderr, "Process \"%s\" doesn't have an entry point.\n",
+              p->data[0]->name);
+      exit (1);
+    }
+
+  /* check the copy */
+  if (pcopy >= MAX_COPIES)
+    {
+      fprintf (stderr, "Copy number (%d) out of range.\n", pcopy);
+      exit (1);
+    }
+  if (pcopy == -1)
+    {
+      /* search for a copy number */
+      this_copy = get_next_copy_number (p);
+    }
+  else
+    {
+      if (p->copies[pcopy])
+       {
+         /* FIXME: should be exception 'startfail' */
+         fprintf (stderr, "Copy number %d already in use for \"%s\".\n",
+                  pcopy, p->data[0]->name);
+         exit (1);
+       }
+      p->copies[this_copy = pcopy] = 1;
+    }
+
+  /* ready to build start_queue entry */
+  s = xmalloc (sizeof (StartEntry));
+  s->forward = 0;
+  s->whoami.pcopy = this_copy;
+  s->whoami.ptype = ptype;
+  s->entry = pc;
+  s->datalen = arg_size;
+  if (args)
+    {
+      s->data = xmalloc (arg_size);
+      memcpy (s->data, args, arg_size);
+    }
+  else
+    s->data = 0;
+
+  /* queue that stuff in */
+  wrk = (StartEntry *)&start_queue;
+  while (wrk->forward)
+    wrk = wrk->forward;
+  wrk->forward = s;
+
+  /* if we have a pointer to ins -- set it */
+  if (ins)
+    {
+      ins->ptype = ptype;
+      ins->pcopy = this_copy;
+    }
+}
+\f
+void
+__stop_process ()
+{
+  if (!jump_buffer_initialized)
+    {
+      fprintf (stderr, "STOP called before START.\n");
+      exit (1);
+    }
+  longjmp (jump_buffer, 1);
+}
+
+
+/* function returns INSTANCE of current process */
+INSTANCE
+__whoami ()
+{
+  INSTANCE whoami;
+  if (current_process)
+    whoami = current_process->whoami;
+  else
+    {
+      whoami.ptype = 0;
+      whoami.pcopy = 0;
+    }
+  return (whoami);
+}
+
+typedef struct
+{
+  short *sc;
+  int    data_len;
+  void  *data;
+} SignalDescr;
+
+typedef struct SIGNALQUEUE
+{
+  struct SIGNALQUEUE *forward;
+  short    sc;
+  int      data_len;
+  void    *data;
+  INSTANCE to;
+  INSTANCE from;
+} SignalQueue;
+
+/* define the signal queue */
+static SignalQueue *msg_queue = 0;
+\f
+/* send a signal */
+void
+__send_signal (s, to, prio, with_len, with)
+     SignalDescr *s;
+     INSTANCE     to;
+     int          prio;
+     int          with_len;
+     void        *with;
+{
+  SignalQueue *wrk = (SignalQueue *)&msg_queue;
+  SignalQueue *p;
+  TaskingStructList *t = task_array[Process];
+
+  /* search for process is defined and running */
+  while (t)
+    {
+      if (*(t->data[0]->value) == to.ptype)
+       break;
+      t = t->forward;
+    }
+  if (!t || !t->copies[to.pcopy])
+    {
+      fprintf (stderr, "Can't find instance [%d,%d].\n",
+              to.ptype, to.pcopy);
+      exit (1);
+    }
+
+  /* go to the end of the msg_queue */
+  while (wrk->forward)
+    wrk = wrk->forward;
+
+  p = xmalloc (sizeof (SignalQueue));
+  p->sc = *(s->sc);
+  if (p->data_len = s->data_len)
+    {
+      p->data = xmalloc (s->data_len);
+      memcpy (p->data, s->data, s->data_len);
+    }
+  else
+    p->data = 0;
+  p->to = to;
+  p->from = __whoami ();
+  p->forward = 0;
+  wrk->forward = p;
+}
+\f
+void
+start_signal_timeout (i, s, j)
+     int i;
+     SignalDescr *s;
+     int j;
+{
+  __send_signal (s, __whoami (), 0, 0, 0);
+}
+
+
+/* receive a signal */
+int
+__wait_signal_timed (sig_got, nsigs, sigptr, datap,
+                    datalen, ins, else_branche,
+                    to, filename, lineno)
+     short    *sig_got;
+     int       nsigs;
+     short    *sigptr[];
+     void     *datap;
+     int       datalen;
+     INSTANCE *ins;
+     int       else_branche;
+     void     *to; 
+     char     *filename;
+     int       lineno; 
+{
+  INSTANCE me = __whoami ();
+  SignalQueue *wrk, *p = msg_queue;
+  int i;
+  short sc;
+
+  /* search for a signal to `me' */
+  wrk = (SignalQueue *)&msg_queue;
+
+  while (p)
+    {
+      if (p->to.ptype == me.ptype
+         && p->to.pcopy == me.pcopy)
+       break;
+      wrk = p;
+      p = p->forward;
+    }
+
+  if (!p)
+    {
+      fprintf (stderr, "No signal for [%d,%d].\n",
+              me.ptype, me.pcopy);
+      exit (1);
+    }
+
+  /* queue the message out */
+  wrk->forward = p->forward;
+
+  /* now look for signal in list */
+  for (i = 0; i < nsigs; i++)
+    if (*(sigptr[i]) == p->sc)
+      break;
+
+  if (i >= nsigs && ! else_branche)
+    /* signal not in list and no ELSE in code */
+    __cause_exception ("signalfail", __FILE__, __LINE__);
+
+  if (i >= nsigs)
+    {
+      /* signal not in list */
+      sc = p->sc;
+      if (ins)
+       *ins = p->from;
+      if (p->data)
+       free (p->data);
+      free (p);
+      *sig_got = sc;
+      return (0);
+    }
+
+  /* we have found a signal in the list */
+  if (p->data_len)
+    {
+      if (datalen >= p->data_len
+         && datap)
+       memcpy (datap, p->data, p->data_len);
+      else
+       __cause_exception ("spacefail", __FILE__, __LINE__);
+    }
+
+  sc = p->sc;
+  if (ins)
+    *ins = p->from;
+  if (p->data)
+    free (p->data);
+  free (p);
+  *sig_got = sc;
+  return (0);
+}
+\f
+/* wait a certain amount of seconds */
+int
+__sleep_till (abstime, reltime, fname, lineno)
+     time_t abstime;
+     int    reltime;
+     char  *fname;
+     int    lineno;
+{
+  sleep (reltime);
+  return 0;
+}
+\f
+/* set up an alarm */
+static int timeout_flag = 0;
+
+static void alarm_handler ()
+{
+  timeout_flag = 1;
+}
+
+int *
+__define_timeout (howlong, filename, lineno)
+     unsigned long howlong;  /* comes in millisecs */
+     char         *filename;
+     int           lineno;
+{
+  unsigned int  prev_alarm_value;
+
+  signal (SIGALRM, alarm_handler);
+  prev_alarm_value = alarm ((unsigned int)(howlong / 1000));
+  return &timeout_flag;
+}
+\f
+/* wait till timeout expires */
+void
+__wait_timeout (toid, filename, lineno)
+     volatile int    *toid;
+     char   *filename;
+     int     lineno;
+{
+  while (! *toid) ;
+  *toid = 0;
+}
diff --git a/libchill/rts.h b/libchill/rts.h
new file mode 100644 (file)
index 0000000..27019e7
--- /dev/null
@@ -0,0 +1,52 @@
+/* GNU CHILL compiler regression test file
+ Copyright (C) 1992, 1993 Free Software Foundation, Inc.
+ This file is part of GNU CC.
+
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING.  If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef __rts_h_
+#define __rts_h_
+
+typedef enum
+{
+  UNUSED,
+  Process,
+  Signal,
+  Buffer,
+  Event,
+  Synonym,
+  Exception,
+  LAST_AND_UNUSED,
+} TaskingEnum;
+
+typedef void (*EntryPoint) ();
+
+typedef struct
+{
+  char       *name;
+  short      *value;
+  int         value_defined;
+  EntryPoint  entry;
+  unsigned char /*TaskingEnum*/ type;
+} TaskingStruct;
+
+typedef struct
+{
+  short ptype;
+  short pcopy;
+} INSTANCE;
+
+#endif /* __rts_h_ */
diff --git a/libchill/rtsdummy.c b/libchill/rtsdummy.c
new file mode 100644 (file)
index 0000000..cff2289
--- /dev/null
@@ -0,0 +1,65 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <setjmp.h>
+/*#include "gvarargs.h"        Gcc source and runtime libs use gvarargs.h */
+
+#include "rtltypes.h"
+
+typedef void (*init_ptr) ();
+typedef int * tasking_ptr;
+
+/* Dummy functions for rts access. When we come here we have an error. */
+
+typedef char *(*fetch_names) (int number);
+typedef int (*fetch_numbers) (char *name);
+
+static void __rts_main_loop ()
+{
+  /* do nothing in case of no run time system */
+}
+init_ptr       __RTS_MAIN_LOOP__ = __rts_main_loop;
+
+static void __rts_init ()
+{
+  /* do nothing in case of no run time system */
+}
+init_ptr       __RTS_INIT__ = __rts_init;
+
+static char *__fetch_name (int number)
+{
+    fprintf (stderr, "ChillLib: fetch_name: no runtime system library linked.\n");
+    fflush (stderr);
+    abort ();
+}
+fetch_names    __RTS_FETCH_NAMES__ = __fetch_name;
+
+static int __fetch_number (char *name)
+{
+    fprintf (stderr, "ChillLib: fetch_number: no runtime system library linked.\n");
+    fflush (stderr);
+    abort ();
+}
+fetch_numbers  __RTS_FETCH_NUMBERS__ = __fetch_number;
diff --git a/libchill/sendbuffer.c b/libchill/sendbuffer.c
new file mode 100644 (file)
index 0000000..2c2cc3e
--- /dev/null
@@ -0,0 +1,175 @@
+/* Implement tasking-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rtltypes.h"
+#include "rts.h"
+
+EXCEPTION (sendfail);
+
+extern void __cause_ex1 (char *ex, char *file, int lineno);
+
+#define CAUSE_SENDFAIL  __cause_ex1 ("sendfail", filename, lineno)
+
+/*
+ * function __send_buffer
+ *
+ * parameters:
+ *     buffer     pointer to buffer descriptor
+ *     data       pointer to data descriptor
+ *     prio       priority for send action
+ *     timeout   pointer to timeout value
+ *     filename   source file name where function gets called
+ *     lineno     linenumber in source file
+ *
+ * returns:
+ *     int       0 .. success
+ *                1 .. timeout
+ *
+ * exceptions:
+ *     sendfail
+ *
+ * abstract:
+ *     implement the CHILL SEND buffer action.
+ */
+
+int
+__send_buffer (buffer, data, prio, timeout, filename, lineno)
+     Buffer_Descr    *buffer;
+     Data_Descr      *data;
+     int              prio;
+     void            *timeout;
+     char            *filename;
+     int              lineno;
+{
+  Buffer_Queue        *bq;
+  Buffer_Send_Queue   *bsq, *bsq_entry, *prev_bsq_entry;
+  int                  cnt = 0;
+  int                 retval = 0;
+  
+  /* if we don't have anything queued on that buffer,
+     set up the structure */
+  memcpy (&bq, buffer->buf, sizeof (Buffer_Queue *));
+  if (bq == 0)
+    {
+      MALLOC (bq, sizeof (Buffer_Queue));
+      memset (bq, 0, sizeof (Buffer_Queue));
+      memcpy (buffer->buf, &bq, sizeof (Buffer_Queue *));
+    }
+
+  /* look if there is a process delayed on that buffer */
+  if (bq->waitqueue != 0)
+    {
+       Buffer_Wait_Queue       *listentry;
+       
+       /* there is already a processes waiting for that buffer,
+          check datalength and copy the data in */
+       if (bq->waitqueue->datalen < data->length)
+           CAUSE_SENDFAIL;
+       memcpy (bq->waitqueue->dataptr, data->ptr, data->length);
+       
+       /* set up the entry */
+       bq->waitqueue->is_sent = 1;
+       bq->waitqueue->who_sent = THIS;
+
+       /* continue waiting process */
+       __continue_that (bq->waitqueue->this, prio, filename, lineno);
+       
+       /* now dequeue all entries of this list */
+       listentry = bq->waitqueue->startlist;
+       while (listentry != 0)
+       {
+           Buffer_Wait_Queue   *tmp, *prev_entry, *bwq;
+           Buffer_Queue        *bq;
+
+           tmp = listentry->chain;
+           memcpy (&bq, listentry->bufferaddr, sizeof (Buffer_Queue *));
+           prev_entry = (Buffer_Wait_Queue *)&bq->waitqueue;
+           bwq = bq->waitqueue;
+
+           while (bwq != listentry)
+           {
+               prev_entry = bwq;
+               bwq = bwq->forward;
+           }
+           /* dequeue it */
+           prev_entry->forward = bwq->forward;
+           bq->waitqueuelength--;
+           listentry = tmp;
+       }
+       
+       /* all done */
+       return 0;
+    }
+
+  /* nothing in waitqueue, set up an entry for sendqueue.
+     Note: we allocate here space for the data too, to reduce
+     calls to malloc and let the dataptr point just behind
+     the Buffer_Send_Queue structure. */
+  MALLOC (bsq_entry, sizeof (Buffer_Send_Queue) + data->length);
+  memset (bsq_entry, 0, sizeof (Buffer_Send_Queue));
+
+  bsq_entry->priority = prio;
+  bsq_entry->this = THIS;
+  bsq_entry->datalen = data->length;
+  bsq_entry->dataptr = bsq_entry + 1;
+  memcpy (bsq_entry->dataptr, data->ptr, data->length);
+
+  /* add entry to sendqueue */
+  prev_bsq_entry = (Buffer_Send_Queue *)&bq->sendqueue;
+  bsq = bq->sendqueue;
+
+  while (bsq != 0 && bsq->priority >= prio)
+    {
+      prev_bsq_entry = bsq;
+      bsq = bsq->forward;
+    }
+  if (bsq == 0)
+    {
+      /* beginning or end of the list */
+      prev_bsq_entry->forward = bsq_entry;
+    }
+  else
+    {
+      /* somewhere in the middle */
+      bsq_entry->forward = prev_bsq_entry->forward;
+      prev_bsq_entry->forward = bsq_entry;
+    }
+
+  if (buffer->maxqueuelength != (unsigned long)-1L &&
+      bq->sendqueuelength >= buffer->maxqueuelength)
+    {
+      /* we have to delay this process */
+      bsq_entry->is_delayed = 1;
+      retval = __delay_this (wait_buffer_send, timeout, filename, lineno);
+      if (retval)
+        {
+         prev_bsq_entry->forward = bsq_entry->forward;
+         FREE (bsq_entry);
+        }
+    }
+  else
+    /* just say that there is one more entry in the queue */
+    bq->sendqueuelength++;
+  return retval;
+}
+
+/* force function __print_buffer to be linked */
+extern void __print_buffer ();
+static EntryPoint pev = __print_buffer;
diff --git a/libchill/sequencible.c b/libchill/sequencible.c
new file mode 100644 (file)
index 0000000..94166ff
--- /dev/null
@@ -0,0 +1,32 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__sequencible( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+  if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+  return TEST_FLAG(the_assoc, IO_SEQUENCIBLE) ? True : False;
+}
+
diff --git a/libchill/setbitps.c b/libchill/setbitps.c
new file mode 100644 (file)
index 0000000..f465548
--- /dev/null
@@ -0,0 +1,89 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+extern void __cause_ex1 (char *exname, char *file, int lineno);
+
+/*
+ * function __setbitpowerset
+ *
+ * parameters:
+ *     set             destination set
+ *     bitlength       length of powerset in bits
+ *      minval          lowest valid set value
+ *      bitno           bit number within set
+ *      new_value       zero or one - (new bit value)
+ *
+ * returns:
+ *     int             1 .. found
+ *                     0 .. not found
+ *
+ * exceptions:
+ *  rangefail
+ *
+ * abstract:
+ *  checks if a given value is included in a powerset
+ *
+ */
+void
+__setbitpowerset (powerset, bitlength, minval, bitno, new_value, filename, lineno)
+     SET_WORD      *powerset;
+     unsigned long  bitlength;
+     long           minval;
+     long          bitno;
+     char          new_value; /* booleans are represented as 8 bit value */
+     char *        filename;
+     int           lineno;
+{
+  if (powerset == NULL
+      || bitno < minval 
+      || (bitno - minval) >= bitlength)
+    __cause_ex1 ("rangefail", filename, lineno);
+
+  bitno -= minval;
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      if (new_value & 1)
+       SET_BIT_IN_CHAR (*((SET_CHAR *)powerset), bitno);
+      else
+       CLEAR_BIT_IN_CHAR (*((SET_CHAR *)powerset), bitno);
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      if (new_value & 1)
+       SET_BIT_IN_SHORT (*((SET_SHORT *)powerset), bitno);
+      else
+       CLEAR_BIT_IN_SHORT (*((SET_SHORT *)powerset), bitno);
+    }
+  else
+    {
+      powerset += (bitno/SET_WORD_SIZE);
+      bitno %= SET_WORD_SIZE;
+      if (new_value & 1)
+       SET_BIT_IN_WORD (*powerset, bitno);
+      else
+       CLEAR_BIT_IN_WORD (*powerset, bitno);
+    }
+}
diff --git a/libchill/setbits.c b/libchill/setbits.c
new file mode 100644 (file)
index 0000000..1e3045c
--- /dev/null
@@ -0,0 +1,85 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+extern void __cause_ex1 (char *exname, char *file, int lineno);
+
+/*
+ * function __setbits
+ *
+ * parameters:
+ *     out             result
+ *      bitlength       length of bitstring in bits
+ *     startbit        starting bitnumber
+ *     endbit          ending bitnumber
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *   rangefail
+ *
+ * abstract:
+ *  set all bits from starting bitnumber to ending bitnumber
+ *  in a powerset
+ *
+ */
+void
+__setbits (out, bitlength, startbit, endbit)
+     SET_WORD      *out;
+     unsigned long  bitlength;
+     long  startbit;
+     long  endbit;
+{
+  unsigned long i;
+  
+  if (out == NULL
+      || startbit < 0
+      || startbit >= bitlength 
+      || endbit < 0
+      || endbit >= bitlength 
+      || endbit < startbit)
+    __cause_ex1 ("rangefail", "__setbits", __LINE__);
+  
+  if (bitlength <= SET_CHAR_SIZE)
+    for (i = startbit; i <= endbit; i++)
+      SET_BIT_IN_CHAR (*((SET_CHAR *)out), i);
+  else if (bitlength <= SET_SHORT_SIZE)
+    for (i = startbit; i <= endbit; i++)
+      SET_BIT_IN_SHORT (*((SET_SHORT *)out), i);
+  else
+    {
+      SET_WORD *p;
+      unsigned long       bitnr;
+      
+      /* FIXME - this is inefficient! */
+      for (i = startbit; i <= endbit; i++)
+       {
+         p = out + (i / SET_WORD_SIZE);
+         bitnr = i % SET_WORD_SIZE;
+         SET_BIT_IN_WORD (*p, bitnr);
+       }
+    }
+} 
diff --git a/libchill/settextaccess.c b/libchill/settextaccess.c
new file mode 100644 (file)
index 0000000..014db4a
--- /dev/null
@@ -0,0 +1,39 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+void
+__settextaccess( Text_Mode*   the_text,
+                 Access_Mode* the_access,
+                 char*        file,
+                 int          line )
+{
+  if( !the_text )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_TEXT );
+
+  if( !the_access )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS );  
+
+  CLR_FLAG( the_text->access_sub, IO_TEXTIO );
+
+  the_text->access_sub = the_access;
+  SET_FLAG( the_access, IO_TEXTIO );
+}
diff --git a/libchill/settextindex.c b/libchill/settextindex.c
new file mode 100644 (file)
index 0000000..94b9266
--- /dev/null
@@ -0,0 +1,38 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+void
+__settextindex( Text_Mode*  the_text,
+                signed long the_text_index, 
+                char*       file,
+                int         line )
+{
+  if( !the_text )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_TEXT );
+
+  if( the_text_index < 0 
+      || the_text->access_sub->reclength - 2 < the_text_index )
+    CHILLEXCEPTION( file, line, TEXTFAIL, BAD_TEXTINDEX );
+  
+  the_text->actual_index = the_text_index;
+}
+
diff --git a/libchill/settextrecord.c b/libchill/settextrecord.c
new file mode 100644 (file)
index 0000000..34a2643
--- /dev/null
@@ -0,0 +1,37 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+void
+__settextrecord( Text_Mode* the_text,
+                 VarString* the_text_rec,
+                 char*      file,
+                 int        line )
+{
+  if( !the_text )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_TEXT );
+
+  if( !the_text_rec )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_TEXTREC );  
+
+  the_text->text_record = the_text_rec;
+}
+
diff --git a/libchill/sliceps.c b/libchill/sliceps.c
new file mode 100644 (file)
index 0000000..939a0b8
--- /dev/null
@@ -0,0 +1,65 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __powerset_slice
+ *
+ * parameters:
+ *      dps             dest powerset
+ *      dbl             destination bit length
+ *     sps             sourcepowerset
+ *     sbl             source powerset length in bits
+ *      start           starting bit number
+ *      end             ending bit number
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  Extract into a powerset a slice of another powerset.
+ *
+ */
+extern void
+__pscpy (SET_WORD      *dps,
+        unsigned long  dbl,
+        unsigned long  doffset,
+        SET_WORD      *sps,
+        unsigned long  sbl,
+        unsigned long  start,
+        unsigned long  length);
+
+void
+__psslice (dps, dbl, sps, sbl, start, length)
+     SET_WORD      *dps;
+     unsigned long  dbl;
+     SET_WORD      *sps;
+     unsigned long  sbl;
+     unsigned long  start;
+     unsigned long  length;
+{
+  /* simply supply a zero destination offset and copy the slice */
+  __pscpy (dps, dbl, (unsigned long)0, sps, sbl, start, length);
+}
diff --git a/libchill/terminate.c b/libchill/terminate.c
new file mode 100644 (file)
index 0000000..ea2044e
--- /dev/null
@@ -0,0 +1,60 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdlib.h>
+#include "rtltypes.h"
+
+extern void __cause_ex1 (char *exname, char *file, int lineno);
+
+/* define needed exceptions */
+EXCEPTION (empty)
+
+/*
+ * function __terminate
+ *
+ * parameter:
+ *  ptr                        pointer to memory to free
+ *  filename            source file which issued the call
+ *  linenumber          line number of the call within that file
+ *
+ * returns:
+ *  void
+ *
+ * exceptions:
+ *  empty
+ *
+ * abstract:
+ *  free memory previously allocated by __allocate.
+ *
+*/
+
+void
+__terminate (ptr, filename, linenumber)
+     void *ptr;
+     char *filename;
+     int linenumber;
+{
+  if (! ptr)
+    __cause_ex1 ("empty", filename, linenumber);
+  free (ptr);
+}
diff --git a/libchill/unhex.c b/libchill/unhex.c
new file mode 100644 (file)
index 0000000..3bd23dc
--- /dev/null
@@ -0,0 +1,57 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <setjmp.h>
+
+/*
+ * function unhandled_exception
+ *
+ * parameter:
+ *  exname             name of exception
+ *  file               filename
+ *  lineno             line number
+ *  user_arg           user specified argument
+ *
+ * returns:
+ *  never
+ *
+ * abstract:
+ *  print an error message about unhandled exception and call abort
+ *
+ */
+
+void
+unhandled_exception (exname, file, lineno, user_arg)
+     char *exname;
+     char *file;
+     int lineno;
+     int user_arg;
+{
+  sleep (1); /* give previous output a chance to finish */
+  fprintf (stderr, "ChillLib: unhandled exception `%s' in file %s at line %d\n",
+          exname, file, lineno);
+  fflush (stderr);
+  abort ();
+} /* unhandled_exception */
diff --git a/libchill/unhex1.c b/libchill/unhex1.c
new file mode 100644 (file)
index 0000000..375f6a5
--- /dev/null
@@ -0,0 +1,58 @@
+/* Implement runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <setjmp.h>
+
+extern void cause_exception (char *ex, char *file, int lineno, int arg);
+extern void unhandled_exception (char *ex, char *file, int lineno, int arg);
+
+/*
+ * function __unhandled_ex
+ *
+ * parameter:
+ *  exname             name of exception
+ *  file               filename
+ *  lineno             line number
+ *
+ * returns:
+ *  never
+ *
+ * abstract:
+ *  This function gets called by compiler generated code when an unhandled
+ *  exception occures.
+ *  First cause_exception gets called (which may be user defined) and
+ *  then the standard unhandled exception routine gets called.
+ *
+ */
+
+void
+__unhandled_ex (exname, file, lineno)
+     char *exname;
+     char *file;
+     int lineno;
+{
+    cause_exception (exname, file, lineno, 0);
+    unhandled_exception (exname, file, lineno, 0);
+} /* unhandled_exception */
diff --git a/libchill/variable.c b/libchill/variable.c
new file mode 100644 (file)
index 0000000..69810b3
--- /dev/null
@@ -0,0 +1,31 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__variable( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+  if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+  return TEST_FLAG( the_assoc, IO_VARIABLE ) ? True : False;
+}
diff --git a/libchill/waitbuffer.c b/libchill/waitbuffer.c
new file mode 100644 (file)
index 0000000..05b0151
--- /dev/null
@@ -0,0 +1,297 @@
+/* Implement tasking-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rtltypes.h"
+#include "rts.h"
+
+extern void __cause_ex1 (char *ex, char *file, int lineno);
+
+EXCEPTION (bufferinconsistency)
+#define CAUSE_BUFFINCONS  __cause_ex1 ("bufferinconsistency", filename, lineno)
+EXCEPTION (spacefail);
+#define CAUSE_SPACEFAIL   __cause_ex1 ("spacefail", filename, lineno)
+    
+/*
+ * function __wait_buffer
+ *
+ * parameters:
+ *     buf_got    pointer to location for writing the received buffer address
+ *     nbuf        number of buffers in RECEIVE CASE
+ *     bufptr      array of pointers to buffer descriptor
+ *     datap       pointer where to store data
+ *     datalen     length of data
+ *     ins         pointer to instance location or 0
+ *     else_clause else specified or not
+ *     to_loc      pointer to timesupervision value
+ *     filename    source file name where function gets called
+ *     lineno      linenumber in source file
+ *
+ * returns:
+ *     int        0 .. success
+ *                 1 .. timed out
+ *
+ * exceptions:
+ *     bufferinconsistency  if something's wrong in the buffer queue's
+ *     spacefail            out of heap space of datalength of receiver
+ *                          less then data avilable.
+ *
+ * abstract:
+ *     implement the CHILL RECEIVE buffer CASE action.
+ */
+
+int
+__wait_buffer (buf_got, nbuf, bufptr, datap, datalen, ins,
+               else_clause, to, filename, lineno)
+     void           **buf_got;
+     int              nbuf;
+     Buffer_Descr    *bufptr[];
+     void            *datap;
+     int              datalen;
+     INSTANCE        *ins;
+     int              else_clause;
+     void            *to;
+     char            *filename;
+     int              lineno;
+{
+  int i;
+  Buffer_Wait_Queue     *start_list;
+  Buffer_Queue         **retval;
+  Buffer_Queue         **highprio;
+  int                    timed_out;
+  
+  /* look if there is a buffer already sent */
+  highprio = 0;
+  for (i = 0; i < nbuf; i++)
+    {
+      Buffer_Queue      *bq;
+
+      memcpy (&bq, bufptr[i]->buf, sizeof (Buffer_Queue *));
+      if (bq != 0 && bq->sendqueue != 0)
+        {
+          if (highprio != 0)
+            {
+              Buffer_Queue      *bsq = *highprio;
+              
+              if (bq->sendqueue->priority > bsq->sendqueue->priority)
+                highprio = bufptr[i]->buf;
+            }
+          else
+            highprio = bufptr[i]->buf;
+        }
+    }
+  
+  if (highprio != 0)
+    {
+      Buffer_Queue      *bq;
+
+      memcpy (&bq, highprio, sizeof (Buffer_Queue *));
+      if (bq != 0 && bq->sendqueue != 0)
+        {
+          Buffer_Send_Queue *bsq = bq->sendqueue;
+          Buffer_Send_Queue *tmp;
+
+          /* check data length */
+          if (datalen < bsq->datalen)
+            /* something's totaly wrong. Raise exception */
+            CAUSE_SPACEFAIL;
+
+          /* copy data out */
+          memcpy (datap, bsq->dataptr, bsq->datalen);
+
+          /* update instance, if present */
+          if (ins != 0)
+            memcpy (ins, &bsq->this, sizeof (INSTANCE));
+
+          /* dequeue entry */
+          tmp = bsq;
+          bq->sendqueue = tmp->forward;
+
+          if (tmp->is_delayed)
+            {
+              /* there is an instance delayed on a send,
+                 continue it. */
+              __continue_that (tmp->this, tmp->priority, filename, lineno);
+              FREE (tmp);
+
+              /* return the buffer we have received from */
+             *buf_got = (void *)highprio;
+              return 0;
+            }
+
+          /* just decrease sendqueue length */
+          bq->sendqueuelength--;
+
+          FREE (tmp);
+
+          /* as we got an entry free, we should continue
+             an INSTANCE which is delayed on a send at this
+             buffer */
+          bsq = bq->sendqueue;
+          while (bsq != 0)
+            {
+              if (bsq->is_delayed)
+                {
+                  bq->sendqueuelength++;
+                  bsq->is_delayed = 0;
+                  __continue_that (bsq->this, bsq->priority, filename, lineno);
+                  break;
+                }
+              bsq = bsq->forward;
+            }
+          /* return the buffer we have received from */
+          *buf_got = (void *)highprio;
+         return 0;
+        }
+      }
+
+  /* if we come here, there is no buffer already sent */
+  if (else_clause != 0)
+    {
+      /* in that case we return immediately */
+      *buf_got = 0;
+      return 0;
+    }
+  
+  /* now we have to queue ourself to the wait queue(s) */
+  start_list = 0;
+  for (i = 0; i < nbuf; i++)
+    {
+      Buffer_Queue      *bq;
+      Buffer_Wait_Queue *wrk;
+      Buffer_Wait_Queue *bwq;
+      Buffer_Wait_Queue *prev_queue_entry = 0;
+      Buffer_Wait_Queue *prev_list_entry;
+      int                j, have_done = 0;
+      
+      for (j = 0; j < i; j++)
+        {
+          if (bufptr[i]->buf == bufptr[j]->buf)
+            {
+              have_done = 1;
+              break;
+            }
+        }
+      if (have_done)
+        continue;
+      
+      memcpy (&bq, bufptr[i]->buf, sizeof (Buffer_Queue *));
+      if (bq == 0)
+        {
+          MALLOC (bq, sizeof (Buffer_Queue));
+          memset (bq, 0, sizeof (Buffer_Queue));
+          /* *(bufptr[i]->buf) = bq; may be unaligned */
+         memcpy (bufptr[i]->buf, &bq, sizeof (Buffer_Queue *));
+        }
+      MALLOC (wrk, sizeof (Buffer_Wait_Queue));
+      memset (wrk, 0, sizeof (Buffer_Wait_Queue));
+      bwq = (Buffer_Wait_Queue *)&bq->waitqueue;
+      
+      wrk->this = THIS;
+      wrk->datalen = datalen;
+      wrk->dataptr = datap;
+      wrk->bufferaddr = bufptr[i]->buf;
+
+      /* queue it at the end of buffer wait queue */
+      while (bwq->forward != 0)
+          bwq = bwq->forward;
+      wrk->forward = bwq->forward;
+      bwq->forward = wrk;
+      
+      /* queue it into list */
+      wrk->startlist = start_list;
+      if (! start_list)
+        {
+          start_list = wrk;
+          prev_list_entry = wrk;
+          wrk->startlist = start_list;
+        }
+      else
+        {
+          prev_list_entry->chain = wrk;
+          prev_list_entry = wrk;
+        }
+      
+      /* increment wait queue count */
+      bq->waitqueuelength++;
+    }
+
+  /* tell runtime system to delay this process */
+  timed_out = __delay_this (wait_buffer_receive, to, filename, lineno);
+  if (timed_out)
+    {
+      /* remove all entries from buffer queues */
+      Buffer_Wait_Queue *listentry = start_list;
+      
+      while (listentry != 0)
+        {
+         Buffer_Queue *bq = *(listentry->bufferaddr);
+         Buffer_Wait_Queue *prev_entry = (Buffer_Wait_Queue *)&bq->waitqueue;
+         Buffer_Wait_Queue *bwq = bq->waitqueue;
+         
+         while (bwq != listentry)
+           {
+             prev_entry = bwq;
+             bwq = bwq->forward;
+           }
+         /* dequeue it */
+         prev_entry->forward = bwq->forward;
+         bq->waitqueuelength--;
+         listentry = listentry->chain;
+        }
+    }
+  
+  /* someone has continued us, find which buffer got ready */
+  retval = 0;
+
+  while (start_list != 0)
+    {
+      Buffer_Wait_Queue *tmp = start_list->chain;
+      
+      if (start_list->is_sent)
+        {
+          /* this one has been sent */
+          /* save return value */
+          if (retval == 0)
+              retval = start_list->bufferaddr;
+          else
+              /* more then one has been sent, that's wrong */
+              CAUSE_BUFFINCONS;
+          
+          /* update instance, if present */
+          if (ins != 0)
+            memcpy (ins, &start_list->who_sent, sizeof (INSTANCE));
+        }
+      FREE (start_list);
+      start_list = tmp;
+    }
+
+  /* now check if there was really a buffer got */
+  if (retval == 0 && !timed_out)
+    /* something's totally wrong, raise an exception  */
+    CAUSE_BUFFINCONS;
+
+  if (!timed_out)
+    *buf_got = (void *)retval;
+  return timed_out;
+}
+
+/* force function __print_buffer to be linked */
+extern void __print_buffer ();
+static EntryPoint pev = __print_buffer;
diff --git a/libchill/waituntil.c b/libchill/waituntil.c
new file mode 100644 (file)
index 0000000..dfe57be
--- /dev/null
@@ -0,0 +1,74 @@
+/* Implement timing-related runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "rtltypes.h"
+#include "rts.h"
+
+EXCEPTION (timerfail);
+
+/*
+ * function __wait_until
+ *
+ * parameters:
+ *     abstime   absolute time value
+ *     filename
+ *     linenumber
+ *
+ * returns:
+ *     int   0 on success, 1 on failure
+ *
+ * exceptions:
+ *     timerfail
+ *
+ * abstract:
+ *     check for given argument is valid, calculate how long to wait in
+ *     seconds and call os to do it.
+ *
+ */
+
+int
+__wait_until (abstime, filename, linenumber)
+     unsigned long  abstime;
+     char          *filename;
+     int            linenumber;
+{
+  RtsTime      now, delta, abs_rtstime;
+    
+  /* get current time */
+  __rtstime (&now);
+    
+  abs_rtstime.secs = abstime;
+  abs_rtstime.nanosecs = 0;
+  
+  if (abs_rtstime.nanosecs < now.nanosecs)
+    {
+      abs_rtstime.secs--;
+      abs_rtstime.nanosecs += 1000000000;
+    }
+  
+  delta.secs = abs_rtstime.secs - now.secs;
+  delta.nanosecs = abs_rtstime.nanosecs - now.nanosecs;
+  
+  if (delta.secs > abs_rtstime.secs)
+    /* cannot wait into past */
+    return 1;
+  
+  return __delay_this (wait_wait, &delta, filename, linenumber) == 1 ? 0 : 1;
+}
diff --git a/libchill/writeable.c b/libchill/writeable.c
new file mode 100644 (file)
index 0000000..cf0f5cd
--- /dev/null
@@ -0,0 +1,31 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include "fileio.h"
+
+Boolean
+__writeable( Association_Mode* the_assoc, char* file, int line )
+{
+  if( !the_assoc )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION );
+  if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) )
+    CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED );
+  return TEST_FLAG(the_assoc, IO_WRITEABLE) ? True : False;
+}
diff --git a/libchill/writerecord.c b/libchill/writerecord.c
new file mode 100644 (file)
index 0000000..7e88322
--- /dev/null
@@ -0,0 +1,133 @@
+/* Implement Input/Output runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#include <setjmp.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "fileio.h"
+
+static
+void
+doWrite( Access_Mode* the_access, void* buf, size_t nbyte )
+{
+  size_t nwrit;
+
+  nwrit = write( the_access->association->handle, buf, nbyte );
+
+  if( nwrit < nbyte )
+  {
+    the_access->association->syserrno = errno;
+    RWEXCEPTION( WRITEFAIL, OS_IO_ERROR );
+  }
+}
+
+
+void
+__writerecord( Access_Mode*  the_access,
+               signed long   the_index,
+               char*         the_val_addr,
+               unsigned long the_val_len,
+               char*         file,
+               int           line )
+
+{
+  Association_Mode* the_assoc;
+  unsigned long  info;
+  char*          actaddr;
+  unsigned short actlen;
+  off_t          filepos;
+
+  if( !the_access )
+    CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS );
+
+  if( !(the_assoc = the_access->association) )
+    CHILLEXCEPTION( file, line, NOTCONNECTED, IS_NOT_CONNECTED );
+
+  /* Usage must no be ReadOnly */
+  if( the_assoc->usage == ReadOnly )
+    CHILLEXCEPTION( file, line, WRITEFAIL, BAD_USAGE );
+
+  /*
+   *  Positioning
+   */
+  if( TEST_FLAG( the_access, IO_INDEXED ) )
+  {
+    /* index expression must be within bounds of index mode */
+    if( the_index < the_access->lowindex
+        || the_access->highindex < the_index )
+      CHILLEXCEPTION( file, line, RANGEFAIL, BAD_INDEX );
+    filepos = the_access->base + 
+              (the_index - the_access->lowindex) * the_access->reclength;
+
+    if( lseek( the_assoc->handle, filepos, SEEK_SET ) == -1L )
+      CHILLEXCEPTION( file, line, WRITEFAIL, LSEEK_FAILS );
+  }
+
+  if( (info = setjmp( __rw_exception )) )
+    CHILLEXCEPTION( file, line, info>>16, info & 0xffff );
+
+  if( TEST_FLAG( the_access, IO_TEXTIO ) )
+  {
+    if( TEST_FLAG( the_access, IO_INDEXED ) )
+    {
+      int nspace = the_access->reclength - the_val_len;
+      memset( the_val_addr + 2 + the_val_len, ' ', nspace );
+      actlen = the_access->reclength - 2;
+      MOV2(the_val_addr,&actlen);
+      doWrite( the_access, the_val_addr, the_access->reclength );
+    }
+    else
+    { 
+      if( the_assoc->ctl_pre )
+       write( the_assoc->handle, &the_assoc->ctl_pre, 1 );
+      MOV2(&actlen,the_val_addr);
+      write( the_assoc->handle, the_val_addr + 2, actlen );
+      if( the_assoc->ctl_post )
+       write( the_assoc->handle, &the_assoc->ctl_post, 1 );
+      the_assoc->ctl_pre  = '\0';
+      the_assoc->ctl_post = '\n';
+    }
+  }
+  else
+  {
+    switch( the_access->rectype )
+    {
+    case Fixed:
+      if( TEST_FLAG( the_assoc, IO_VARIABLE ) )
+      {
+        actlen = the_access->reclength;
+        doWrite( the_access, &actlen, sizeof(actlen) );
+      }
+      doWrite( the_access, the_val_addr, the_val_len );
+      break;
+    case VaryingChars:
+      MOV2(&actlen,the_val_addr);
+      if( actlen > the_access->reclength - 2 )
+        CHILLEXCEPTION( file, line, RANGEFAIL, RECORD_TOO_LONG );
+      actlen = TEST_FLAG( the_access, IO_INDEXED ) 
+               ? the_access->reclength : actlen + 2;
+      doWrite( the_access, the_val_addr, actlen );
+      break;
+    }
+  }
+}
diff --git a/libchill/xorps.c b/libchill/xorps.c
new file mode 100644 (file)
index 0000000..ddf0012
--- /dev/null
@@ -0,0 +1,76 @@
+/* Implement POWERSET runtime actions for CHILL.
+   Copyright (C) 1992,1993 Free Software Foundation, Inc.
+   Author: Wilfried Moser, et al
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#define __CHILL_LIB__
+
+#include "config.h"
+#include <stdio.h>
+#include "powerset.h"
+
+/*
+ * function __xorpowerset
+ *
+ * parameters:
+ *     out             return from __xorpowerset
+ *     left            left powerset
+ *     right           right powerset
+ *     bitlength       length of powerset in bits
+ *
+ * returns:
+ *     void
+ *
+ * exceptions:
+ *  none
+ *
+ * abstract:
+ *  xor's 2 powersets
+ *
+ */
+
+void
+__xorpowerset (out, left, right, bitlength)
+     SET_WORD      *out;
+     SET_WORD      *left;
+     SET_WORD      *right;
+     unsigned long  bitlength;
+{
+  if (bitlength <= SET_CHAR_SIZE)
+    {
+      *((SET_CHAR *)out) = *((SET_CHAR *)left) ^
+                           *((SET_CHAR *)right);
+      MASK_UNUSED_CHAR_BITS((SET_CHAR *)out, bitlength);
+    }
+  else if (bitlength <= SET_SHORT_SIZE)
+    {
+      *((SET_SHORT *)out) = *((SET_SHORT *)left) ^
+                            *((SET_SHORT *)right);
+      MASK_UNUSED_SHORT_BITS((SET_SHORT *)out, bitlength);
+    }
+  else
+    {
+      unsigned long len = BITS_TO_WORDS(bitlength);
+      register unsigned long i;
+
+      for (i = 0; i < len; i++)
+       out[i] = left[i] ^ right[i];
+      MASK_UNUSED_WORD_BITS ((out + len - 1), 
+                            bitlength % SET_WORD_SIZE);
+    }
+}