brk.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 ___brk_addr,4,4
  22. .section ".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,___brk_addr@got(r5)
  37. mtlr r4
  38. stw r3,0(r5)
  39. #else
  40. lis r4,___brk_addr@ha
  41. stw r3,___brk_addr@l(r4)
  42. #endif
  43. cmplw r6,r3
  44. addi r1,r1,16
  45. li r3,0
  46. blelr+
  47. li r3,ENOMEM
  48. #ifdef __PIC__
  49. b __syscall_error@plt
  50. #else
  51. b __syscall_error
  52. #endif
  53. .size __brk,.-__brk
  54. .weak brk;
  55. brk=__brk
  56. #endif