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        brnz,pn %g1, 1f;                                              \
00034         mov SYS_ify(syscall_name), %g1;                              \
00035        ta 0x6d;                                                      \
00036        bcs,pn %xcc, __syscall_error_handler;                                \
00037         nop;                                                         \
00038        .subsection 2;                                                       \
00039 1:     save %sp, -192, %sp;                                          \
00040        CENABLE;                                                      \
00041         nop;                                                         \
00042        mov %o0, %l0;                                                 \
00043        COPY_ARGS_##args                                              \
00044        mov SYS_ify(syscall_name), %g1;                                      \
00045        ta 0x6d;                                                      \
00046        bcs,pn %xcc, __syscall_error_handler2;                               \
00047         mov %o0, %l1;                                                       \
00048        CDISABLE;                                                     \
00049         mov %l0, %o0;                                                       \
00050        jmpl %i7 + 8, %g0;                                            \
00051         restore %g0, %l1, %o0;                                              \
00052        .previous;                                                    \
00053        SYSCALL_ERROR_HANDLER                                                \
00054        SYSCALL_ERROR_HANDLER2
00055 
00056 #define SYSCALL_ERROR_HANDLER2                                              \
00057 SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2)                       \
00058        .global __errno_location;                                     \
00059         .type   __errno_location,@function;                                 \
00060        CDISABLE;                                                     \
00061         mov   %l0, %o0;                                              \
00062        call   __errno_location;                                      \
00063         nop;                                                         \
00064        st     %l1, [%o0];                                            \
00065        jmpl   %i7 + 8, %g0;                                          \
00066         restore %g0, -1, %o0;                                               \
00067        .previous;
00068 
00069 # ifdef IS_IN_libpthread
00070 #  define CENABLE    call __pthread_enable_asynccancel
00071 #  define CDISABLE   call __pthread_disable_asynccancel
00072 # elif !defined NOT_IN_libc
00073 #  define CENABLE    call __libc_enable_asynccancel
00074 #  define CDISABLE   call __libc_disable_asynccancel
00075 # else
00076 #  define CENABLE    call __librt_enable_asynccancel
00077 #  define CDISABLE   call __librt_disable_asynccancel
00078 # endif
00079 
00080 #define COPY_ARGS_0  /* Nothing */
00081 #define COPY_ARGS_1  COPY_ARGS_0 mov %i0, %o0;
00082 #define COPY_ARGS_2  COPY_ARGS_1 mov %i1, %o1;
00083 #define COPY_ARGS_3  COPY_ARGS_2 mov %i2, %o2;
00084 #define COPY_ARGS_4  COPY_ARGS_3 mov %i3, %o3;
00085 #define COPY_ARGS_5  COPY_ARGS_4 mov %i4, %o4;
00086 #define COPY_ARGS_6  COPY_ARGS_5 mov %i5, %o5;
00087 
00088 # ifndef __ASSEMBLER__
00089 #  define SINGLE_THREAD_P \
00090   __builtin_expect (THREAD_GETMEM (THREAD_SELF,                             \
00091                                p_header.data.multiple_threads) == 0, 1)
00092 # else
00093 #  define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
00094 # endif
00095 
00096 #elif !defined __ASSEMBLER__
00097 
00098 /* This code should never be used but we define it anyhow.  */
00099 # define SINGLE_THREAD_P (1)
00100 
00101 #endif