__init_brk.c 564 B

12345678910111213141516171819202122232425262728293031
  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 = 0;
  7. int
  8. __init_brk (void)
  9. {
  10. if (__curbrk == 0) {
  11. /* Notice that we don't need to save/restore the GOT
  12. * register since that is not call clobbered by the syscall.
  13. */
  14. asm ("clear.d $r10\n\t"
  15. "movu.w " STR(__NR_brk) ",$r9\n\t"
  16. "break 13\n\t"
  17. "move.d $r10, %0"
  18. : "=r" (__curbrk)
  19. :
  20. : "r9", "r10");
  21. if (__curbrk == 0) {
  22. __set_errno(ENOMEM);
  23. return -1;
  24. }
  25. }
  26. return 0;
  27. }