sysdep-cancel.h 3.4 KB

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