brk.c 549 B

123456789101112131415161718192021222324252627282930
  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. void *__curbrk attribute_hidden = 0;
  12. int brk (void *addr)
  13. {
  14. void *newbrk;
  15. newbrk = (void *)INLINE_SYSCALL(brk, 1, addr);
  16. __curbrk = newbrk;
  17. if (newbrk < addr) {
  18. __set_errno (ENOMEM);
  19. return -1;
  20. }
  21. return 0;
  22. }
  23. libc_hidden_def(brk)