brk.c 583 B

123456789101112131415161718192021222324252627
  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. int brk(void * end_data_seg)
  14. {
  15. if (__init_brk () == 0)
  16. {
  17. __curbrk = _brk(end_data_seg);
  18. if (__curbrk == end_data_seg)
  19. return 0;
  20. __set_errno(ENOMEM);
  21. }
  22. return -1;
  23. }
  24. libc_hidden_def(brk)