1 /* Copyright (C) 2014 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, see
16 <http://www.gnu.org/licenses/>. */
21 # include <pthreadP.h>
24 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
27 # define PSEUDO(name, syscall_name, args) \
28 ENTRY(__##syscall_name##_nocancel); \
30 DO_CALL(syscall_name); \
31 l.j L(pseudo_finish); \
33 END(__##syscall_name##_nocancel); \
35 SINGLE_THREAD_P(r13); \
37 l.bnf L(pseudo_nocancel); \
39 /* Reserve the same amount of stack space, effectivly disregarding \
40 * how many args we're supposed to push. This makes the code easier. */ \
42 cfi_adjust_cfa_offset(28); \
43 PUSHARGS_##args; /* CENABLE is a function call, save args for syscall. */ \
47 DO_CALL(syscall_name); \
48 l.lwz r3,24(r1); /* pass return value from CENABLE to CDISABLE. */ \
49 l.sw 24(r1),r11; /* save syscall return value for after CDISABLE. */ \
51 l.lwz r11,24(r1); /* restore syscall return value. */ \
52 cfi_adjust_cfa_offset(-28); \
55 /* if -4096 < ret < 0 holds, it's an error */ \
56 l.sfgeui r11,0xf001; \
61 # define PSEUDO_END(name) \
63 l.j SYSCALL_ERROR_NAME; \
67 # define PUSHARGS_0 /* nothing to do */
68 # define PUSHARGS_1 PUSHARGS_0 l.sw 0(r1),r3;
69 # define PUSHARGS_2 PUSHARGS_1 l.sw 4(r1),r4;
70 # define PUSHARGS_3 PUSHARGS_2 l.sw 8(r1),r5;
71 # define PUSHARGS_4 PUSHARGS_3 l.sw 12(r1),r6;
72 # define PUSHARGS_5 PUSHARGS_4 l.sw 16(r1),r7;
73 # define PUSHARGS_6 PUSHARGS_5 l.sw 20(r1),r8;
75 # define POPARGS_0 /* nothing to do */
76 # define POPARGS_1 POPARGS_0 l.lwz r3,0(r1);
77 # define POPARGS_2 POPARGS_1 l.lwz r4,4(r1);
78 # define POPARGS_3 POPARGS_2 l.lwz r5,8(r1);
79 # define POPARGS_4 POPARGS_3 l.lwz r6,12(r1);
80 # define POPARGS_5 POPARGS_4 l.lwz r7,16(r1);
81 # define POPARGS_6 POPARGS_5 l.lwz r8,20(r1);
83 # define PSEUDO_JMP(sym) l.jal sym; l.nop;
85 # ifdef IS_IN_libpthread
86 # define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel)
87 # define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel)
88 # elif defined IS_IN_librt
89 # define CENABLE PSEUDO_JMP (__librt_enable_asynccancel)
90 # define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel)
92 # define CENABLE PSEUDO_JMP (__libc_enable_asynccancel)
93 # define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel)
96 # ifndef __ASSEMBLER__
97 # define SINGLE_THREAD_P \
98 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
99 header.multiple_threads) == 0, 1)
101 /* It's not super nice to have "r10" hardcoded here */
102 # define SINGLE_THREAD_P(reg) l.lwz reg, MULTIPLE_THREADS_OFFSET(r10)
105 #elif !defined __ASSEMBLER__
107 # define SINGLE_THREAD_P 1
108 # define NO_CANCELLATION 1
112 #ifndef __ASSEMBLER__
113 # define RTLD_SINGLE_THREAD_P \
114 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
115 header.multiple_threads) == 0, 1)