1 /* 2 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> 3 * 4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. 5 */ 6 7 #include <errno.h> 8 #include <unistd.h> 9 #include <sys/syscall.h> 10 11 #define __NR___syscall_brk __NR_brk 12 static __always_inline _syscall1(void *, __syscall_brk, void *, end) 13 14 /* This must be initialized data because commons can't have aliases. */ 15 void * __curbrk attribute_hidden = 0; 16 brk(void * addr)17int brk(void *addr) 18 { 19 void *newbrk = __syscall_brk(addr); 20 21 __curbrk = newbrk; 22 23 if (newbrk < addr) { 24 __set_errno (ENOMEM); 25 return -1; 26 } 27 28 return 0; 29 } 30 libc_hidden_def(brk) 31