sysdep-cancel.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 <sysdep.h>
  16. #include <tls.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. brnz,pn %g1, 1f; \
  28. .type __##syscall_name##_nocancel,@function; \
  29. .globl __##syscall_name##_nocancel; \
  30. __##syscall_name##_nocancel: \
  31. mov SYS_ify(syscall_name), %g1; \
  32. ta 0x6d; \
  33. bcc,pt %xcc, 8f; \
  34. mov %o7, %g1; \
  35. call __syscall_error; \
  36. mov %g1, %o7; \
  37. 8: jmpl %o7 + 8, %g0; \
  38. nop; \
  39. .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
  40. 1: save %sp, -192, %sp; \
  41. cfi_def_cfa_register(%fp); \
  42. cfi_window_save; \
  43. cfi_register(%o7, %i7); \
  44. CENABLE; \
  45. nop; \
  46. mov %o0, %l0; \
  47. COPY_ARGS_##args \
  48. mov SYS_ify(syscall_name), %g1; \
  49. ta 0x6d; \
  50. bcc,pt %xcc, 1f; \
  51. mov %o0, %l1; \
  52. CDISABLE; \
  53. mov %l0, %o0; \
  54. call __syscall_error; \
  55. mov %l1, %o0; \
  56. ba,pt %xcc, 2f; \
  57. mov -1, %l1; \
  58. 1: CDISABLE; \
  59. mov %l0, %o0; \
  60. 2: jmpl %i7 + 8, %g0; \
  61. restore %g0, %l1, %o0;
  62. # ifdef IS_IN_libpthread
  63. # define CENABLE call __pthread_enable_asynccancel
  64. # define CDISABLE call __pthread_disable_asynccancel
  65. # elif !defined NOT_IN_libc
  66. # define CENABLE call __libc_enable_asynccancel
  67. # define CDISABLE call __libc_disable_asynccancel
  68. # elif defined IS_IN_librt
  69. # define CENABLE call __librt_enable_asynccancel
  70. # define CDISABLE call __librt_disable_asynccancel
  71. # else
  72. # error Unsupported library
  73. # endif
  74. #define COPY_ARGS_0 /* Nothing */
  75. #define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0;
  76. #define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1;
  77. #define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2;
  78. #define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3;
  79. #define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4;
  80. #define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5;
  81. # ifndef __ASSEMBLER__
  82. # define SINGLE_THREAD_P \
  83. __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  84. header.multiple_threads) == 0, 1)
  85. # else
  86. # define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
  87. # endif
  88. #elif !defined __ASSEMBLER__
  89. # define SINGLE_THREAD_P (1)
  90. # define NO_CANCELLATION 1
  91. #endif
  92. #ifndef __ASSEMBLER__
  93. # define RTLD_SINGLE_THREAD_P \
  94. __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  95. header.multiple_threads) == 0, 1)
  96. #endif