diff options
Diffstat (limited to 'gcc/ch/runtime')
-rw-r--r-- | gcc/ch/runtime/concatstr.c | 69 | ||||
-rw-r--r-- | gcc/ch/runtime/continue.c | 83 | ||||
-rw-r--r-- | gcc/ch/runtime/convdurrtstime.c | 52 | ||||
-rw-r--r-- | gcc/ch/runtime/ffsetclrps.c | 102 | ||||
-rw-r--r-- | gcc/ch/runtime/flsetclrps.c | 99 | ||||
-rw-r--r-- | gcc/ch/runtime/leps.c | 76 | ||||
-rw-r--r-- | gcc/ch/runtime/powerset.h | 106 | ||||
-rw-r--r-- | gcc/ch/runtime/queuelength.c | 79 | ||||
-rw-r--r-- | gcc/ch/runtime/readrecord.c | 208 | ||||
-rw-r--r-- | gcc/ch/runtime/rtsdummy.c | 65 | ||||
-rw-r--r-- | gcc/ch/runtime/sequencible.c | 32 | ||||
-rw-r--r-- | gcc/ch/runtime/setbitps.c | 89 | ||||
-rw-r--r-- | gcc/ch/runtime/setbits.c | 85 | ||||
-rw-r--r-- | gcc/ch/runtime/settextindex.c | 38 | ||||
-rw-r--r-- | gcc/ch/runtime/variable.c | 31 | ||||
-rw-r--r-- | gcc/ch/runtime/writeable.c | 31 |
16 files changed, 1245 insertions, 0 deletions
diff --git a/gcc/ch/runtime/concatstr.c b/gcc/ch/runtime/concatstr.c new file mode 100644 index 0000000..e4105d6 --- /dev/null +++ b/gcc/ch/runtime/concatstr.c @@ -0,0 +1,69 @@ +/* Implement string-related runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Bill Cox + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +extern void cause_exception (char *exname, char *file, int lineno); + +/* + * function __concatstring + * + * parameters: + * OUT - pointer to output string + * S1 - pointer to left string + * LEN1 - length of left string + * S2 - pointer to right string + * LEN2 - length of right string + * + * returns: + * pointer to OUT string + * + * exceptions: + * none + * + * abstract: + * concatenates two character strings into the output string + * + */ + +char * +__concatstring (out, s1, len1, s2, len2) + char *out, *s1; + int len1; + char *s2; + int len2; +{ + if (out) + { + if (s2 /* Check for overlap between s2 and out. */ + && ((s2 >= out && s2 < (out + len1 + len2)) + || (s2 + len2 > out && s2 <= out + len1))) + { + char *tmp = alloca (len2); + memcpy (tmp, s2, len2); + s2 = tmp; + } + if (s1) + memmove (out, s1, len1); + if (s2) + memcpy (&out[len1], s2, len2); + } + return out; +} diff --git a/gcc/ch/runtime/continue.c b/gcc/ch/runtime/continue.c new file mode 100644 index 0000000..76d457d --- /dev/null +++ b/gcc/ch/runtime/continue.c @@ -0,0 +1,83 @@ +/* Implement tasking-related runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "rtltypes.h" +#include "rts.h" + +/* + * function __continue + * + * parameters: + * evaddr pointer to Eventlocation + * filename source file name where function gets called + * lineno linenumber in source file + * + * returns: + * void + * + * exceptions: + * none + * + * abstract: + * implement the CHILL CONTINUE action. + */ + +void +__continue (evaddr, filename, lineno) + Event_Queue **evaddr; + char *filename; + int lineno; +{ + Event_Queue *ev = *evaddr; + Event_Queue *wrk; + + if (ev == 0) + /* nothing to do */ + return; + + /* search for 1st one is not already continued */ + while (ev && ev->is_continued) + ev = ev->forward; + if (!ev) + /* all have been continued in that queue, do nothing */ + return; + + wrk = ev->startlist; + while (wrk) + { + Event_Queue *tmp = (Event_Queue *)wrk->listhead; + + while (tmp->forward != wrk) + tmp = tmp->forward; + tmp->forward = wrk->forward; + wrk = wrk->chain; + } + + /* so far so good, continue this one */ + ev->is_continued = 1; + ev->who_continued = THIS; + + /* tell the runtime system to activate the process */ + __continue_that (ev->this, ev->priority, filename, lineno); +} + +/* force function print_event to be linked */ +extern void __print_event (); +static EntryPoint pev = __print_event; diff --git a/gcc/ch/runtime/convdurrtstime.c b/gcc/ch/runtime/convdurrtstime.c new file mode 100644 index 0000000..f56fc3a --- /dev/null +++ b/gcc/ch/runtime/convdurrtstime.c @@ -0,0 +1,52 @@ +/* Implement timing-related runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "rts.h" + +/* + * function __convert_duration_rtstime + * + * parameters: + * dur the duration value + * t pointer to the duration value converted to RtsTime + * + * returns: + * void + * + * exceptions: + * none + * + * abstract: + * converts a duration value (unsigned long in millisecs) to RtsTime + * format. + * + */ + +void +__convert_duration_rtstime (dur, t) + unsigned long dur; + RtsTime *t; +{ + unsigned long tmp; + + t->secs = dur / 1000; + tmp = dur - (t->secs * 1000); + t->nanosecs = tmp * 1000000; +} diff --git a/gcc/ch/runtime/ffsetclrps.c b/gcc/ch/runtime/ffsetclrps.c new file mode 100644 index 0000000..bb5b965 --- /dev/null +++ b/gcc/ch/runtime/ffsetclrps.c @@ -0,0 +1,102 @@ +/* Implement POWERSET runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define __CHILL_LIB__ + +#include "config.h" +#include <stdio.h> +#include "powerset.h" + +/* + * function __ffsetclrpowerset + * + * parameters: + * ps powerset + * bitlength length of powerset + * + * returns: + * int -1 .. nothing found + * >=0 .. index of first true bit found + * exceptions: + * none + */ + +int +__ffsetclrpowerset (ps, bitlength, first_bit) + SET_WORD *ps; + unsigned long bitlength; + int first_bit; +{ + register int bitno; + + if (first_bit >= bitlength) + return -1; + +#ifndef USE_CHARS + if (bitlength <= SET_CHAR_SIZE) + { + for (bitno = first_bit; bitno < bitlength; bitno++) + if (GET_BIT_IN_CHAR (*((SET_CHAR *)ps), bitno)) + break; + return bitno == bitlength ? -1 : bitno; + } + else if (bitlength <= SET_SHORT_SIZE) + { + for (bitno = first_bit; bitno < bitlength; bitno++) + if (GET_BIT_IN_SHORT (*((SET_SHORT *)ps), bitno)) + break; + return bitno == bitlength ? -1 : bitno; + } + else +#endif + { + unsigned int words_to_skip = (unsigned) first_bit / SET_WORD_SIZE; + unsigned long cnt = words_to_skip * SET_WORD_SIZE; + SET_WORD *p = ps + words_to_skip; + SET_WORD *endp = ps + BITS_TO_WORDS(bitlength); + SET_WORD c; + first_bit = (unsigned) first_bit % (unsigned) SET_WORD_SIZE; + + c = *p++; + if (c) + { + for (bitno = first_bit; bitno < SET_WORD_SIZE; bitno++) + if (GET_BIT_IN_WORD(c, bitno)) + goto found; + } + cnt += SET_WORD_SIZE; + + while (p < endp) + { + if ((c = *p++)) + { + /* found a bit set .. calculate which */ + for (bitno = 0; bitno < SET_WORD_SIZE; bitno++) + if (GET_BIT_IN_WORD(c, bitno)) + goto found; + } + cnt += SET_WORD_SIZE; + } + return -1; + found: + bitno += cnt; + return bitno >= bitlength ? -1 : bitno; + } +} diff --git a/gcc/ch/runtime/flsetclrps.c b/gcc/ch/runtime/flsetclrps.c new file mode 100644 index 0000000..e768a47 --- /dev/null +++ b/gcc/ch/runtime/flsetclrps.c @@ -0,0 +1,99 @@ +/* Implement POWERSET runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define __CHILL_LIB__ + +#include "config.h" +#include <stdio.h> +#include "powerset.h" + +/* + * function __flsetclrpowerset + * + * parameters: + * ps powerset + * bitlength length of powerset + * + * returns: + * int -1 .. nothing found + * >= 0 .. index of last set bit + * exceptions: + * none + * + * abstract: + * Find last bit set in a powerset and return the corresponding value + * in *out and clear this bit. Return 0 for no more found, else 1. + * + */ +int +__flsetclrpowerset (ps, bitlength, first_bit) + SET_WORD *ps; + unsigned long bitlength; + int first_bit; +{ + register int bitno; + +#ifndef USE_CHARS + if (bitlength <= SET_CHAR_SIZE) + { + for (bitno = bitlength - 1; bitno >= first_bit; bitno--) + if (GET_BIT_IN_CHAR (*((SET_CHAR *)ps), bitno)) + break; + return bitno < first_bit ? -1 : bitno; + } + else if (bitlength <= SET_SHORT_SIZE) + { + for (bitno = bitlength - 1; bitno >= first_bit; bitno--) + if (GET_BIT_IN_SHORT (*((SET_SHORT *)ps), bitno)) + break; + return bitno < first_bit ? -1 : bitno; + } + else +#endif + { + SET_WORD *p, c; + bitno = bitlength - 1; + if (bitno < first_bit) + return -1; + p = &ps[(unsigned) bitno / SET_WORD_SIZE]; + c = *p; + if (((unsigned) bitlength % SET_WORD_SIZE) != 0) + MASK_UNUSED_WORD_BITS(&c, (unsigned) bitlength % SET_WORD_SIZE); + if (c) + goto found; + else + bitno -= ((unsigned) bitno % SET_WORD_SIZE) + 1; + while (bitno >= first_bit) + { + c = *--p; + if (c) + goto found; + bitno -= SET_WORD_SIZE; + } + return -1; + found: + for (; bitno >= first_bit; bitno--) + { + if (GET_BIT_IN_WORD (c, (unsigned) bitno % SET_WORD_SIZE)) + return bitno; + } + return -1; + } +} diff --git a/gcc/ch/runtime/leps.c b/gcc/ch/runtime/leps.c new file mode 100644 index 0000000..7c5231a --- /dev/null +++ b/gcc/ch/runtime/leps.c @@ -0,0 +1,76 @@ +/* Implement POWERSET runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define __CHILL_LIB__ + +#include "config.h" +#include <stdio.h> +#include "powerset.h" + +/* + * function __lepowerset + * + * parameters: + * left powerset + * right powerset + * bitlength length of powerset + * + * returns: + * int 1 .. left is included in right + * 0 .. not + * + * abstract: + * check if one powerset is included in another + * + */ +int +__lepowerset (left, right, bitlength) + SET_WORD *left; + SET_WORD *right; + unsigned long bitlength; +{ + if (bitlength <= SET_CHAR_SIZE) + { + if ((*((SET_CHAR *)left) & *((SET_CHAR *)right)) + != *((SET_CHAR *)left)) + return 0; + return 1; + } + else if (bitlength <= SET_SHORT_SIZE) + { + if ((*((SET_SHORT *)left) & *((SET_SHORT *)right)) + != *((SET_SHORT *)left)) + return 0; + return 1; + } + else + { + SET_WORD *endp = left + BITS_TO_WORDS(bitlength); + + while (left < endp) + { + if ((*right & *left) != *left) + return 0; + left++; + right++; + } + return 1; + } +} diff --git a/gcc/ch/runtime/powerset.h b/gcc/ch/runtime/powerset.h new file mode 100644 index 0000000..3ceb776 --- /dev/null +++ b/gcc/ch/runtime/powerset.h @@ -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 (BITS_PER_UNIT * sizeof (SET_WORD)) +#define SET_SHORT_SIZE (BITS_PER_UNIT * sizeof (SET_SHORT)) +#define SET_CHAR_SIZE BITS_PER_UNIT + +/* Powersets and bit strings are stored as arrays of SET_WORD. + if they are a word or longer. Powersets and bit strings whic + fit in a byte or short are stored that way by the compiler. + + The order of the bits follows native bit order: + If BITS_BIG_ENDIAN, bit 0 is the most significant bit (i.e. 0x80..00); + otherwise, bit 0 is the least significant bit (i.e. 0x1). + + MASK_UNUSED_BITS masks out unused bits in powersets and bitstrings. + GET_BIT_IN_WORD(W,B) yields 1 (or 0) if the B'th bit if W is set (cleared). +*/ + +#if BITS_BIG_ENDIAN +#define GET_BIT_IN_WORD(w,b) (((w) >> (SET_WORD_SIZE - 1 - (b))) & 1) +#define GET_BIT_IN_SHORT(w,b) (((w) >> (SET_SHORT_SIZE - 1 - (b))) & 1) +#define GET_BIT_IN_CHAR(w,b) (((w) >> (SET_CHAR_SIZE - 1 - (b))) & 1) + +#define SET_BIT_IN_WORD(w,b) ((w) |= 1 << ((SET_WORD_SIZE) - 1 - (b))) +#define SET_BIT_IN_SHORT(w,b) ((w) |= 1 << ((SET_SHORT_SIZE) - 1 - (b))) +#define SET_BIT_IN_CHAR(w,b) ((w) |= 1 << ((SET_CHAR_SIZE) - 1 - (b))) + +#define CLEAR_BIT_IN_WORD(w,b) ((w) &= ~(1 << ((SET_WORD_SIZE) - 1 - (b)))) +#define CLEAR_BIT_IN_SHORT(w,b) ((w) &= ~(1 << ((SET_SHORT_SIZE) - 1 - (b)))) +#define CLEAR_BIT_IN_CHAR(w,b) ((w) &= ~(1 << ((SET_CHAR_SIZE) - 1 - (b)))) +#define MASK_UNUSED_WORD_BITS(p,b) \ +{ if (b) *(p) &= (~0) << (SET_WORD_SIZE - (b)); } +#define MASK_UNUSED_SHORT_BITS(p,b) \ +{ if (b) *(p) &= (~0) << (SET_SHORT_SIZE - (b)); } +#define MASK_UNUSED_CHAR_BITS(p,b) \ +{ if (b) *(p) &= (~0) << (SET_CHAR_SIZE - (b)); } + +#else /* !BITS_BIG_ENDIAN */ + +#define GET_BIT_IN_WORD(w,b) (((w) >> (b)) & 1) +#define GET_BIT_IN_SHORT(w,b) GET_BIT_IN_WORD(w,b) +#define GET_BIT_IN_CHAR(w,b) GET_BIT_IN_WORD(w,b) + +#define SET_BIT_IN_WORD(w,b) ((w) |= 1 << (b)) +#define SET_BIT_IN_SHORT(w,b) SET_BIT_IN_WORD(w,b) +#define SET_BIT_IN_CHAR(w,b) SET_BIT_IN_WORD(w,b) + +#define CLEAR_BIT_IN_WORD(w,b) ((w) &= ~(1 << (b))) +#define CLEAR_BIT_IN_SHORT(w,b) CLEAR_BIT_IN_WORD(w,b) +#define CLEAR_BIT_IN_CHAR(w,b) CLEAR_BIT_IN_WORD(w,b) + +#define MASK_UNUSED_WORD_BITS(p,b) \ +{ if (b) *(p) &= ~((~0) << (b)); } +#define MASK_UNUSED_SHORT_BITS(p,b) MASK_UNUSED_WORD_BITS(p,b) +#define MASK_UNUSED_CHAR_BITS(p,b) MASK_UNUSED_WORD_BITS(p,b) + +#endif + + +/* Number of words needed for a bitstring/powerset of size BITLENGTH. + This definition handles the (BITLENGTH==0) by yielding 0. */ + +#define BITS_TO_WORDS(BITLENGTH) \ + (((BITLENGTH) + (SET_WORD_SIZE-1)) / SET_WORD_SIZE) +#define BITS_TO_CHARS(BITLENGTH) \ + (((BITLENGTH) + (SET_CHAR_SIZE-1)) / SET_CHAR_SIZE) + +#endif diff --git a/gcc/ch/runtime/queuelength.c b/gcc/ch/runtime/queuelength.c new file mode 100644 index 0000000..417d175 --- /dev/null +++ b/gcc/ch/runtime/queuelength.c @@ -0,0 +1,79 @@ +/* Implement tasking-related runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "rtltypes.h" +#include "rts.h" + +/* + * function __queue_length + * + * parameters: + * buf_ev Buffer or event location + * is_event 0 .. buf_ev is a buffer location + * 1 .. buf_ev is an event location + * + * returns: + * int number of delayed processeson an event location + * or number of send delayed processes on a buffer + * + * exceptions: + * none + * + * abstract: + * implements the QUEUE_LENGTH built-in. + * + */ + +int +__queue_length (buf_ev, is_event) + void *buf_ev; + int is_event; +{ + int retval = 0; + + /* if buf_ev == 0 then we don't have anything */ + if (buf_ev == 0) + return 0; + + if (is_event) + { + /* process an event queue */ + Event_Queue *ev = buf_ev; + + while (ev) + { + retval++; + ev = ev->forward; + } + } + else + { + /* process a buffer queue */ + Buffer_Queue *bq = buf_ev; + Buffer_Send_Queue *bsq = bq->sendqueue; + + while (bsq) + { + retval++; + bsq = bsq->forward; + } + } + return retval; +} diff --git a/gcc/ch/runtime/readrecord.c b/gcc/ch/runtime/readrecord.c new file mode 100644 index 0000000..03641f9 --- /dev/null +++ b/gcc/ch/runtime/readrecord.c @@ -0,0 +1,208 @@ +/* Implement Input/Output runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <setjmp.h> +#include <stdlib.h> +#include <errno.h> +#include <unistd.h> + +#include "fileio.h" + +#ifdef EOF +#undef EOF +#endif +#define EOF -1 + +static +Boolean +doRead( Access_Mode* the_access, void* buf, size_t nbyte ) +{ + size_t nread; + + nread = read( the_access->association->handle, buf, nbyte ); + if( nread == nbyte ) + { + CLR_FLAG( the_access, IO_OUTOFFILE ); + return True; + } + if( nread == 0 ) + { + SET_FLAG( the_access, IO_OUTOFFILE ); + return False; + } + the_access->association->syserrno = errno; + RWEXCEPTION( READFAIL, OS_IO_ERROR ); + /* no return */ +} + +static +int bgetc( int handle, readbuf_t* rbptr ) +{ + if( rbptr->cur >= rbptr->len ) + { + rbptr->len = read( handle, rbptr->buf, READBUFLEN ); + if( rbptr->len == 0 ) + return EOF; + rbptr->cur = 0; + } + return rbptr->buf[rbptr->cur++]; +} + +static +void bungetc( readbuf_t* rbptr, int c ) +{ + rbptr->buf[--rbptr->cur] = c; +} + +void* +__readrecord( Access_Mode* the_access, + signed long the_index, + char* the_buf_addr, + char* file, + int line ) +{ + unsigned long info; + char* actaddr; + unsigned short actlen; + off_t filepos; + unsigned short reclen; + unsigned long readlen; + + if( !the_access ) + CHILLEXCEPTION( file, line, EMPTY, NULL_ACCESS ); + + if( !the_access->association ) + CHILLEXCEPTION( file, line, NOTCONNECTED, IS_NOT_CONNECTED ); + + /* Usage must not be WriteOnly */ + if( the_access->association->usage == WriteOnly ) + CHILLEXCEPTION( file, line, READFAIL, BAD_USAGE ); + + /* OUTOFFILE must not be True when connected for sequential read */ + if( !TEST_FLAG( the_access, IO_INDEXED ) + && TEST_FLAG( the_access, IO_OUTOFFILE ) ) + CHILLEXCEPTION( file, line, READFAIL, OUT_OF_FILE ); + + /* + * Positioning + */ + if( TEST_FLAG( the_access, IO_INDEXED ) ) + { + /* index expression must be within bounds of index mode */ + if( the_index < the_access->lowindex + || the_access->highindex < the_index ) + CHILLEXCEPTION( file, line, RANGEFAIL, BAD_INDEX ); + + filepos = the_access->base + + (the_index - the_access->lowindex) * the_access->reclength; + + if( lseek( the_access->association->handle, filepos, SEEK_SET ) == -1L ) + CHILLEXCEPTION( file, line, READFAIL, LSEEK_FAILS ); + } + + /* establish store loc */ + if( !(actaddr = the_buf_addr )) + { + /* if not yet allocated, do it now */ + if (!the_access->store_loc) + if( !(the_access->store_loc = (char*)malloc( the_access->reclength ) ) ) + CHILLEXCEPTION( file, line, SPACEFAIL, STORE_LOC_ALLOC ); + actaddr = the_access->store_loc; + } + actlen = the_access->reclength; + + if( (info = setjmp( __rw_exception )) ) + CHILLEXCEPTION( file, line, info>>16, info & 0xffff ); + + if( TEST_FLAG( the_access, IO_TEXTIO ) ) + { + readlen = actlen - 2; + if( TEST_FLAG( the_access, IO_INDEXED ) ) + { + if( ! doRead( the_access, &reclen, sizeof(reclen) ) ) + return NULL; + if( reclen > readlen ) + CHILLEXCEPTION( file, line, RANGEFAIL, RECORD_TOO_LONG ); + if( ! doRead( the_access, actaddr + 2, reclen ) ) + CHILLEXCEPTION( file, line, READFAIL, RECORD_TOO_SHORT ); + } + else + { + Association_Mode *assoc = the_access->association; + int handle = assoc->handle; + readbuf_t* rbuf = assoc->bufptr; + char* cptr = actaddr+2; + int curr; + + reclen = 0; + while( readlen-- ) + { + curr = bgetc( handle, rbuf ); + if( curr == '\n' ) + goto end_of_line; + if( curr == EOF ) + { + if( !reclen ) + SET_FLAG( the_access, IO_OUTOFFILE ); + goto end_of_line; + } + *cptr++ = curr; + reclen++; + } + if( (curr = bgetc( handle, rbuf )) != '\n' ) + { + bungetc( rbuf, curr ); + CHILLEXCEPTION( file, line, RANGEFAIL, RECORD_TOO_LONG ); + } +end_of_line: ; + } + MOV2(actaddr,&reclen); + } + else + { + switch( the_access->rectype ) + { + case Fixed: + if( ! doRead( the_access, actaddr, actlen ) ) + return NULL; + break; + case VaryingChars: + if( TEST_FLAG( the_access->association, IO_VARIABLE ) ) + { + if( ! doRead( the_access, &reclen, sizeof(reclen) ) ) + return NULL; + if( reclen > actlen - 2 ) + CHILLEXCEPTION( file, line, RANGEFAIL, RECORD_TOO_LONG ); + readlen = TEST_FLAG( the_access, IO_INDEXED ) ? actlen - 2 : reclen; + if( ! doRead( the_access, actaddr + 2, readlen ) ) + CHILLEXCEPTION( file, line, READFAIL, RECORD_TOO_SHORT ); + } + else + { + if( ! doRead( the_access, actaddr + 2, reclen = actlen - 2 ) ) + CHILLEXCEPTION( file, line, READFAIL, RECORD_TOO_SHORT ); + } + MOV2(actaddr,&reclen); + break; + } + } + + return actaddr; +} diff --git a/gcc/ch/runtime/rtsdummy.c b/gcc/ch/runtime/rtsdummy.c new file mode 100644 index 0000000..cff2289 --- /dev/null +++ b/gcc/ch/runtime/rtsdummy.c @@ -0,0 +1,65 @@ +/* Implement runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define __CHILL_LIB__ + +#include "config.h" +#include <stdio.h> +#include <stdlib.h> +#include <setjmp.h> +/*#include "gvarargs.h" Gcc source and runtime libs use gvarargs.h */ + +#include "rtltypes.h" + +typedef void (*init_ptr) (); +typedef int * tasking_ptr; + +/* Dummy functions for rts access. When we come here we have an error. */ + +typedef char *(*fetch_names) (int number); +typedef int (*fetch_numbers) (char *name); + +static void __rts_main_loop () +{ + /* do nothing in case of no run time system */ +} +init_ptr __RTS_MAIN_LOOP__ = __rts_main_loop; + +static void __rts_init () +{ + /* do nothing in case of no run time system */ +} +init_ptr __RTS_INIT__ = __rts_init; + +static char *__fetch_name (int number) +{ + fprintf (stderr, "ChillLib: fetch_name: no runtime system library linked.\n"); + fflush (stderr); + abort (); +} +fetch_names __RTS_FETCH_NAMES__ = __fetch_name; + +static int __fetch_number (char *name) +{ + fprintf (stderr, "ChillLib: fetch_number: no runtime system library linked.\n"); + fflush (stderr); + abort (); +} +fetch_numbers __RTS_FETCH_NUMBERS__ = __fetch_number; diff --git a/gcc/ch/runtime/sequencible.c b/gcc/ch/runtime/sequencible.c new file mode 100644 index 0000000..94166ff --- /dev/null +++ b/gcc/ch/runtime/sequencible.c @@ -0,0 +1,32 @@ +/* Implement Input/Output runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "fileio.h" + +Boolean +__sequencible( Association_Mode* the_assoc, char* file, int line ) +{ + if( !the_assoc ) + CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION ); + if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) ) + CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED ); + return TEST_FLAG(the_assoc, IO_SEQUENCIBLE) ? True : False; +} + diff --git a/gcc/ch/runtime/setbitps.c b/gcc/ch/runtime/setbitps.c new file mode 100644 index 0000000..f465548 --- /dev/null +++ b/gcc/ch/runtime/setbitps.c @@ -0,0 +1,89 @@ +/* Implement POWERSET runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define __CHILL_LIB__ + +#include "config.h" +#include <stdio.h> +#include "powerset.h" + +extern void __cause_ex1 (char *exname, char *file, int lineno); + +/* + * function __setbitpowerset + * + * parameters: + * set destination set + * bitlength length of powerset in bits + * minval lowest valid set value + * bitno bit number within set + * new_value zero or one - (new bit value) + * + * returns: + * int 1 .. found + * 0 .. not found + * + * exceptions: + * rangefail + * + * abstract: + * checks if a given value is included in a powerset + * + */ +void +__setbitpowerset (powerset, bitlength, minval, bitno, new_value, filename, lineno) + SET_WORD *powerset; + unsigned long bitlength; + long minval; + long bitno; + char new_value; /* booleans are represented as 8 bit value */ + char * filename; + int lineno; +{ + if (powerset == NULL + || bitno < minval + || (bitno - minval) >= bitlength) + __cause_ex1 ("rangefail", filename, lineno); + + bitno -= minval; + if (bitlength <= SET_CHAR_SIZE) + { + if (new_value & 1) + SET_BIT_IN_CHAR (*((SET_CHAR *)powerset), bitno); + else + CLEAR_BIT_IN_CHAR (*((SET_CHAR *)powerset), bitno); + } + else if (bitlength <= SET_SHORT_SIZE) + { + if (new_value & 1) + SET_BIT_IN_SHORT (*((SET_SHORT *)powerset), bitno); + else + CLEAR_BIT_IN_SHORT (*((SET_SHORT *)powerset), bitno); + } + else + { + powerset += (bitno/SET_WORD_SIZE); + bitno %= SET_WORD_SIZE; + if (new_value & 1) + SET_BIT_IN_WORD (*powerset, bitno); + else + CLEAR_BIT_IN_WORD (*powerset, bitno); + } +} diff --git a/gcc/ch/runtime/setbits.c b/gcc/ch/runtime/setbits.c new file mode 100644 index 0000000..1e3045c --- /dev/null +++ b/gcc/ch/runtime/setbits.c @@ -0,0 +1,85 @@ +/* Implement POWERSET runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define __CHILL_LIB__ + +#include "config.h" +#include <stdio.h> +#include "powerset.h" + +extern void __cause_ex1 (char *exname, char *file, int lineno); + +/* + * function __setbits + * + * parameters: + * out result + * bitlength length of bitstring in bits + * startbit starting bitnumber + * endbit ending bitnumber + * + * returns: + * void + * + * exceptions: + * rangefail + * + * abstract: + * set all bits from starting bitnumber to ending bitnumber + * in a powerset + * + */ +void +__setbits (out, bitlength, startbit, endbit) + SET_WORD *out; + unsigned long bitlength; + long startbit; + long endbit; +{ + unsigned long i; + + if (out == NULL + || startbit < 0 + || startbit >= bitlength + || endbit < 0 + || endbit >= bitlength + || endbit < startbit) + __cause_ex1 ("rangefail", "__setbits", __LINE__); + + if (bitlength <= SET_CHAR_SIZE) + for (i = startbit; i <= endbit; i++) + SET_BIT_IN_CHAR (*((SET_CHAR *)out), i); + else if (bitlength <= SET_SHORT_SIZE) + for (i = startbit; i <= endbit; i++) + SET_BIT_IN_SHORT (*((SET_SHORT *)out), i); + else + { + SET_WORD *p; + unsigned long bitnr; + + /* FIXME - this is inefficient! */ + for (i = startbit; i <= endbit; i++) + { + p = out + (i / SET_WORD_SIZE); + bitnr = i % SET_WORD_SIZE; + SET_BIT_IN_WORD (*p, bitnr); + } + } +} diff --git a/gcc/ch/runtime/settextindex.c b/gcc/ch/runtime/settextindex.c new file mode 100644 index 0000000..94b9266 --- /dev/null +++ b/gcc/ch/runtime/settextindex.c @@ -0,0 +1,38 @@ +/* Implement Input/Output runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "fileio.h" + +void +__settextindex( Text_Mode* the_text, + signed long the_text_index, + char* file, + int line ) +{ + if( !the_text ) + CHILLEXCEPTION( file, line, EMPTY, NULL_TEXT ); + + if( the_text_index < 0 + || the_text->access_sub->reclength - 2 < the_text_index ) + CHILLEXCEPTION( file, line, TEXTFAIL, BAD_TEXTINDEX ); + + the_text->actual_index = the_text_index; +} + diff --git a/gcc/ch/runtime/variable.c b/gcc/ch/runtime/variable.c new file mode 100644 index 0000000..69810b3 --- /dev/null +++ b/gcc/ch/runtime/variable.c @@ -0,0 +1,31 @@ +/* Implement Input/Output runtime actions for CHILL. + Copyright (C) 1992,1993 Free Software Foundation, Inc. + Author: Wilfried Moser, et al + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "fileio.h" + +Boolean +__variable( Association_Mode* the_assoc, char* file, int line ) +{ + if( !the_assoc ) + CHILLEXCEPTION( file, line, EMPTY, NULL_ASSOCIATION ); + if( !TEST_FLAG(the_assoc, IO_ISASSOCIATED) ) + CHILLEXCEPTION( file, line, NOTASSOCIATED, IS_NOT_ASSOCIATED ); + return TEST_FLAG( the_assoc, IO_VARIABLE ) ? True : False; +} diff --git a/gcc/ch/runtime/writeable.c b/gcc/ch/runtime/writeable.c new file mode 100644 index 0000000..cf0f5cd --- /dev/null +++ b/gcc/ch/runtime/writeable.c @@ -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; +} |