henesyinit from p9fce6d0435 years agoHistory
65 lines · 897 B · C
RawDownload
#include	"u.h"#include	"../port/lib.h"#include	"mem.h"#include	"dat.h"#include	"fns.h"#include	"io.h" /* * Allocate memory for use in kernel bitblts. */ /* a 0->3 bitblt can take 900 words */enum {	nbbarena=8192	/* number of words in an arena */}; static ulong	bbarena[nbbarena];static ulong	*bbcur = bbarena;static ulong	*bblast = 0; void *bbmalloc(int nbytes){	int nw;	int s;	ulong *ans; 	nw = nbytes/sizeof(long);	s = splhi();	if(bbcur + nw > &bbarena[nbbarena])		ans = bbarena;	else		ans = bbcur;	bbcur = ans + nw;	splx(s);	bblast = ans;	ans = (void *)ans;	return ans;} voidbbfree(void *p, int n){	if(p == bblast)		bbcur = (ulong *)(((char *)bblast) + n);} intbbonstack(void){	if(u)		return 1;	return 0;} voidbbexec(void (*memstart)(void), int len, int onstack){	if(onstack) {		memstart();		return;	}	memstart();	bbfree(memstart, len);}