(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / sysdeps / unix / sysv / linux / alpha / sysdep-cancel.h
blob9ea779e0d55de750af6833f6749e49837caddf5b
1 /* Copyright (C) 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #include <sysdep.h>
20 #ifndef __ASSEMBLER__
21 # include <linuxthreads/internals.h>
22 #endif
24 #if !defined NOT_IN_libc || defined IS_IN_libpthread
26 # ifdef PROF
27 # define PSEUDO_PROF \
28 .set noat; \
29 lda AT, _mcount; \
30 jsr AT, (AT), _mcount; \
31 .set at
32 # else
33 # define PSEUDO_PROF
34 # endif
36 /* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END
37 besides "ret". */
39 # undef PSEUDO
40 # define PSEUDO(name, syscall_name, args) \
41 .globl name; \
42 .align 4; \
43 .type name, @function; \
44 .usepv name, std; \
45 cfi_startproc; \
46 __LABEL(name) \
47 ldgp gp, 0(pv); \
48 PSEUDO_PROF; \
49 PSEUDO_PREPARE_ARGS \
50 SINGLE_THREAD_P(t0); \
51 bne t0, $pseudo_cancel; \
52 lda v0, SYS_ify(syscall_name); \
53 call_pal PAL_callsys; \
54 bne a3, SYSCALL_ERROR_LABEL; \
55 __LABEL($pseudo_ret) \
56 .subsection 2; \
57 __LABEL($pseudo_cancel) \
58 subq sp, 64, sp; \
59 cfi_def_cfa_offset(64); \
60 stq ra, 0(sp); \
61 cfi_offset(ra, -64); \
62 SAVE_ARGS_##args; \
63 CENABLE; \
64 LOAD_ARGS_##args; \
65 lda v0, SYS_ify(syscall_name); \
66 call_pal PAL_callsys; \
67 stq v0, 8(sp); \
68 bne a3, $multi_error; \
69 CDISABLE; \
70 ldq ra, 0(sp); \
71 ldq v0, 8(sp); \
72 addq sp, 64, sp; \
73 cfi_remember_state; \
74 cfi_restore(ra); \
75 cfi_def_cfa_offset(0); \
76 ret; \
77 cfi_restore_state; \
78 __LABEL($multi_error) \
79 CDISABLE; \
80 ldq ra, 0(sp); \
81 ldq v0, 8(sp); \
82 addq sp, 64, sp; \
83 cfi_restore(ra); \
84 cfi_def_cfa_offset(0); \
85 __LABEL($syscall_error) \
86 SYSCALL_ERROR_HANDLER; \
87 .previous
89 # undef PSEUDO_END
90 # define PSEUDO_END(sym) \
91 .subsection 2; \
92 cfi_endproc; \
93 .size sym, .-sym
95 # define SAVE_ARGS_0 /* Nothing. */
96 # define SAVE_ARGS_1 SAVE_ARGS_0; stq a0, 8(sp)
97 # define SAVE_ARGS_2 SAVE_ARGS_1; stq a1, 16(sp)
98 # define SAVE_ARGS_3 SAVE_ARGS_2; stq a2, 24(sp)
99 # define SAVE_ARGS_4 SAVE_ARGS_3; stq a3, 32(sp)
100 # define SAVE_ARGS_5 SAVE_ARGS_4; stq a4, 40(sp)
101 # define SAVE_ARGS_6 SAVE_ARGS_5; stq a5, 48(sp)
103 # define LOAD_ARGS_0 /* Nothing. */
104 # define LOAD_ARGS_1 LOAD_ARGS_0; ldq a0, 8(sp)
105 # define LOAD_ARGS_2 LOAD_ARGS_1; ldq a1, 16(sp)
106 # define LOAD_ARGS_3 LOAD_ARGS_2; ldq a2, 24(sp)
107 # define LOAD_ARGS_4 LOAD_ARGS_3; ldq a3, 32(sp)
108 # define LOAD_ARGS_5 LOAD_ARGS_4; ldq a4, 40(sp)
109 # define LOAD_ARGS_6 LOAD_ARGS_5; ldq a5, 48(sp)
111 # ifdef IS_IN_libpthread
112 # define __local_enable_asynccancel __pthread_enable_asynccancel
113 # define __local_disable_asynccancel __pthread_disable_asynccancel
114 # define __local_multiple_threads __pthread_multiple_threads
115 # else
116 # define __local_enable_asynccancel __libc_enable_asynccancel
117 # define __local_disable_asynccancel __libc_disable_asynccancel
118 # define __local_multiple_threads __libc_multiple_threads
119 # endif
121 # ifdef PIC
122 # define CENABLE bsr ra, __local_enable_asynccancel !samegp
123 # define CDISABLE bsr ra, __local_disable_asynccancel !samegp
124 # else
125 # define CENABLE jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp)
126 # define CDISABLE jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp)
127 # endif
129 # ifndef __ASSEMBLER__
130 extern int __local_multiple_threads attribute_hidden;
131 # define SINGLE_THREAD_P \
132 __builtin_expect (__local_multiple_threads == 0, 1)
133 # elif defined(PIC)
134 # define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel
135 # else
136 # define SINGLE_THREAD_P(reg) \
137 ldah reg, __local_multiple_threads(gp) !gprelhigh; \
138 ldl reg, __local_multiple_threads(reg) !gprellow
139 # endif
141 #elif !defined __ASSEMBLER__
143 /* This code should never be used but we define it anyhow. */
144 # define SINGLE_THREAD_P (1)
146 #endif