]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libpthread / linuxthreads / sysdeps / unix / sysv / linux / sparc / sparc32 / sysdep-cancel.h
1 /* Copyright (C) 2002, 2003, 2004 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 <tls.h>
20 #ifndef __ASSEMBLER__
21 # include <linuxthreads/internals.h>
22 #endif
23
24 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
25
26 # undef PSEUDO
27 # define PSEUDO(name, syscall_name, args)                                     \
28         .text;                                                                \
29 ENTRY(name)                                                                   \
30         ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;                              \
31         cmp %g1, 0;                                                           \
32         bne 1f;                                                               \
33          mov SYS_ify(syscall_name), %g1;                                      \
34         ta 0x10;                                                              \
35         bcs __syscall_error_handler;                                          \
36          nop;                                                                 \
37         .subsection 2;                                                        \
38 1:      save %sp, -96, %sp;                                                   \
39         CENABLE;                                                              \
40          nop;                                                                 \
41         mov %o0, %l0;                                                         \
42         COPY_ARGS_##args                                                      \
43         mov SYS_ify(syscall_name), %g1;                                       \
44         ta 0x10;                                                              \
45         bcs __syscall_error_handler2;                                         \
46          mov %o0, %l1;                                                        \
47         CDISABLE;                                                             \
48          mov %l0, %o0;                                                        \
49         jmpl %i7 + 8, %g0;                                                    \
50          restore %g0, %l1, %o0;                                               \
51         .previous;                                                            \
52         SYSCALL_ERROR_HANDLER                                                 \
53         SYSCALL_ERROR_HANDLER2
54
55 #define SYSCALL_ERROR_HANDLER2                                                \
56 SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2)                         \
57         .global __errno_location;                                             \
58         .type   __errno_location,@function;                                   \
59         CDISABLE;                                                             \
60          mov    %l0, %o0;                                                     \
61         call    __errno_location;                                             \
62          nop;                                                                 \
63         st      %l1, [%o0];                                                   \
64         jmpl    %i7 + 8, %g0;                                                 \
65          restore %g0, -1, %o0;                                                \
66         .previous;
67
68 # ifdef IS_IN_libpthread
69 #  define CENABLE       call __pthread_enable_asynccancel
70 #  define CDISABLE      call __pthread_disable_asynccancel
71 # elif !defined NOT_IN_libc
72 #  define CENABLE       call __libc_enable_asynccancel
73 #  define CDISABLE      call __libc_disable_asynccancel
74 # else
75 #  define CENABLE       call __librt_enable_asynccancel
76 #  define CDISABLE      call __librt_disable_asynccancel
77 # endif
78
79 #define COPY_ARGS_0     /* Nothing */
80 #define COPY_ARGS_1     COPY_ARGS_0 mov %i0, %o0;
81 #define COPY_ARGS_2     COPY_ARGS_1 mov %i1, %o1;
82 #define COPY_ARGS_3     COPY_ARGS_2 mov %i2, %o2;
83 #define COPY_ARGS_4     COPY_ARGS_3 mov %i3, %o3;
84 #define COPY_ARGS_5     COPY_ARGS_4 mov %i4, %o4;
85 #define COPY_ARGS_6     COPY_ARGS_5 mov %i5, %o5;
86
87 # ifndef __ASSEMBLER__
88 #  define SINGLE_THREAD_P \
89   __builtin_expect (THREAD_GETMEM (THREAD_SELF,                               \
90                                    p_header.data.multiple_threads) == 0, 1)
91 # else
92 #  define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
93 # endif
94
95 #elif !defined __ASSEMBLER__
96
97 /* This code should never be used but we define it anyhow.  */
98 # define SINGLE_THREAD_P (1)
99
100 #endif