44 lines · 852 B · C
RawDownload
/*  * This file is part of the UCB release of Plan 9. It is subject to the license * terms in the LICENSE file found in the top-level directory of this * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No * part of the UCB release of Plan 9, including this file, may be copied, * modified, propagated, or distributed except according to the terms contained * in the LICENSE file. */ #include <u.h>#include <libc.h> extern	char	end[];static	char	*bloc = { end };extern	int	brk_(void*); enum{	Round	= 7}; intbrk(void *p){	uintptr bl; 	bl = ((uintptr)p + Round) & ~Round;	if(brk_((void*)bl) < 0)		return -1;	bloc = (char*)bl;	return 0;} void*sbrk(ulong n){	uintptr bl; 	bl = ((uintptr)bloc + Round) & ~Round;	if(brk_((void*)(bl+n)) < 0)		return (void*)-1;	bloc = (char*)bl + n;	return (void*)bl;}