__init_brk.c 632 B

1234567891011121314151617181920212223242526272829303132
  1. /* From libc-5.3.12 */
  2. #include <unistd.h>
  3. #include <sys/syscall.h>
  4. #include <errno.h>
  5. #include "sysdep.h"
  6. void * __curbrk attribute_hidden = 0;
  7. extern int __init_brk (void) attribute_hidden;
  8. int
  9. __init_brk (void)
  10. {
  11. if (__curbrk == 0) {
  12. /* Notice that we don't need to save/restore the GOT
  13. * register since that is not call clobbered by the syscall.
  14. */
  15. __asm__ ("clear.d $r10\n\t"
  16. "movu.w " STR(__NR_brk) ",$r9\n\t"
  17. "break 13\n\t"
  18. "move.d $r10, %0"
  19. : "=r" (__curbrk)
  20. :
  21. : "r9", "r10");
  22. if (__curbrk == 0) {
  23. __set_errno(ENOMEM);
  24. return -1;
  25. }
  26. }
  27. return 0;
  28. }