]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / linuxthreads / sysdeps / unix / sysv / linux / s390 / s390-32 / sysdep-cancel.h
1 /* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #include <sysdep.h>
20 #include <tls.h>
21 #ifndef __ASSEMBLER__
22 # include <linuxthreads/internals.h>
23 #endif
24
25 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
26
27 # if !defined NOT_IN_libc || defined IS_IN_libpthread
28
29 #  define PSEUDO_CANCEL(name, syscall_name, args)                             \
30 L(pseudo_cancel):                                                             \
31         STM_##args                                                            \
32         stm     %r12,%r15,48(%r15);                                           \
33         lr      %r14,%r15;                                                    \
34         ahi     %r15,-96;                                                     \
35         st      %r14,0(%r15);                                                 \
36         basr    %r13,0;                                                       \
37 0:      l       %r1,1f-0b(%r13);                                              \
38         bas     %r14,0(%r1,%r13);                                             \
39         lr      %r0,%r2;                                                      \
40         LM_##args                                                             \
41         DO_CALL(syscall_name, args);                                          \
42         l       %r1,2f-0b(%r13);                                              \
43         lr      %r12,%r2;                                                     \
44         lr      %r2,%r0;                                                      \
45         bas     %r14,0(%r1,%r13);                                             \
46         lr      %r2,%r12;                                                     \
47         lm      %r12,%r15,48+96(%r15);                                        \
48         j       L(pseudo_check);                                              \
49 1:      .long   CENABLE-0b;                                                   \
50 2:      .long   CDISABLE-0b;
51
52 # else /* !libc.so && !libpthread.so */
53
54 #  define PSEUDO_CANCEL(name, syscall_name, args)                             \
55 L(pseudo_cancel):                                                             \
56         STM_##args                                                            \
57         stm     %r11,%r15,44(%r15);                                           \
58         lr      %r14,%r15;                                                    \
59         ahi     %r15,-96;                                                     \
60         st      %r14,0(%r15);                                                 \
61         basr    %r13,0;                                                       \
62 0:      l       %r12,3f-0b(%r13);                                             \
63         l       %r1,1f-0b(%r13);                                              \
64         la      %r12,0(%r12,%r13);                                            \
65         bas     %r14,0(%r1,%r13);                                             \
66         lr      %r0,%r2;                                                      \
67         LM_##args                                                             \
68         DO_CALL(syscall_name, args);                                          \
69         l       %r1,2f-0b(%r13);                                              \
70         lr      %r11,%r2;                                                     \
71         lr      %r2,%r0;                                                      \
72         bas     %r14,0(%r1,%r13);                                             \
73         lr      %r2,%r11;                                                     \
74         lm      %r11,%r15,44+96(%r15);                                        \
75         j       L(pseudo_check);                                              \
76 1:      .long   CENABLE@PLT-0b;                                               \
77 2:      .long   CDISABLE@PLT-0b;                                              \
78 3:      .long   _GLOBAL_OFFSET_TABLE_-0b;
79
80 # endif
81
82 # undef PSEUDO
83 # define PSEUDO(name, syscall_name, args)                                     \
84         .text;                                                                \
85 PSEUDO_CANCEL(name, syscall_name, args)                                       \
86 ENTRY(name)                                                                   \
87         SINGLE_THREAD_P(%r1)                                                  \
88         jne     L(pseudo_cancel);                                             \
89         DO_CALL(syscall_name, args);                                          \
90 L(pseudo_check):                                                              \
91         lhi     %r4,-4095;                                                    \
92         clr     %r2,%r4;                                                      \
93         jnl     SYSCALL_ERROR_LABEL;                                          \
94 L(pseudo_end):
95
96 # ifdef IS_IN_libpthread
97 #  define CENABLE       __pthread_enable_asynccancel
98 #  define CDISABLE      __pthread_disable_asynccancel
99 # elif !defined NOT_IN_libc
100 #  define CENABLE       __libc_enable_asynccancel
101 #  define CDISABLE      __libc_disable_asynccancel
102 # else
103 #  define CENABLE       __librt_enable_asynccancel
104 #  define CDISABLE      __librt_disable_asynccancel
105 # endif
106
107 #define STM_0           /* Nothing */
108 #define STM_1           st %r2,8(%r15);
109 #define STM_2           stm %r2,%r3,8(%r15);
110 #define STM_3           stm %r2,%r4,8(%r15);
111 #define STM_4           stm %r2,%r5,8(%r15);
112 #define STM_5           stm %r2,%r5,8(%r15);
113
114 #define LM_0            /* Nothing */
115 #define LM_1            l %r2,8+96(%r15);
116 #define LM_2            lm %r2,%r3,8+96(%r15);
117 #define LM_3            lm %r2,%r4,8+96(%r15);
118 #define LM_4            lm %r2,%r5,8+96(%r15);
119 #define LM_5            lm %r2,%r5,8+96(%r15);
120
121 # ifndef __ASSEMBLER__
122 #  define SINGLE_THREAD_P \
123   __builtin_expect (THREAD_GETMEM (THREAD_SELF,                               \
124                                    p_header.data.multiple_threads) == 0, 1)
125 # else
126 #  define SINGLE_THREAD_P(reg) \
127         ear     reg,%a0;                                                      \
128         icm     reg,15,MULTIPLE_THREADS_OFFSET(reg);
129 # endif
130
131 #elif !defined __ASSEMBLER__
132
133 /* This code should never be used but we define it anyhow.  */
134 # define SINGLE_THREAD_P (1)
135
136 #endif