1988-02-19 15:54:01 +00:00
|
|
|
/*
|
|
|
|
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Module: runtime support for conformant arrays
|
|
|
|
Author: Ceriel J.H. Jacobs
|
|
|
|
Version: $Header$
|
|
|
|
*/
|
1987-07-09 15:15:22 +00:00
|
|
|
#include <m2_traps.h>
|
|
|
|
|
1988-03-18 14:23:04 +00:00
|
|
|
#if EM_WSIZE==EM_PSIZE
|
|
|
|
typedef unsigned pcnt;
|
|
|
|
#else
|
|
|
|
typedef unsigned long pcnt;
|
|
|
|
#endif
|
|
|
|
|
1987-06-23 17:12:42 +00:00
|
|
|
struct descr {
|
|
|
|
char *addr;
|
|
|
|
int low;
|
|
|
|
unsigned int highminlow;
|
|
|
|
unsigned int size;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct descr *descrs[10];
|
|
|
|
static struct descr **ppdescr = descrs;
|
|
|
|
|
|
|
|
char *
|
1988-03-23 17:55:57 +00:00
|
|
|
new_stackptr(pdescr, a)
|
1987-06-23 17:12:42 +00:00
|
|
|
register struct descr *pdescr;
|
|
|
|
{
|
1988-03-18 14:23:04 +00:00
|
|
|
pcnt size = (((pdescr->highminlow + 1) * pdescr->size +
|
1987-06-23 17:12:42 +00:00
|
|
|
(EM_WSIZE - 1)) & ~(EM_WSIZE - 1));
|
|
|
|
|
|
|
|
if (ppdescr >= &descrs[10]) {
|
|
|
|
/* to many nested traps + handlers ! */
|
1987-07-09 15:15:22 +00:00
|
|
|
TRP(M2_TOOMANY);
|
1987-06-23 17:12:42 +00:00
|
|
|
}
|
|
|
|
*ppdescr++ = pdescr;
|
|
|
|
if ((char *) &a - (char *) &size > 0) {
|
|
|
|
/* stack grows downwards */
|
|
|
|
return (char *) &a - size;
|
|
|
|
}
|
|
|
|
else return (char *) &a + size;
|
|
|
|
}
|
|
|
|
|
1988-03-23 17:55:57 +00:00
|
|
|
copy_array(p, a)
|
1987-11-02 11:22:06 +00:00
|
|
|
register char *p;
|
1987-06-23 17:12:42 +00:00
|
|
|
{
|
1987-11-02 11:22:06 +00:00
|
|
|
register char *q;
|
1988-03-18 14:23:04 +00:00
|
|
|
register pcnt sz;
|
1987-06-23 17:12:42 +00:00
|
|
|
char dummy;
|
|
|
|
|
|
|
|
ppdescr--;
|
1987-11-03 15:04:21 +00:00
|
|
|
sz = ((*ppdescr)->highminlow + 1) * (*ppdescr)->size;
|
1987-06-23 17:12:42 +00:00
|
|
|
|
|
|
|
if ((char *) &a - (char *) &dummy > 0) {
|
1987-11-02 11:22:06 +00:00
|
|
|
(*ppdescr)->addr = q = (char *) &a;
|
1987-06-23 17:12:42 +00:00
|
|
|
}
|
1987-11-03 15:04:21 +00:00
|
|
|
else (*ppdescr)->addr = q = (char *) &a -
|
|
|
|
((sz + (EM_WSIZE - 1)) & ~ (EM_WSIZE - 1));
|
1987-06-23 17:12:42 +00:00
|
|
|
|
|
|
|
while (sz--) *q++ = *p++;
|
|
|
|
}
|