blob: 88b593e11e2f13803eb41fd76751f8b583fb5fb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <u.h>
#include <libc.h>
extern char end[];
static char *bloc = { end };
extern int brk_(void*);
enum
{
Round = 7
};
int
brk(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;
}
|