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