Created
June 9, 2014 13:13
-
-
Save ltiao/f733942a2331de16b4fd to your computer and use it in GitHub Desktop.
I'm da real mvp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sys_sbrk(__intptr_t change, void **retval) { | |
struct addrspace *as = proc_getas(); | |
if (as == NULL) { | |
return EFAULT; | |
} | |
vaddr_t heapbreak = as->as_heapvbase + as->as_heapsize; | |
// we're not checking page alignment of | |
// change (amount) here or anything | |
// clever like that here (@273) | |
as->as_heapsize += change; | |
// address lower than the beginning of the heap | |
if (as->as_heapvbase + as->as_heapsize < as->as_heapvbase) { | |
*retval = (void *)-1; | |
return EINVAL; | |
} | |
// address growing into the stack | |
if (as->as_heapvbase + as->as_heapsize >= USERSTACK - PAGE_SIZE * VM_STACKPAGES) { | |
*retval = (void *)-1; | |
return EINVAL; | |
} | |
*retval = (void *) heapbreak; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment