Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / unix / sysv / linux / ia64 / nptl / sysdep-cancel.h
blob5b08748949e951c83c950c28b9a529dc003ef38e
1 /* Copyright (C) 2002-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <sysdep.h>
20 #include <tls.h>
21 #ifndef __ASSEMBLER__
22 # include <nptl/pthreadP.h>
23 #endif
25 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
27 # undef PSEUDO
29 # ifndef NOT_IN_libc
30 # define SYSDEP_CANCEL_ERRNO __libc_errno
31 # else
32 # define SYSDEP_CANCEL_ERRNO errno
33 # endif
34 # define SYSDEP_CANCEL_ERROR(args) \
35 .section .gnu.linkonce.t.__syscall_error_##args, "ax"; \
36 .align 32; \
37 .proc __syscall_error_##args; \
38 .global __syscall_error_##args; \
39 .hidden __syscall_error_##args; \
40 .size __syscall_error_##args, 64; \
41 __syscall_error_##args: \
42 .prologue; \
43 .regstk args, 5, args, 0; \
44 .save ar.pfs, loc0; \
45 .save rp, loc1; \
46 .body; \
47 addl loc4 = @ltoff(@tprel(SYSDEP_CANCEL_ERRNO)), gp;; \
48 ld8 loc4 = [loc4]; \
49 mov rp = loc1;; \
50 mov r8 = -1; \
51 add loc4 = loc4, r13;; \
52 st4 [loc4] = loc3; \
53 mov ar.pfs = loc0
55 # ifndef USE_DL_SYSINFO
57 # define PSEUDO(name, syscall_name, args) \
58 .text; \
59 ENTRY (name) \
60 adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \
61 ld4 r14 = [r14]; \
62 mov r15 = SYS_ify(syscall_name);; \
63 cmp4.ne p6, p7 = 0, r14; \
64 (p6) br.cond.spnt .Lpseudo_cancel;; \
65 break __BREAK_SYSCALL;; \
66 cmp.eq p6,p0=-1,r10; \
67 (p6) br.cond.spnt.few __syscall_error; \
68 ret;; \
69 .endp name; \
70 .proc __GC_##name; \
71 .globl __GC_##name; \
72 .hidden __GC_##name; \
73 __GC_##name: \
74 .Lpseudo_cancel: \
75 .prologue; \
76 .regstk args, 5, args, 0; \
77 .save ar.pfs, loc0; \
78 alloc loc0 = ar.pfs, args, 5, args, 0; \
79 .save rp, loc1; \
80 mov loc1 = rp;; \
81 .body; \
82 CENABLE;; \
83 mov loc2 = r8; \
84 COPY_ARGS_##args \
85 mov r15 = SYS_ify(syscall_name); \
86 break __BREAK_SYSCALL;; \
87 mov loc3 = r8; \
88 mov loc4 = r10; \
89 mov out0 = loc2; \
90 CDISABLE;; \
91 cmp.eq p6,p0=-1,loc4; \
92 (p6) br.cond.spnt.few __syscall_error_##args; \
93 mov r8 = loc3; \
94 mov rp = loc1; \
95 mov ar.pfs = loc0; \
96 .Lpseudo_end: \
97 ret; \
98 .endp __GC_##name; \
99 SYSDEP_CANCEL_ERROR(args)
101 # else /* USE_DL_SYSINFO */
103 # define PSEUDO(name, syscall_name, args) \
104 .text; \
105 ENTRY (name) \
106 .prologue; \
107 adds r2 = SYSINFO_OFFSET, r13; \
108 adds r14 = MULTIPLE_THREADS_OFFSET, r13; \
109 .save ar.pfs, r11; \
110 mov r11 = ar.pfs;; \
111 .body; \
112 ld4 r14 = [r14]; \
113 ld8 r2 = [r2]; \
114 mov r15 = SYS_ify(syscall_name);; \
115 cmp4.ne p6, p7 = 0, r14; \
116 mov b7 = r2; \
117 (p6) br.cond.spnt .Lpseudo_cancel; \
118 br.call.sptk.many b6 = b7;; \
119 mov ar.pfs = r11; \
120 cmp.eq p6,p0 = -1, r10; \
121 (p6) br.cond.spnt.few __syscall_error; \
122 ret;; \
123 .endp name; \
124 .proc __GC_##name; \
125 .globl __GC_##name; \
126 .hidden __GC_##name; \
127 __GC_##name: \
128 .Lpseudo_cancel: \
129 .prologue; \
130 .regstk args, 5, args, 0; \
131 .save ar.pfs, loc0; \
132 alloc loc0 = ar.pfs, args, 5, args, 0; \
133 adds loc4 = SYSINFO_OFFSET, r13; \
134 .save rp, loc1; \
135 mov loc1 = rp;; \
136 .body; \
137 ld8 loc4 = [loc4]; \
138 CENABLE;; \
139 mov loc2 = r8; \
140 mov b7 = loc4; \
141 COPY_ARGS_##args \
142 mov r15 = SYS_ify(syscall_name); \
143 br.call.sptk.many b6 = b7;; \
144 mov loc3 = r8; \
145 mov loc4 = r10; \
146 mov out0 = loc2; \
147 CDISABLE;; \
148 cmp.eq p6,p0=-1,loc4; \
149 (p6) br.cond.spnt.few __syscall_error_##args; \
150 mov r8 = loc3; \
151 mov rp = loc1; \
152 mov ar.pfs = loc0; \
153 .Lpseudo_end: \
154 ret; \
155 .endp __GC_##name; \
156 SYSDEP_CANCEL_ERROR(args)
158 # endif /* USE_DL_SYSINFO */
160 # undef PSEUDO_END
161 # define PSEUDO_END(name) .endp
163 # ifdef IS_IN_libpthread
164 # define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel
165 # define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel
166 # elif !defined NOT_IN_libc
167 # define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel
168 # define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel
169 # elif defined IS_IN_librt
170 # define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel
171 # define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel
172 # else
173 # error Unsupported library
174 # endif
176 # define COPY_ARGS_0 /* Nothing */
177 # define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0;
178 # define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1;
179 # define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2;
180 # define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3;
181 # define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4;
182 # define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5;
183 # define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6;
185 # ifndef __ASSEMBLER__
186 # define SINGLE_THREAD_P \
187 __builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1)
188 # else
189 # define SINGLE_THREAD_P \
190 adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
191 # endif
193 #elif !defined __ASSEMBLER__
195 # define SINGLE_THREAD_P (1)
196 # define NO_CANCELLATION 1
198 #endif
200 #ifndef __ASSEMBLER__
201 # define RTLD_SINGLE_THREAD_P \
202 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
203 header.multiple_threads) == 0, 1)
204 #endif