Commit b79f73df by Jeff Law

* 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
parent 18023934
# 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
/* 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;
}
/* 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);
}
/* 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;
}
/* 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;
}
/* 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);
}
}
/* 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
/* 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
/* 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);
}
}
/* 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;
{
}
/* 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);
}
/* 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 */
/* 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));
}
/* 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);
}
/* 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;
}
# 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:
/* 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;
/* 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;
}
/* 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);
}
}
/* 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;
/* 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 );
}
/* 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);
}
}
/* 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;
}
/* 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;
}
}
/* 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);
}
/* 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);
}
/* 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;
}
/* 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;
}
/* 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;
}
}
/* 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);
}
/* 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
/* 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;
}
}
/* 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);
}
/* 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_
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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);
}
/* 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;
}
/* 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);
}
/* 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);
}
/* 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;
/* 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
/* 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
/* 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;
}
/* 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;
}
}
/* 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;
}
}
/* 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);
}
/* 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;
}
/* 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);
}
/* 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);
}
}
/* 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);
}
}
/* 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;
}
/* 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
/* 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");
}
/* 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");
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment