Back to index

glibc  2.9
sysdep-cancel.h
Go to the documentation of this file.
00001 /* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <sysdep.h>
00021 #include <tls.h>
00022 #ifndef __ASSEMBLER__
00023 # include <nptl/pthreadP.h>
00024 #endif
00025 
00026 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
00027 
00028 # undef PSEUDO
00029 # define PSEUDO(name, syscall_name, args)                            \
00030        .text;                                                        \
00031 L(pseudo_cancel):                                                    \
00032        cfi_startproc;                                                       \
00033        STM_##args                                                    \
00034        stm    %r12,%r15,48(%r15);                                    \
00035        cfi_offset (%r15, -36);                                              \
00036        cfi_offset (%r14, -40);                                              \
00037        cfi_offset (%r13, -44);                                              \
00038        cfi_offset (%r12, -48);                                              \
00039        lr     %r14,%r15;                                             \
00040        ahi    %r15,-96;                                              \
00041        cfi_adjust_cfa_offset (96);                                   \
00042        st     %r14,0(%r15);                                          \
00043        basr    %r13,0;                                                      \
00044 0:     l      %r1,1f-0b(%r13);                                       \
00045        bas    %r14,0(%r1,%r13);                                      \
00046        lr     %r0,%r2;                                               \
00047        LM_##args                                                     \
00048        .if SYS_ify (syscall_name) < 256;                             \
00049        svc SYS_ify (syscall_name);                                   \
00050        .else;                                                        \
00051        lhi %r1,SYS_ify (syscall_name);                                      \
00052        svc 0;                                                        \
00053        .endif;                                                              \
00054        LR7_##args                                                    \
00055        l      %r1,2f-0b(%r13);                                       \
00056        lr     %r12,%r2;                                              \
00057        lr     %r2,%r0;                                               \
00058        bas    %r14,0(%r1,%r13);                                      \
00059        lr     %r2,%r12;                                              \
00060        lm     %r12,%r15,48+96(%r15);                                        \
00061        cfi_endproc;                                                  \
00062        j      L(pseudo_check);                                       \
00063 1:     .long  CENABLE-0b;                                            \
00064 2:     .long  CDISABLE-0b;                                           \
00065 ENTRY(name)                                                          \
00066        SINGLE_THREAD_P(%r1)                                          \
00067        jne    L(pseudo_cancel);                                      \
00068 .type  __##syscall_name##_nocancel,@function;                               \
00069 .globl __##syscall_name##_nocancel;                                         \
00070 __##syscall_name##_nocancel:                                                \
00071        DO_CALL(syscall_name, args);                                         \
00072 L(pseudo_check):                                                     \
00073        lhi    %r4,-4095;                                             \
00074        clr    %r2,%r4;                                               \
00075        jnl    SYSCALL_ERROR_LABEL;                                   \
00076 .size  __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;           \
00077 L(pseudo_end):
00078 
00079 # ifdef IS_IN_libpthread
00080 #  define CENABLE    __pthread_enable_asynccancel
00081 #  define CDISABLE   __pthread_disable_asynccancel
00082 # elif !defined NOT_IN_libc
00083 #  define CENABLE    __libc_enable_asynccancel
00084 #  define CDISABLE   __libc_disable_asynccancel
00085 # elif defined IS_IN_librt
00086 #  define CENABLE    __librt_enable_asynccancel
00087 #  define CDISABLE   __librt_disable_asynccancel
00088 # else
00089 #  error Unsupported library
00090 # endif
00091 
00092 #define STM_0        /* Nothing */
00093 #define STM_1        st %r2,8(%r15);
00094 #define STM_2        stm %r2,%r3,8(%r15);
00095 #define STM_3        stm %r2,%r4,8(%r15);
00096 #define STM_4        stm %r2,%r5,8(%r15);
00097 #define STM_5        stm %r2,%r5,8(%r15);
00098 #define STM_6        stm %r2,%r7,8(%r15);
00099 
00100 #define LM_0         /* Nothing */
00101 #define LM_1         l %r2,8+96(%r15);
00102 #define LM_2         lm %r2,%r3,8+96(%r15);
00103 #define LM_3         lm %r2,%r4,8+96(%r15);
00104 #define LM_4         lm %r2,%r5,8+96(%r15);
00105 #define LM_5         lm %r2,%r5,8+96(%r15);
00106 #define LM_6         lm %r2,%r5,8+96(%r15); \
00107                      cfi_offset (%r7, -68); \
00108                      l %r7,96+96(%r15);
00109 
00110 #define LR7_0        /* Nothing */
00111 #define LR7_1        /* Nothing */
00112 #define LR7_2        /* Nothing */
00113 #define LR7_3        /* Nothing */
00114 #define LR7_4        /* Nothing */
00115 #define LR7_5        /* Nothing */
00116 #define LR7_6        l %r7,28+96(%r15); \
00117                      cfi_restore (%r7);
00118 
00119 # ifndef __ASSEMBLER__
00120 #  define SINGLE_THREAD_P \
00121   __builtin_expect (THREAD_GETMEM (THREAD_SELF,                             \
00122                                header.multiple_threads) == 0, 1)
00123 # else
00124 #  define SINGLE_THREAD_P(reg) \
00125        ear    reg,%a0;                                               \
00126        icm    reg,15,MULTIPLE_THREADS_OFFSET(reg);
00127 # endif
00128 
00129 #elif !defined __ASSEMBLER__
00130 
00131 # define SINGLE_THREAD_P (1)
00132 # define NO_CANCELLATION 1
00133 
00134 #endif
00135 
00136 #ifndef __ASSEMBLER__
00137 # define RTLD_SINGLE_THREAD_P \
00138   __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
00139                                header.multiple_threads) == 0, 1)
00140 #endif