sysdep.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
  4. Based on code originally written by David Mosberger-Tang
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef _LINUX_IA64_SYSDEP_H
  17. #define _LINUX_IA64_SYSDEP_H 1
  18. #include <features.h>
  19. #include <asm/unistd.h>
  20. #ifdef __ASSEMBLER__
  21. /* Macros to help writing .prologue directives in assembly code. */
  22. #define ASM_UNW_PRLG_RP 0x8
  23. #define ASM_UNW_PRLG_PFS 0x4
  24. #define ASM_UNW_PRLG_PSP 0x2
  25. #define ASM_UNW_PRLG_PR 0x1
  26. #define ASM_UNW_PRLG_GRSAVE(ninputs) (32+(ninputs))
  27. #ifdef __STDC__
  28. #define C_LABEL(name) name :
  29. #else
  30. #define C_LABEL(name) name/**/:
  31. #endif
  32. #define CALL_MCOUNT
  33. #define ENTRY(name) \
  34. .text; \
  35. .align 32; \
  36. .proc C_SYMBOL_NAME(name); \
  37. .global C_SYMBOL_NAME(name); \
  38. C_LABEL(name) \
  39. CALL_MCOUNT
  40. #define HIDDEN_ENTRY(name) \
  41. .text; \
  42. .align 32; \
  43. .proc C_SYMBOL_NAME(name); \
  44. .global C_SYMBOL_NAME(name); \
  45. .hidden C_SYMBOL_NAME(name); \
  46. C_LABEL(name) \
  47. CALL_MCOUNT
  48. #define LEAF(name) \
  49. .text; \
  50. .align 32; \
  51. .proc C_SYMBOL_NAME(name); \
  52. .global name; \
  53. C_LABEL(name)
  54. /* Mark the end of function SYM. */
  55. #undef END
  56. #define END(sym) .endp C_SYMBOL_NAME(sym)
  57. /* For Linux we can use the system call table in the header file
  58. /usr/include/asm/unistd.h
  59. of the kernel. But these symbols do not follow the SYS_* syntax
  60. so we have to redefine the `SYS_ify' macro here. */
  61. #undef SYS_ify
  62. #ifdef __STDC__
  63. # define SYS_ify(syscall_name) __NR_##syscall_name
  64. #else
  65. # define SYS_ify(syscall_name) __NR_/**/syscall_name
  66. #endif
  67. /* Linux uses a negative return value to indicate syscall errors, unlike
  68. most Unices, which use the condition codes' carry flag.
  69. Since version 2.1 the return value of a system call might be negative
  70. even if the call succeeded. E.g., the `lseek' system call might return
  71. a large offset. Therefore we must not anymore test for < 0, but test
  72. for a real error by making sure the value in %d0 is a real error
  73. number. Linus said he will make sure the no syscall returns a value
  74. in -1 .. -4095 as a valid result so we can savely test with -4095. */
  75. /* We don't want the label for the error handler to be visible in the symbol
  76. table when we define it here. */
  77. #define SYSCALL_ERROR_LABEL __syscall_error
  78. #undef PSEUDO
  79. #define PSEUDO(name, syscall_name, args) \
  80. ENTRY(name) \
  81. DO_CALL (SYS_ify(syscall_name)); \
  82. cmp.eq p6,p0=-1,r10; \
  83. (p6) br.cond.spnt.few __syscall_error;
  84. #define DO_CALL_VIA_BREAK(num) \
  85. mov r15=num; \
  86. break __BREAK_SYSCALL
  87. #ifdef IA64_USE_NEW_STUB
  88. # ifdef SHARED
  89. # define DO_CALL(num) \
  90. .prologue; \
  91. adds r2 = SYSINFO_OFFSET, r13;; \
  92. ld8 r2 = [r2]; \
  93. .save ar.pfs, r11; \
  94. mov r11 = ar.pfs;; \
  95. .body; \
  96. mov r15 = num; \
  97. mov b7 = r2; \
  98. br.call.sptk.many b6 = b7;; \
  99. .restore sp; \
  100. mov ar.pfs = r11; \
  101. .prologue; \
  102. .body
  103. # else /* !SHARED */
  104. # define DO_CALL(num) \
  105. .prologue; \
  106. mov r15 = num; \
  107. movl r2 = _dl_sysinfo;; \
  108. ld8 r2 = [r2]; \
  109. .save ar.pfs, r11; \
  110. mov r11 = ar.pfs;; \
  111. .body; \
  112. mov b7 = r2; \
  113. br.call.sptk.many b6 = b7;; \
  114. .restore sp; \
  115. mov ar.pfs = r11; \
  116. .prologue; \
  117. .body
  118. # endif
  119. #else
  120. # define DO_CALL(num) DO_CALL_VIA_BREAK(num)
  121. #endif
  122. #undef PSEUDO_END
  123. #define PSEUDO_END(name) .endp C_SYMBOL_NAME(name);
  124. #undef PSEUDO_NOERRNO
  125. #define PSEUDO_NOERRNO(name, syscall_name, args) \
  126. ENTRY(name) \
  127. DO_CALL (SYS_ify(syscall_name));
  128. #undef PSEUDO_END_NOERRNO
  129. #define PSEUDO_END_NOERRNO(name) .endp C_SYMBOL_NAME(name);
  130. #undef PSEUDO_ERRVAL
  131. #define PSEUDO_ERRVAL(name, syscall_name, args) \
  132. ENTRY(name) \
  133. DO_CALL (SYS_ify(syscall_name)); \
  134. cmp.eq p6,p0=-1,r10; \
  135. (p6) mov r10=r8;
  136. #undef PSEUDO_END_ERRVAL
  137. #define PSEUDO_END_ERRVAL(name) .endp C_SYMBOL_NAME(name);
  138. #undef END
  139. #define END(name) \
  140. .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \
  141. .endp C_SYMBOL_NAME(name)
  142. #define ret br.ret.sptk.few b0
  143. #define ret_NOERRNO ret
  144. #define ret_ERRVAL ret
  145. #endif /* not __ASSEMBLER__ */
  146. #endif /* linux/ia64/sysdep.h */