brk.S 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <features.h>
  17. #include "ppc_asm.h"
  18. #define _ERRNO_H 1
  19. #include <bits/errno.h>
  20. #include <sys/syscall.h>
  21. #ifdef __NR_brk
  22. #ifdef __PIC__
  23. .section .bss
  24. .align 4
  25. .globl __curbrk
  26. .hidden __curbrk
  27. __curbrk: .skip 4
  28. .type __curbrk,@object
  29. .size __curbrk,4
  30. #else
  31. .comm __curbrk, 4,4
  32. #endif
  33. .text
  34. .globl brk
  35. .type brk,@function
  36. .align 2
  37. brk:
  38. stwu r1,-16(r1)
  39. stw r3,8(r1)
  40. li 0, __NR_brk;
  41. sc
  42. lwz r6,8(r1)
  43. #ifdef __PIC__
  44. mflr r4
  45. bl _GLOBAL_OFFSET_TABLE_@local-4
  46. mflr r5
  47. lwz r5,__curbrk@got(r5)
  48. mtlr r4
  49. stw r3,0(r5)
  50. #else
  51. lis r4,__curbrk@ha
  52. stw r3,__curbrk@l(r4)
  53. #endif
  54. cmplw r6,r3
  55. addi r1,r1,16
  56. li r3,0
  57. blelr+
  58. li r3,ENOMEM
  59. b __syscall_error
  60. .size brk,.-brk
  61. libc_hidden_def(brk)
  62. #endif