sysdep-cancel.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sysdep.h>
  16. #include <tls.h>
  17. #ifndef __ASSEMBLER__
  18. # include <linuxthreads/internals.h>
  19. #endif
  20. #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
  21. # ifdef IS_IN_librt
  22. # define PSEUDO_NLOCAL 6
  23. # define PSEUDO_SAVE_GP mov loc5 = gp
  24. # define PSEUDO_RESTORE_GP mov gp = loc5
  25. # define PSEUDO_SAVE_GP_1
  26. # define PSEUDO_RESTORE_GP_1 mov gp = loc5
  27. # else
  28. # define PSEUDO_NLOCAL 5
  29. # define PSEUDO_SAVE_GP
  30. # define PSEUDO_RESTORE_GP
  31. # define PSEUDO_SAVE_GP_1 mov loc4 = gp;;
  32. # define PSEUDO_RESTORE_GP_1 mov gp = loc4
  33. # endif
  34. # undef PSEUDO
  35. # define PSEUDO(name, syscall_name, args) \
  36. .text; \
  37. ENTRY (name) \
  38. adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \
  39. ld4 r14 = [r14]; \
  40. mov r15 = SYS_ify(syscall_name);; \
  41. cmp4.ne p6, p7 = 0, r14; \
  42. (p6) br.cond.spnt .Lpseudo_cancel;; \
  43. break __BREAK_SYSCALL;; \
  44. cmp.eq p6,p0=-1,r10; \
  45. (p6) br.cond.spnt.few __syscall_error; \
  46. ret;; \
  47. .endp name; \
  48. .proc __GC_##name; \
  49. .globl __GC_##name; \
  50. .hidden __GC_##name; \
  51. __GC_##name: \
  52. .Lpseudo_cancel: \
  53. .prologue; \
  54. .regstk args, PSEUDO_NLOCAL, args, 0; \
  55. .save ar.pfs, loc0; \
  56. alloc loc0 = ar.pfs, args, PSEUDO_NLOCAL, args, 0; \
  57. .save rp, loc1; \
  58. mov loc1 = rp; \
  59. PSEUDO_SAVE_GP;; \
  60. .body; \
  61. CENABLE;; \
  62. PSEUDO_RESTORE_GP; \
  63. mov loc2 = r8; \
  64. COPY_ARGS_##args \
  65. mov r15 = SYS_ify(syscall_name); \
  66. break __BREAK_SYSCALL;; \
  67. mov loc3 = r8; \
  68. mov loc4 = r10; \
  69. mov out0 = loc2; \
  70. CDISABLE;; \
  71. PSEUDO_RESTORE_GP; \
  72. cmp.eq p6,p0=-1,loc4; \
  73. (p6) br.cond.spnt.few __syscall_error_##args; \
  74. mov r8 = loc3; \
  75. mov rp = loc1; \
  76. mov ar.pfs = loc0; \
  77. .Lpseudo_end: \
  78. ret; \
  79. .endp __GC_##name; \
  80. .section .gnu.linkonce.t.__syscall_error_##args, "ax"; \
  81. .align 32; \
  82. .proc __syscall_error_##args; \
  83. .global __syscall_error_##args; \
  84. .hidden __syscall_error_##args; \
  85. .size __syscall_error_##args, 64; \
  86. __syscall_error_##args: \
  87. .prologue; \
  88. .regstk args, PSEUDO_NLOCAL, args, 0; \
  89. .save ar.pfs, loc0; \
  90. .save rp, loc1; \
  91. .body; \
  92. PSEUDO_SAVE_GP_1; \
  93. br.call.sptk.many b0 = __errno_location;; \
  94. st4 [r8] = loc3; \
  95. PSEUDO_RESTORE_GP_1; \
  96. mov rp = loc1; \
  97. mov r8 = -1; \
  98. mov ar.pfs = loc0
  99. #undef PSEUDO_END
  100. #define PSEUDO_END(name) .endp
  101. # ifdef IS_IN_libpthread
  102. # define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel
  103. # define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel
  104. # elif !defined NOT_IN_libc
  105. # define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel
  106. # define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel
  107. # else
  108. # define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel
  109. # define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel
  110. # endif
  111. #define COPY_ARGS_0 /* Nothing */
  112. #define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0;
  113. #define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1;
  114. #define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2;
  115. #define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3;
  116. #define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4;
  117. #define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5;
  118. #define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6;
  119. # ifndef __ASSEMBLER__
  120. # define SINGLE_THREAD_P \
  121. __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
  122. # else
  123. # define SINGLE_THREAD_P \
  124. adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
  125. # endif
  126. #elif !defined __ASSEMBLER__
  127. /* This code should never be used but we define it anyhow. */
  128. # define SINGLE_THREAD_P (1)
  129. #endif