Replace FSF snail mail address with URLs.
[glibc.git] / nptl / sysdeps / unix / sysv / linux / powerpc / powerpc64 / sysdep-cancel.h
bloba017d0459004086e75851e7a76808db98eef1a62
1 /* Cancellable system call stubs. Linux/PowerPC64 version.
2 Copyright (C) 2003, 2004, 2006 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 # undef PSEUDO
35 # define PSEUDO(name, syscall_name, args) \
36 .section ".text"; \
37 ENTRY (name) \
38 SINGLE_THREAD_P; \
39 bne- .Lpseudo_cancel; \
40 .type DASHDASHPFX(syscall_name##_nocancel),@function; \
41 .globl DASHDASHPFX(syscall_name##_nocancel); \
42 DASHDASHPFX(syscall_name##_nocancel): \
43 DO_CALL (SYS_ify (syscall_name)); \
44 PSEUDO_RET; \
45 .size DASHDASHPFX(syscall_name##_nocancel),.-DASHDASHPFX(syscall_name##_nocancel); \
46 .Lpseudo_cancel: \
47 stdu 1,-128(1); \
48 cfi_adjust_cfa_offset (128); \
49 mflr 9; \
50 std 9,128+16(1); \
51 cfi_offset (lr, 16); \
52 DOCARGS_##args; /* save syscall args around CENABLE. */ \
53 CENABLE; \
54 std 3,112(1); /* store CENABLE return value (MASK). */ \
55 UNDOCARGS_##args; /* restore syscall args. */ \
56 DO_CALL (SYS_ify (syscall_name)); \
57 mfcr 0; /* save CR/R3 around CDISABLE. */ \
58 std 3,120(1); \
59 std 0,128+8(1); \
60 cfi_offset (cr, 8); \
61 ld 3,112(1); /* pass MASK to CDISABLE. */ \
62 CDISABLE; \
63 ld 9,128+16(1); \
64 ld 0,128+8(1); /* restore CR/R3. */ \
65 ld 3,120(1); \
66 mtlr 9; \
67 mtcr 0; \
68 addi 1,1,128; \
69 cfi_adjust_cfa_offset (-128); \
70 cfi_restore (lr); \
71 cfi_restore (cr)
73 # define DOCARGS_0
74 # define UNDOCARGS_0
76 # define DOCARGS_1 std 3,128+48(1); DOCARGS_0
77 # define UNDOCARGS_1 ld 3,128+48(1); UNDOCARGS_0
79 # define DOCARGS_2 std 4,128+56(1); DOCARGS_1
80 # define UNDOCARGS_2 ld 4,128+56(1); UNDOCARGS_1
82 # define DOCARGS_3 std 5,128+64(1); DOCARGS_2
83 # define UNDOCARGS_3 ld 5,128+64(1); UNDOCARGS_2
85 # define DOCARGS_4 std 6,128+72(1); DOCARGS_3
86 # define UNDOCARGS_4 ld 6,128+72(1); UNDOCARGS_3
88 # define DOCARGS_5 std 7,128+80(1); DOCARGS_4
89 # define UNDOCARGS_5 ld 7,128+80(1); UNDOCARGS_4
91 # define DOCARGS_6 std 8,128+88(1); DOCARGS_5
92 # define UNDOCARGS_6 ld 8,128+88(1); UNDOCARGS_5
94 # ifdef IS_IN_libpthread
95 # ifdef SHARED
96 # define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel)
97 # define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel)
98 # else
99 # define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel); nop
100 # define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel); nop
101 # endif
102 # elif !defined NOT_IN_libc
103 # ifdef SHARED
104 # define CENABLE bl JUMPTARGET(__libc_enable_asynccancel)
105 # define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel)
106 # else
107 # define CENABLE bl JUMPTARGET(__libc_enable_asynccancel); nop
108 # define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel); nop
109 # endif
110 # elif defined IS_IN_librt
111 # ifdef SHARED
112 # define CENABLE bl JUMPTARGET(__librt_enable_asynccancel)
113 # define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel)
114 # else
115 # define CENABLE bl JUMPTARGET(__librt_enable_asynccancel); nop
116 # define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel); nop
117 # endif
118 # else
119 # error Unsupported library
120 # endif
122 # ifndef __ASSEMBLER__
123 # define SINGLE_THREAD_P \
124 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
125 header.multiple_threads) == 0, 1)
126 # else
127 # define SINGLE_THREAD_P \
128 lwz 10,MULTIPLE_THREADS_OFFSET(13); \
129 cmpwi 10,0
130 # endif
132 #elif !defined __ASSEMBLER__
134 # define SINGLE_THREAD_P (1)
135 # define NO_CANCELLATION 1
137 #endif
139 #ifndef __ASSEMBLER__
140 # define RTLD_SINGLE_THREAD_P \
141 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
142 header.multiple_threads) == 0, 1)
143 #endif