brk.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. __curbrk: .skip 4
  27. .type __curbrk,@object
  28. .size __curbrk,4
  29. #else
  30. .comm __curbrk, 4,4
  31. #endif
  32. .text
  33. .globl brk
  34. .type brk,@function
  35. .align 2
  36. brk:
  37. stwu r1,-16(r1)
  38. stw r3,8(r1)
  39. li 0, __NR_brk;
  40. sc
  41. lwz r6,8(r1)
  42. #ifdef __PIC__
  43. mflr r4
  44. bl _GLOBAL_OFFSET_TABLE_@local-4
  45. mflr r5
  46. lwz r5,__curbrk@got(r5)
  47. mtlr r4
  48. stw r3,0(r5)
  49. #else
  50. lis r4,__curbrk@ha
  51. stw r3,__curbrk@l(r4)
  52. #endif
  53. cmplw r6,r3
  54. addi r1,r1,16
  55. li r3,0
  56. blelr+
  57. li r3,ENOMEM
  58. b __syscall_error
  59. .size brk,.-brk
  60. libc_hidden_def(brk)
  61. #endif