2.9
[glibc/nacl-glibc.git] / nptl / sysdeps / unix / sysv / linux / powerpc / powerpc32 / sysdep-cancel.h
blob88b24e7d95c1f4d82bf00c4e1765fbd5f5a3cffb
1 /* Cancellable system call stubs. Linux/PowerPC version.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007 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, write to the Free
18 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
19 02110-1301 USA. */
21 #include <sysdep.h>
22 #include <tls.h>
23 #ifndef __ASSEMBLER__
24 # include <nptl/pthreadP.h>
25 #endif
27 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
29 # undef PSEUDO
30 # define PSEUDO(name, syscall_name, args) \
31 .section ".text"; \
32 ENTRY (name) \
33 SINGLE_THREAD_P; \
34 bne- .Lpseudo_cancel; \
35 .type __##syscall_name##_nocancel,@function; \
36 .globl __##syscall_name##_nocancel; \
37 __##syscall_name##_nocancel: \
38 DO_CALL (SYS_ify (syscall_name)); \
39 PSEUDO_RET; \
40 .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
41 .Lpseudo_cancel: \
42 stwu 1,-48(1); \
43 cfi_adjust_cfa_offset (48); \
44 mflr 9; \
45 stw 9,52(1); \
46 cfi_offset (lr, 4); \
47 DOCARGS_##args; /* save syscall args around CENABLE. */ \
48 CENABLE; \
49 stw 3,16(1); /* store CENABLE return value (MASK). */ \
50 UNDOCARGS_##args; /* restore syscall args. */ \
51 DO_CALL (SYS_ify (syscall_name)); \
52 mfcr 0; /* save CR/R3 around CDISABLE. */ \
53 stw 3,8(1); \
54 stw 0,12(1); \
55 lwz 3,16(1); /* pass MASK to CDISABLE. */ \
56 CDISABLE; \
57 lwz 4,52(1); \
58 lwz 0,12(1); /* restore CR/R3. */ \
59 lwz 3,8(1); \
60 mtlr 4; \
61 mtcr 0; \
62 addi 1,1,48;
64 # define DOCARGS_0
65 # define UNDOCARGS_0
67 # define DOCARGS_1 stw 3,20(1); DOCARGS_0
68 # define UNDOCARGS_1 lwz 3,20(1); UNDOCARGS_0
70 # define DOCARGS_2 stw 4,24(1); DOCARGS_1
71 # define UNDOCARGS_2 lwz 4,24(1); UNDOCARGS_1
73 # define DOCARGS_3 stw 5,28(1); DOCARGS_2
74 # define UNDOCARGS_3 lwz 5,28(1); UNDOCARGS_2
76 # define DOCARGS_4 stw 6,32(1); DOCARGS_3
77 # define UNDOCARGS_4 lwz 6,32(1); UNDOCARGS_3
79 # define DOCARGS_5 stw 7,36(1); DOCARGS_4
80 # define UNDOCARGS_5 lwz 7,36(1); UNDOCARGS_4
82 # define DOCARGS_6 stw 8,40(1); DOCARGS_5
83 # define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5
85 # ifdef IS_IN_libpthread
86 # define CENABLE bl __pthread_enable_asynccancel@local
87 # define CDISABLE bl __pthread_disable_asynccancel@local
88 # elif !defined NOT_IN_libc
89 # define CENABLE bl __libc_enable_asynccancel@local
90 # define CDISABLE bl __libc_disable_asynccancel@local
91 # elif defined IS_IN_librt
92 # define CENABLE bl __librt_enable_asynccancel@local
93 # define CDISABLE bl __librt_disable_asynccancel@local
94 # else
95 # error Unsupported library
96 # endif
98 # ifndef __ASSEMBLER__
99 # define SINGLE_THREAD_P \
100 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
101 header.multiple_threads) == 0, 1)
102 # else
103 # define SINGLE_THREAD_P \
104 lwz 10,MULTIPLE_THREADS_OFFSET(2); \
105 cmpwi 10,0
106 # endif
108 #elif !defined __ASSEMBLER__
110 # define SINGLE_THREAD_P (1)
111 # define NO_CANCELLATION 1
113 #endif
115 #ifndef __ASSEMBLER__
116 # define RTLD_SINGLE_THREAD_P \
117 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
118 header.multiple_threads) == 0, 1)
119 #endif