pub fn sys_brk(addr: u64) -> Result<u64, SyscallError>Expand description
SYS_BRK (102): set or query the program break (top of heap).
Calling convention (matches Linux):
addr | Behaviour |
|---|---|
0 | Query — return current break unchanged. |
> current_brk | Extend heap; new pages are zero-filled RW anonymous. |
< current_brk | Shrink heap; backing pages are freed. |
< BRK_BASE | Invalid — return current break unchanged (Linux compat). |
On any error (OOM, out-of-range) the unchanged break is returned rather
than a negative code — this is the Linux brk(2) contract.