brk.S 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* brk system call for Linux/ppc.
  2. Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #include "ppc_asm.h"
  17. #define _ERRNO_H 1
  18. #include <bits/errno.h>
  19. #include <sys/syscall.h>
  20. #ifdef __NR_brk
  21. .comm __curbrk,4,4
  22. .text
  23. .globl __brk
  24. .type __brk,@function
  25. .align 2
  26. __brk:
  27. stwu r1,-16(r1)
  28. stw r3,8(r1)
  29. li 0, __NR_brk;
  30. sc
  31. lwz r6,8(r1)
  32. #ifdef __PIC__
  33. mflr r4
  34. bl _GLOBAL_OFFSET_TABLE_@local-4
  35. mflr r5
  36. lwz r5,__curbrk@got(r5)
  37. mtlr r4
  38. stw r3,0(r5)
  39. #else
  40. lis r4,__curbrk@ha
  41. stw r3,__curbrk@l(r4)
  42. #endif
  43. cmplw r6,r3
  44. addi r1,r1,16
  45. li r3,0
  46. blelr+
  47. li r3,ENOMEM
  48. b __syscall_error
  49. .size __brk,.-__brk
  50. .weak brk
  51. brk=__brk
  52. #endif