1 /* Copyright (C) 2002-2006, 2009 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, see
17 <http://www.gnu.org/licenses/>. */
22 # include <nptl/pthreadP.h>
25 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
27 /* The code to disable cancellation depends on the fact that the called
28 functions are special. They don't modify registers other than %rax
29 and %r11 if they return. Therefore we don't have to preserve other
30 registers around these calls. */
32 # define PSEUDO(name, syscall_name, args) \
36 jne L(pseudo_cancel); \
37 .type __##syscall_name##_nocancel,@function; \
38 .globl __##syscall_name##_nocancel; \
39 __##syscall_name##_nocancel: \
40 DO_CALL (syscall_name, args); \
42 jae SYSCALL_ERROR_LABEL; \
44 .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
46 /* We always have to align the stack before calling a function. */ \
47 subq $8, %rsp; cfi_adjust_cfa_offset (8); \
49 /* The return value from CENABLE is argument for CDISABLE. */ \
51 DO_CALL (syscall_name, args); \
53 /* Save %rax since it's the error code from the syscall. */ \
57 addq $8,%rsp; cfi_adjust_cfa_offset (-8); \
59 jae SYSCALL_ERROR_LABEL; \
63 # ifdef IS_IN_libpthread
64 # define CENABLE call __pthread_enable_asynccancel;
65 # define CDISABLE call __pthread_disable_asynccancel;
66 # define __local_multiple_threads __pthread_multiple_threads
67 # elif !defined NOT_IN_libc
68 # define CENABLE call __libc_enable_asynccancel;
69 # define CDISABLE call __libc_disable_asynccancel;
70 # define __local_multiple_threads __libc_multiple_threads
71 # elif defined IS_IN_librt
72 # define CENABLE call __librt_enable_asynccancel;
73 # define CDISABLE call __librt_disable_asynccancel;
75 # error Unsupported library
78 # if defined IS_IN_libpthread || !defined NOT_IN_libc
79 # ifndef __ASSEMBLER__
80 extern int __local_multiple_threads attribute_hidden
;
81 # define SINGLE_THREAD_P \
82 __builtin_expect (__local_multiple_threads == 0, 1)
84 # define SINGLE_THREAD_P cmpl $0, __local_multiple_threads(%rip)
89 # ifndef __ASSEMBLER__
90 # define SINGLE_THREAD_P \
91 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
92 header.multiple_threads) == 0, 1)
94 # define SINGLE_THREAD_P cmpl $0, %fs:MULTIPLE_THREADS_OFFSET
99 #elif !defined __ASSEMBLER__
101 # define SINGLE_THREAD_P (1)
102 # define NO_CANCELLATION 1
106 #ifndef __ASSEMBLER__
107 # define RTLD_SINGLE_THREAD_P \
108 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
109 header.multiple_threads) == 0, 1)