getservbyport_r: fix wrong result if getnameinfo fails with EAI_OVERFLOW
[musl] / src / linux / sbrk.c
index 5fab74b..bb86630 100644 (file)
@@ -1,9 +1,11 @@
-#include <stddef.h>
+#define _BSD_SOURCE
+#include <unistd.h>
+#include <stdint.h>
+#include <errno.h>
 #include "syscall.h"
 
-void *sbrk(ptrdiff_t inc)
+void *sbrk(intptr_t inc)
 {
-       unsigned long cur = syscall(SYS_brk, 0);
-       if (inc && syscall(SYS_brk, cur+inc) != cur+inc) return (void *)-1;
-       return (void *)cur;
+       if (inc) return (void *)__syscall_ret(-ENOMEM);
+       return (void *)__syscall(SYS_brk, 0);
 }