sysdep-cancel.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Cancellable system call stubs. Linux/PowerPC version.
  2. Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <sysdep.h>
  17. #include <tls.h>
  18. #ifndef __ASSEMBLER__
  19. # include <pthreadP.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. .type __##syscall_name##_nocancel,@function; \
  29. .globl __##syscall_name##_nocancel; \
  30. __##syscall_name##_nocancel: \
  31. DO_CALL (SYS_ify (syscall_name)); \
  32. PSEUDO_RET; \
  33. .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
  34. .Lpseudo_cancel: \
  35. stwu 1,-48(1); \
  36. cfi_adjust_cfa_offset (48); \
  37. mflr 9; \
  38. stw 9,52(1); \
  39. cfi_offset (lr, 4); \
  40. DOCARGS_##args; /* save syscall args around CENABLE. */ \
  41. CENABLE; \
  42. stw 3,16(1); /* store CENABLE return value (MASK). */ \
  43. UNDOCARGS_##args; /* restore syscall args. */ \
  44. DO_CALL (SYS_ify (syscall_name)); \
  45. mfcr 0; /* save CR/R3 around CDISABLE. */ \
  46. stw 3,8(1); \
  47. stw 0,12(1); \
  48. lwz 3,16(1); /* pass MASK to CDISABLE. */ \
  49. CDISABLE; \
  50. lwz 4,52(1); \
  51. lwz 0,12(1); /* restore CR/R3. */ \
  52. lwz 3,8(1); \
  53. mtlr 4; \
  54. mtcr 0; \
  55. addi 1,1,48;
  56. # define DOCARGS_0
  57. # define UNDOCARGS_0
  58. # define DOCARGS_1 stw 3,20(1); DOCARGS_0
  59. # define UNDOCARGS_1 lwz 3,20(1); UNDOCARGS_0
  60. # define DOCARGS_2 stw 4,24(1); DOCARGS_1
  61. # define UNDOCARGS_2 lwz 4,24(1); UNDOCARGS_1
  62. # define DOCARGS_3 stw 5,28(1); DOCARGS_2
  63. # define UNDOCARGS_3 lwz 5,28(1); UNDOCARGS_2
  64. # define DOCARGS_4 stw 6,32(1); DOCARGS_3
  65. # define UNDOCARGS_4 lwz 6,32(1); UNDOCARGS_3
  66. # define DOCARGS_5 stw 7,36(1); DOCARGS_4
  67. # define UNDOCARGS_5 lwz 7,36(1); UNDOCARGS_4
  68. # define DOCARGS_6 stw 8,40(1); DOCARGS_5
  69. # define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5
  70. # ifdef IS_IN_libpthread
  71. # define CENABLE bl __pthread_enable_asynccancel@local
  72. # define CDISABLE bl __pthread_disable_asynccancel@local
  73. # elif !defined NOT_IN_libc
  74. # define CENABLE bl __libc_enable_asynccancel@local
  75. # define CDISABLE bl __libc_disable_asynccancel@local
  76. # elif defined IS_IN_librt
  77. # define CENABLE bl __librt_enable_asynccancel@local
  78. # define CDISABLE bl __librt_disable_asynccancel@local
  79. # else
  80. # error Unsupported library
  81. # endif
  82. # ifndef __ASSEMBLER__
  83. # define SINGLE_THREAD_P \
  84. __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  85. header.multiple_threads) == 0, 1)
  86. # else
  87. # define SINGLE_THREAD_P \
  88. lwz 10,MULTIPLE_THREADS_OFFSET(2); \
  89. cmpwi 10,0
  90. # endif
  91. #elif !defined __ASSEMBLER__
  92. # define SINGLE_THREAD_P (1)
  93. # define NO_CANCELLATION 1
  94. #endif
  95. #ifndef __ASSEMBLER__
  96. # define RTLD_SINGLE_THREAD_P \
  97. __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  98. header.multiple_threads) == 0, 1)
  99. #endif