+__DEFINE_LXSYSCALL1(void*, sbrk, ssize_t, incr)
+{
+ struct proc_mm* pvms = vmspace(__current);
+ struct mm_region* heap = pvms->heap;
+
+ assert(heap);
+ int err = mem_adjust_inplace(&pvms->regions, heap, heap->end + incr);
+ if (err) {
+ return (void*)DO_STATUS(err);
+ }
+ return (void*)heap->end;
+}
+
+__DEFINE_LXSYSCALL1(int, brk, void*, addr)
+{
+ struct proc_mm* pvms = vmspace(__current);
+ struct mm_region* heap = pvms->heap;
+
+ if (!heap) {
+ return DO_STATUS(create_heap(pvms, (ptr_t)addr));
+ }
+
+ assert(heap);
+ int err = mem_adjust_inplace(&pvms->regions, heap, (ptr_t)addr);
+ return DO_STATUS(err);