mirror of git://git.musl-libc.org/musl
fix brk/sbrk behavior to match the real legacy functions
This commit is contained in:
parent
c5025bfabe
commit
19892bf0a7
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
int brk(void *end)
|
int brk(void *end)
|
||||||
{
|
{
|
||||||
return -(syscall(SYS_brk, end) == -1);
|
return -(syscall(SYS_brk, end) != (unsigned long)end);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,7 @@
|
||||||
|
|
||||||
void *sbrk(ptrdiff_t inc)
|
void *sbrk(ptrdiff_t inc)
|
||||||
{
|
{
|
||||||
return (void *)syscall(SYS_brk, syscall(SYS_brk, 0)+inc);
|
unsigned long cur = syscall(SYS_brk, 0);
|
||||||
|
if (inc && syscall(SYS_brk, cur+inc) != cur+inc) return (void *)-1;
|
||||||
|
return (void *)cur;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue