(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / sysdeps / unix / sysv / linux / ia64 / sysdep-cancel.h
blobdd9637d2b51216075c90314e45d63a22c7a49c4d
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.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <sysdep.h>
21 #include <tls.h>
22 #ifndef __ASSEMBLER__
23 # include <linuxthreads/internals.h>
24 #endif
26 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
28 # ifdef IS_IN_librt
29 # define PSEUDO_NLOCAL 6
30 # define PSEUDO_SAVE_GP mov loc5 = gp
31 # define PSEUDO_RESTORE_GP mov gp = loc5
32 # define PSEUDO_SAVE_GP_1
33 # define PSEUDO_RESTORE_GP_1 mov gp = loc5
34 # else
35 # define PSEUDO_NLOCAL 5
36 # define PSEUDO_SAVE_GP
37 # define PSEUDO_RESTORE_GP
38 # define PSEUDO_SAVE_GP_1 mov loc4 = gp;;
39 # define PSEUDO_RESTORE_GP_1 mov gp = loc4
40 # endif
42 # undef PSEUDO
43 # define PSEUDO(name, syscall_name, args) \
44 .text; \
45 ENTRY (name) \
46 adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \
47 ld4 r14 = [r14]; \
48 mov r15 = SYS_ify(syscall_name);; \
49 cmp4.ne p6, p7 = 0, r14; \
50 (p6) br.cond.spnt .Lpseudo_cancel;; \
51 break __BREAK_SYSCALL;; \
52 cmp.eq p6,p0=-1,r10; \
53 (p6) br.cond.spnt.few __syscall_error; \
54 ret;; \
55 .endp name; \
56 .proc __GC_##name; \
57 .globl __GC_##name; \
58 .hidden __GC_##name; \
59 __GC_##name: \
60 .Lpseudo_cancel: \
61 .prologue; \
62 .regstk args, PSEUDO_NLOCAL, args, 0; \
63 .save ar.pfs, loc0; \
64 alloc loc0 = ar.pfs, args, PSEUDO_NLOCAL, args, 0; \
65 .save rp, loc1; \
66 mov loc1 = rp; \
67 PSEUDO_SAVE_GP;; \
68 .body; \
69 CENABLE;; \
70 PSEUDO_RESTORE_GP; \
71 mov loc2 = r8; \
72 COPY_ARGS_##args \
73 mov r15 = SYS_ify(syscall_name); \
74 break __BREAK_SYSCALL;; \
75 mov loc3 = r8; \
76 mov loc4 = r10; \
77 mov out0 = loc2; \
78 CDISABLE;; \
79 PSEUDO_RESTORE_GP; \
80 cmp.eq p6,p0=-1,loc4; \
81 (p6) br.cond.spnt.few __syscall_error_##args; \
82 mov r8 = loc3; \
83 mov rp = loc1; \
84 mov ar.pfs = loc0; \
85 .Lpseudo_end: \
86 ret; \
87 .endp __GC_##name; \
88 .section .gnu.linkonce.t.__syscall_error_##args, "ax"; \
89 .align 32; \
90 .proc __syscall_error_##args; \
91 .global __syscall_error_##args; \
92 .hidden __syscall_error_##args; \
93 .size __syscall_error_##args, 64; \
94 __syscall_error_##args: \
95 .prologue; \
96 .regstk args, PSEUDO_NLOCAL, args, 0; \
97 .save ar.pfs, loc0; \
98 .save rp, loc1; \
99 .body; \
100 PSEUDO_SAVE_GP_1; \
101 br.call.sptk.many b0 = __errno_location;; \
102 st4 [r8] = loc3; \
103 PSEUDO_RESTORE_GP_1; \
104 mov rp = loc1; \
105 mov r8 = -1; \
106 mov ar.pfs = loc0
108 #undef PSEUDO_END
109 #define PSEUDO_END(name) .endp
111 # ifdef IS_IN_libpthread
112 # define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel
113 # define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel
114 # elif !defined NOT_IN_libc
115 # define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel
116 # define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel
117 # else
118 # define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel
119 # define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel
120 # endif
122 #define COPY_ARGS_0 /* Nothing */
123 #define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0;
124 #define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1;
125 #define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2;
126 #define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3;
127 #define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4;
128 #define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5;
129 #define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6;
131 # ifndef __ASSEMBLER__
132 # define SINGLE_THREAD_P \
133 __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
134 # else
135 # define SINGLE_THREAD_P \
136 adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
137 # endif
139 #elif !defined __ASSEMBLER__
141 /* This code should never be used but we define it anyhow. */
142 # define SINGLE_THREAD_P (1)
144 #endif