sysdep-cancel.h 4.1 KB

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