brk.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. .hidden __brk
  25. .type __brk,@function
  26. .align 2
  27. __brk:
  28. stwu r1,-16(r1)
  29. stw r3,8(r1)
  30. li 0, __NR_brk;
  31. sc
  32. lwz r6,8(r1)
  33. #ifdef __PIC__
  34. mflr r4
  35. bl _GLOBAL_OFFSET_TABLE_@local-4
  36. mflr r5
  37. lwz r5,__curbrk@got(r5)
  38. mtlr r4
  39. stw r3,0(r5)
  40. #else
  41. lis r4,__curbrk@ha
  42. stw r3,__curbrk@l(r4)
  43. #endif
  44. cmplw r6,r3
  45. addi r1,r1,16
  46. li r3,0
  47. blelr+
  48. li r3,ENOMEM
  49. b __syscall_error
  50. .size __brk,.-__brk
  51. .weak brk
  52. brk=__brk
  53. #endif