]> sourceware.org Git - glibc.git/blob - ports/sysdeps/unix/sysv/linux/alpha/nptl/sysdep-cancel.h
alpha: Fix all users of SYSCALL_ERROR_HANDLER
[glibc.git] / ports / sysdeps / unix / sysv / linux / alpha / nptl / sysdep-cancel.h
1 /* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18 #include <sysdep.h>
19 #include <tls.h>
20 #ifndef __ASSEMBLER__
21 # include <nptl/pthreadP.h>
22 #endif
23
24 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
25
26 /* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END
27 besides "ret". */
28
29 # undef PSEUDO
30 # define PSEUDO(name, syscall_name, args) \
31 .globl name; \
32 .align 4; \
33 .type name, @function; \
34 .usepv name, std; \
35 cfi_startproc; \
36 __LABEL(name) \
37 ldgp gp, 0(pv); \
38 PSEUDO_PROF; \
39 PSEUDO_PREPARE_ARGS \
40 SINGLE_THREAD_P(t0); \
41 bne t0, $pseudo_cancel; \
42 lda v0, SYS_ify(syscall_name); \
43 call_pal PAL_callsys; \
44 bne a3, SYSCALL_ERROR_LABEL; \
45 __LABEL($pseudo_ret) \
46 .subsection 2; \
47 cfi_startproc; \
48 __LABEL($pseudo_cancel) \
49 subq sp, 64, sp; \
50 cfi_def_cfa_offset(64); \
51 stq ra, 0(sp); \
52 cfi_offset(ra, -64); \
53 SAVE_ARGS_##args; \
54 CENABLE; \
55 LOAD_ARGS_##args; \
56 /* Save the CENABLE return value in RA. That register \
57 is preserved across syscall and the real return \
58 address is saved on the stack. */ \
59 mov v0, ra; \
60 lda v0, SYS_ify(syscall_name); \
61 call_pal PAL_callsys; \
62 stq v0, 8(sp); \
63 mov ra, a0; \
64 bne a3, $multi_error; \
65 CDISABLE; \
66 ldq ra, 0(sp); \
67 ldq v0, 8(sp); \
68 addq sp, 64, sp; \
69 cfi_remember_state; \
70 cfi_restore(ra); \
71 cfi_def_cfa_offset(0); \
72 ret; \
73 cfi_restore_state; \
74 __LABEL($multi_error) \
75 CDISABLE; \
76 ldq ra, 0(sp); \
77 ldq v0, 8(sp); \
78 addq sp, 64, sp; \
79 cfi_restore(ra); \
80 cfi_def_cfa_offset(0); \
81 SYSCALL_ERROR_FALLTHRU; \
82 SYSCALL_ERROR_HANDLER; \
83 cfi_endproc; \
84 .previous
85
86 # undef PSEUDO_END
87 # define PSEUDO_END(sym) \
88 cfi_endproc; \
89 .subsection 2; \
90 .size sym, .-sym
91
92 # define SAVE_ARGS_0 /* Nothing. */
93 # define SAVE_ARGS_1 SAVE_ARGS_0; stq a0, 8(sp)
94 # define SAVE_ARGS_2 SAVE_ARGS_1; stq a1, 16(sp)
95 # define SAVE_ARGS_3 SAVE_ARGS_2; stq a2, 24(sp)
96 # define SAVE_ARGS_4 SAVE_ARGS_3; stq a3, 32(sp)
97 # define SAVE_ARGS_5 SAVE_ARGS_4; stq a4, 40(sp)
98 # define SAVE_ARGS_6 SAVE_ARGS_5; stq a5, 48(sp)
99
100 # define LOAD_ARGS_0 /* Nothing. */
101 # define LOAD_ARGS_1 LOAD_ARGS_0; ldq a0, 8(sp)
102 # define LOAD_ARGS_2 LOAD_ARGS_1; ldq a1, 16(sp)
103 # define LOAD_ARGS_3 LOAD_ARGS_2; ldq a2, 24(sp)
104 # define LOAD_ARGS_4 LOAD_ARGS_3; ldq a3, 32(sp)
105 # define LOAD_ARGS_5 LOAD_ARGS_4; ldq a4, 40(sp)
106 # define LOAD_ARGS_6 LOAD_ARGS_5; ldq a5, 48(sp)
107
108 # ifdef IS_IN_libpthread
109 # define __local_enable_asynccancel __pthread_enable_asynccancel
110 # define __local_disable_asynccancel __pthread_disable_asynccancel
111 # define __local_multiple_threads __pthread_multiple_threads
112 # elif !defined NOT_IN_libc
113 # define __local_enable_asynccancel __libc_enable_asynccancel
114 # define __local_disable_asynccancel __libc_disable_asynccancel
115 # define __local_multiple_threads __libc_multiple_threads
116 # elif defined IS_IN_librt
117 # define __local_enable_asynccancel __librt_enable_asynccancel
118 # define __local_disable_asynccancel __librt_disable_asynccancel
119 # else
120 # error Unsupported library
121 # endif
122
123 # ifdef PIC
124 # define CENABLE bsr ra, __local_enable_asynccancel !samegp
125 # define CDISABLE bsr ra, __local_disable_asynccancel !samegp
126 # else
127 # define CENABLE jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp)
128 # define CDISABLE jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp)
129 # endif
130
131 # if defined IS_IN_libpthread || !defined NOT_IN_libc
132 # ifndef __ASSEMBLER__
133 extern int __local_multiple_threads attribute_hidden;
134 # define SINGLE_THREAD_P \
135 __builtin_expect (__local_multiple_threads == 0, 1)
136 # elif defined(PIC)
137 # define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel
138 # else
139 # define SINGLE_THREAD_P(reg) \
140 ldah reg, __local_multiple_threads(gp) !gprelhigh; \
141 ldl reg, __local_multiple_threads(reg) !gprellow
142 # endif
143 # else
144 # ifndef __ASSEMBLER__
145 # define SINGLE_THREAD_P \
146 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
147 header.multiple_threads) == 0, 1)
148 # else
149 # define SINGLE_THREAD_P(reg) \
150 call_pal PAL_rduniq; \
151 ldl reg, MULTIPLE_THREADS_OFFSET($0)
152 # endif
153 # endif
154
155 #else
156
157 # define SINGLE_THREAD_P (1)
158 # define NO_CANCELLATION 1
159
160 #endif
161
162 #ifndef __ASSEMBLER__
163 # define RTLD_SINGLE_THREAD_P \
164 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
165 header.multiple_threads) == 0, 1)
166 #endif
This page took 0.038916 seconds and 5 git commands to generate.