Update copyright notices with scripts/update-copyrights
[glibc.git] / nptl / sysdeps / unix / sysv / linux / s390 / s390-64 / sysdep-cancel.h
blobb3560c8e4e5f8b31fdb5aefbfb8ba746e6533818
1 /* Copyright (C) 2003-2014 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, 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
28 # define PSEUDO(name, syscall_name, args) \
29 .text; \
30 L(pseudo_cancel): \
31 cfi_startproc; \
32 STM_##args \
33 stmg %r13,%r15,104(%r15); \
34 cfi_offset (%r15,-40); \
35 cfi_offset (%r14,-48); \
36 cfi_offset (%r13,-56); \
37 lgr %r14,%r15; \
38 aghi %r15,-160; \
39 cfi_adjust_cfa_offset (160); \
40 stg %r14,0(%r15); \
41 brasl %r14,CENABLE; \
42 lgr %r0,%r2; \
43 LM_##args \
44 .if SYS_ify (syscall_name) < 256; \
45 svc SYS_ify (syscall_name); \
46 .else; \
47 lghi %r1,SYS_ify (syscall_name); \
48 svc 0; \
49 .endif; \
50 LR7_##args \
51 lgr %r13,%r2; \
52 lgr %r2,%r0; \
53 brasl %r14,CDISABLE; \
54 lgr %r2,%r13; \
55 lmg %r13,%r15,104+160(%r15); \
56 cfi_endproc; \
57 j L(pseudo_check); \
58 ENTRY(name) \
59 SINGLE_THREAD_P \
60 jne L(pseudo_cancel); \
61 .type __##syscall_name##_nocancel,@function; \
62 .globl __##syscall_name##_nocancel; \
63 __##syscall_name##_nocancel: \
64 DO_CALL(syscall_name, args); \
65 L(pseudo_check): \
66 lghi %r4,-4095; \
67 clgr %r2,%r4; \
68 jgnl SYSCALL_ERROR_LABEL; \
69 .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
70 L(pseudo_end):
72 # ifdef IS_IN_libpthread
73 # define CENABLE __pthread_enable_asynccancel
74 # define CDISABLE __pthread_disable_asynccancel
75 # define __local_multiple_threads __pthread_multiple_threads
76 # elif !defined NOT_IN_libc
77 # define CENABLE __libc_enable_asynccancel
78 # define CDISABLE __libc_disable_asynccancel
79 # define __local_multiple_threads __libc_multiple_threads
80 # elif defined IS_IN_librt
81 # define CENABLE __librt_enable_asynccancel
82 # define CDISABLE __librt_disable_asynccancel
83 # else
84 # error Unsupported library
85 # endif
87 #define STM_0 /* Nothing */
88 #define STM_1 stg %r2,16(%r15);
89 #define STM_2 stmg %r2,%r3,16(%r15);
90 #define STM_3 stmg %r2,%r4,16(%r15);
91 #define STM_4 stmg %r2,%r5,16(%r15);
92 #define STM_5 stmg %r2,%r5,16(%r15);
93 #define STM_6 stmg %r2,%r7,16(%r15);
95 #define LM_0 /* Nothing */
96 #define LM_1 lg %r2,16+160(%r15);
97 #define LM_2 lmg %r2,%r3,16+160(%r15);
98 #define LM_3 lmg %r2,%r4,16+160(%r15);
99 #define LM_4 lmg %r2,%r5,16+160(%r15);
100 #define LM_5 lmg %r2,%r5,16+160(%r15);
101 #define LM_6 lmg %r2,%r5,16+160(%r15); \
102 cfi_offset (%r7, -104); \
103 lg %r7,160+160(%r15);
105 #define LR7_0 /* Nothing */
106 #define LR7_1 /* Nothing */
107 #define LR7_2 /* Nothing */
108 #define LR7_3 /* Nothing */
109 #define LR7_4 /* Nothing */
110 #define LR7_5 /* Nothing */
111 #define LR7_6 lg %r7,56+160(%r15); \
112 cfi_restore (%r7);
114 # if defined IS_IN_libpthread || !defined NOT_IN_libc
115 # ifndef __ASSEMBLER__
116 extern int __local_multiple_threads attribute_hidden;
117 # define SINGLE_THREAD_P \
118 __builtin_expect (__local_multiple_threads == 0, 1)
119 # else
120 # define SINGLE_THREAD_P \
121 larl %r1,__local_multiple_threads; \
122 icm %r0,15,0(%r1);
123 # endif
125 # else
127 # ifndef __ASSEMBLER__
128 # define SINGLE_THREAD_P \
129 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
130 header.multiple_threads) == 0, 1)
131 # else
132 # define SINGLE_THREAD_P \
133 ear %r1,%a0; \
134 sllg %r1,%r1,32; \
135 ear %r1,%a1; \
136 icm %r1,15,MULTIPLE_THREADS_OFFSET(%r1);
137 # endif
139 # endif
141 #elif !defined __ASSEMBLER__
143 # define SINGLE_THREAD_P (1)
144 # define NO_CANCELLATION 1
146 #endif
148 #ifndef __ASSEMBLER__
149 # define RTLD_SINGLE_THREAD_P \
150 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
151 header.multiple_threads) == 0, 1)
152 #endif