]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / linuxthreads / sysdeps / unix / sysv / linux / alpha / sysdep-cancel.h
1 /* Copyright (C) 2003 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17
18 #include <sysdep.h>
19 #ifndef __ASSEMBLER__
20 # include <linuxthreads/internals.h>
21 #endif
22
23 #if !defined NOT_IN_libc || defined IS_IN_libpthread
24
25 # ifdef PROF
26 #  define PSEUDO_PROF                           \
27         .set noat;                              \
28         lda     AT, _mcount;                    \
29         jsr     AT, (AT), _mcount;              \
30         .set at
31 # else
32 #  define PSEUDO_PROF
33 # endif
34
35 /* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END
36    besides "ret".  */
37
38 # undef PSEUDO
39 # define PSEUDO(name, syscall_name, args)                       \
40         .globl name;                                            \
41         .align 4;                                               \
42         .type name, @function;                                  \
43         .usepv name, std;                                       \
44         cfi_startproc;                                          \
45 __LABEL(name)                                                   \
46         ldgp    gp, 0(pv);                                      \
47         PSEUDO_PROF;                                            \
48         PSEUDO_PREPARE_ARGS                                     \
49         SINGLE_THREAD_P(t0);                                    \
50         bne     t0, $pseudo_cancel;                             \
51         lda     v0, SYS_ify(syscall_name);                      \
52         call_pal PAL_callsys;                                   \
53         bne     a3, SYSCALL_ERROR_LABEL;                        \
54 __LABEL($pseudo_ret)                                            \
55         .subsection 2;                                          \
56 __LABEL($pseudo_cancel)                                         \
57         subq    sp, 64, sp;                                     \
58         cfi_def_cfa_offset(64);                                 \
59         stq     ra, 0(sp);                                      \
60         cfi_offset(ra, -64);                                    \
61         SAVE_ARGS_##args;                                       \
62         CENABLE;                                                \
63         LOAD_ARGS_##args;                                       \
64         lda     v0, SYS_ify(syscall_name);                      \
65         call_pal PAL_callsys;                                   \
66         stq     v0, 8(sp);                                      \
67         bne     a3, $multi_error;                               \
68         CDISABLE;                                               \
69         ldq     ra, 0(sp);                                      \
70         ldq     v0, 8(sp);                                      \
71         addq    sp, 64, sp;                                     \
72         cfi_remember_state;                                     \
73         cfi_restore(ra);                                        \
74         cfi_def_cfa_offset(0);                                  \
75         ret;                                                    \
76         cfi_restore_state;                                      \
77 __LABEL($multi_error)                                           \
78         CDISABLE;                                               \
79         ldq     ra, 0(sp);                                      \
80         ldq     v0, 8(sp);                                      \
81         addq    sp, 64, sp;                                     \
82         cfi_restore(ra);                                        \
83         cfi_def_cfa_offset(0);                                  \
84 __LABEL($syscall_error)                                         \
85         SYSCALL_ERROR_HANDLER;                                  \
86         .previous
87
88 # undef PSEUDO_END
89 # define PSEUDO_END(sym)                                        \
90         .subsection 2;                                          \
91         cfi_endproc;                                            \
92         .size sym, .-sym
93
94 # define SAVE_ARGS_0    /* Nothing.  */
95 # define SAVE_ARGS_1    SAVE_ARGS_0; stq a0, 8(sp)
96 # define SAVE_ARGS_2    SAVE_ARGS_1; stq a1, 16(sp)
97 # define SAVE_ARGS_3    SAVE_ARGS_2; stq a2, 24(sp)
98 # define SAVE_ARGS_4    SAVE_ARGS_3; stq a3, 32(sp)
99 # define SAVE_ARGS_5    SAVE_ARGS_4; stq a4, 40(sp)
100 # define SAVE_ARGS_6    SAVE_ARGS_5; stq a5, 48(sp)
101
102 # define LOAD_ARGS_0    /* Nothing.  */
103 # define LOAD_ARGS_1    LOAD_ARGS_0; ldq a0, 8(sp)
104 # define LOAD_ARGS_2    LOAD_ARGS_1; ldq a1, 16(sp)
105 # define LOAD_ARGS_3    LOAD_ARGS_2; ldq a2, 24(sp)
106 # define LOAD_ARGS_4    LOAD_ARGS_3; ldq a3, 32(sp)
107 # define LOAD_ARGS_5    LOAD_ARGS_4; ldq a4, 40(sp)
108 # define LOAD_ARGS_6    LOAD_ARGS_5; ldq a5, 48(sp)
109
110 # ifdef IS_IN_libpthread
111 #  define __local_enable_asynccancel    __pthread_enable_asynccancel
112 #  define __local_disable_asynccancel   __pthread_disable_asynccancel
113 #  define __local_multiple_threads      __pthread_multiple_threads
114 # else
115 #  define __local_enable_asynccancel    __libc_enable_asynccancel
116 #  define __local_disable_asynccancel   __libc_disable_asynccancel
117 #  define __local_multiple_threads      __libc_multiple_threads
118 # endif
119
120 # ifdef __PIC__
121 #  define CENABLE       bsr ra, __local_enable_asynccancel !samegp
122 #  define CDISABLE      bsr ra, __local_disable_asynccancel !samegp
123 # else
124 #  define CENABLE       jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp)
125 #  define CDISABLE      jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp)
126 # endif
127
128 # ifndef __ASSEMBLER__
129 extern int __local_multiple_threads attribute_hidden;
130 #   define SINGLE_THREAD_P \
131   __builtin_expect (__local_multiple_threads == 0, 1)
132 # elif defined(__PIC__)
133 #  define SINGLE_THREAD_P(reg)  ldl reg, __local_multiple_threads(gp) !gprel
134 # else
135 #  define SINGLE_THREAD_P(reg)                                  \
136         ldah    reg, __local_multiple_threads(gp) !gprelhigh;   \
137         ldl     reg, __local_multiple_threads(reg) !gprellow
138 # endif
139
140 #elif !defined __ASSEMBLER__
141
142 /* This code should never be used but we define it anyhow.  */
143 # define SINGLE_THREAD_P (1)
144
145 #endif