brk.c 612 B

12345678910111213141516171819202122232425262728
  1. /* From libc-5.3.12 */
  2. /*
  3. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include <errno.h>
  8. #include <unistd.h>
  9. #include <sys/syscall.h>
  10. extern void * __curbrk attribute_hidden;
  11. extern int __init_brk (void) attribute_hidden;
  12. extern void *_brk(void *ptr) attribute_hidden;
  13. /* libc_hidden_proto(brk) */
  14. int brk(void * end_data_seg)
  15. {
  16. if (__init_brk () == 0)
  17. {
  18. __curbrk = _brk(end_data_seg);
  19. if (__curbrk == end_data_seg)
  20. return 0;
  21. __set_errno(ENOMEM);
  22. }
  23. return -1;
  24. }
  25. libc_hidden_def(brk)