Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/ape/lib/ap/plan9/brk.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "lib.h"
2
#include <errno.h>
3
#include "sys9.h"
4
 
5
char	end[];
6
static	char	*bloc = { end };
7
extern	int	_BRK_(void*);
8
 
9
char *
10
brk(char *p)
11
{
12
	unsigned long n;
13
 
14
	n = (unsigned long)p;
15
	n += 3;
16
	n &= ~3;
17
	if(_BRK_((void*)n) < 0){
18
		errno = ENOMEM;
19
		return (char *)-1;
20
	}
21
	bloc = (char *)n;
22
	return 0;
23
}
24
 
25
void *
26
sbrk(unsigned long n)
27
{
28
	n += 3;
29
	n &= ~3;
30
	if(_BRK_((void *)(bloc+n)) < 0){
31
		errno = ENOMEM;
32
		return (void *)-1;
33
	}
34
	bloc += n;
35
	return (void *)(bloc-n);
36
}