提交 19892bf0 编写于 作者: R Rich Felker

fix brk/sbrk behavior to match the real legacy functions

上级 c5025bfa
......@@ -2,5 +2,5 @@
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)
{
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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册