meta: move photon/libc to root
This commit is contained in:
22
libc/sys/linux/sbrk.c
Normal file
22
libc/sys/linux/sbrk.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "unistd.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void *__curr_brk = NULL;
|
||||
|
||||
void *sbrk(intptr_t increment)
|
||||
{
|
||||
if (!__curr_brk) {
|
||||
brk(NULL);
|
||||
}
|
||||
|
||||
uintptr_t end = (uintptr_t)__curr_brk + increment;
|
||||
void *start = __curr_brk;
|
||||
int res = brk((void *)end);
|
||||
|
||||
if (res == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
Reference in New Issue
Block a user