sysdep-cancel.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
  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 <tls.h>
  16. #include <sysdep.h>
  17. #ifndef __ASSEMBLER__
  18. # include <pthreadP.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. .text; \
  24. .globl __syscall_error; \
  25. ENTRY(name) \
  26. ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\
  27. cmp %g1, 0; \
  28. bne 1f; \
  29. .type __##syscall_name##_nocancel,@function; \
  30. .globl __##syscall_name##_nocancel; \
  31. __##syscall_name##_nocancel: \
  32. mov SYS_ify(syscall_name), %g1; \
  33. ta 0x10; \
  34. bcc 8f; \
  35. mov %o7, %g1; \
  36. call __syscall_error; \
  37. mov %g1, %o7; \
  38. 8: jmpl %o7 + 8, %g0; \
  39. nop; \
  40. .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
  41. 1: save %sp, -96, %sp; \
  42. cfi_def_cfa_register(%fp); \
  43. cfi_window_save; \
  44. cfi_register(%o7, %i7); \
  45. CENABLE; \
  46. nop; \
  47. mov %o0, %l0; \
  48. COPY_ARGS_##args \
  49. mov SYS_ify(syscall_name), %g1; \
  50. ta 0x10; \
  51. bcc 1f; \
  52. mov %o0, %l1; \
  53. CDISABLE; \
  54. mov %l0, %o0; \
  55. call __syscall_error; \
  56. mov %l1, %o0; \
  57. b 2f; \
  58. mov -1, %l1; \
  59. 1: CDISABLE; \
  60. mov %l0, %o0; \
  61. 2: jmpl %i7 + 8, %g0; \
  62. restore %g0, %l1, %o0;
  63. # ifdef IS_IN_libpthread
  64. # define CENABLE call __pthread_enable_asynccancel
  65. # define CDISABLE call __pthread_disable_asynccancel
  66. # elif !defined NOT_IN_libc
  67. # define CENABLE call __libc_enable_asynccancel
  68. # define CDISABLE call __libc_disable_asynccancel
  69. # elif defined IS_IN_librt
  70. # define CENABLE call __librt_enable_asynccancel
  71. # define CDISABLE call __librt_disable_asynccancel
  72. # else
  73. # error Unsupported library
  74. # endif
  75. #define COPY_ARGS_0 /* Nothing */
  76. #define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0;
  77. #define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1;
  78. #define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2;
  79. #define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3;
  80. #define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4;
  81. #define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5;
  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 ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
  88. # endif
  89. #elif !defined __ASSEMBLER__
  90. # define SINGLE_THREAD_P (1)
  91. # define NO_CANCELLATION 1
  92. #endif
  93. #ifndef __ASSEMBLER__
  94. # define RTLD_SINGLE_THREAD_P \
  95. __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  96. header.multiple_threads) == 0, 1)
  97. #endif