__aeabi_ldivmod: fix sign logic
[minix.git] / lib / libc / sys-minix / brk.c
blobb4f76cdee5c8550dd57fc074222b68c07c6901eb
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <unistd.h>
7 #ifdef __weak_alias
8 __weak_alias(brk, _brk)
9 #endif
11 extern char *_brksize;
13 /* Both OSF/1 and SYSVR4 man pages specify that brk(2) returns int.
14 * However, BSD4.3 specifies that brk() returns char*. POSIX omits
15 * brk() on the grounds that it imposes a memory model on an architecture.
16 * For this reason, brk() and sbrk() are not in the lib/posix directory.
17 * On the other hand, they are so crucial to correct operation of so many
18 * parts of the system, that we have chosen to hide the name brk using _brk,
19 * as with system calls. In this way, if a user inadvertently defines a
20 * procedure brk, MINIX may continue to work because the true call is _brk.
22 int brk(addr)
23 void *addr;
25 message m;
27 if (addr != _brksize) {
28 m.PMBRK_ADDR = addr;
29 if (_syscall(PM_PROC_NR, BRK, &m) < 0) return(-1);
30 _brksize = m.m2_p1;
32 return(0);