sysdep.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Assembler macros for ARM.
  2. Copyright (C) 1997, 1998, 2003 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 <sysdeps/generic/sysdep.h>
  17. #ifdef __ASSEMBLER__
  18. /* Syntactic details of assembler. */
  19. #define ALIGNARG(log2) log2
  20. /* For ELF we need the `.type' directive to make shared libs work right. */
  21. #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,%##typearg;
  22. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
  23. /* In ELF C symbols are asm symbols. */
  24. #undef NO_UNDERSCORES
  25. #define NO_UNDERSCORES
  26. #define PLTJMP(_x) _x##(PLT)
  27. /* APCS-32 doesn't preserve the condition codes across function call. */
  28. #ifdef __APCS_32__
  29. #define LOADREGS(cond, base, reglist...)\
  30. ldm##cond base,reglist
  31. #ifdef __USE_BX__
  32. #define RETINSTR(cond, reg) \
  33. bx##cond reg
  34. #define DO_RET(_reg) \
  35. bx _reg
  36. #else
  37. #define RETINSTR(cond, reg) \
  38. mov##cond pc, reg
  39. #define DO_RET(_reg) \
  40. mov pc, _reg
  41. #endif
  42. #else /* APCS-26 */
  43. #define LOADREGS(cond, base, reglist...)\
  44. ldm##cond base,reglist^
  45. #define RETINSTR(cond, reg) \
  46. mov##cond##s pc, reg
  47. #define DO_RET(_reg) \
  48. movs pc, _reg
  49. #endif
  50. /* Define an entry point visible from C. */
  51. #define ENTRY(name) \
  52. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
  53. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function) \
  54. .align ALIGNARG(4); \
  55. name##: \
  56. CALL_MCOUNT
  57. #undef END
  58. #define END(name) \
  59. ASM_SIZE_DIRECTIVE(name)
  60. /* If compiled for profiling, call `mcount' at the start of each function. */
  61. #ifdef PROF
  62. #define CALL_MCOUNT \
  63. str lr,[sp, #-4]! ; \
  64. bl PLTJMP(mcount) ; \
  65. ldr lr, [sp], #4 ;
  66. #else
  67. #define CALL_MCOUNT /* Do nothing. */
  68. #endif
  69. #ifdef NO_UNDERSCORES
  70. /* Since C identifiers are not normally prefixed with an underscore
  71. on this system, the asm identifier `syscall_error' intrudes on the
  72. C name space. Make sure we use an innocuous name. */
  73. #define syscall_error __syscall_error
  74. #define mcount _mcount
  75. #endif
  76. #endif /* __ASSEMBLER__ */