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 <common/sysdep.h>
  19. #include <features.h>
  20. #include <asm/unistd.h>
  21. #ifdef __ASSEMBLER__
  22. /* Macros to help writing .prologue directives in assembly code. */
  23. #define ASM_UNW_PRLG_RP 0x8
  24. #define ASM_UNW_PRLG_PFS 0x4
  25. #define ASM_UNW_PRLG_PSP 0x2
  26. #define ASM_UNW_PRLG_PR 0x1
  27. #define ASM_UNW_PRLG_GRSAVE(ninputs) (32+(ninputs))
  28. #ifdef __STDC__
  29. #define C_LABEL(name) name :
  30. #else
  31. #define C_LABEL(name) name/**/:
  32. #endif
  33. #define CALL_MCOUNT
  34. #define ENTRY(name) \
  35. .text; \
  36. .align 32; \
  37. .proc C_SYMBOL_NAME(name); \
  38. .global C_SYMBOL_NAME(name); \
  39. C_LABEL(name) \
  40. CALL_MCOUNT
  41. #define HIDDEN_ENTRY(name) \
  42. .text; \
  43. .align 32; \
  44. .proc C_SYMBOL_NAME(name); \
  45. .global C_SYMBOL_NAME(name); \
  46. .hidden C_SYMBOL_NAME(name); \
  47. C_LABEL(name) \
  48. CALL_MCOUNT
  49. #define LEAF(name) \
  50. .text; \
  51. .align 32; \
  52. .proc C_SYMBOL_NAME(name); \
  53. .global name; \
  54. C_LABEL(name)
  55. /* Mark the end of function SYM. */
  56. #undef END
  57. #define END(sym) .endp C_SYMBOL_NAME(sym)
  58. /* For Linux we can use the system call table in the header file
  59. /usr/include/asm/unistd.h
  60. of the kernel. But these symbols do not follow the SYS_* syntax
  61. so we have to redefine the `SYS_ify' macro here. */
  62. #undef SYS_ify
  63. #ifdef __STDC__
  64. # define SYS_ify(syscall_name) __NR_##syscall_name
  65. #else
  66. # define SYS_ify(syscall_name) __NR_/**/syscall_name
  67. #endif
  68. /* Linux uses a negative return value to indicate syscall errors, unlike
  69. most Unices, which use the condition codes' carry flag.
  70. Since version 2.1 the return value of a system call might be negative
  71. even if the call succeeded. E.g., the `lseek' system call might return
  72. a large offset. Therefore we must not anymore test for < 0, but test
  73. for a real error by making sure the value in %d0 is a real error
  74. number. Linus said he will make sure the no syscall returns a value
  75. in -1 .. -4095 as a valid result so we can savely test with -4095. */
  76. /* We don't want the label for the error handler to be visible in the symbol
  77. table when we define it here. */
  78. #define SYSCALL_ERROR_LABEL __syscall_error
  79. #undef PSEUDO
  80. #define PSEUDO(name, syscall_name, args) \
  81. ENTRY(name) \
  82. DO_CALL (SYS_ify(syscall_name)); \
  83. cmp.eq p6,p0=-1,r10; \
  84. (p6) br.cond.spnt.few __syscall_error;
  85. #define DO_CALL_VIA_BREAK(num) \
  86. mov r15=num; \
  87. break __BREAK_SYSCALL
  88. #ifdef IA64_USE_NEW_STUB
  89. # ifdef SHARED
  90. # define DO_CALL(num) \
  91. .prologue; \
  92. adds r2 = SYSINFO_OFFSET, r13;; \
  93. ld8 r2 = [r2]; \
  94. .save ar.pfs, r11; \
  95. mov r11 = ar.pfs;; \
  96. .body; \
  97. mov r15 = num; \
  98. mov b7 = r2; \
  99. br.call.sptk.many b6 = b7;; \
  100. .restore sp; \
  101. mov ar.pfs = r11; \
  102. .prologue; \
  103. .body
  104. # else /* !SHARED */
  105. # define DO_CALL(num) \
  106. .prologue; \
  107. mov r15 = num; \
  108. movl r2 = _dl_sysinfo;; \
  109. ld8 r2 = [r2]; \
  110. .save ar.pfs, r11; \
  111. mov r11 = ar.pfs;; \
  112. .body; \
  113. mov b7 = r2; \
  114. br.call.sptk.many b6 = b7;; \
  115. .restore sp; \
  116. mov ar.pfs = r11; \
  117. .prologue; \
  118. .body
  119. # endif
  120. #else
  121. # define DO_CALL(num) DO_CALL_VIA_BREAK(num)
  122. #endif
  123. #undef PSEUDO_END
  124. #define PSEUDO_END(name) .endp C_SYMBOL_NAME(name);
  125. #undef PSEUDO_NOERRNO
  126. #define PSEUDO_NOERRNO(name, syscall_name, args) \
  127. ENTRY(name) \
  128. DO_CALL (SYS_ify(syscall_name));
  129. #undef PSEUDO_END_NOERRNO
  130. #define PSEUDO_END_NOERRNO(name) .endp C_SYMBOL_NAME(name);
  131. #undef PSEUDO_ERRVAL
  132. #define PSEUDO_ERRVAL(name, syscall_name, args) \
  133. ENTRY(name) \
  134. DO_CALL (SYS_ify(syscall_name)); \
  135. cmp.eq p6,p0=-1,r10; \
  136. (p6) mov r10=r8;
  137. #undef PSEUDO_END_ERRVAL
  138. #define PSEUDO_END_ERRVAL(name) .endp C_SYMBOL_NAME(name);
  139. #undef END
  140. #define END(name) \
  141. .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \
  142. .endp C_SYMBOL_NAME(name)
  143. #define ret br.ret.sptk.few b0
  144. #define ret_NOERRNO ret
  145. #endif /* not __ASSEMBLER__ */
  146. #endif /* linux/ia64/sysdep.h */