]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / linuxthreads / sysdeps / unix / sysv / linux / ia64 / sysdep-cancel.h
1 /* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
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 # ifdef IS_IN_librt
28 #  define PSEUDO_NLOCAL         6
29 #  define PSEUDO_SAVE_GP        mov loc5 = gp
30 #  define PSEUDO_RESTORE_GP     mov gp = loc5
31 #  define PSEUDO_SAVE_GP_1
32 #  define PSEUDO_RESTORE_GP_1   mov gp = loc5
33 # else
34 #  define PSEUDO_NLOCAL         5
35 #  define PSEUDO_SAVE_GP
36 #  define PSEUDO_RESTORE_GP
37 #  define PSEUDO_SAVE_GP_1      mov loc4 = gp;;
38 #  define PSEUDO_RESTORE_GP_1   mov gp = loc4
39 # endif
40
41 # undef PSEUDO
42 # define PSEUDO(name, syscall_name, args)                                     \
43 .text;                                                                        \
44 ENTRY (name)                                                                  \
45      adds r14 = MULTIPLE_THREADS_OFFSET, r13;;                                \
46      ld4 r14 = [r14];                                                         \
47      mov r15 = SYS_ify(syscall_name);;                                        \
48      cmp4.ne p6, p7 = 0, r14;                                                 \
49 (p6) br.cond.spnt .Lpseudo_cancel;;                                           \
50      break __BREAK_SYSCALL;;                                                  \
51      cmp.eq p6,p0=-1,r10;                                                     \
52 (p6) br.cond.spnt.few __syscall_error;                                        \
53      ret;;                                                                    \
54      .endp name;                                                              \
55      .proc __GC_##name;                                                       \
56      .globl __GC_##name;                                                      \
57      .hidden __GC_##name;                                                     \
58 __GC_##name:                                                                  \
59 .Lpseudo_cancel:                                                              \
60      .prologue;                                                               \
61      .regstk args, PSEUDO_NLOCAL, args, 0;                                    \
62      .save ar.pfs, loc0;                                                      \
63      alloc loc0 = ar.pfs, args, PSEUDO_NLOCAL, args, 0;                       \
64      .save rp, loc1;                                                          \
65      mov loc1 = rp;                                                           \
66      PSEUDO_SAVE_GP;;                                                         \
67      .body;                                                                   \
68      CENABLE;;                                                                \
69      PSEUDO_RESTORE_GP;                                                       \
70      mov loc2 = r8;                                                           \
71      COPY_ARGS_##args                                                         \
72      mov r15 = SYS_ify(syscall_name);                                         \
73      break __BREAK_SYSCALL;;                                                  \
74      mov loc3 = r8;                                                           \
75      mov loc4 = r10;                                                          \
76      mov out0 = loc2;                                                         \
77      CDISABLE;;                                                               \
78      PSEUDO_RESTORE_GP;                                                       \
79      cmp.eq p6,p0=-1,loc4;                                                    \
80 (p6) br.cond.spnt.few __syscall_error_##args;                                 \
81      mov r8 = loc3;                                                           \
82      mov rp = loc1;                                                           \
83      mov ar.pfs = loc0;                                                       \
84 .Lpseudo_end:                                                                 \
85      ret;                                                                     \
86      .endp __GC_##name;                                                       \
87 .section .gnu.linkonce.t.__syscall_error_##args, "ax";                        \
88      .align 32;                                                               \
89      .proc __syscall_error_##args;                                            \
90      .global __syscall_error_##args;                                          \
91      .hidden __syscall_error_##args;                                          \
92      .size __syscall_error_##args, 64;                                        \
93 __syscall_error_##args:                                                       \
94      .prologue;                                                               \
95      .regstk args, PSEUDO_NLOCAL, args, 0;                                    \
96      .save ar.pfs, loc0;                                                      \
97      .save rp, loc1;                                                          \
98      .body;                                                                   \
99      PSEUDO_SAVE_GP_1;                                                        \
100      br.call.sptk.many b0 = __errno_location;;                                \
101      st4 [r8] = loc3;                                                         \
102      PSEUDO_RESTORE_GP_1;                                                     \
103      mov rp = loc1;                                                           \
104      mov r8 = -1;                                                             \
105      mov ar.pfs = loc0
106
107 #undef PSEUDO_END
108 #define PSEUDO_END(name) .endp
109
110 # ifdef IS_IN_libpthread
111 #  define CENABLE       br.call.sptk.many b0 = __pthread_enable_asynccancel
112 #  define CDISABLE      br.call.sptk.many b0 = __pthread_disable_asynccancel
113 # elif !defined NOT_IN_libc
114 #  define CENABLE       br.call.sptk.many b0 = __libc_enable_asynccancel
115 #  define CDISABLE      br.call.sptk.many b0 = __libc_disable_asynccancel
116 # else
117 #  define CENABLE       br.call.sptk.many b0 = __librt_enable_asynccancel
118 #  define CDISABLE      br.call.sptk.many b0 = __librt_disable_asynccancel
119 # endif
120
121 #define COPY_ARGS_0     /* Nothing */
122 #define COPY_ARGS_1     COPY_ARGS_0 mov out0 = in0;
123 #define COPY_ARGS_2     COPY_ARGS_1 mov out1 = in1;
124 #define COPY_ARGS_3     COPY_ARGS_2 mov out2 = in2;
125 #define COPY_ARGS_4     COPY_ARGS_3 mov out3 = in3;
126 #define COPY_ARGS_5     COPY_ARGS_4 mov out4 = in4;
127 #define COPY_ARGS_6     COPY_ARGS_5 mov out5 = in5;
128 #define COPY_ARGS_7     COPY_ARGS_6 mov out6 = in6;
129
130 # ifndef __ASSEMBLER__
131 #  define SINGLE_THREAD_P \
132   __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
133 # else
134 #  define SINGLE_THREAD_P \
135   adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
136 # endif
137
138 #elif !defined __ASSEMBLER__
139
140 /* This code should never be used but we define it anyhow.  */
141 # define SINGLE_THREAD_P (1)
142
143 #endif