libroot: Add brk() and sbrk().

This commit replaces the placeholder implementation of sbrk(), which
operated on a process' heap, with real implementations of brk() and
sbrk() that adjust a process' program break.

* unistd.h: Add standard definitions of brk() and sbrk(); include
  stdint.h for intptr_t.
* thread.cpp: Recognize RLIMIT_AS and RLIMIT_DATA resource limits
  (both currently unlimited); order limit identifiers alphabetically.
* arch-specific.cpp: Remove sbrk_hook().
* malloc_debug_api.cpp: Remove sbrk_hook().
* unistd/Jamfile: Build brk.c instead of sbrk.c.
* unistd/brk.c: Add.
* unistd/sbrk.c: Delete (placeholder implementation).
* libroot_stubs.c: Remove sbrk_hook().
* libroot_stubs_legacy.c: Remove sbrk_hook().
* src/tests/.../posix/Jamfile: Build brk_test.c.
* brk_test.c: Add (simple unit test that demonstrates behaviour of
  sbrk()).

Signed-off-by: Jérôme Duval <[email protected]>
This commit is contained in:
Simon South
2015-11-22 17:59:22 +01:00
committed by Jérôme Duval
parent dc0347f13e
commit dbf060a3f7
11 changed files with 429 additions and 51 deletions
+4 -1
View File
@@ -7,6 +7,7 @@
#include <null.h>
#include <stdint.h>
#include <sys/types.h>
@@ -221,7 +222,9 @@ extern void _exit(int status) __attribute__ ((noreturn));
extern pid_t tcgetpgrp(int fd);
extern int tcsetpgrp(int fd, pid_t pgrpid);
extern void *sbrk(long incr);
extern int brk(void *addr);
extern void *sbrk(intptr_t increment);
extern unsigned int alarm(unsigned int seconds);
extern useconds_t ualarm(useconds_t microSeconds, useconds_t interval);