* 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.

From-SVN: r22238
This commit is contained in:
Jeff Law 1998-09-04 19:11:54 -06:00
parent 1802393487
commit b79f73df6a
88 changed files with 12403 additions and 0 deletions

742
libchill/ChangeLog Normal file
View file

@ -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.

166
libchill/Makefile.in Normal file
View file

@ -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

131
libchill/abstime.c Normal file
View file

@ -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;
}

61
libchill/allgmem.c Normal file
View file

@ -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);
}

73
libchill/allmem.c Normal file
View file

@ -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;
}

67
libchill/allocate.c Normal file
View file

@ -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;
}

76
libchill/andps.c Normal file
View file

@ -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);
}
}

45
libchill/auxtypes.h Normal file
View file

@ -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

467
libchill/basicio.c Normal file
View file

@ -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;
}

29
libchill/bitstring.h Normal file
View file

@ -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

99
libchill/cardps.c Normal file
View file

@ -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);
}
}

48
libchill/cause.c Normal file
View file

@ -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;
{
}

65
libchill/checkcycle.c Normal file
View file

@ -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);
}

147
libchill/chillrt0.c Normal file
View file

@ -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"
/* 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;
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_ */
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 */

210
libchill/chillstdio.c Normal file
View file

@ -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));
}

93
libchill/concatps.c Normal file
View file

@ -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);
}

69
libchill/concatstr.c Normal file
View file

@ -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;
}

1474
libchill/configure vendored Executable file

File diff suppressed because it is too large Load diff

121
libchill/configure.in Normal file
View file

@ -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:

83
libchill/continue.c Normal file
View file

@ -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;

52
libchill/convdurrtstime.c Normal file
View file

@ -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;
}

111
libchill/copyps.c Normal file
View file

@ -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);
}
}

220
libchill/delaycase.c Normal file
View file

@ -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;

42
libchill/delete.c Normal file
View file

@ -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 );
}

74
libchill/diffps.c Normal file
View file

@ -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);
}
}

30
libchill/eoln.c Normal file
View file

@ -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;
}

88
libchill/eqps.c Normal file
View file

@ -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;
}
}

54
libchill/eqstr.c Normal file
View file

@ -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);
}

152
libchill/exh.c Normal file
View file

@ -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);
}

40
libchill/exhstack.c Normal file
View file

@ -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;
}

31
libchill/existing.c Normal file
View file

@ -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;
}

102
libchill/ffsetclrps.c Normal file
View file

@ -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;
}
}

109
libchill/ffsetps.c Normal file
View file

@ -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);
}

153
libchill/fileio.h Normal file
View file

@ -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

99
libchill/flsetclrps.c Normal file
View file

@ -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;
}
}

107
libchill/flsetps.c Normal file
View file

@ -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);
}

2186
libchill/format.c Normal file

File diff suppressed because it is too large Load diff

71
libchill/format.h Normal file
View file

@ -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_

37
libchill/getassoc.c Normal file
View file

@ -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;
}

31
libchill/gettextaccess.c Normal file
View file

@ -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;
}

30
libchill/gettextindex.c Normal file
View file

@ -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;
}

30
libchill/gettextrecord.c Normal file
View file

@ -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;
}

40
libchill/getusage.c Normal file
View file

@ -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;
}

74
libchill/inbitstr.c Normal file
View file

@ -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);
}

31
libchill/indexable.c Normal file
View file

@ -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;
}

65
libchill/inps.c Normal file
View file

@ -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);
}

85
libchill/inttime.c Normal file
View file

@ -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);
}

45
libchill/ioerror.c Normal file
View file

@ -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;

161
libchill/ioerror.h Normal file
View file

@ -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

251
libchill/iomodes.h Normal file
View file

@ -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

29
libchill/isassociated.c Normal file
View file

@ -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;
}

76
libchill/leps.c Normal file
View file

@ -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;
}
}

86
libchill/ltps.c Normal file
View file

@ -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;
}
}

55
libchill/ltstr.c Normal file
View file

@ -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);
}

63
libchill/memmove.c Normal file
View file

@ -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;
}

52
libchill/neps.c Normal file
View file

@ -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);
}

81
libchill/notps.c Normal file
View file

@ -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);
}
}

75
libchill/orps.c Normal file
View file

@ -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);
}
}

40
libchill/outoffile.c Normal file
View file

@ -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;
}

106
libchill/powerset.h Normal file
View file

@ -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

116
libchill/printbuffer.c Normal file
View file

@ -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");
}

93
libchill/printevent.c Normal file
View file

@ -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");
}

79
libchill/queuelength.c Normal file
View file

@ -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;
}

32
libchill/readable.c Normal file
View file

@ -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;
}

208
libchill/readrecord.c Normal file
View file

@ -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;
}

83
libchill/remaintime.c Normal file
View file

@ -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;
}

52
libchill/retmem.c Normal file
View file

@ -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);
}

61
libchill/rtltypes.h Normal file
View file

@ -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__ */

655
libchill/rts.c Normal file
View file

@ -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;
}
}
/* 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;
/* 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;
}
}
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;
/* 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;
}
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);
}
/* 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;
}
/* 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;
}
/* wait till timeout expires */
void
__wait_timeout (toid, filename, lineno)
volatile int *toid;
char *filename;
int lineno;
{
while (! *toid) ;
*toid = 0;
}

52
libchill/rts.h Normal file
View file

@ -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_ */

65
libchill/rtsdummy.c Normal file
View file

@ -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;

175
libchill/sendbuffer.c Normal file
View file

@ -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;

32
libchill/sequencible.c Normal file
View file

@ -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;
}

89
libchill/setbitps.c Normal file
View file

@ -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);
}
}

85
libchill/setbits.c Normal file
View file

@ -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);
}
}
}

39
libchill/settextaccess.c Normal file
View file

@ -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 );
}

38
libchill/settextindex.c Normal file
View file

@ -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;
}

37
libchill/settextrecord.c Normal file
View file

@ -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;
}

65
libchill/sliceps.c Normal file
View file

@ -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);
}

60
libchill/terminate.c Normal file
View file

@ -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);
}

57
libchill/unhex.c Normal file
View file

@ -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 */

58
libchill/unhex1.c Normal file
View file

@ -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 */

31
libchill/variable.c Normal file
View file

@ -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;
}

297
libchill/waitbuffer.c Normal file
View file

@ -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;

74
libchill/waituntil.c Normal file
View file

@ -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;
}

31
libchill/writeable.c Normal file
View file

@ -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;
}

133
libchill/writerecord.c Normal file
View file

@ -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;
}
}
}

76
libchill/xorps.c Normal file
View file

@ -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);
}
}