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