From: Alan Cox Date: Sat, 16 May 2015 20:39:04 +0000 (+0100) Subject: sh: correct end and use sbrk() rather than v7 linkages X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a8f425877d6773a9d14099599b22f3f799fa19b4;p=FUZIX.git sh: correct end and use sbrk() rather than v7 linkages With this change the v7 Bourne shell now runs, even on 32K userspace boxes. Later she added quite a few things (see http://heirloom.cvs.sourceforge.net/heirloom/heirloom-sh/) however most of those are memory expensive. Probably we should add the use of '#' as a comment character as this is nowdays considered normal. Of the other features - an external test suits our memory size better, while the later builtins aren't that useful and again have size issues. Only unset cannot be external and might be useful. Of the late features it might be nice to get 8bit clean - --- diff --git a/Applications/V7/cmd/sh/blok.c b/Applications/V7/cmd/sh/blok.c index e1b012f2..f1c3ec7e 100644 --- a/Applications/V7/cmd/sh/blok.c +++ b/Applications/V7/cmd/sh/blok.c @@ -22,10 +22,15 @@ #define busy(x) (Rcheat((x)->word)&BUSY) POS brkincr = BRKINCR; -BLKPTR blokp; /*current search pointer */ -BLKPTR bloktop = BLK(end); /*top of arena (last blok) */ - +BLKPTR blokp; /* current search pointer */ +BLKPTR bloktop; /* top of arena (last blok) */ +static void *end; /* end of memory */ +void blokinit(void) +{ + end = sbrk(0); /* Find where space starts */ + bloktop = BLK(end); +} ADDRESS alloc(POS nbytes) { diff --git a/Applications/V7/cmd/sh/defs.h b/Applications/V7/cmd/sh/defs.h index 3fbb8846..19ecbb03 100644 --- a/Applications/V7/cmd/sh/defs.h +++ b/Applications/V7/cmd/sh/defs.h @@ -267,8 +267,6 @@ extern const char badexec[]; extern const char notfound[]; extern const char badfile[]; -extern address end[]; - #include "ctype.h" /* args.c */ @@ -278,6 +276,7 @@ extern DOLPTR freeargs(DOLPTR blk); extern void clearup(void); extern DOLPTR useargs(void); /* blok.c */ +void blokinit(void); ADDRESS alloc(POS nbytes); extern void addblok(POS reqd); extern void sh_free(void *ap); diff --git a/Applications/V7/cmd/sh/glob.c b/Applications/V7/cmd/sh/glob.c index 1011da8f..cdd0923f 100644 --- a/Applications/V7/cmd/sh/glob.c +++ b/Applications/V7/cmd/sh/glob.c @@ -26,7 +26,6 @@ ARGPTR wdarg; BOOL reserv; int wdnum; BOOL trapnote; -address end[1]; /* FIXME */ int serial; BLKPTR stakbsy; STKPTR stakbas; diff --git a/Applications/V7/cmd/sh/main.c b/Applications/V7/cmd/sh/main.c index 06102c48..ac4b9d64 100644 --- a/Applications/V7/cmd/sh/main.c +++ b/Applications/V7/cmd/sh/main.c @@ -32,6 +32,8 @@ int main(int c, const char *v[]) register int rflag = ttyflg; /* initialise storage allocation */ + blokinit(); + stdsigs(); setbrk(BRKINCR);