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 <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. .comm __curbrk,4,4
  23. .text
  24. .globl 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. libc_hidden_def(brk)
  52. /* won't help too much, HIDDEN_JUMPTARGET should be used here as well, now the reloc remains */
  53. libc_hidden_data_def(__curbrk)
  54. #endif