plan 9 kernel history: overview | file list | diff list

1993/0501/ss/bbmalloc.c (diff list | history)

1992/0711/sys/src/9/ss/bbmalloc.c:1,541993/0501/sys/src/9/ss/bbmalloc.c:0 (short | long | prev)
Deleted.
rsc Mon Mar 7 10:33:04 2005
1991/0723    
#include	"u.h" 
1992/0321    
#include	"../port/lib.h" 
1991/0723    
#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; 
} 
                 
void 
bbfree(void *p, int n) 
{ 
	if(p == bblast) 
		bbcur = (ulong *)(((char *)bblast) + n); 
} 
                 
1992/0116    
int 
bbonstack(void) 
1991/0723    
{ 
1992/0116    
	if(u) 
		return 1; 
	return 0; 
1991/0723    
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)