1 /* Copyright (C) 2003-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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/>. */
22 # include <nptl/pthreadP.h>
25 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
28 # define PSEUDO(name, syscall_name, args) \
30 .type __##syscall_name##_nocancel,%function; \
31 .globl __##syscall_name##_nocancel; \
32 __##syscall_name##_nocancel: \
34 DO_CALL (syscall_name, args); \
36 b.cs .Lsyscall_error; \
39 .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
42 bne .Lpseudo_cancel; \
43 DO_CALL (syscall_name, 0); \
45 b.cs .Lsyscall_error; \
48 DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \
50 mov x16, x0; /* put mask in safe place. */ \
51 UNDOCARGS_##args; /* restore syscall args. */ \
52 mov x8, SYS_ify (syscall_name); /* do the call. */ \
54 str x0, [sp, -16]!; /* save syscall return value. */ \
55 cfi_adjust_cfa_offset (16); \
56 mov x0, x16; /* get mask back. */ \
59 cfi_adjust_cfa_offset (-16); \
61 cfi_adjust_cfa_offset (-16); \
67 str x30, [sp, -16]!; \
68 cfi_adjust_cfa_offset (16); \
69 cfi_rel_offset (x30, 0)
76 cfi_adjust_cfa_offset (16); \
77 cfi_rel_offset (x0, 0)
79 # define UNDOCARGS_1 \
82 cfi_adjust_cfa_offset (-16); \
87 cfi_adjust_cfa_offset (16); \
88 cfi_rel_offset (x1, 0)
90 # define UNDOCARGS_2 \
93 cfi_adjust_cfa_offset (-16); \
99 cfi_adjust_cfa_offset (16); \
100 cfi_rel_offset (x2, 0)
102 # define UNDOCARGS_3 \
105 cfi_adjust_cfa_offset (-16); \
110 str x3, [sp, -16]!; \
111 cfi_adjust_cfa_offset (16); \
112 cfi_rel_offset (x3, 0)
114 # define UNDOCARGS_4 \
117 cfi_adjust_cfa_offset (-16); \
122 str x4, [sp, -16]!; \
123 cfi_adjust_cfa_offset (16); \
124 cfi_rel_offset (x4, 0)
126 # define UNDOCARGS_5 \
129 cfi_adjust_cfa_offset (-16); \
134 str x5, [sp, -16]!; \
135 cfi_adjust_cfa_offset (16); \
136 cfi_rel_offset (x5, 0)
138 # define UNDOCARGS_6 \
141 cfi_adjust_cfa_offset (-16); \
144 # ifdef IS_IN_libpthread
145 # define CENABLE bl __pthread_enable_asynccancel
146 # define CDISABLE bl __pthread_disable_asynccancel
147 # define __local_multiple_threads __pthread_multiple_threads
148 # elif !defined NOT_IN_libc
149 # define CENABLE bl __libc_enable_asynccancel
150 # define CDISABLE bl __libc_disable_asynccancel
151 # define __local_multiple_threads __libc_multiple_threads
152 # elif defined IS_IN_librt
153 # define CENABLE bl __librt_enable_asynccancel
154 # define CDISABLE bl __librt_disable_asynccancel
156 # error Unsupported library
159 # if defined IS_IN_libpthread || !defined NOT_IN_libc
160 # ifndef __ASSEMBLER__
161 extern int __local_multiple_threads attribute_hidden
;
162 # define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
164 # define SINGLE_THREAD_P \
165 adrp x16, __local_multiple_threads; \
166 ldr w16, [x16, :lo12:__local_multiple_threads]; \
170 /* There is no __local_multiple_threads for librt, so use the TCB. */
171 # ifndef __ASSEMBLER__
172 # define SINGLE_THREAD_P \
173 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
174 header.multiple_threads) == 0, 1)
176 # define SINGLE_THREAD_P \
177 stp x0, x30, [sp, -16]!; \
178 cfi_adjust_cfa_offset (16); \
179 cfi_rel_offset (x0, 0); \
180 cfi_rel_offset (x30, 8); \
182 sub x0, x0, PTHREAD_SIZEOF; \
183 ldr w16, [x0, PTHREAD_MULTIPLE_THREADS_OFFSET]; \
184 ldp x0, x30, [sp], 16; \
187 cfi_adjust_cfa_offset (-16); \
192 #elif !defined __ASSEMBLER__
194 /* For rtld, et cetera. */
195 # define SINGLE_THREAD_P 1
196 # define NO_CANCELLATION 1
200 #ifndef __ASSEMBLER__
201 # define RTLD_SINGLE_THREAD_P \
202 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
203 header.multiple_threads) == 0, 1)