Back to index

glibc  2.9
sysdep-cancel.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002, 2003, 2004 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 <linuxthreads/internals.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 ENTRY(name)                                                          \
00032        ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;                      \
00033        cmp %g1, 0;                                                   \
00034        bne 1f;                                                              \
00035         mov SYS_ify(syscall_name), %g1;                              \
00036        ta 0x10;                                                      \
00037        bcs __syscall_error_handler;                                         \
00038         nop;                                                         \
00039        .subsection 2;                                                       \
00040 1:     save %sp, -96, %sp;                                           \
00041        CENABLE;                                                      \
00042         nop;                                                         \
00043        mov %o0, %l0;                                                 \
00044        COPY_ARGS_##args                                              \
00045        mov SYS_ify(syscall_name), %g1;                                      \
00046        ta 0x10;                                                      \
00047        bcs __syscall_error_handler2;                                        \
00048         mov %o0, %l1;                                                       \
00049        CDISABLE;                                                     \
00050         mov %l0, %o0;                                                       \
00051        jmpl %i7 + 8, %g0;                                            \
00052         restore %g0, %l1, %o0;                                              \
00053        .previous;                                                    \
00054        SYSCALL_ERROR_HANDLER                                                \
00055        SYSCALL_ERROR_HANDLER2
00056 
00057 #define SYSCALL_ERROR_HANDLER2                                              \
00058 SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2)                       \
00059        .global __errno_location;                                     \
00060         .type   __errno_location,@function;                                 \
00061        CDISABLE;                                                     \
00062         mov   %l0, %o0;                                              \
00063        call   __errno_location;                                      \
00064         nop;                                                         \
00065        st     %l1, [%o0];                                            \
00066        jmpl   %i7 + 8, %g0;                                          \
00067         restore %g0, -1, %o0;                                               \
00068        .previous;
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 # else
00077 #  define CENABLE    call __librt_enable_asynccancel
00078 #  define CDISABLE   call __librt_disable_asynccancel
00079 # endif
00080 
00081 #define COPY_ARGS_0  /* Nothing */
00082 #define COPY_ARGS_1  COPY_ARGS_0 mov %i0, %o0;
00083 #define COPY_ARGS_2  COPY_ARGS_1 mov %i1, %o1;
00084 #define COPY_ARGS_3  COPY_ARGS_2 mov %i2, %o2;
00085 #define COPY_ARGS_4  COPY_ARGS_3 mov %i3, %o3;
00086 #define COPY_ARGS_5  COPY_ARGS_4 mov %i4, %o4;
00087 #define COPY_ARGS_6  COPY_ARGS_5 mov %i5, %o5;
00088 
00089 # ifndef __ASSEMBLER__
00090 #  define SINGLE_THREAD_P \
00091   __builtin_expect (THREAD_GETMEM (THREAD_SELF,                             \
00092                                p_header.data.multiple_threads) == 0, 1)
00093 # else
00094 #  define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
00095 # endif
00096 
00097 #elif !defined __ASSEMBLER__
00098 
00099 /* This code should never be used but we define it anyhow.  */
00100 # define SINGLE_THREAD_P (1)
00101 
00102 #endif