sysdep-cancel.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Copyright (C) 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
  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. # undef PSEUDO
  22. # define PSEUDO(name, syscall_name, args) \
  23. .section ".text"; \
  24. ENTRY (name) \
  25. SINGLE_THREAD_P; \
  26. bne- .Lpseudo_cancel; \
  27. DO_CALL (SYS_ify (syscall_name)); \
  28. PSEUDO_RET; \
  29. .Lpseudo_cancel: \
  30. stdu 1,-128(1); \
  31. mflr 9; \
  32. std 9,128+16(1); \
  33. DOCARGS_##args; /* save syscall args around CENABLE. */ \
  34. CENABLE; \
  35. std 3,72(1); /* store CENABLE return value (MASK). */ \
  36. UNDOCARGS_##args; /* restore syscall args. */ \
  37. DO_CALL (SYS_ify (syscall_name)); \
  38. mfcr 0; /* save CR/R3 around CDISABLE. */ \
  39. std 3,64(1); \
  40. std 0,8(1); \
  41. ld 3,72(1); /* pass MASK to CDISABLE. */ \
  42. CDISABLE; \
  43. ld 9,128+16(1); \
  44. ld 0,8(1); /* restore CR/R3. */ \
  45. ld 3,64(1); \
  46. mtlr 9; \
  47. mtcr 0; \
  48. addi 1,1,128;
  49. # define DOCARGS_0
  50. # define UNDOCARGS_0
  51. # define DOCARGS_1 std 3,80(1); DOCARGS_0
  52. # define UNDOCARGS_1 ld 3,80(1); UNDOCARGS_0
  53. # define DOCARGS_2 std 4,88(1); DOCARGS_1
  54. # define UNDOCARGS_2 ld 4,88(1); UNDOCARGS_1
  55. # define DOCARGS_3 std 5,96(1); DOCARGS_2
  56. # define UNDOCARGS_3 ld 5,96(1); UNDOCARGS_2
  57. # define DOCARGS_4 std 6,104(1); DOCARGS_3
  58. # define UNDOCARGS_4 ld 6,104(1); UNDOCARGS_3
  59. # define DOCARGS_5 std 7,112(1); DOCARGS_4
  60. # define UNDOCARGS_5 ld 7,112(1); UNDOCARGS_4
  61. # define DOCARGS_6 std 8,120(1); DOCARGS_5
  62. # define UNDOCARGS_6 ld 8,120(1); UNDOCARGS_5
  63. # ifdef IS_IN_libpthread
  64. # define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel)
  65. # define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel)
  66. # define __local_multiple_threads __pthread_multiple_threads
  67. # elif !defined NOT_IN_libc
  68. # define CENABLE bl JUMPTARGET(__libc_enable_asynccancel)
  69. # define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel)
  70. # define __local_multiple_threads __libc_multiple_threads
  71. # else
  72. # define CENABLE bl JUMPTARGET(__librt_enable_asynccancel); nop
  73. # define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel); nop
  74. # define __local_multiple_threads __librt_multiple_threads
  75. # endif
  76. # ifdef HAVE_TLS_SUPPORT
  77. # ifndef __ASSEMBLER__
  78. # define SINGLE_THREAD_P \
  79. __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
  80. # else
  81. # define SINGLE_THREAD_P \
  82. lwz 10,MULTIPLE_THREADS_OFFSET(13); \
  83. cmpwi 10,0
  84. # endif
  85. # else /* !HAVE_TLS_SUPPORT */
  86. # ifndef __ASSEMBLER__
  87. extern int __local_multiple_threads
  88. # if !defined NOT_IN_libc || defined IS_IN_libpthread
  89. attribute_hidden;
  90. # else
  91. ;
  92. # endif
  93. # define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
  94. # else
  95. # define SINGLE_THREAD_P \
  96. .section ".toc","aw"; \
  97. .LC__local_multiple_threads:; \
  98. .tc __local_multiple_threads[TC],__local_multiple_threads; \
  99. .previous; \
  100. ld 10,.LC__local_multiple_threads@toc(2); \
  101. lwz 10,0(10); \
  102. cmpwi 10,0
  103. # endif
  104. # endif
  105. #elif !defined __ASSEMBLER__
  106. /* This code should never be used but we define it anyhow. */
  107. # define SINGLE_THREAD_P (1)
  108. #endif