brk.c 578 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) 2004-2007 Atmel Corporation
  3. *
  4. * This file is subject to the terms and conditions of the GNU Lesser General
  5. * Public License. See the file "COPYING.LIB" in the main directory of this
  6. * archive for more details.
  7. */
  8. #include <errno.h>
  9. #include <unistd.h>
  10. #include <sys/syscall.h>
  11. /* libc_hidden_proto(brk) */
  12. void *__curbrk attribute_hidden = 0;
  13. int brk (void *addr)
  14. {
  15. void *newbrk;
  16. newbrk = (void *)INLINE_SYSCALL(brk, 1, addr);
  17. __curbrk = newbrk;
  18. if (newbrk < addr) {
  19. __set_errno (ENOMEM);
  20. return -1;
  21. }
  22. return 0;
  23. }
  24. libc_hidden_def(brk)