sysdep-cancel.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Copyright (C) 2002, 2003, 2004 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. #ifndef __ASSEMBLER__
  17. # include <linuxthreads/internals.h>
  18. #endif
  19. #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
  20. # undef PSEUDO
  21. # define PSEUDO(name, syscall_name, args) \
  22. .text; \
  23. ENTRY(name) \
  24. ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1; \
  25. cmp %g1, 0; \
  26. bne 1f; \
  27. mov SYS_ify(syscall_name), %g1; \
  28. ta 0x10; \
  29. bcs __syscall_error_handler; \
  30. nop; \
  31. .subsection 2; \
  32. 1: save %sp, -96, %sp; \
  33. CENABLE; \
  34. nop; \
  35. mov %o0, %l0; \
  36. COPY_ARGS_##args \
  37. mov SYS_ify(syscall_name), %g1; \
  38. ta 0x10; \
  39. bcs __syscall_error_handler2; \
  40. mov %o0, %l1; \
  41. CDISABLE; \
  42. mov %l0, %o0; \
  43. jmpl %i7 + 8, %g0; \
  44. restore %g0, %l1, %o0; \
  45. .previous; \
  46. SYSCALL_ERROR_HANDLER \
  47. SYSCALL_ERROR_HANDLER2
  48. #define SYSCALL_ERROR_HANDLER2 \
  49. SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
  50. .global __errno_location; \
  51. .type __errno_location,@function; \
  52. CDISABLE; \
  53. mov %l0, %o0; \
  54. call __errno_location; \
  55. nop; \
  56. st %l1, [%o0]; \
  57. jmpl %i7 + 8, %g0; \
  58. restore %g0, -1, %o0; \
  59. .previous;
  60. # ifdef IS_IN_libpthread
  61. # define CENABLE call __pthread_enable_asynccancel
  62. # define CDISABLE call __pthread_disable_asynccancel
  63. # elif !defined NOT_IN_libc
  64. # define CENABLE call __libc_enable_asynccancel
  65. # define CDISABLE call __libc_disable_asynccancel
  66. # else
  67. # define CENABLE call __librt_enable_asynccancel
  68. # define CDISABLE call __librt_disable_asynccancel
  69. # endif
  70. #define COPY_ARGS_0 /* Nothing */
  71. #define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0;
  72. #define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1;
  73. #define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2;
  74. #define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3;
  75. #define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4;
  76. #define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5;
  77. # ifndef __ASSEMBLER__
  78. # define SINGLE_THREAD_P \
  79. __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
  80. p_header.data.multiple_threads) == 0, 1)
  81. # else
  82. # define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
  83. # endif
  84. #elif !defined __ASSEMBLER__
  85. /* This code should never be used but we define it anyhow. */
  86. # define SINGLE_THREAD_P (1)
  87. #endif