]>
Commit | Line | Data |
---|---|---|
d063d164 | 1 | /* Copyright (C) 2002, 2003, 2004, 2006, 2011 Free Software Foundation, Inc. |
b33e6163 RM |
2 | This file is part of the GNU C Library. |
3 | Contributed by Jakub Jelinek <jakub@redhat.com>, 2002. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
19 | ||
20 | #include <sysdep.h> | |
21 | #include <tls.h> | |
22 | #ifndef __ASSEMBLER__ | |
23 | # include <nptl/pthreadP.h> | |
24 | #endif | |
25 | ||
7a114794 | 26 | #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt |
b33e6163 RM |
27 | |
28 | # undef PSEUDO | |
c776b3d7 | 29 | |
d063d164 UD |
30 | # ifndef NOT_IN_libc |
31 | # define SYSDEP_CANCEL_ERRNO __libc_errno | |
32 | # else | |
33 | # define SYSDEP_CANCEL_ERRNO errno | |
34 | # endif | |
35 | # define SYSDEP_CANCEL_ERROR(args) \ | |
27b02589 UD |
36 | .section .gnu.linkonce.t.__syscall_error_##args, "ax"; \ |
37 | .align 32; \ | |
38 | .proc __syscall_error_##args; \ | |
39 | .global __syscall_error_##args; \ | |
40 | .hidden __syscall_error_##args; \ | |
41 | .size __syscall_error_##args, 64; \ | |
42 | __syscall_error_##args: \ | |
43 | .prologue; \ | |
44 | .regstk args, 5, args, 0; \ | |
45 | .save ar.pfs, loc0; \ | |
46 | .save rp, loc1; \ | |
47 | .body; \ | |
48 | addl loc4 = @ltoff(@tprel(SYSDEP_CANCEL_ERRNO)), gp;; \ | |
49 | ld8 loc4 = [loc4]; \ | |
50 | mov rp = loc1;; \ | |
51 | mov r8 = -1; \ | |
52 | add loc4 = loc4, r13;; \ | |
53 | st4 [loc4] = loc3; \ | |
54 | mov ar.pfs = loc0 | |
c776b3d7 | 55 | |
27b02589 UD |
56 | # ifndef USE_DL_SYSINFO |
57 | ||
58 | # define PSEUDO(name, syscall_name, args) \ | |
b33e6163 RM |
59 | .text; \ |
60 | ENTRY (name) \ | |
61 | adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \ | |
62 | ld4 r14 = [r14]; \ | |
63 | mov r15 = SYS_ify(syscall_name);; \ | |
64 | cmp4.ne p6, p7 = 0, r14; \ | |
65 | (p6) br.cond.spnt .Lpseudo_cancel;; \ | |
66 | break __BREAK_SYSCALL;; \ | |
67 | cmp.eq p6,p0=-1,r10; \ | |
68 | (p6) br.cond.spnt.few __syscall_error; \ | |
69 | ret;; \ | |
57a5ea02 UD |
70 | .endp name; \ |
71 | .proc __GC_##name; \ | |
72 | .globl __GC_##name; \ | |
73 | .hidden __GC_##name; \ | |
74 | __GC_##name: \ | |
b33e6163 RM |
75 | .Lpseudo_cancel: \ |
76 | .prologue; \ | |
77 | .regstk args, 5, args, 0; \ | |
78 | .save ar.pfs, loc0; \ | |
79 | alloc loc0 = ar.pfs, args, 5, args, 0; \ | |
80 | .save rp, loc1; \ | |
81 | mov loc1 = rp;; \ | |
82 | .body; \ | |
83 | CENABLE;; \ | |
84 | mov loc2 = r8; \ | |
85 | COPY_ARGS_##args \ | |
86 | mov r15 = SYS_ify(syscall_name); \ | |
87 | break __BREAK_SYSCALL;; \ | |
88 | mov loc3 = r8; \ | |
89 | mov loc4 = r10; \ | |
90 | mov out0 = loc2; \ | |
91 | CDISABLE;; \ | |
92 | cmp.eq p6,p0=-1,loc4; \ | |
93 | (p6) br.cond.spnt.few __syscall_error_##args; \ | |
94 | mov r8 = loc3; \ | |
95 | mov rp = loc1; \ | |
96 | mov ar.pfs = loc0; \ | |
97 | .Lpseudo_end: \ | |
98 | ret; \ | |
57a5ea02 | 99 | .endp __GC_##name; \ |
27b02589 | 100 | SYSDEP_CANCEL_ERROR(args) |
b33e6163 | 101 | |
27b02589 | 102 | # else /* USE_DL_SYSINFO */ |
c776b3d7 | 103 | |
27b02589 | 104 | # define PSEUDO(name, syscall_name, args) \ |
c776b3d7 UD |
105 | .text; \ |
106 | ENTRY (name) \ | |
107 | .prologue; \ | |
108 | adds r2 = SYSINFO_OFFSET, r13; \ | |
109 | adds r14 = MULTIPLE_THREADS_OFFSET, r13; \ | |
110 | .save ar.pfs, r11; \ | |
111 | mov r11 = ar.pfs;; \ | |
112 | .body; \ | |
113 | ld4 r14 = [r14]; \ | |
114 | ld8 r2 = [r2]; \ | |
115 | mov r15 = SYS_ify(syscall_name);; \ | |
116 | cmp4.ne p6, p7 = 0, r14; \ | |
117 | mov b7 = r2; \ | |
118 | (p6) br.cond.spnt .Lpseudo_cancel; \ | |
119 | br.call.sptk.many b6 = b7;; \ | |
120 | mov ar.pfs = r11; \ | |
121 | cmp.eq p6,p0 = -1, r10; \ | |
122 | (p6) br.cond.spnt.few __syscall_error; \ | |
123 | ret;; \ | |
124 | .endp name; \ | |
125 | .proc __GC_##name; \ | |
126 | .globl __GC_##name; \ | |
127 | .hidden __GC_##name; \ | |
128 | __GC_##name: \ | |
129 | .Lpseudo_cancel: \ | |
130 | .prologue; \ | |
131 | .regstk args, 5, args, 0; \ | |
132 | .save ar.pfs, loc0; \ | |
133 | alloc loc0 = ar.pfs, args, 5, args, 0; \ | |
134 | adds loc4 = SYSINFO_OFFSET, r13; \ | |
135 | .save rp, loc1; \ | |
136 | mov loc1 = rp;; \ | |
137 | .body; \ | |
138 | ld8 loc4 = [loc4]; \ | |
139 | CENABLE;; \ | |
140 | mov loc2 = r8; \ | |
141 | mov b7 = loc4; \ | |
142 | COPY_ARGS_##args \ | |
143 | mov r15 = SYS_ify(syscall_name); \ | |
144 | br.call.sptk.many b6 = b7;; \ | |
145 | mov loc3 = r8; \ | |
146 | mov loc4 = r10; \ | |
147 | mov out0 = loc2; \ | |
148 | CDISABLE;; \ | |
149 | cmp.eq p6,p0=-1,loc4; \ | |
150 | (p6) br.cond.spnt.few __syscall_error_##args; \ | |
151 | mov r8 = loc3; \ | |
152 | mov rp = loc1; \ | |
153 | mov ar.pfs = loc0; \ | |
154 | .Lpseudo_end: \ | |
155 | ret; \ | |
156 | .endp __GC_##name; \ | |
27b02589 | 157 | SYSDEP_CANCEL_ERROR(args) |
c776b3d7 | 158 | |
27b02589 | 159 | # endif /* USE_DL_SYSINFO */ |
c776b3d7 | 160 | |
27b02589 UD |
161 | # undef PSEUDO_END |
162 | # define PSEUDO_END(name) .endp | |
57a5ea02 | 163 | |
b33e6163 RM |
164 | # ifdef IS_IN_libpthread |
165 | # define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel | |
166 | # define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel | |
bbde8527 | 167 | # elif !defined NOT_IN_libc |
b33e6163 RM |
168 | # define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel |
169 | # define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel | |
bbde8527 UD |
170 | # elif defined IS_IN_librt |
171 | # define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel | |
172 | # define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel | |
173 | # else | |
174 | # error Unsupported library | |
b33e6163 RM |
175 | # endif |
176 | ||
27b02589 UD |
177 | # define COPY_ARGS_0 /* Nothing */ |
178 | # define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0; | |
179 | # define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1; | |
180 | # define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2; | |
181 | # define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3; | |
182 | # define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4; | |
183 | # define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5; | |
184 | # define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6; | |
b33e6163 RM |
185 | |
186 | # ifndef __ASSEMBLER__ | |
187 | # define SINGLE_THREAD_P \ | |
468777e1 | 188 | __builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1) |
b33e6163 RM |
189 | # else |
190 | # define SINGLE_THREAD_P \ | |
191 | adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14 | |
192 | # endif | |
193 | ||
194 | #elif !defined __ASSEMBLER__ | |
195 | ||
6e627806 | 196 | # define SINGLE_THREAD_P (1) |
ce6e047f | 197 | # define NO_CANCELLATION 1 |
b33e6163 RM |
198 | |
199 | #endif | |
6e627806 UD |
200 | |
201 | #ifndef __ASSEMBLER__ | |
202 | # define RTLD_SINGLE_THREAD_P \ | |
203 | __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ | |
204 | header.multiple_threads) == 0, 1) | |
205 | #endif |