(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / nptl / sysdeps / unix / sysv / linux / sh / sysdep-cancel.h
blobfc3c2340b6055d6320205d9427363906ebffa082
1 /* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
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 # define _IMM12 #-12
28 # define _IMM16 #-16
29 # define _IMP16 #16
30 # undef PSEUDO
31 # define PSEUDO(name, syscall_name, args) \
32 .text; \
33 ENTRY (name); \
34 .Lpseudo_start: \
35 SINGLE_THREAD_P; \
36 bf .Lpseudo_cancel; \
37 .type __##syscall_name##_nocancel,@function; \
38 .globl __##syscall_name##_nocancel; \
39 __##syscall_name##_nocancel: \
40 DO_CALL (syscall_name, args); \
41 mov r0,r1; \
42 mov _IMM12,r2; \
43 shad r2,r1; \
44 not r1,r1; \
45 tst r1,r1; \
46 bt .Lsyscall_error; \
47 bra .Lpseudo_end; \
48 nop; \
49 .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
50 .Lpseudo_cancel: \
51 sts.l pr,@-r15; \
52 .LCFI0: \
53 add _IMM16,r15; \
54 SAVE_ARGS_##args; \
55 .LCFI1: \
56 CENABLE; \
57 LOAD_ARGS_##args; \
58 add _IMP16,r15; \
59 .LCFI2: \
60 lds.l @r15+,pr; \
61 .LCFI3: \
62 DO_CALL(syscall_name, args); \
63 SYSCALL_INST_PAD; \
64 sts.l pr,@-r15; \
65 .LCFI4: \
66 mov.l r0,@-r15; \
67 .LCFI5: \
68 CDISABLE; \
69 mov.l @r15+,r0; \
70 .LCFI6: \
71 lds.l @r15+,pr; \
72 .LCFI7: \
73 mov r0,r1; \
74 mov _IMM12,r2; \
75 shad r2,r1; \
76 not r1,r1; \
77 tst r1,r1; \
78 bf .Lpseudo_end; \
79 .Lsyscall_error: \
80 SYSCALL_ERROR_HANDLER; \
81 .Lpseudo_end: \
82 /* Create unwinding information for the syscall wrapper. */ \
83 .section .eh_frame,"a",@progbits; \
84 .Lframe1: \
85 .ualong .LECIE1-.LSCIE1; \
86 .LSCIE1: \
87 .ualong 0x0; \
88 .byte 0x1; \
89 AUGMENTATION_STRING; \
90 .uleb128 0x1; \
91 .sleb128 -4; \
92 .byte 0x11; \
93 AUGMENTATION_PARAM; \
94 .byte 0xc; \
95 .uleb128 0xf; \
96 .uleb128 0x0; \
97 .align 2; \
98 .LECIE1: \
99 .LSFDE1: \
100 .ualong .LEFDE1-.LASFDE1; \
101 .LASFDE1: \
102 .ualong .LASFDE1-.Lframe1; \
103 START_SYMBOL_REF; \
104 .ualong .Lpseudo_end - .Lpseudo_start; \
105 AUGMENTATION_PARAM_FDE; \
106 .byte 0x4; \
107 .ualong .LCFI0-.Lpseudo_start; \
108 .byte 0xe; \
109 .uleb128 0x4; \
110 .byte 0x91; \
111 .uleb128 0x1; \
112 .byte 0x4; \
113 .ualong .LCFI1-.LCFI0; \
114 .byte 0xe; \
115 .uleb128 0x14; \
116 FRAME_REG_##args; \
117 .byte 0x4; \
118 .ualong .LCFI2-.LCFI1; \
119 .byte 0xe; \
120 .uleb128 0x4; \
121 .byte 0x4; \
122 .ualong .LCFI3-.LCFI2; \
123 .byte 0xe; \
124 .uleb128 0x0; \
125 .byte 0xd1; \
126 .byte 0x4; \
127 .ualong .LCFI4-.LCFI3; \
128 .byte 0xe; \
129 .uleb128 0x4; \
130 .byte 0x91; \
131 .uleb128 0x1; \
132 .byte 0x4; \
133 .ualong .LCFI5-.LCFI4; \
134 .byte 0xe; \
135 .uleb128 0x8; \
136 .byte 0x80; \
137 .uleb128 0x2; \
138 .byte 0x4; \
139 .ualong .LCFI6-.LCFI5; \
140 .byte 0xe; \
141 .uleb128 0x4; \
142 .byte 0xc0; \
143 .byte 0x4; \
144 .ualong .LCFI7-.LCFI6; \
145 .byte 0xe; \
146 .uleb128 0x0; \
147 .byte 0xd1; \
148 .align 2; \
149 .LEFDE1: \
150 .previous
152 # ifdef SHARED
153 # define AUGMENTATION_STRING .string "zR"
154 # define AUGMENTATION_PARAM .uleb128 1; .byte 0x1b
155 # define AUGMENTATION_PARAM_FDE .uleb128 0
156 # define START_SYMBOL_REF .long .Lpseudo_start-.
157 # else
158 # define AUGMENTATION_STRING .ascii "\0"
159 # define AUGMENTATION_PARAM
160 # define AUGMENTATION_PARAM_FDE
161 # define START_SYMBOL_REF .long .Lpseudo_start
162 # endif
164 # define FRAME_REG_0 /* Nothing. */
165 # define FRAME_REG_1 FRAME_REG_0; .byte 0x84; .uleb128 5
166 # define FRAME_REG_2 FRAME_REG_1; .byte 0x85; .uleb128 4
167 # define FRAME_REG_3 FRAME_REG_2; .byte 0x86; .uleb128 3
168 # define FRAME_REG_4 FRAME_REG_3; .byte 0x87; .uleb128 2
169 # define FRAME_REG_5 FRAME_REG_4
170 # define FRAME_REG_6 FRAME_REG_5
172 # undef PSEUDO_END
173 # define PSEUDO_END(sym) \
174 END (sym)
176 # define SAVE_ARGS_0 /* Nothing. */
177 # define SAVE_ARGS_1 SAVE_ARGS_0; mov.l r4,@(0,r15)
178 # define SAVE_ARGS_2 SAVE_ARGS_1; mov.l r5,@(4,r15)
179 # define SAVE_ARGS_3 SAVE_ARGS_2; mov.l r6,@(8,r15)
180 # define SAVE_ARGS_4 SAVE_ARGS_3; mov.l r7,@(12,r15)
181 # define SAVE_ARGS_5 SAVE_ARGS_4
182 # define SAVE_ARGS_6 SAVE_ARGS_5
184 # define LOAD_ARGS_0 /* Nothing. */
185 # define LOAD_ARGS_1 LOAD_ARGS_0; mov.l @(0,r15),r4
186 # define LOAD_ARGS_2 LOAD_ARGS_1; mov.l @(4,r15),r5
187 # define LOAD_ARGS_3 LOAD_ARGS_2; mov.l @(8,r15),r6
188 # define LOAD_ARGS_4 LOAD_ARGS_3; mov.l @(12,r15),r7
189 # define LOAD_ARGS_5 LOAD_ARGS_4
190 # define LOAD_ARGS_6 LOAD_ARGS_5
192 # ifdef IS_IN_libpthread
193 # define __local_enable_asynccancel __pthread_enable_asynccancel
194 # define __local_disable_asynccancel __pthread_disable_asynccancel
195 # elif !defined NOT_IN_libc
196 # define __local_enable_asynccancel __libc_enable_asynccancel
197 # define __local_disable_asynccancel __libc_disable_asynccancel
198 # elif defined IS_IN_librt
199 # define __local_enable_asynccancel __librt_enable_asynccancel
200 # define __local_disable_asynccancel __librt_disable_asynccancel
201 # else
202 # error Unsupported library
203 # endif
205 # define CENABLE \
206 mov.l 1f,r0; \
207 bsrf r0; \
208 nop; \
209 0: bra 2f; \
210 mov r0,r2; \
211 .align 2; \
212 1: .long __local_enable_asynccancel - 0b; \
215 # define CDISABLE \
216 mov.l 1f,r0; \
217 bsrf r0; \
218 mov r2,r4; \
219 0: bra 2f; \
220 nop; \
221 .align 2; \
222 1: .long __local_disable_asynccancel - 0b; \
225 # ifndef __ASSEMBLER__
226 # define SINGLE_THREAD_P \
227 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
228 header.multiple_threads) == 0, 1)
229 # else
230 # define SINGLE_THREAD_P \
231 stc gbr,r0; \
232 mov.w 0f,r1; \
233 sub r1,r0; \
234 mov.l @(MULTIPLE_THREADS_OFFSET,r0),r0; \
235 bra 1f; \
236 tst r0,r0; \
237 0: .word TLS_PRE_TCB_SIZE; \
240 # endif
242 #elif !defined __ASSEMBLER__
244 # define SINGLE_THREAD_P (1)
245 # define NO_CANCELLATION 1
247 #endif