sysdep.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* Assembly macros for 32-bit PowerPC.
  2. Copyright (C) 1999, 2001, 2002, 2003, 2006 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, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifdef __ASSEMBLER__
  16. #ifdef __ELF__
  17. /* If compiled for profiling, call `_mcount' at the start of each
  18. function. */
  19. #ifdef PROF
  20. /* The mcount code relies on a the return address being on the stack
  21. to locate our caller and so it can restore it; so store one just
  22. for its benefit. */
  23. # define CALL_MCOUNT \
  24. mflr r0; \
  25. stw r0,4(r1); \
  26. cfi_offset (lr, 4); \
  27. bl JUMPTARGET(_mcount);
  28. #else /* PROF */
  29. # define CALL_MCOUNT /* Do nothing. */
  30. #endif /* PROF */
  31. #define ENTRY(name) \
  32. .globl C_SYMBOL_NAME(name); \
  33. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
  34. .align ALIGNARG(2); \
  35. C_LABEL(name) \
  36. cfi_startproc; \
  37. CALL_MCOUNT
  38. #define EALIGN_W_0 /* No words to insert. */
  39. #define EALIGN_W_1 nop
  40. #define EALIGN_W_2 nop;nop
  41. #define EALIGN_W_3 nop;nop;nop
  42. #define EALIGN_W_4 EALIGN_W_3;nop
  43. #define EALIGN_W_5 EALIGN_W_4;nop
  44. #define EALIGN_W_6 EALIGN_W_5;nop
  45. #define EALIGN_W_7 EALIGN_W_6;nop
  46. /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
  47. past a 2^align boundary. */
  48. #ifdef PROF
  49. # define EALIGN(name, alignt, words) \
  50. .globl C_SYMBOL_NAME(name); \
  51. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
  52. .align ALIGNARG(2); \
  53. C_LABEL(name) \
  54. cfi_startproc; \
  55. CALL_MCOUNT \
  56. b 0f; \
  57. .align ALIGNARG(alignt); \
  58. EALIGN_W_##words; \
  59. 0:
  60. #else /* PROF */
  61. # define EALIGN(name, alignt, words) \
  62. .globl C_SYMBOL_NAME(name); \
  63. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
  64. .align ALIGNARG(alignt); \
  65. EALIGN_W_##words; \
  66. C_LABEL(name) \
  67. cfi_startproc;
  68. #endif
  69. #undef END
  70. #define END(name) \
  71. cfi_endproc; \
  72. ASM_SIZE_DIRECTIVE(name)
  73. #define DO_CALL(syscall) \
  74. li 0,syscall; \
  75. sc
  76. #undef JUMPTARGET
  77. #ifdef PIC
  78. # define JUMPTARGET(name) name##@plt
  79. #else
  80. # define JUMPTARGET(name) name
  81. #endif
  82. #if defined SHARED && defined DO_VERSIONING && defined PIC \
  83. && !defined NO_HIDDEN
  84. # undef HIDDEN_JUMPTARGET
  85. # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
  86. #endif
  87. #define PSEUDO(name, syscall_name, args) \
  88. .section ".text"; \
  89. ENTRY (name) \
  90. DO_CALL (SYS_ify (syscall_name));
  91. #define PSEUDO_RET \
  92. bnslr+; \
  93. b __syscall_error@local
  94. #define ret PSEUDO_RET
  95. #undef PSEUDO_END
  96. #define PSEUDO_END(name) \
  97. END (name)
  98. #define PSEUDO_NOERRNO(name, syscall_name, args) \
  99. .section ".text"; \
  100. ENTRY (name) \
  101. DO_CALL (SYS_ify (syscall_name));
  102. #define PSEUDO_RET_NOERRNO \
  103. blr
  104. #define ret_NOERRNO PSEUDO_RET_NOERRNO
  105. #undef PSEUDO_END_NOERRNO
  106. #define PSEUDO_END_NOERRNO(name) \
  107. END (name)
  108. #define PSEUDO_ERRVAL(name, syscall_name, args) \
  109. .section ".text"; \
  110. ENTRY (name) \
  111. DO_CALL (SYS_ify (syscall_name));
  112. #define PSEUDO_RET_ERRVAL \
  113. blr
  114. #undef ret_ERRVAL
  115. #define ret_ERRVAL PSEUDO_RET_ERRVAL
  116. #undef PSEUDO_END_ERRVAL
  117. #define PSEUDO_END_ERRVAL(name) \
  118. END (name)
  119. /* Local labels stripped out by the linker. */
  120. #undef L
  121. #define L(x) .L##x
  122. /* Label in text section. */
  123. #define C_TEXT(name) name
  124. #endif /* __ELF__ */
  125. #endif /* __ASSEMBLER__ */