sysdep.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* Assembler macros for CRIS.
  2. Copyright (C) 1999, 2000, 2001 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 Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. 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. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #ifndef _SYSDEP_H_
  17. #define _SYSDEP_H_
  18. #include <sys/syscall.h>
  19. #ifndef C_LABEL
  20. /* Define a macro we can use to construct the asm name for a C symbol. */
  21. #ifdef __STDC__
  22. #define C_LABEL(name) name##:
  23. #else
  24. #define C_LABEL(name) name/**/:
  25. #endif
  26. #endif /* C_LABEL */
  27. #define __STR(x) #x
  28. #define STR(x) __STR(x)
  29. /* Mark the end of function named SYM. This is used on some platforms
  30. to generate correct debugging information. */
  31. #ifndef END
  32. #define END(sym)
  33. #endif
  34. #undef SYS_ify
  35. #define SYS_ify(syscall_name) (__NR_##syscall_name)
  36. #ifdef __ASSEMBLER__
  37. #undef SYS_ify
  38. #define SYS_ify(syscall_name) __NR_##syscall_name
  39. /* Syntactic details of assembly-code. */
  40. /* It is *not* generally true that "ELF uses byte-counts for .align, most
  41. others use log2 of count of bytes", like some neighboring configs say.
  42. See "align" in gas/read.c which is not overridden by
  43. gas/config/obj-elf.c. It takes a log2 argument. *Some* targets
  44. override it to take a byte argument. People should read source instead
  45. of relying on hearsay. */
  46. #define ALIGNARG(log2) log2
  47. #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
  48. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
  49. /* The non-PIC jump is preferred, since it does not stall, and does not
  50. invoke generation of a PLT. These macros assume that $r0 is set up as
  51. GOT register. */
  52. #ifdef __arch_v32
  53. #ifdef __PIC__
  54. #define PLTJUMP(_x) \
  55. ba C_SYMBOL_NAME (_x):PLT @ \
  56. nop
  57. #define PLTCALL(_x) \
  58. bsr C_SYMBOL_NAME (_x):PLT @ \
  59. nop
  60. #define SETUP_PIC \
  61. subq 4,$sp @ \
  62. move.d $r0,[$sp] @ \
  63. lapc _GLOBAL_OFFSET_TABLE_,$r0
  64. #define TEARDOWN_PIC move.d [$sp+],$r0
  65. #else
  66. #define PLTJUMP(_x) \
  67. ba C_SYMBOL_NAME (_x) @ \
  68. nop
  69. #define PLTCALL(_x) \
  70. bsr C_SYMBOL_NAME (_x) @ \
  71. nop
  72. #define SETUP_PIC
  73. #define TEARDOWN_PIC
  74. #endif
  75. #else
  76. #ifdef __PIC__
  77. #define PLTJUMP(_x) \
  78. add.d C_SYMBOL_NAME (_x):PLT,$pc
  79. #define PLTCALL(_x) \
  80. jsr [$r0+C_SYMBOL_NAME (_x):GOTPLT16]
  81. #define SETUP_PIC \
  82. push $r0 @ \
  83. move.d $pc,$r0 @ \
  84. sub.d .:GOTOFF,$r0
  85. #define TEARDOWN_PIC pop $r0
  86. #else
  87. #define PLTJUMP(_x) jump C_SYMBOL_NAME (_x)
  88. #define PLTCALL(_x) jsr C_SYMBOL_NAME (_x)
  89. #define SETUP_PIC
  90. #define TEARDOWN_PIC
  91. #endif
  92. #endif /* __arch_v32 */
  93. /* Define an entry point visible from C. */
  94. #define ENTRY(name) \
  95. .text @ \
  96. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name) @ \
  97. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
  98. .align ALIGNARG (2) @ \
  99. C_LABEL(name)
  100. #undef END
  101. #define END(name) \
  102. ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
  103. #define PSEUDO(name, syscall_name, args) \
  104. ENTRY (name) @ \
  105. DOARGS_##args @ \
  106. movu.w SYS_ify (syscall_name),$r9 @ \
  107. break 13 @ \
  108. cmps.w -4096,$r10 @ \
  109. bhs 0f @ \
  110. nop @ \
  111. UNDOARGS_return_##args
  112. #define PSEUDO_END(name) \
  113. 0: @ \
  114. SETUP_PIC @ \
  115. PLTJUMP (__syscall_error) @ \
  116. END (name)
  117. #endif /* __ASSEMBLER__ */
  118. #endif /* _SYSDEP_H_ */