sysdep-cancel.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Jakub Jelinek <jakub@redhat.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. .text; \
  25. L(pseudo_cancel): \
  26. STM_##args \
  27. stmg %r13,%r15,104(%r15); \
  28. lgr %r14,%r15; \
  29. aghi %r15,-160; \
  30. stg %r14,0(%r15); \
  31. brasl %r14,CENABLE; \
  32. lgr %r0,%r2; \
  33. LM_##args \
  34. DO_CALL(syscall_name, args); \
  35. lgr %r13,%r2; \
  36. lgr %r2,%r0; \
  37. brasl %r14,CDISABLE; \
  38. lgr %r2,%r13; \
  39. lmg %r13,%r15,104+160(%r15); \
  40. j L(pseudo_check); \
  41. ENTRY(name) \
  42. SINGLE_THREAD_P \
  43. jne L(pseudo_cancel); \
  44. DO_CALL(syscall_name, args); \
  45. L(pseudo_check): \
  46. lghi %r4,-4095; \
  47. clgr %r2,%r4; \
  48. jgnl SYSCALL_ERROR_LABEL; \
  49. L(pseudo_end):
  50. # ifdef IS_IN_libpthread
  51. # define CENABLE __pthread_enable_asynccancel
  52. # define CDISABLE __pthread_disable_asynccancel
  53. # define __local_multiple_threads __pthread_multiple_threads
  54. # elif !defined NOT_IN_libc
  55. # define CENABLE __libc_enable_asynccancel
  56. # define CDISABLE __libc_disable_asynccancel
  57. # define __local_multiple_threads __libc_multiple_threads
  58. # else
  59. # define CENABLE __librt_enable_asynccancel@PLT
  60. # define CDISABLE __librt_disable_asynccancel@PLT
  61. # endif
  62. #define STM_0 /* Nothing */
  63. #define STM_1 stg %r2,16(%r15);
  64. #define STM_2 stmg %r2,%r3,16(%r15);
  65. #define STM_3 stmg %r2,%r4,16(%r15);
  66. #define STM_4 stmg %r2,%r5,16(%r15);
  67. #define STM_5 stmg %r2,%r5,16(%r15);
  68. #define LM_0 /* Nothing */
  69. #define LM_1 lg %r2,16+160(%r15);
  70. #define LM_2 lmg %r2,%r3,16+160(%r15);
  71. #define LM_3 lmg %r2,%r4,16+160(%r15);
  72. #define LM_4 lmg %r2,%r5,16+160(%r15);
  73. #define LM_5 lmg %r2,%r5,16+160(%r15);
  74. # if !defined NOT_IN_libc || defined IS_IN_libpthread
  75. # ifndef __ASSEMBLER__
  76. extern int __local_multiple_threads attribute_hidden;
  77. # define SINGLE_THREAD_P \
  78. __builtin_expect (__local_multiple_threads == 0, 1)
  79. # else
  80. # define SINGLE_THREAD_P \
  81. larl %r1,__local_multiple_threads; \
  82. icm %r0,15,0(%r1);
  83. # endif
  84. # else
  85. # ifndef __ASSEMBLER__
  86. # define SINGLE_THREAD_P \
  87. __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  88. p_header.data.multiple_threads) == 0, 1)
  89. # else
  90. # define SINGLE_THREAD_P \
  91. ear %r1,%a0; \
  92. sllg %r1,%r1,32; \
  93. ear %r1,%a1; \
  94. icm %r1,15,MULTIPLE_THREADS_OFFSET(%r1);
  95. # endif
  96. # endif
  97. #elif !defined __ASSEMBLER__
  98. /* This code should never be used but we define it anyhow. */
  99. # define SINGLE_THREAD_P (1)
  100. #endif