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