619-mips64_fix_sysdep_cancel.patch 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. --- a/extra/Configs/Config.in
  2. +++ b/extra/Configs/Config.in
  3. @@ -235,6 +235,7 @@ config TARGET_SUBARCH
  4. default "i486" if CONFIG_486
  5. default "i586" if CONFIG_586 || CONFIG_586MMX
  6. default "i686" if TARGET_ARCH = "i386"
  7. + default "mips64" if CONFIG_MIPS_N64_ABI
  8. default ""
  9. source "extra/Configs/Config.in.arch"
  10. --- /dev/null
  11. +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
  12. @@ -0,0 +1,182 @@
  13. +/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  14. + This file is part of the GNU C Library.
  15. +
  16. + The GNU C Library is free software; you can redistribute it and/or
  17. + modify it under the terms of the GNU Lesser General Public
  18. + License as published by the Free Software Foundation; either
  19. + version 2.1 of the License, or (at your option) any later version.
  20. +
  21. + The GNU C Library is distributed in the hope that it will be useful,
  22. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  24. + Lesser General Public License for more details.
  25. +
  26. + You should have received a copy of the GNU Lesser General Public
  27. + License along with the GNU C Library. If not, see
  28. + <http://www.gnu.org/licenses/>. */
  29. +
  30. +#include <sysdep.h>
  31. +#include <tls.h>
  32. +#ifndef __ASSEMBLER__
  33. +# include <pthreadP.h>
  34. +#endif
  35. +#include <sys/asm.h>
  36. +
  37. +/* Gas will put the initial save of $gp into the CIE, because it appears to
  38. + happen before any instructions. So we use cfi_same_value instead of
  39. + cfi_restore. */
  40. +
  41. +#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
  42. +
  43. +#ifdef __PIC__
  44. +# undef PSEUDO
  45. +# define PSEUDO(name, syscall_name, args) \
  46. + .align 2; \
  47. + L(pseudo_start): \
  48. + cfi_startproc; \
  49. + cfi_adjust_cfa_offset (STKSPACE); \
  50. + cfi_rel_offset (gp, STKOFF_GP); \
  51. + 99: move a0, v0; \
  52. + PTR_LA t9,__syscall_error; \
  53. + /* manual cpreturn */ \
  54. + REG_L gp, STKOFF_GP(sp); \
  55. + cfi_same_value (gp); \
  56. + RESTORESTK; \
  57. + jr t9; \
  58. + .type __##syscall_name##_nocancel, @function; \
  59. + .globl __##syscall_name##_nocancel; \
  60. + __##syscall_name##_nocancel: \
  61. + SAVESTK; \
  62. + .cpsetup t9, STKOFF_GP, name; \
  63. + cfi_rel_offset (gp, STKOFF_GP); \
  64. + li v0, SYS_ify(syscall_name); \
  65. + syscall; \
  66. + bne a3, zero, SYSCALL_ERROR_LABEL; \
  67. + /* manual cpreturn */ \
  68. + REG_L gp, STKOFF_GP(sp); \
  69. + cfi_same_value (gp); \
  70. + RESTORESTK; \
  71. + ret; \
  72. + .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
  73. + ENTRY (name) \
  74. + SAVESTK; \
  75. + .cpsetup t9, STKOFF_GP, name; \
  76. + cfi_rel_offset (gp, STKOFF_GP); \
  77. + SINGLE_THREAD_P(v1); \
  78. + bne zero, v1, L(pseudo_cancel); \
  79. + .set noreorder; \
  80. + li v0, SYS_ify(syscall_name); \
  81. + syscall; \
  82. + .set reorder; \
  83. + bne a3, zero, SYSCALL_ERROR_LABEL; \
  84. + /* manual cpreturn */ \
  85. + REG_L gp, STKOFF_GP(sp); \
  86. + cfi_same_value (gp); \
  87. + RESTORESTK; \
  88. + ret; \
  89. + L(pseudo_cancel): \
  90. + cfi_adjust_cfa_offset (STKSPACE); \
  91. + cfi_rel_offset (gp, STKOFF_GP); \
  92. + REG_S ra, STKOFF_RA(sp); \
  93. + cfi_rel_offset (ra, STKOFF_RA); \
  94. + PUSHARGS_##args; /* save syscall args */ \
  95. + CENABLE; \
  96. + REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \
  97. + POPARGS_##args; /* restore syscall args */ \
  98. + .set noreorder; \
  99. + li v0, SYS_ify (syscall_name); \
  100. + syscall; \
  101. + .set reorder; \
  102. + REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \
  103. + REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \
  104. + REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \
  105. + CDISABLE; \
  106. + REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \
  107. + REG_L ra, STKOFF_RA(sp); /* restore return address */ \
  108. + REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \
  109. + bne a3, zero, SYSCALL_ERROR_LABEL; \
  110. + /* manual cpreturn */ \
  111. + REG_L gp, STKOFF_GP(sp); \
  112. + cfi_same_value (gp); \
  113. + RESTORESTK; \
  114. + L(pseudo_end):
  115. +
  116. +
  117. +# undef PSEUDO_END
  118. +# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
  119. +
  120. +#endif
  121. +
  122. +# define PUSHARGS_0 /* nothing to do */
  123. +# define PUSHARGS_1 PUSHARGS_0 REG_S a0, STKOFF_A0(sp); cfi_rel_offset (a0, STKOFF_A0);
  124. +# define PUSHARGS_2 PUSHARGS_1 REG_S a1, STKOFF_A1(sp); cfi_rel_offset (a1, STKOFF_A1);
  125. +# define PUSHARGS_3 PUSHARGS_2 REG_S a2, STKOFF_A2(sp); cfi_rel_offset (a2, STKOFF_A2);
  126. +# define PUSHARGS_4 PUSHARGS_3 REG_S a3, STKOFF_A3(sp); cfi_rel_offset (a3, STKOFF_A3);
  127. +# define PUSHARGS_5 PUSHARGS_4 REG_S a4, STKOFF_A4(sp); cfi_rel_offset (a3, STKOFF_A4);
  128. +# define PUSHARGS_6 PUSHARGS_5 REG_S a5, STKOFF_A5(sp); cfi_rel_offset (a3, STKOFF_A5);
  129. +
  130. +# define POPARGS_0 /* nothing to do */
  131. +# define POPARGS_1 POPARGS_0 REG_L a0, STKOFF_A0(sp);
  132. +# define POPARGS_2 POPARGS_1 REG_L a1, STKOFF_A1(sp);
  133. +# define POPARGS_3 POPARGS_2 REG_L a2, STKOFF_A2(sp);
  134. +# define POPARGS_4 POPARGS_3 REG_L a3, STKOFF_A3(sp);
  135. +# define POPARGS_5 POPARGS_4 REG_L a4, STKOFF_A4(sp);
  136. +# define POPARGS_6 POPARGS_5 REG_L a5, STKOFF_A5(sp);
  137. +
  138. +/* Save an even number of slots. Should be 0 if an even number of slots
  139. + are used below, or SZREG if an odd number are used. */
  140. +# define STK_PAD SZREG
  141. +
  142. +/* Place values that we are more likely to use later in this sequence, i.e.
  143. + closer to the SP at function entry. If you do that, the are more
  144. + likely to already be in your d-cache. */
  145. +# define STKOFF_A5 (STK_PAD)
  146. +# define STKOFF_A4 (STKOFF_A5 + SZREG)
  147. +# define STKOFF_A3 (STKOFF_A4 + SZREG)
  148. +# define STKOFF_A2 (STKOFF_A3 + SZREG) /* MT and more args. */
  149. +# define STKOFF_A1 (STKOFF_A2 + SZREG) /* MT and 2 args. */
  150. +# define STKOFF_A0 (STKOFF_A1 + SZREG) /* MT and 1 arg. */
  151. +# define STKOFF_RA (STKOFF_A0 + SZREG) /* Used if MT. */
  152. +# define STKOFF_SC_V0 (STKOFF_RA + SZREG) /* Used if MT. */
  153. +# define STKOFF_SC_ERR (STKOFF_SC_V0 + SZREG) /* Used if MT. */
  154. +# define STKOFF_SVMSK (STKOFF_SC_ERR + SZREG) /* Used if MT. */
  155. +# define STKOFF_GP (STKOFF_SVMSK + SZREG) /* Always used. */
  156. +
  157. +# define STKSPACE (STKOFF_GP + SZREG)
  158. +# define SAVESTK PTR_SUBU sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE)
  159. +# define RESTORESTK PTR_ADDU sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE)
  160. +
  161. +# ifdef IS_IN_libpthread
  162. +# define CENABLE PTR_LA t9, __pthread_enable_asynccancel; jalr t9
  163. +# define CDISABLE PTR_LA t9, __pthread_disable_asynccancel; jalr t9
  164. +# elif defined IS_IN_librt
  165. +# define CENABLE PTR_LA t9, __librt_enable_asynccancel; jalr t9
  166. +# define CDISABLE PTR_LA t9, __librt_disable_asynccancel; jalr t9
  167. +# else
  168. +# define CENABLE PTR_LA t9, __libc_enable_asynccancel; jalr t9
  169. +# define CDISABLE PTR_LA t9, __libc_disable_asynccancel; jalr t9
  170. +# endif
  171. +
  172. +# ifndef __ASSEMBLER__
  173. +# define SINGLE_THREAD_P \
  174. + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  175. + header.multiple_threads) \
  176. + == 0, 1)
  177. +# else
  178. +# define SINGLE_THREAD_P(reg) \
  179. + READ_THREAD_POINTER(reg); \
  180. + lw reg, MULTIPLE_THREADS_OFFSET(reg)
  181. +#endif
  182. +
  183. +#elif !defined __ASSEMBLER__
  184. +
  185. +# define SINGLE_THREAD_P 1
  186. +# define NO_CANCELLATION 1
  187. +
  188. +#endif
  189. +
  190. +#ifndef __ASSEMBLER__
  191. +# define RTLD_SINGLE_THREAD_P \
  192. + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  193. + header.multiple_threads) == 0, 1)
  194. +#endif