[haiku-bugs] [Haiku] #12438: Implement brk and sbrk

  • From: "simonsouth" <trac@xxxxxxxxxxxx>
  • Date: Thu, 29 Oct 2015 18:03:42 -0000

#12438: Implement brk and sbrk
--------------------------+------------------------------
Reporter: simonsouth | Owner: nobody
Type: enhancement | Status: new
Priority: normal | Milestone: Unscheduled
Component: System/POSIX | Version: R1/Development
Keywords: | Blocked By:
Blocking: | Has a Patch: 0
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_AS` and `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
[http://linux.die.net/man/2/brk the man page]: On success, the function
returns the ''previous'' program break; on error, it returns -1 and sets
`errno` to `ENOMEM` (and leaves the program break unchanged).

--
Ticket URL: <https://dev.haiku-os.org/ticket/12438>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: