sysdep-cancel.h 3.3 KB

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