sysdep-cancel.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* Copyright (C) 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #include <sysdep.h>
  16. #ifndef __ASSEMBLER__
  17. # include <linuxthreads/internals.h>
  18. #endif
  19. #if !defined NOT_IN_libc || defined IS_IN_libpthread
  20. # ifdef PROF
  21. # define PSEUDO_PROF \
  22. .set noat; \
  23. lda AT, _mcount; \
  24. jsr AT, (AT), _mcount; \
  25. .set at
  26. # else
  27. # define PSEUDO_PROF
  28. # endif
  29. /* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END
  30. besides "ret". */
  31. # undef PSEUDO
  32. # define PSEUDO(name, syscall_name, args) \
  33. .globl name; \
  34. .align 4; \
  35. .type name, @function; \
  36. .usepv name, std; \
  37. cfi_startproc; \
  38. __LABEL(name) \
  39. ldgp gp, 0(pv); \
  40. PSEUDO_PROF; \
  41. PSEUDO_PREPARE_ARGS \
  42. SINGLE_THREAD_P(t0); \
  43. bne t0, $pseudo_cancel; \
  44. lda v0, SYS_ify(syscall_name); \
  45. call_pal PAL_callsys; \
  46. bne a3, SYSCALL_ERROR_LABEL; \
  47. __LABEL($pseudo_ret) \
  48. .subsection 2; \
  49. __LABEL($pseudo_cancel) \
  50. subq sp, 64, sp; \
  51. cfi_def_cfa_offset(64); \
  52. stq ra, 0(sp); \
  53. cfi_offset(ra, -64); \
  54. SAVE_ARGS_##args; \
  55. CENABLE; \
  56. LOAD_ARGS_##args; \
  57. lda v0, SYS_ify(syscall_name); \
  58. call_pal PAL_callsys; \
  59. stq v0, 8(sp); \
  60. bne a3, $multi_error; \
  61. CDISABLE; \
  62. ldq ra, 0(sp); \
  63. ldq v0, 8(sp); \
  64. addq sp, 64, sp; \
  65. cfi_remember_state; \
  66. cfi_restore(ra); \
  67. cfi_def_cfa_offset(0); \
  68. ret; \
  69. cfi_restore_state; \
  70. __LABEL($multi_error) \
  71. CDISABLE; \
  72. ldq ra, 0(sp); \
  73. ldq v0, 8(sp); \
  74. addq sp, 64, sp; \
  75. cfi_restore(ra); \
  76. cfi_def_cfa_offset(0); \
  77. __LABEL($syscall_error) \
  78. SYSCALL_ERROR_HANDLER; \
  79. .previous
  80. # undef PSEUDO_END
  81. # define PSEUDO_END(sym) \
  82. .subsection 2; \
  83. cfi_endproc; \
  84. .size sym, .-sym
  85. # define SAVE_ARGS_0 /* Nothing. */
  86. # define SAVE_ARGS_1 SAVE_ARGS_0; stq a0, 8(sp)
  87. # define SAVE_ARGS_2 SAVE_ARGS_1; stq a1, 16(sp)
  88. # define SAVE_ARGS_3 SAVE_ARGS_2; stq a2, 24(sp)
  89. # define SAVE_ARGS_4 SAVE_ARGS_3; stq a3, 32(sp)
  90. # define SAVE_ARGS_5 SAVE_ARGS_4; stq a4, 40(sp)
  91. # define SAVE_ARGS_6 SAVE_ARGS_5; stq a5, 48(sp)
  92. # define LOAD_ARGS_0 /* Nothing. */
  93. # define LOAD_ARGS_1 LOAD_ARGS_0; ldq a0, 8(sp)
  94. # define LOAD_ARGS_2 LOAD_ARGS_1; ldq a1, 16(sp)
  95. # define LOAD_ARGS_3 LOAD_ARGS_2; ldq a2, 24(sp)
  96. # define LOAD_ARGS_4 LOAD_ARGS_3; ldq a3, 32(sp)
  97. # define LOAD_ARGS_5 LOAD_ARGS_4; ldq a4, 40(sp)
  98. # define LOAD_ARGS_6 LOAD_ARGS_5; ldq a5, 48(sp)
  99. # ifdef IS_IN_libpthread
  100. # define __local_enable_asynccancel __pthread_enable_asynccancel
  101. # define __local_disable_asynccancel __pthread_disable_asynccancel
  102. # define __local_multiple_threads __pthread_multiple_threads
  103. # else
  104. # define __local_enable_asynccancel __libc_enable_asynccancel
  105. # define __local_disable_asynccancel __libc_disable_asynccancel
  106. # define __local_multiple_threads __libc_multiple_threads
  107. # endif
  108. # ifdef PIC
  109. # define CENABLE bsr ra, __local_enable_asynccancel !samegp
  110. # define CDISABLE bsr ra, __local_disable_asynccancel !samegp
  111. # else
  112. # define CENABLE jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp)
  113. # define CDISABLE jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp)
  114. # endif
  115. # ifndef __ASSEMBLER__
  116. extern int __local_multiple_threads attribute_hidden;
  117. # define SINGLE_THREAD_P \
  118. __builtin_expect (__local_multiple_threads == 0, 1)
  119. # elif defined(PIC)
  120. # define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel
  121. # else
  122. # define SINGLE_THREAD_P(reg) \
  123. ldah reg, __local_multiple_threads(gp) !gprelhigh; \
  124. ldl reg, __local_multiple_threads(reg) !gprellow
  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