(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / sysdeps / unix / sysv / linux / s390 / s390-32 / sysdep-cancel.h
blob06f7aed7dcdee573c7ebef1d32f6cfc3ea5746f0
1 /* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <sysdep.h>
21 #include <tls.h>
22 #ifndef __ASSEMBLER__
23 # include <linuxthreads/internals.h>
24 #endif
26 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
28 # if !defined NOT_IN_libc || defined IS_IN_libpthread
30 # define PSEUDO_CANCEL(name, syscall_name, args) \
31 L(pseudo_cancel): \
32 STM_##args \
33 stm %r12,%r15,48(%r15); \
34 lr %r14,%r15; \
35 ahi %r15,-96; \
36 st %r14,0(%r15); \
37 basr %r13,0; \
38 0: l %r1,1f-0b(%r13); \
39 bas %r14,0(%r1,%r13); \
40 lr %r0,%r2; \
41 LM_##args \
42 DO_CALL(syscall_name, args); \
43 l %r1,2f-0b(%r13); \
44 lr %r12,%r2; \
45 lr %r2,%r0; \
46 bas %r14,0(%r1,%r13); \
47 lr %r2,%r12; \
48 lm %r12,%r15,48+96(%r15); \
49 j L(pseudo_check); \
50 1: .long CENABLE-0b; \
51 2: .long CDISABLE-0b;
53 # else /* !libc.so && !libpthread.so */
55 # define PSEUDO_CANCEL(name, syscall_name, args) \
56 L(pseudo_cancel): \
57 STM_##args \
58 stm %r11,%r15,44(%r15); \
59 lr %r14,%r15; \
60 ahi %r15,-96; \
61 st %r14,0(%r15); \
62 basr %r13,0; \
63 0: l %r12,3f-0b(%r13); \
64 l %r1,1f-0b(%r13); \
65 la %r12,0(%r12,%r13); \
66 bas %r14,0(%r1,%r13); \
67 lr %r0,%r2; \
68 LM_##args \
69 DO_CALL(syscall_name, args); \
70 l %r1,2f-0b(%r13); \
71 lr %r11,%r2; \
72 lr %r2,%r0; \
73 bas %r14,0(%r1,%r13); \
74 lr %r2,%r11; \
75 lm %r11,%r15,44+96(%r15); \
76 j L(pseudo_check); \
77 1: .long CENABLE@PLT-0b; \
78 2: .long CDISABLE@PLT-0b; \
79 3: .long _GLOBAL_OFFSET_TABLE_-0b;
81 # endif
83 # undef PSEUDO
84 # define PSEUDO(name, syscall_name, args) \
85 .text; \
86 PSEUDO_CANCEL(name, syscall_name, args) \
87 ENTRY(name) \
88 SINGLE_THREAD_P(%r1) \
89 jne L(pseudo_cancel); \
90 DO_CALL(syscall_name, args); \
91 L(pseudo_check): \
92 lhi %r4,-4095; \
93 clr %r2,%r4; \
94 jnl SYSCALL_ERROR_LABEL; \
95 L(pseudo_end):
97 # ifdef IS_IN_libpthread
98 # define CENABLE __pthread_enable_asynccancel
99 # define CDISABLE __pthread_disable_asynccancel
100 # elif !defined NOT_IN_libc
101 # define CENABLE __libc_enable_asynccancel
102 # define CDISABLE __libc_disable_asynccancel
103 # else
104 # define CENABLE __librt_enable_asynccancel
105 # define CDISABLE __librt_disable_asynccancel
106 # endif
108 #define STM_0 /* Nothing */
109 #define STM_1 st %r2,8(%r15);
110 #define STM_2 stm %r2,%r3,8(%r15);
111 #define STM_3 stm %r2,%r4,8(%r15);
112 #define STM_4 stm %r2,%r5,8(%r15);
113 #define STM_5 stm %r2,%r5,8(%r15);
115 #define LM_0 /* Nothing */
116 #define LM_1 l %r2,8+96(%r15);
117 #define LM_2 lm %r2,%r3,8+96(%r15);
118 #define LM_3 lm %r2,%r4,8+96(%r15);
119 #define LM_4 lm %r2,%r5,8+96(%r15);
120 #define LM_5 lm %r2,%r5,8+96(%r15);
122 # ifndef __ASSEMBLER__
123 # define SINGLE_THREAD_P \
124 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
125 p_header.data.multiple_threads) == 0, 1)
126 # else
127 # define SINGLE_THREAD_P(reg) \
128 ear reg,%a0; \
129 icm reg,15,MULTIPLE_THREADS_OFFSET(reg);
130 # endif
132 #elif !defined __ASSEMBLER__
134 /* This code should never be used but we define it anyhow. */
135 # define SINGLE_THREAD_P (1)
137 #endif