Implement brk and sbrk
|Reported by:||simonsouth||Owned by:||nobody|
|Has a Patch:||no||Platform:||All|
This patch adds
brk and (a real implementation of)
sbrk, functions that change the amount of memory allocated to a process by adjusting its program break (the first memory location past the end of its data segment).
As part of this the patch also changes
getrlimit to recognize two additional resource limits,
RLIMIT_DATA, that represent limits on the size of a process' virtual-memory address space and of its data segment, respectively. As far as I can tell Haiku places no artificial restriction on these so I have set them to "unlimited"---if anyone knows differently, I will update the patch.
I've also included a simple unit test that demonstrates the behaviour of
sbrk (and of
brk, indirectly). Compare with the behaviour specified in the man page: On success, the function returns the previous program break; on error, it returns -1 and sets
ENOMEM (and leaves the program break unchanged).