2.9
[glibc/nacl-glibc.git] / nptl / sysdeps / unix / sysv / linux / sparc / sparc32 / sysdep-cancel.h
blobf0349906b2a75275dd54fbe0924074adeaf497a4
1 /* Copyright (C) 2002, 2003, 2004, 2006 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 <nptl/pthreadP.h>
24 #endif
26 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
28 # undef PSEUDO
29 # define PSEUDO(name, syscall_name, args) \
30 .text; \
31 .globl __syscall_error; \
32 ENTRY(name) \
33 ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\
34 cmp %g1, 0; \
35 bne 1f; \
36 .type __##syscall_name##_nocancel,@function; \
37 .globl __##syscall_name##_nocancel; \
38 __##syscall_name##_nocancel: \
39 mov SYS_ify(syscall_name), %g1; \
40 ta 0x10; \
41 bcc 8f; \
42 mov %o7, %g1; \
43 call __syscall_error; \
44 mov %g1, %o7; \
45 8: jmpl %o7 + 8, %g0; \
46 nop; \
47 .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
48 1: save %sp, -96, %sp; \
49 cfi_def_cfa_register(%fp); \
50 cfi_window_save; \
51 cfi_register(%o7, %i7); \
52 CENABLE; \
53 nop; \
54 mov %o0, %l0; \
55 COPY_ARGS_##args \
56 mov SYS_ify(syscall_name), %g1; \
57 ta 0x10; \
58 bcc 1f; \
59 mov %o0, %l1; \
60 CDISABLE; \
61 mov %l0, %o0; \
62 call __syscall_error; \
63 mov %l1, %o0; \
64 b 2f; \
65 mov -1, %l1; \
66 1: CDISABLE; \
67 mov %l0, %o0; \
68 2: jmpl %i7 + 8, %g0; \
69 restore %g0, %l1, %o0;
72 # ifdef IS_IN_libpthread
73 # define CENABLE call __pthread_enable_asynccancel
74 # define CDISABLE call __pthread_disable_asynccancel
75 # elif !defined NOT_IN_libc
76 # define CENABLE call __libc_enable_asynccancel
77 # define CDISABLE call __libc_disable_asynccancel
78 # elif defined IS_IN_librt
79 # define CENABLE call __librt_enable_asynccancel
80 # define CDISABLE call __librt_disable_asynccancel
81 # else
82 # error Unsupported library
83 # endif
85 #define COPY_ARGS_0 /* Nothing */
86 #define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0;
87 #define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1;
88 #define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2;
89 #define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3;
90 #define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4;
91 #define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5;
93 # ifndef __ASSEMBLER__
94 # define SINGLE_THREAD_P \
95 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
96 header.multiple_threads) == 0, 1)
97 # else
98 # define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
99 # endif
101 #elif !defined __ASSEMBLER__
103 # define SINGLE_THREAD_P (1)
104 # define NO_CANCELLATION 1
106 #endif
108 #ifndef __ASSEMBLER__
109 # define RTLD_SINGLE_THREAD_P \
110 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
111 header.multiple_threads) == 0, 1)
112 #endif