1 /* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Guido Guenther <agx@sigxcpu.org>, 2003.
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
22 # include <linuxthreads/internals.h>
25 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
29 # define PSEUDO(name, syscall_name, args) \
32 la t9,__syscall_error; \
38 SINGLE_THREAD_P(t0); \
39 bne zero, t0, L(pseudo_cancel); \
41 li v0, SYS_ify(syscall_name); \
44 bne a3, zero, SYSCALL_ERROR_LABEL; \
50 PUSHARGS_##args; /* save syscall args */ \
53 sw v0, 44(sp); /* save mask */ \
54 POPARGS_##args; /* restore syscall args */ \
56 li v0, SYS_ify (syscall_name); \
59 sw v0, 36(sp); /* save syscall result */ \
60 sw a3, 40(sp); /* save syscall error flag */ \
61 lw a0, 44(sp); /* pass mask as arg1 */ \
64 lw v0, 36(sp); /* restore syscall result */ \
65 lw a3, 40(sp); /* restore syscall error flag */ \
66 lw ra, 28(sp); /* restore return address */ \
68 bne a3, zero, SYSCALL_ERROR_LABEL; \
72 # define PUSHARGS_0 /* nothing to do */
73 # define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp);
74 # define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp);
75 # define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp);
76 # define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp);
77 # define PUSHARGS_5 PUSHARGS_4 /* handeld by SAVESTK_## */
78 # define PUSHARGS_6 PUSHARGS_5
79 # define PUSHARGS_7 PUSHARGS_6
81 # define POPARGS_0 /* nothing to do */
82 # define POPARGS_1 POPARGS_0 lw a0, 0(sp);
83 # define POPARGS_2 POPARGS_1 lw a1, 4(sp);
84 # define POPARGS_3 POPARGS_2 lw a2, 8(sp);
85 # define POPARGS_4 POPARGS_3 lw a3, 12(sp);
86 # define POPARGS_5 POPARGS_4 /* args already in new stackframe */
87 # define POPARGS_6 POPARGS_5
88 # define POPARGS_7 POPARGS_6
92 # define SAVESTK_0 subu sp, STKSPACE
93 # define SAVESTK_1 SAVESTK_0
94 # define SAVESTK_2 SAVESTK_1
95 # define SAVESTK_3 SAVESTK_2
96 # define SAVESTK_4 SAVESTK_3
97 # define SAVESTK_5 lw t0, 16(sp); \
101 # define SAVESTK_6 lw t0, 16(sp); \
107 # define SAVESTK_7 lw t0, 16(sp); \
115 # define RESTORESTK addu sp, STKSPACE
118 # ifdef IS_IN_libpthread
119 # define CENABLE la t9, __pthread_enable_asynccancel; jalr t9;
120 # define CDISABLE la t9, __pthread_disable_asynccancel; jalr t9;
121 # define __local_multiple_threads __pthread_multiple_threads
122 # elif defined IS_IN_librt
123 # define CENABLE la t9, __librt_enable_asynccancel; jalr t9;
124 # define CDISABLE la t9, __librt_disable_asynccancel; jalr t9;
125 # define __local_multiple_threads __librt_multiple_threads
127 # define CENABLE la t9, __libc_enable_asynccancel; jalr t9;
128 # define CDISABLE la t9, __libc_disable_asynccancel; jalr t9;
129 # define __local_multiple_threads __libc_multiple_threads
132 # ifndef __ASSEMBLER__
133 extern int __local_multiple_threads attribute_hidden;
134 # define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
136 # define SINGLE_THREAD_P(reg) lw reg, __local_multiple_threads
139 #elif !defined __ASSEMBLER__
141 /* This code should never be used but we define it anyhow. */
142 # define SINGLE_THREAD_P (1)