sysdep-cancel.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Andreas Schwab <schwab@suse.de>, 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 <sysdep.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. SINGLE_THREAD_P; \
  26. jne .Lpseudo_cancel; \
  27. DO_CALL (syscall_name, args); \
  28. cmp.l &-4095, %d0; \
  29. jcc SYSCALL_ERROR_LABEL; \
  30. rts; \
  31. .Lpseudo_cancel: \
  32. CENABLE; \
  33. DOCARGS_##args \
  34. move.l %d0, -(%sp); \
  35. move.l &SYS_ify (syscall_name), %d0; \
  36. trap &0; \
  37. move.l %d0, %d2; \
  38. CDISABLE; \
  39. addq.l &4, %sp; \
  40. move.l %d2, %d0; \
  41. UNDOCARGS_##args \
  42. cmp.l &-4095, %d0; \
  43. jcc SYSCALL_ERROR_LABEL
  44. # define DOCARGS_0 move.l %d2, -(%sp);
  45. # define _DOCARGS_0(n)
  46. # define UNDOCARGS_0 move.l (%sp)+, %d2;
  47. # define DOCARGS_1 _DOCARGS_1 (4); DOCARGS_0
  48. # define _DOCARGS_1(n) move.l n(%sp), %d1; _DOARGS_0 (n)
  49. # define UNDOCARGS_1 UNDOCARGS_0
  50. # define DOCARGS_2 _DOCARGS_2 (8)
  51. # define _DOCARGS_2(n) move.l %d2, -(%sp); move.l n+4(%sp), %d2; \
  52. _DOCARGS_1 (n)
  53. # define UNDOCARGS_2 UNDOCARGS_1
  54. # define DOCARGS_3 _DOCARGS_3 (12)
  55. # define _DOCARGS_3(n) move.l %d3, -(%sp); move.l n+4(%sp), %d3; \
  56. _DOCARGS_2 (n)
  57. # define UNDOCARGS_3 UNDOCARGS_2; move.l (%sp)+, %d3;
  58. # define DOCARGS_4 _DOCARGS_4 (16)
  59. # define _DOCARGS_4(n) move.l %d4, -(%sp); move.l n+4(%sp), %d4; \
  60. _DOCARGS_3 (n)
  61. # define UNDOCARGS_4 UNDOCARGS_3; move.l (%sp)+, %d4;
  62. # define DOCARGS_5 _DOCARGS_5 (20)
  63. # define _DOCARGS_5(n) move.l %d5, -(%sp); move.l n+4(%sp), %d5; \
  64. _DOCARGS_4 (n)
  65. # define UNDOCARGS_5 UNDOCARGS_4; move.l (%sp)+, %d5;
  66. # ifdef IS_IN_libpthread
  67. # ifdef PIC
  68. # define CENABLE jbsr __pthread_enable_asynccancel@PLTPC
  69. # define CDISABLE jbsr __pthread_disable_asynccancel@PLTPC
  70. # else
  71. # define CENABLE jbsr __pthread_enable_asynccancel
  72. # define CDISABLE jbsr __pthread_disable_asynccancel
  73. # endif
  74. # elif !defined NOT_IN_libc
  75. # ifdef PIC
  76. # define CENABLE jbsr __libc_enable_asynccancel@PLTPC
  77. # define CDISABLE jbsr __libc_disable_asynccancel@PLTPC
  78. # else
  79. # define CENABLE jbsr __libc_enable_asynccancel
  80. # define CDISABLE jbsr __libc_disable_asynccancel
  81. # endif
  82. # else
  83. # ifdef PIC
  84. # define CENABLE jbsr __librt_enable_asynccancel@PLTPC
  85. # define CDISABLE jbsr __librt_disable_asynccancel@PLTPC
  86. # else
  87. # define CENABLE jbsr __librt_enable_asynccancel
  88. # define CDISABLE jbsr __librt_disable_asynccancel
  89. # endif
  90. # endif
  91. # if !defined NOT_IN_libc
  92. # define __local_multiple_threads __libc_multiple_threads
  93. # elif defined IS_IN_libpthread
  94. # define __local_multiple_threads __pthread_multiple_threads
  95. # else
  96. # define __local_multiple_threads __librt_multiple_threads
  97. # endif
  98. # ifndef __ASSEMBLER__
  99. extern int __local_multiple_threads attribute_hidden;
  100. # define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
  101. # else
  102. # if !defined PIC
  103. # define SINGLE_THREAD_P tst.l __local_multiple_threads
  104. # else
  105. # define SINGLE_THREAD_P tst.l (__local_multiple_threads, %pc)
  106. # endif
  107. # endif
  108. #elif !defined __ASSEMBLER__
  109. /* This code should never be used but we define it anyhow. */
  110. # define SINGLE_THREAD_P (1)
  111. #endif