Update copyright notices with scripts/update-copyrights
[glibc.git] / nptl / sysdeps / unix / sysv / linux / powerpc / powerpc64 / sysdep-cancel.h
blob5807d9d5bceac84f8cf9a8a1633b4a6bf5dc9126
1 /* Cancellable system call stubs. Linux/PowerPC64 version.
2 Copyright (C) 2003-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
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.
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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <sysdep.h>
21 #include <tls.h>
22 #ifndef __ASSEMBLER__
23 # include <nptl/pthreadP.h>
24 #endif
26 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
28 # ifdef HAVE_ASM_GLOBAL_DOT_NAME
29 # define DASHDASHPFX(str) .__##str
30 # else
31 # define DASHDASHPFX(str) __##str
32 # endif
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
42 # undef PSEUDO
43 # define PSEUDO(name, syscall_name, args) \
44 .section ".text"; \
45 ENTRY (name) \
46 SINGLE_THREAD_P; \
47 bne- .Lpseudo_cancel; \
48 .type DASHDASHPFX(syscall_name##_nocancel),@function; \
49 .globl DASHDASHPFX(syscall_name##_nocancel); \
50 DASHDASHPFX(syscall_name##_nocancel): \
51 DO_CALL (SYS_ify (syscall_name)); \
52 PSEUDO_RET; \
53 .size DASHDASHPFX(syscall_name##_nocancel),.-DASHDASHPFX(syscall_name##_nocancel); \
54 .Lpseudo_cancel: \
55 stdu 1,-CANCEL_FRAMESIZE(1); \
56 cfi_adjust_cfa_offset (CANCEL_FRAMESIZE); \
57 mflr 9; \
58 std 9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1); \
59 cfi_offset (lr, FRAME_LR_SAVE); \
60 DOCARGS_##args; /* save syscall args around CENABLE. */ \
61 CENABLE; \
62 std 3,FRAME_MIN_SIZE(1); /* store CENABLE return value (MASK). */ \
63 UNDOCARGS_##args; /* restore syscall args. */ \
64 DO_CALL (SYS_ify (syscall_name)); \
65 mfcr 0; /* save CR/R3 around CDISABLE. */ \
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. */ \
70 CDISABLE; \
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); \
74 mtlr 9; \
75 mtcr 0; \
76 addi 1,1,CANCEL_FRAMESIZE; \
77 cfi_adjust_cfa_offset (-CANCEL_FRAMESIZE); \
78 cfi_restore (lr); \
79 cfi_restore (cr)
81 # define DOCARGS_0
82 # define UNDOCARGS_0
84 # define DOCARGS_1 std 3,CANCEL_PARM_SAVE(1); DOCARGS_0
85 # define UNDOCARGS_1 ld 3,CANCEL_PARM_SAVE(1); UNDOCARGS_0
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
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
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
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
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
102 # ifdef IS_IN_libpthread
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
110 # elif !defined NOT_IN_libc
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
118 # elif defined IS_IN_librt
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
126 # else
127 # error Unsupported library
128 # endif
130 # ifndef __ASSEMBLER__
131 # define SINGLE_THREAD_P \
132 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
133 header.multiple_threads) == 0, 1)
134 # else
135 # define SINGLE_THREAD_P \
136 lwz 10,MULTIPLE_THREADS_OFFSET(13); \
137 cmpwi 10,0
138 # endif
140 #elif !defined __ASSEMBLER__
142 # define SINGLE_THREAD_P (1)
143 # define NO_CANCELLATION 1
145 #endif
147 #ifndef __ASSEMBLER__
148 # define RTLD_SINGLE_THREAD_P \
149 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
150 header.multiple_threads) == 0, 1)
151 #endif