made return value of topsize an unsigned. Some 2/4 back-ends do

not implement BLS 4
This commit is contained in:
ceriel 1989-03-10 14:03:34 +00:00
parent 162b824030
commit 183942e70c
2 changed files with 20 additions and 26 deletions

View file

@ -19,20 +19,16 @@
#include <m2_traps.h> #include <m2_traps.h>
#if EM_WSIZE == EM_PSIZE
#define ptrsiz unsigned
#else
#define ptrsiz unsigned long
#endif
#define MAXMAIN 2048 #define MAXMAIN 2048
struct proc { struct proc {
ptrsiz size; /* size of saved stackframe(s) */ unsigned size; /* size of saved stackframe(s) */
int (*proc)(); /* address of coroutine procedure */ int (*proc)(); /* address of coroutine procedure */
char *brk; /* stack break of this coroutine */ char *brk; /* stack break of this coroutine */
}; };
extern unsigned topsize();
static struct proc mainproc[MAXMAIN/sizeof(struct proc) + 1]; static struct proc mainproc[MAXMAIN/sizeof(struct proc) + 1];
static struct proc *curproc = 0;/* current coroutine */ static struct proc *curproc = 0;/* current coroutine */
@ -54,7 +50,7 @@ _SYSTEM__NEWPROCESS(p, a, n, p1)
must be level 0 procedures without parameters. must be level 0 procedures without parameters.
*/ */
char *brk = 0; char *brk = 0;
ptrsiz sz = topsize(&brk); unsigned sz = topsize(&brk);
if (sz + sizeof(struct proc) > n) { if (sz + sizeof(struct proc) > n) {
/* not enough space */ /* not enough space */
@ -86,7 +82,7 @@ _SYSTEM__TRANSFER(a, b)
descriptor in the space indicated by "a", and transfering to descriptor in the space indicated by "a", and transfering to
the coroutine in descriptor "b". the coroutine in descriptor "b".
*/ */
ptrsiz size; unsigned size;
if (! curproc) { if (! curproc) {
/* the current coroutine is the main process; /* the current coroutine is the main process;

View file

@ -21,7 +21,7 @@
; This implementation assumes a continuous stack growing downwards ; This implementation assumes a continuous stack growing downwards
exp $topsize exp $topsize
pro $topsize, 2*EM_WSIZE+4*EM_PSIZE pro $topsize, 3*EM_WSIZE+3*EM_PSIZE
; local space for line-number, ignoremask, filename, stack-break, size, ; local space for line-number, ignoremask, filename, stack-break, size,
; and stack-pointer (see the topsave routine) ; and stack-pointer (see the topsave routine)
mes 11 mes 11
@ -46,9 +46,9 @@
; the whole frame. ; the whole frame.
lor 1 ; stack-break SP lor 1 ; stack-break SP
sbs EM_PSIZE ; stack-break-SP sbs EM_WSIZE ; stack-break-SP
ret EM_PSIZE ; return size of block to be saved ret EM_WSIZE ; return size of block to be saved
end 2*EM_WSIZE+4*EM_PSIZE end 3*EM_WSIZE+3*EM_PSIZE
exp $topsave exp $topsave
pro $topsave, 0 pro $topsave, 0
@ -62,20 +62,18 @@
loi EM_PSIZE ; stack-break loi EM_PSIZE ; stack-break
lpb lpb
lor 1 lor 1
sbs EM_PSIZE sbs EM_WSIZE
loc EM_PSIZE loc EM_WSIZE
adu EM_PSIZE ; gives size adu EM_WSIZE ; gives size
dup EM_PSIZE dup EM_WSIZE
lal 0 stl 0 ; save size
sti EM_PSIZE ; save size
lor 1 ; SP (the SP BEFORE pushing) lor 1 ; SP (the SP BEFORE pushing)
lor 1 ; SP (address of stack top to save) lor 1 ; SP (address of stack top to save)
lal EM_PSIZE ; area lal EM_PSIZE ; area
loi EM_PSIZE loi EM_PSIZE
lal 0 ; size lol 0 ; size
loi EM_PSIZE bls EM_WSIZE ; move whole block
bls EM_PSIZE ; move whole block asp 3*EM_PSIZE+3*EM_WSIZE ; remove the lot from the stack
asp 4*EM_PSIZE+2*EM_WSIZE ; remove the lot from the stack
loc 1 loc 1
ret EM_WSIZE ; return 1 ret EM_WSIZE ; return 1
end 0 end 0
@ -117,10 +115,10 @@ sv
lae sv lae sv
loi EM_PSIZE loi EM_PSIZE
adp EM_PSIZE adp EM_PSIZE
loi EM_PSIZE ; size of block loi EM_WSIZE ; size of block
bls EM_PSIZE ; move block back (SP becomes the SP AFTER again, bls EM_WSIZE ; move block back (SP becomes the SP AFTER again,
; because of the asp -EM_PSIZE!) ; because of the asp -EM_PSIZE!)
asp 2*EM_PSIZE ; drop size + SP asp EM_PSIZE+EM_WSIZE ; drop size + SP
str 0 ; restore local base str 0 ; restore local base
sim ; ignore mask sim ; ignore mask
lae 4 lae 4