sysdep-cancel.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #include <sysdep.h>
  17. #include <tls.h>
  18. #ifndef __ASSEMBLER__
  19. # include <linuxthreads/internals.h>
  20. #endif
  21. #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
  22. # ifdef IS_IN_librt
  23. # define PSEUDO_NLOCAL 6
  24. # define PSEUDO_SAVE_GP mov loc5 = gp
  25. # define PSEUDO_RESTORE_GP mov gp = loc5
  26. # define PSEUDO_SAVE_GP_1
  27. # define PSEUDO_RESTORE_GP_1 mov gp = loc5
  28. # else
  29. # define PSEUDO_NLOCAL 5
  30. # define PSEUDO_SAVE_GP
  31. # define PSEUDO_RESTORE_GP
  32. # define PSEUDO_SAVE_GP_1 mov loc4 = gp;;
  33. # define PSEUDO_RESTORE_GP_1 mov gp = loc4
  34. # endif
  35. # undef PSEUDO
  36. # define PSEUDO(name, syscall_name, args) \
  37. .text; \
  38. ENTRY (name) \
  39. adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \
  40. ld4 r14 = [r14]; \
  41. mov r15 = SYS_ify(syscall_name);; \
  42. cmp4.ne p6, p7 = 0, r14; \
  43. (p6) br.cond.spnt .Lpseudo_cancel;; \
  44. break __BREAK_SYSCALL;; \
  45. cmp.eq p6,p0=-1,r10; \
  46. (p6) br.cond.spnt.few __syscall_error; \
  47. ret;; \
  48. .endp name; \
  49. .proc __GC_##name; \
  50. .globl __GC_##name; \
  51. .hidden __GC_##name; \
  52. __GC_##name: \
  53. .Lpseudo_cancel: \
  54. .prologue; \
  55. .regstk args, PSEUDO_NLOCAL, args, 0; \
  56. .save ar.pfs, loc0; \
  57. alloc loc0 = ar.pfs, args, PSEUDO_NLOCAL, args, 0; \
  58. .save rp, loc1; \
  59. mov loc1 = rp; \
  60. PSEUDO_SAVE_GP;; \
  61. .body; \
  62. CENABLE;; \
  63. PSEUDO_RESTORE_GP; \
  64. mov loc2 = r8; \
  65. COPY_ARGS_##args \
  66. mov r15 = SYS_ify(syscall_name); \
  67. break __BREAK_SYSCALL;; \
  68. mov loc3 = r8; \
  69. mov loc4 = r10; \
  70. mov out0 = loc2; \
  71. CDISABLE;; \
  72. PSEUDO_RESTORE_GP; \
  73. cmp.eq p6,p0=-1,loc4; \
  74. (p6) br.cond.spnt.few __syscall_error_##args; \
  75. mov r8 = loc3; \
  76. mov rp = loc1; \
  77. mov ar.pfs = loc0; \
  78. .Lpseudo_end: \
  79. ret; \
  80. .endp __GC_##name; \
  81. .section .gnu.linkonce.t.__syscall_error_##args, "ax"; \
  82. .align 32; \
  83. .proc __syscall_error_##args; \
  84. .global __syscall_error_##args; \
  85. .hidden __syscall_error_##args; \
  86. .size __syscall_error_##args, 64; \
  87. __syscall_error_##args: \
  88. .prologue; \
  89. .regstk args, PSEUDO_NLOCAL, args, 0; \
  90. .save ar.pfs, loc0; \
  91. .save rp, loc1; \
  92. .body; \
  93. PSEUDO_SAVE_GP_1; \
  94. br.call.sptk.many b0 = __errno_location;; \
  95. st4 [r8] = loc3; \
  96. PSEUDO_RESTORE_GP_1; \
  97. mov rp = loc1; \
  98. mov r8 = -1; \
  99. mov ar.pfs = loc0
  100. #undef PSEUDO_END
  101. #define PSEUDO_END(name) .endp
  102. # ifdef IS_IN_libpthread
  103. # define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel
  104. # define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel
  105. # elif !defined NOT_IN_libc
  106. # define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel
  107. # define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel
  108. # else
  109. # define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel
  110. # define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel
  111. # endif
  112. #define COPY_ARGS_0 /* Nothing */
  113. #define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0;
  114. #define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1;
  115. #define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2;
  116. #define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3;
  117. #define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4;
  118. #define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5;
  119. #define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6;
  120. # ifndef __ASSEMBLER__
  121. # define SINGLE_THREAD_P \
  122. __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
  123. # else
  124. # define SINGLE_THREAD_P \
  125. adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
  126. # endif
  127. #elif !defined __ASSEMBLER__
  128. /* This code should never be used but we define it anyhow. */
  129. # define SINGLE_THREAD_P (1)
  130. #endif