OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / libpthread / linuxthreads / sysdeps / unix / sysv / linux / s390 / s390-64 / 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 # undef PSEUDO
28 # define PSEUDO(name, syscall_name, args)                                     \
29         .text;                                                                \
30 L(pseudo_cancel):                                                             \
31         STM_##args                                                            \
32         stmg    %r13,%r15,104(%r15);                                          \
33         lgr     %r14,%r15;                                                    \
34         aghi    %r15,-160;                                                    \
35         stg     %r14,0(%r15);                                                 \
36         brasl   %r14,CENABLE;                                                 \
37         lgr     %r0,%r2;                                                      \
38         LM_##args                                                             \
39         DO_CALL(syscall_name, args);                                          \
40         lgr     %r13,%r2;                                                     \
41         lgr     %r2,%r0;                                                      \
42         brasl   %r14,CDISABLE;                                                \
43         lgr     %r2,%r13;                                                     \
44         lmg     %r13,%r15,104+160(%r15);                                      \
45         j       L(pseudo_check);                                              \
46 ENTRY(name)                                                                   \
47         SINGLE_THREAD_P                                                       \
48         jne     L(pseudo_cancel);                                             \
49         DO_CALL(syscall_name, args);                                          \
50 L(pseudo_check):                                                              \
51         lghi    %r4,-4095;                                                    \
52         clgr    %r2,%r4;                                                      \
53         jgnl    SYSCALL_ERROR_LABEL;                                          \
54 L(pseudo_end):
55
56 # ifdef IS_IN_libpthread
57 #  define CENABLE       __pthread_enable_asynccancel
58 #  define CDISABLE      __pthread_disable_asynccancel
59 #  define __local_multiple_threads      __pthread_multiple_threads
60 # elif !defined NOT_IN_libc
61 #  define CENABLE       __libc_enable_asynccancel
62 #  define CDISABLE      __libc_disable_asynccancel
63 #  define __local_multiple_threads      __libc_multiple_threads
64 # else
65 #  define CENABLE       __librt_enable_asynccancel@PLT
66 #  define CDISABLE      __librt_disable_asynccancel@PLT
67 # endif
68
69 #define STM_0           /* Nothing */
70 #define STM_1           stg %r2,16(%r15);
71 #define STM_2           stmg %r2,%r3,16(%r15);
72 #define STM_3           stmg %r2,%r4,16(%r15);
73 #define STM_4           stmg %r2,%r5,16(%r15);
74 #define STM_5           stmg %r2,%r5,16(%r15);
75
76 #define LM_0            /* Nothing */
77 #define LM_1            lg %r2,16+160(%r15);
78 #define LM_2            lmg %r2,%r3,16+160(%r15);
79 #define LM_3            lmg %r2,%r4,16+160(%r15);
80 #define LM_4            lmg %r2,%r5,16+160(%r15);
81 #define LM_5            lmg %r2,%r5,16+160(%r15);
82
83 # if !defined NOT_IN_libc || defined IS_IN_libpthread
84 #  ifndef __ASSEMBLER__
85 extern int __local_multiple_threads attribute_hidden;
86 #   define SINGLE_THREAD_P \
87   __builtin_expect (__local_multiple_threads == 0, 1)
88 #  else
89 #   define SINGLE_THREAD_P \
90         larl    %r1,__local_multiple_threads;                                 \
91         icm     %r0,15,0(%r1);
92 #  endif
93
94 # else
95
96 #  ifndef __ASSEMBLER__
97 #   define SINGLE_THREAD_P \
98   __builtin_expect (THREAD_GETMEM (THREAD_SELF,                               \
99                                    p_header.data.multiple_threads) == 0, 1)
100 #  else
101 #   define SINGLE_THREAD_P \
102         ear     %r1,%a0;                                                      \
103         sllg    %r1,%r1,32;                                                   \
104         ear     %r1,%a1;                                                      \
105         icm     %r1,15,MULTIPLE_THREADS_OFFSET(%r1);
106 #  endif
107
108 # endif
109
110 #elif !defined __ASSEMBLER__
111
112 /* This code should never be used but we define it anyhow.  */
113 # define SINGLE_THREAD_P (1)
114
115 #endif