]>
Commit | Line | Data |
---|---|---|
f3c13160 | 1 | /* Cancellable system call stubs. Linux/PowerPC64 version. |
568035b7 | 2 | Copyright (C) 2003-2013 Free Software Foundation, Inc. |
f3c13160 RM |
3 | This file is part of the GNU C Library. |
4 | Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Lesser General Public | |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
17 | License along with the GNU C Library; if not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
f3c13160 RM |
19 | |
20 | #include <sysdep.h> | |
21 | #include <tls.h> | |
22 | #ifndef __ASSEMBLER__ | |
23 | # include <nptl/pthreadP.h> | |
24 | #endif | |
25 | ||
7a114794 | 26 | #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt |
f3c13160 | 27 | |
590b40f7 UD |
28 | # ifdef HAVE_ASM_GLOBAL_DOT_NAME |
29 | # define DASHDASHPFX(str) .__##str | |
30 | # else | |
31 | # define DASHDASHPFX(str) __##str | |
32 | # endif | |
33 | ||
8b8a692c UW |
34 | #if _CALL_ELF == 2 |
35 | #define CANCEL_FRAMESIZE (FRAME_MIN_SIZE+16+48) | |
36 | #define CANCEL_PARM_SAVE (FRAME_MIN_SIZE+16) | |
37 | #else | |
38 | #define CANCEL_FRAMESIZE (FRAME_MIN_SIZE+16) | |
39 | #define CANCEL_PARM_SAVE (CANCEL_FRAMESIZE+FRAME_PARM_SAVE) | |
40 | #endif | |
41 | ||
f3c13160 RM |
42 | # undef PSEUDO |
43 | # define PSEUDO(name, syscall_name, args) \ | |
44 | .section ".text"; \ | |
45 | ENTRY (name) \ | |
46 | SINGLE_THREAD_P; \ | |
47 | bne- .Lpseudo_cancel; \ | |
590b40f7 UD |
48 | .type DASHDASHPFX(syscall_name##_nocancel),@function; \ |
49 | .globl DASHDASHPFX(syscall_name##_nocancel); \ | |
50 | DASHDASHPFX(syscall_name##_nocancel): \ | |
f3c13160 RM |
51 | DO_CALL (SYS_ify (syscall_name)); \ |
52 | PSEUDO_RET; \ | |
590b40f7 | 53 | .size DASHDASHPFX(syscall_name##_nocancel),.-DASHDASHPFX(syscall_name##_nocancel); \ |
f3c13160 | 54 | .Lpseudo_cancel: \ |
8b8a692c UW |
55 | stdu 1,-CANCEL_FRAMESIZE(1); \ |
56 | cfi_adjust_cfa_offset (CANCEL_FRAMESIZE); \ | |
f3c13160 | 57 | mflr 9; \ |
8b8a692c UW |
58 | std 9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1); \ |
59 | cfi_offset (lr, FRAME_LR_SAVE); \ | |
f3c13160 RM |
60 | DOCARGS_##args; /* save syscall args around CENABLE. */ \ |
61 | CENABLE; \ | |
8b8a692c | 62 | std 3,FRAME_MIN_SIZE(1); /* store CENABLE return value (MASK). */ \ |
f3c13160 RM |
63 | UNDOCARGS_##args; /* restore syscall args. */ \ |
64 | DO_CALL (SYS_ify (syscall_name)); \ | |
65 | mfcr 0; /* save CR/R3 around CDISABLE. */ \ | |
8b8a692c UW |
66 | std 3,FRAME_MIN_SIZE+8(1); \ |
67 | std 0,CANCEL_FRAMESIZE+FRAME_CR_SAVE(1); \ | |
68 | cfi_offset (cr, FRAME_CR_SAVE); \ | |
69 | ld 3,FRAME_MIN_SIZE(1); /* pass MASK to CDISABLE. */ \ | |
f3c13160 | 70 | CDISABLE; \ |
8b8a692c UW |
71 | ld 9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1); \ |
72 | ld 0,CANCEL_FRAMESIZE+FRAME_CR_SAVE(1); /* restore CR/R3. */ \ | |
73 | ld 3,FRAME_MIN_SIZE+8(1); \ | |
f3c13160 RM |
74 | mtlr 9; \ |
75 | mtcr 0; \ | |
8b8a692c UW |
76 | addi 1,1,CANCEL_FRAMESIZE; \ |
77 | cfi_adjust_cfa_offset (-CANCEL_FRAMESIZE); \ | |
bebff237 AM |
78 | cfi_restore (lr); \ |
79 | cfi_restore (cr) | |
f3c13160 RM |
80 | |
81 | # define DOCARGS_0 | |
82 | # define UNDOCARGS_0 | |
83 | ||
8b8a692c UW |
84 | # define DOCARGS_1 std 3,CANCEL_PARM_SAVE(1); DOCARGS_0 |
85 | # define UNDOCARGS_1 ld 3,CANCEL_PARM_SAVE(1); UNDOCARGS_0 | |
f3c13160 | 86 | |
8b8a692c UW |
87 | # define DOCARGS_2 std 4,CANCEL_PARM_SAVE+8(1); DOCARGS_1 |
88 | # define UNDOCARGS_2 ld 4,CANCEL_PARM_SAVE+8(1); UNDOCARGS_1 | |
f3c13160 | 89 | |
8b8a692c UW |
90 | # define DOCARGS_3 std 5,CANCEL_PARM_SAVE+16(1); DOCARGS_2 |
91 | # define UNDOCARGS_3 ld 5,CANCEL_PARM_SAVE+16(1); UNDOCARGS_2 | |
f3c13160 | 92 | |
8b8a692c UW |
93 | # define DOCARGS_4 std 6,CANCEL_PARM_SAVE+24(1); DOCARGS_3 |
94 | # define UNDOCARGS_4 ld 6,CANCEL_PARM_SAVE+24(1); UNDOCARGS_3 | |
f3c13160 | 95 | |
8b8a692c UW |
96 | # define DOCARGS_5 std 7,CANCEL_PARM_SAVE+32(1); DOCARGS_4 |
97 | # define UNDOCARGS_5 ld 7,CANCEL_PARM_SAVE+32(1); UNDOCARGS_4 | |
f3c13160 | 98 | |
8b8a692c UW |
99 | # define DOCARGS_6 std 8,CANCEL_PARM_SAVE+40(1); DOCARGS_5 |
100 | # define UNDOCARGS_6 ld 8,CANCEL_PARM_SAVE+40(1); UNDOCARGS_5 | |
f3c13160 RM |
101 | |
102 | # ifdef IS_IN_libpthread | |
bebff237 AM |
103 | # ifdef SHARED |
104 | # define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel) | |
105 | # define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel) | |
106 | # else | |
107 | # define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel); nop | |
108 | # define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel); nop | |
109 | # endif | |
bbde8527 | 110 | # elif !defined NOT_IN_libc |
bebff237 AM |
111 | # ifdef SHARED |
112 | # define CENABLE bl JUMPTARGET(__libc_enable_asynccancel) | |
113 | # define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel) | |
114 | # else | |
115 | # define CENABLE bl JUMPTARGET(__libc_enable_asynccancel); nop | |
116 | # define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel); nop | |
117 | # endif | |
bbde8527 | 118 | # elif defined IS_IN_librt |
bebff237 AM |
119 | # ifdef SHARED |
120 | # define CENABLE bl JUMPTARGET(__librt_enable_asynccancel) | |
121 | # define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel) | |
122 | # else | |
123 | # define CENABLE bl JUMPTARGET(__librt_enable_asynccancel); nop | |
124 | # define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel); nop | |
125 | # endif | |
bbde8527 UD |
126 | # else |
127 | # error Unsupported library | |
f3c13160 RM |
128 | # endif |
129 | ||
130 | # ifndef __ASSEMBLER__ | |
131 | # define SINGLE_THREAD_P \ | |
468777e1 UD |
132 | __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ |
133 | header.multiple_threads) == 0, 1) | |
f3c13160 RM |
134 | # else |
135 | # define SINGLE_THREAD_P \ | |
136 | lwz 10,MULTIPLE_THREADS_OFFSET(13); \ | |
211d90c5 | 137 | cmpwi 10,0 |
f3c13160 RM |
138 | # endif |
139 | ||
140 | #elif !defined __ASSEMBLER__ | |
141 | ||
6e627806 | 142 | # define SINGLE_THREAD_P (1) |
ce6e047f | 143 | # define NO_CANCELLATION 1 |
f3c13160 RM |
144 | |
145 | #endif | |
6e627806 UD |
146 | |
147 | #ifndef __ASSEMBLER__ | |
148 | # define RTLD_SINGLE_THREAD_P \ | |
149 | __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ | |
150 | header.multiple_threads) == 0, 1) | |
151 | #endif |