Commit 360c5f15 by Per Bothner

Migrate from devo/gcc/ch.

From-SVN: r22037
parent 3a575f25
# Makefile for GNU CHILL compiler runtime library.
# Copyright (C) 1987, 88, 90, 91, 92, 93, 1994 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.
# The targets for external use include:
# all, doc, TAGS, mostlyclean, clean, distclean, realclean,
srcdir = .
AR_FOR_TARGET = ` \
if [ -f ../../../binutils/ar ] ; then \
echo ../../../binutils/ar ; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo ar; \
else \
t="$(program_transform_name)"; echo ar | sed -e '' $$t ; \
fi \
fi`
AR_FOR_TARGET_FLAGS = rc
# How to invoke ranlib.
RANLIB_FOR_TARGET = ` \
if [ -f ../../../binutils/ranlib ] ; then \
echo ../../../binutils/ranlib ; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo ranlib; \
else \
t="$(program_transform_name)"; echo ranlib | sed -e '' $$t ; \
fi \
fi`
RANLIB_TEST_FOR_TARGET = \
[ -f $(RANLIB_FOR_TARGET) ] \
|| ( [ "$(host_canonical)" = "$(target_canonical)" ] \
&& [ -f /usr/bin/ranlib -o -f /bin/ranlib ] )
# Directory in which to find other cross-compilation tools and headers.
# Used to compile the library
tooldir = $(exec_prefix)/$(target_alias)
BASE = ../..
GCC_FOR_TARGET = $(BASE)/xgcc -B$(BASE)/
CFLAGS = -g -O
# Always search these dirs when compiling.
INCLUDES = -I. -I$(BASE) -I$(srcdir) -I$(srcdir)/$(BASE)/config \
-I../../include -I$(tooldir)/include -I$(srcdir)/$(BASE)
ALL_CFLAGS = $(CFLAGS)
AR_FOR_TARGET = ` \
if [ -f $(BASE)/../binutils/ar ] ; then \
echo $(BASE)/../binutils/ar ; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo ar; \
else \
t="$(program_transform_name)"; echo ar | sed -e '' $$t ; \
fi \
fi`
AR_FOR_TARGET_FLAGS = rc
RANLIB_FOR_TARGET = ` \
if [ -f $(BASE)/../binutils/ranlib ] ; then \
echo $(BASE)/../binutils/ranlib ; \
else \
if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
echo ranlib; \
else \
t="$(program_transform_name)"; echo ranlib | sed -e '' $$t ; \
fi \
fi`
RANLIB_TEST_FOR_TARGET = \
[ -f $(RANLIB_FOR_TARGET) ] \
|| ( [ "$(host_canonical)" = "$(target_canonical)" ] \
&& [ -f /usr/bin/ranlib -o -f /bin/ranlib ] )
AR = $(AR_FOR_TARGET)
AR_FLAGS = $(AR_FOR_TARGET_FLAGS)
# How to invoke ranlib.
RANLIB = $(RANLIB_FOR_TARGET)
# Test to use to see whether ranlib exists on the system.
RANLIB_TEST = $(RANLIB_TEST_FOR_TARGET)
INSTALL = install -c
# These permit overriding just for certain files.
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL)
# End of variables for you to override.
# Definition of `all' is here so that new rules inserted by sed
# do not specify the default target.
all: all.indirect
# This tells GNU Make version 3 not to put all variables in the environment.
.NOEXPORT:
# sed inserts variable overrides after the following lines.
####target overrides
####host overrides
####cross overrides
####build overrides
####site overrides
#### Host, target, and site specific Makefile fragments come in here.
###
.c.o:
$(GCC_FOR_TARGET) -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)
all.indirect: chillrt0.o libchill.a Makefile
.PHONY: check installcheck
check:
installcheck:
libchill.a: $(OBJS)
$(AR_FOR_TARGET) $(AR_FOR_TARGET_FLAGS) $@ $(OBJS)
-if $(RANLIB_TEST_FOR_TARGET) ; then $(RANLIB_FOR_TARGET) $@; else true; fi
$(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
# With a new cc1 compile the library again
$(OBJS): ../../cc1
install-info:
info:
dvi:
Makefile: $(srcdir)/Makefile.in
$(SHELL) ./config.status
mostlyclean:
-rm -f $(OBJS) chillrt0.o
clean: mostlyclean
-rm -f libchill.a
extraclean: clean
true
distclean: extraclean
-rm -f Makefile
realclean: distclean
true
/* 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 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 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. */
#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 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 tasking-related runtime actions for CHILL.
Copyright (C) 1992,1993 Free Software Foundation, Inc.
Author: Wilfried Moser
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "rtltypes.h"
#include "rts.h"
EXCEPTION (sendfail);
extern void __cause_ex1 (char *ex, char *file, int lineno);
#define CAUSE_SENDFAIL __cause_ex1 ("sendfail", filename, lineno)
/*
* function __send_buffer
*
* parameters:
* buffer pointer to buffer descriptor
* data pointer to data descriptor
* prio priority for send action
* timeout pointer to timeout value
* filename source file name where function gets called
* lineno linenumber in source file
*
* returns:
* int 0 .. success
* 1 .. timeout
*
* exceptions:
* sendfail
*
* abstract:
* implement the CHILL SEND buffer action.
*/
int
__send_buffer (buffer, data, prio, timeout, filename, lineno)
Buffer_Descr *buffer;
Data_Descr *data;
int prio;
void *timeout;
char *filename;
int lineno;
{
Buffer_Queue *bq;
Buffer_Send_Queue *bsq, *bsq_entry, *prev_bsq_entry;
int cnt = 0;
int retval = 0;
/* if we don't have anything queued on that buffer,
set up the structure */
memcpy (&bq, buffer->buf, sizeof (Buffer_Queue *));
if (bq == 0)
{
MALLOC (bq, sizeof (Buffer_Queue));
memset (bq, 0, sizeof (Buffer_Queue));
memcpy (buffer->buf, &bq, sizeof (Buffer_Queue *));
}
/* look if there is a process delayed on that buffer */
if (bq->waitqueue != 0)
{
Buffer_Wait_Queue *listentry;
/* there is already a processes waiting for that buffer,
check datalength and copy the data in */
if (bq->waitqueue->datalen < data->length)
CAUSE_SENDFAIL;
memcpy (bq->waitqueue->dataptr, data->ptr, data->length);
/* set up the entry */
bq->waitqueue->is_sent = 1;
bq->waitqueue->who_sent = THIS;
/* continue waiting process */
__continue_that (bq->waitqueue->this, prio, filename, lineno);
/* now dequeue all entries of this list */
listentry = bq->waitqueue->startlist;
while (listentry != 0)
{
Buffer_Wait_Queue *tmp, *prev_entry, *bwq;
Buffer_Queue *bq;
tmp = listentry->chain;
memcpy (&bq, listentry->bufferaddr, sizeof (Buffer_Queue *));
prev_entry = (Buffer_Wait_Queue *)&bq->waitqueue;
bwq = bq->waitqueue;
while (bwq != listentry)
{
prev_entry = bwq;
bwq = bwq->forward;
}
/* dequeue it */
prev_entry->forward = bwq->forward;
bq->waitqueuelength--;
listentry = tmp;
}
/* all done */
return 0;
}
/* nothing in waitqueue, set up an entry for sendqueue.
Note: we allocate here space for the data too, to reduce
calls to malloc and let the dataptr point just behind
the Buffer_Send_Queue structure. */
MALLOC (bsq_entry, sizeof (Buffer_Send_Queue) + data->length);
memset (bsq_entry, 0, sizeof (Buffer_Send_Queue));
bsq_entry->priority = prio;
bsq_entry->this = THIS;
bsq_entry->datalen = data->length;
bsq_entry->dataptr = bsq_entry + 1;
memcpy (bsq_entry->dataptr, data->ptr, data->length);
/* add entry to sendqueue */
prev_bsq_entry = (Buffer_Send_Queue *)&bq->sendqueue;
bsq = bq->sendqueue;
while (bsq != 0 && bsq->priority >= prio)
{
prev_bsq_entry = bsq;
bsq = bsq->forward;
}
if (bsq == 0)
{
/* beginning or end of the list */
prev_bsq_entry->forward = bsq_entry;
}
else
{
/* somewhere in the middle */
bsq_entry->forward = prev_bsq_entry->forward;
prev_bsq_entry->forward = bsq_entry;
}
if (buffer->maxqueuelength != (unsigned long)-1L &&
bq->sendqueuelength >= buffer->maxqueuelength)
{
/* we have to delay this process */
bsq_entry->is_delayed = 1;
retval = __delay_this (wait_buffer_send, timeout, filename, lineno);
if (retval)
{
prev_bsq_entry->forward = bsq_entry->forward;
FREE (bsq_entry);
}
}
else
/* just say that there is one more entry in the queue */
bq->sendqueuelength++;
return retval;
}
/* force function __print_buffer to be linked */
extern void __print_buffer ();
static EntryPoint pev = __print_buffer;
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