sysdep.h 4.7 KB

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