610-mips64_syscall_fix.patch 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. commit e5cde2eb0ed7df9416fdd6070af07c8448c72a30
  2. Author: Steve Ellcey <sellcey@mips.com>
  3. Date: Wed Feb 12 11:01:35 2014 -0800
  4. mips: Remove duplicate macro definitions
  5. The INLINE_SYSCALL, INTERNAL_SYSCALL*, and internal_syscall* macros
  6. are defined for MIPS in both libc/sysdeps/linux/mips/sysdep.h and
  7. libc/sysdeps/linux/mips/bits/syscalls.h. The macros are the same
  8. in both cases except that syscalls.h defines internal_syscalls[567]
  9. the same for N32 and N64 ABIs and has a different definition for O32.
  10. I believe that is correct. The sysdep.h header uses the O32 versions
  11. for N32 and has different definitions for N64. I think that is wrong
  12. and that N32 and N64 should share the same definition (modulo the
  13. type 'long' vs. 'long long' for the arguments. This setup (from
  14. sysdep.h) now agrees with what glibc has.
  15. I am not positive about which header (sysdep.h vs syscalls.h) is
  16. really the right one to have these definitions in but using sysdep.h
  17. seems to work for all my builds.
  18. Signed-off-by: Steve Ellcey <sellcey@mips.com>
  19. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
  20. --- a/libc/sysdeps/linux/mips/sysdep.h
  21. +++ b/libc/sysdeps/linux/mips/sysdep.h
  22. @@ -133,258 +133,6 @@ L(syse1):
  23. #else /* ! __ASSEMBLER__ */
  24. -/* Define a macro which expands into the inline wrapper code for a system
  25. - call. */
  26. -#undef INLINE_SYSCALL
  27. -#define INLINE_SYSCALL(name, nr, args...) \
  28. - ({ INTERNAL_SYSCALL_DECL(err); \
  29. - long result_var = INTERNAL_SYSCALL (name, err, nr, args); \
  30. - if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
  31. - { \
  32. - __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
  33. - result_var = -1L; \
  34. - } \
  35. - result_var; })
  36. -
  37. -#undef INTERNAL_SYSCALL_DECL
  38. -#define INTERNAL_SYSCALL_DECL(err) long err
  39. -
  40. -#undef INTERNAL_SYSCALL_ERROR_P
  41. -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))
  42. -
  43. -#undef INTERNAL_SYSCALL_ERRNO
  44. -#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
  45. -
  46. -#undef INTERNAL_SYSCALL
  47. -#define INTERNAL_SYSCALL(name, err, nr, args...) \
  48. - internal_syscall##nr (, "li\t$2, %2\t\t\t# " #name "\n\t", \
  49. - "i" (SYS_ify (name)), err, args)
  50. -
  51. -#undef INTERNAL_SYSCALL_NCS
  52. -#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
  53. - internal_syscall##nr (= number, , "r" (__v0), err, args)
  54. -#undef internal_syscall0
  55. -#define internal_syscall0(ncs_init, cs_init, input, err, dummy...) \
  56. -({ \
  57. - long _sys_result; \
  58. - \
  59. - { \
  60. - register long __v0 __asm__("$2") ncs_init; \
  61. - register long __a3 __asm__("$7"); \
  62. - __asm__ __volatile__ ( \
  63. - ".set\tnoreorder\n\t" \
  64. - cs_init \
  65. - "syscall\n\t" \
  66. - ".set reorder" \
  67. - : "=r" (__v0), "=r" (__a3) \
  68. - : input \
  69. - : __SYSCALL_CLOBBERS); \
  70. - err = __a3; \
  71. - _sys_result = __v0; \
  72. - } \
  73. - _sys_result; \
  74. -})
  75. -
  76. -#undef internal_syscall1
  77. -#define internal_syscall1(ncs_init, cs_init, input, err, arg1) \
  78. -({ \
  79. - long _sys_result; \
  80. - \
  81. - { \
  82. - register long __v0 __asm__("$2") ncs_init; \
  83. - register long __a0 __asm__("$4") = (long) arg1; \
  84. - register long __a3 __asm__("$7"); \
  85. - __asm__ __volatile__ ( \
  86. - ".set\tnoreorder\n\t" \
  87. - cs_init \
  88. - "syscall\n\t" \
  89. - ".set reorder" \
  90. - : "=r" (__v0), "=r" (__a3) \
  91. - : input, "r" (__a0) \
  92. - : __SYSCALL_CLOBBERS); \
  93. - err = __a3; \
  94. - _sys_result = __v0; \
  95. - } \
  96. - _sys_result; \
  97. -})
  98. -
  99. -#undef internal_syscall2
  100. -#define internal_syscall2(ncs_init, cs_init, input, err, arg1, arg2) \
  101. -({ \
  102. - long _sys_result; \
  103. - \
  104. - { \
  105. - register long __v0 __asm__("$2") ncs_init; \
  106. - register long __a0 __asm__("$4") = (long) arg1; \
  107. - register long __a1 __asm__("$5") = (long) arg2; \
  108. - register long __a3 __asm__("$7"); \
  109. - __asm__ __volatile__ ( \
  110. - ".set\tnoreorder\n\t" \
  111. - cs_init \
  112. - "syscall\n\t" \
  113. - ".set\treorder" \
  114. - : "=r" (__v0), "=r" (__a3) \
  115. - : input, "r" (__a0), "r" (__a1) \
  116. - : __SYSCALL_CLOBBERS); \
  117. - err = __a3; \
  118. - _sys_result = __v0; \
  119. - } \
  120. - _sys_result; \
  121. -})
  122. -
  123. -#undef internal_syscall3
  124. -#define internal_syscall3(ncs_init, cs_init, input, err, arg1, arg2, arg3)\
  125. -({ \
  126. - long _sys_result; \
  127. - \
  128. - { \
  129. - register long __v0 __asm__("$2") ncs_init; \
  130. - register long __a0 __asm__("$4") = (long) arg1; \
  131. - register long __a1 __asm__("$5") = (long) arg2; \
  132. - register long __a2 __asm__("$6") = (long) arg3; \
  133. - register long __a3 __asm__("$7"); \
  134. - __asm__ __volatile__ ( \
  135. - ".set\tnoreorder\n\t" \
  136. - cs_init \
  137. - "syscall\n\t" \
  138. - ".set\treorder" \
  139. - : "=r" (__v0), "=r" (__a3) \
  140. - : input, "r" (__a0), "r" (__a1), "r" (__a2) \
  141. - : __SYSCALL_CLOBBERS); \
  142. - err = __a3; \
  143. - _sys_result = __v0; \
  144. - } \
  145. - _sys_result; \
  146. -})
  147. -
  148. -#undef internal_syscall4
  149. -#define internal_syscall4(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4)\
  150. -({ \
  151. - long _sys_result; \
  152. - \
  153. - { \
  154. - register long __v0 __asm__("$2") ncs_init; \
  155. - register long __a0 __asm__("$4") = (long) arg1; \
  156. - register long __a1 __asm__("$5") = (long) arg2; \
  157. - register long __a2 __asm__("$6") = (long) arg3; \
  158. - register long __a3 __asm__("$7") = (long) arg4; \
  159. - __asm__ __volatile__ ( \
  160. - ".set\tnoreorder\n\t" \
  161. - cs_init \
  162. - "syscall\n\t" \
  163. - ".set\treorder" \
  164. - : "=r" (__v0), "+r" (__a3) \
  165. - : input, "r" (__a0), "r" (__a1), "r" (__a2) \
  166. - : __SYSCALL_CLOBBERS); \
  167. - err = __a3; \
  168. - _sys_result = __v0; \
  169. - } \
  170. - _sys_result; \
  171. -})
  172. -
  173. -/* We need to use a frame pointer for the functions in which we
  174. - adjust $sp around the syscall, or debug information and unwind
  175. - information will be $sp relative and thus wrong during the syscall. As
  176. - of GCC 3.4.3, this is sufficient. */
  177. -#define FORCE_FRAME_POINTER alloca (4)
  178. -
  179. -#undef internal_syscall5
  180. -#define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5)\
  181. -({ \
  182. - long _sys_result; \
  183. - \
  184. - FORCE_FRAME_POINTER; \
  185. - { \
  186. - register long __v0 __asm__("$2") ncs_init; \
  187. - register long __a0 __asm__("$4") = (long) arg1; \
  188. - register long __a1 __asm__("$5") = (long) arg2; \
  189. - register long __a2 __asm__("$6") = (long) arg3; \
  190. - register long __a3 __asm__("$7") = (long) arg4; \
  191. - __asm__ __volatile__ ( \
  192. - ".set\tnoreorder\n\t" \
  193. - "subu\t$29, 32\n\t" \
  194. - "sw\t%6, 16($29)\n\t" \
  195. - cs_init \
  196. - "syscall\n\t" \
  197. - "addiu\t$29, 32\n\t" \
  198. - ".set\treorder" \
  199. - : "=r" (__v0), "+r" (__a3) \
  200. - : input, "r" (__a0), "r" (__a1), "r" (__a2), \
  201. - "r" ((long)arg5) \
  202. - : __SYSCALL_CLOBBERS); \
  203. - err = __a3; \
  204. - _sys_result = __v0; \
  205. - } \
  206. - _sys_result; \
  207. -})
  208. -
  209. -#undef internal_syscall6
  210. -#define internal_syscall6(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6)\
  211. -({ \
  212. - long _sys_result; \
  213. - \
  214. - FORCE_FRAME_POINTER; \
  215. - { \
  216. - register long __v0 __asm__("$2") ncs_init; \
  217. - register long __a0 __asm__("$4") = (long) arg1; \
  218. - register long __a1 __asm__("$5") = (long) arg2; \
  219. - register long __a2 __asm__("$6") = (long) arg3; \
  220. - register long __a3 __asm__("$7") = (long) arg4; \
  221. - __asm__ __volatile__ ( \
  222. - ".set\tnoreorder\n\t" \
  223. - "subu\t$29, 32\n\t" \
  224. - "sw\t%6, 16($29)\n\t" \
  225. - "sw\t%7, 20($29)\n\t" \
  226. - cs_init \
  227. - "syscall\n\t" \
  228. - "addiu\t$29, 32\n\t" \
  229. - ".set\treorder" \
  230. - : "=r" (__v0), "+r" (__a3) \
  231. - : input, "r" (__a0), "r" (__a1), "r" (__a2), \
  232. - "r" ((long)arg5), "r" ((long)arg6) \
  233. - : __SYSCALL_CLOBBERS); \
  234. - err = __a3; \
  235. - _sys_result = __v0; \
  236. - } \
  237. - _sys_result; \
  238. -})
  239. -
  240. -#undef internal_syscall7
  241. -#define internal_syscall7(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6, arg7)\
  242. -({ \
  243. - long _sys_result; \
  244. - \
  245. - FORCE_FRAME_POINTER; \
  246. - { \
  247. - register long __v0 __asm__("$2") ncs_init; \
  248. - register long __a0 __asm__("$4") = (long) arg1; \
  249. - register long __a1 __asm__("$5") = (long) arg2; \
  250. - register long __a2 __asm__("$6") = (long) arg3; \
  251. - register long __a3 __asm__("$7") = (long) arg4; \
  252. - __asm__ __volatile__ ( \
  253. - ".set\tnoreorder\n\t" \
  254. - "subu\t$29, 32\n\t" \
  255. - "sw\t%6, 16($29)\n\t" \
  256. - "sw\t%7, 20($29)\n\t" \
  257. - "sw\t%8, 24($29)\n\t" \
  258. - cs_init \
  259. - "syscall\n\t" \
  260. - "addiu\t$29, 32\n\t" \
  261. - ".set\treorder" \
  262. - : "=r" (__v0), "+r" (__a3) \
  263. - : input, "r" (__a0), "r" (__a1), "r" (__a2), \
  264. - "r" ((long)arg5), "r" ((long)arg6), "r" ((long)arg7) \
  265. - : __SYSCALL_CLOBBERS); \
  266. - err = __a3; \
  267. - _sys_result = __v0; \
  268. - } \
  269. - _sys_result; \
  270. -})
  271. -
  272. -#undef __SYSCALL_CLOBBERS
  273. -#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
  274. - "$14", "$15", "$24", "$25", "memory"
  275. -
  276. /* Pointer mangling is not yet supported for MIPS. */
  277. #define PTR_MANGLE(var) (void) (var)
  278. #define PTR_DEMANGLE(var) (void) (var)