Back to index

glibc  2.9
sysdep-cancel.h
Go to the documentation of this file.
00001 /* Copyright (C) 2003, 2004 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 <linuxthreads/internals.h>
00024 #endif
00025 
00026 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
00027 
00028 # if !defined NOT_IN_libc || defined IS_IN_libpthread
00029 
00030 #  define PSEUDO_CANCEL(name, syscall_name, args)                           \
00031 L(pseudo_cancel):                                                    \
00032        STM_##args                                                    \
00033        stm    %r12,%r15,48(%r15);                                    \
00034        lr     %r14,%r15;                                             \
00035        ahi    %r15,-96;                                              \
00036        st     %r14,0(%r15);                                          \
00037        basr    %r13,0;                                                      \
00038 0:     l      %r1,1f-0b(%r13);                                       \
00039        bas    %r14,0(%r1,%r13);                                      \
00040        lr     %r0,%r2;                                               \
00041        LM_##args                                                     \
00042        DO_CALL(syscall_name, args);                                         \
00043        l      %r1,2f-0b(%r13);                                       \
00044        lr     %r12,%r2;                                              \
00045        lr     %r2,%r0;                                               \
00046        bas    %r14,0(%r1,%r13);                                      \
00047        lr     %r2,%r12;                                              \
00048        lm     %r12,%r15,48+96(%r15);                                        \
00049        j      L(pseudo_check);                                       \
00050 1:     .long  CENABLE-0b;                                            \
00051 2:     .long  CDISABLE-0b;
00052 
00053 # else /* !libc.so && !libpthread.so */
00054 
00055 #  define PSEUDO_CANCEL(name, syscall_name, args)                           \
00056 L(pseudo_cancel):                                                    \
00057        STM_##args                                                    \
00058        stm    %r11,%r15,44(%r15);                                    \
00059        lr     %r14,%r15;                                             \
00060        ahi    %r15,-96;                                              \
00061        st     %r14,0(%r15);                                          \
00062        basr    %r13,0;                                                      \
00063 0:     l      %r12,3f-0b(%r13);                                      \
00064        l      %r1,1f-0b(%r13);                                       \
00065        la     %r12,0(%r12,%r13);                                     \
00066        bas    %r14,0(%r1,%r13);                                      \
00067        lr     %r0,%r2;                                               \
00068        LM_##args                                                     \
00069        DO_CALL(syscall_name, args);                                         \
00070        l      %r1,2f-0b(%r13);                                       \
00071        lr     %r11,%r2;                                              \
00072        lr     %r2,%r0;                                               \
00073        bas    %r14,0(%r1,%r13);                                      \
00074        lr     %r2,%r11;                                              \
00075        lm     %r11,%r15,44+96(%r15);                                        \
00076        j      L(pseudo_check);                                       \
00077 1:     .long  CENABLE@PLT-0b;                                               \
00078 2:     .long  CDISABLE@PLT-0b;                                       \
00079 3:     .long  _GLOBAL_OFFSET_TABLE_-0b;
00080 
00081 # endif
00082 
00083 # undef PSEUDO
00084 # define PSEUDO(name, syscall_name, args)                            \
00085        .text;                                                        \
00086 PSEUDO_CANCEL(name, syscall_name, args)                                     \
00087 ENTRY(name)                                                          \
00088        SINGLE_THREAD_P(%r1)                                          \
00089        jne    L(pseudo_cancel);                                      \
00090        DO_CALL(syscall_name, args);                                         \
00091 L(pseudo_check):                                                     \
00092        lhi    %r4,-4095;                                             \
00093        clr    %r2,%r4;                                               \
00094        jnl    SYSCALL_ERROR_LABEL;                                   \
00095 L(pseudo_end):
00096 
00097 # ifdef IS_IN_libpthread
00098 #  define CENABLE    __pthread_enable_asynccancel
00099 #  define CDISABLE   __pthread_disable_asynccancel
00100 # elif !defined NOT_IN_libc
00101 #  define CENABLE    __libc_enable_asynccancel
00102 #  define CDISABLE   __libc_disable_asynccancel
00103 # else
00104 #  define CENABLE    __librt_enable_asynccancel
00105 #  define CDISABLE   __librt_disable_asynccancel
00106 # endif
00107 
00108 #define STM_0        /* Nothing */
00109 #define STM_1        st %r2,8(%r15);
00110 #define STM_2        stm %r2,%r3,8(%r15);
00111 #define STM_3        stm %r2,%r4,8(%r15);
00112 #define STM_4        stm %r2,%r5,8(%r15);
00113 #define STM_5        stm %r2,%r5,8(%r15);
00114 
00115 #define LM_0         /* Nothing */
00116 #define LM_1         l %r2,8+96(%r15);
00117 #define LM_2         lm %r2,%r3,8+96(%r15);
00118 #define LM_3         lm %r2,%r4,8+96(%r15);
00119 #define LM_4         lm %r2,%r5,8+96(%r15);
00120 #define LM_5         lm %r2,%r5,8+96(%r15);
00121 
00122 # ifndef __ASSEMBLER__
00123 #  define SINGLE_THREAD_P \
00124   __builtin_expect (THREAD_GETMEM (THREAD_SELF,                             \
00125                                p_header.data.multiple_threads) == 0, 1)
00126 # else
00127 #  define SINGLE_THREAD_P(reg) \
00128        ear    reg,%a0;                                               \
00129        icm    reg,15,MULTIPLE_THREADS_OFFSET(reg);
00130 # endif
00131 
00132 #elif !defined __ASSEMBLER__
00133 
00134 /* This code should never be used but we define it anyhow.  */
00135 # define SINGLE_THREAD_P (1)
00136 
00137 #endif