Back to index

glibc  2.9
sysdep-cancel.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002, 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>, 2002.
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        .globl        __syscall_error;     \
00032 ENTRY(name)                               \
00033        ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\
00034        brnz,pn %g1, 1f;                   \
00035 .type  __##syscall_name##_nocancel,@function;    \
00036 .globl __##syscall_name##_nocancel;              \
00037 __##syscall_name##_nocancel:                     \
00038         mov SYS_ify(syscall_name), %g1;   \
00039        ta 0x6d;                           \
00040        bcc,pt %xcc, 8f;                   \
00041         mov %o7, %g1;                            \
00042        call __syscall_error;                     \
00043         mov %g1, %o7;                            \
00044 8:     jmpl %o7 + 8, %g0;                 \
00045         nop;                              \
00046 .size  __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
00047 1:     save %sp, -192, %sp;               \
00048        cfi_def_cfa_register(%fp);         \
00049        cfi_window_save;                   \
00050        cfi_register(%o7, %i7);                   \
00051        CENABLE;                           \
00052         nop;                              \
00053        mov %o0, %l0;                      \
00054        COPY_ARGS_##args                   \
00055        mov SYS_ify(syscall_name), %g1;           \
00056        ta 0x6d;                           \
00057        bcc,pt %xcc, 1f;                   \
00058         mov %o0, %l1;                            \
00059        CDISABLE;                          \
00060         mov %l0, %o0;                            \
00061        call __syscall_error;                     \
00062         mov %l1, %o0;                            \
00063        ba,pt %xcc, 2f;                           \
00064         mov -1, %l1;                      \
00065 1:     CDISABLE;                          \
00066         mov %l0, %o0;                            \
00067 2:     jmpl %i7 + 8, %g0;                 \
00068         restore %g0, %l1, %o0;
00069 
00070 # ifdef IS_IN_libpthread
00071 #  define CENABLE    call __pthread_enable_asynccancel
00072 #  define CDISABLE   call __pthread_disable_asynccancel
00073 # elif !defined NOT_IN_libc
00074 #  define CENABLE    call __libc_enable_asynccancel
00075 #  define CDISABLE   call __libc_disable_asynccancel
00076 # elif defined IS_IN_librt
00077 #  define CENABLE    call __librt_enable_asynccancel
00078 #  define CDISABLE   call __librt_disable_asynccancel
00079 # else
00080 #  error Unsupported library
00081 # endif
00082 
00083 #define COPY_ARGS_0  /* Nothing */
00084 #define COPY_ARGS_1  COPY_ARGS_0 mov %i0, %o0;
00085 #define COPY_ARGS_2  COPY_ARGS_1 mov %i1, %o1;
00086 #define COPY_ARGS_3  COPY_ARGS_2 mov %i2, %o2;
00087 #define COPY_ARGS_4  COPY_ARGS_3 mov %i3, %o3;
00088 #define COPY_ARGS_5  COPY_ARGS_4 mov %i4, %o4;
00089 #define COPY_ARGS_6  COPY_ARGS_5 mov %i5, %o5;
00090 
00091 # ifndef __ASSEMBLER__
00092 #  define SINGLE_THREAD_P \
00093   __builtin_expect (THREAD_GETMEM (THREAD_SELF,                             \
00094                                header.multiple_threads) == 0, 1)
00095 # else
00096 #  define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
00097 # endif
00098 
00099 #elif !defined __ASSEMBLER__
00100 
00101 # define SINGLE_THREAD_P (1)
00102 # define NO_CANCELLATION 1
00103 
00104 #endif
00105 
00106 #ifndef __ASSEMBLER__
00107 # define RTLD_SINGLE_THREAD_P \
00108   __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
00109                                header.multiple_threads) == 0, 1)
00110 #endif