sysdep.h 4.6 KB

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