Back to index

glibc  2.9
sysdep-cancel.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002, 2003 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 # ifdef IS_IN_librt
00029 #  define PSEUDO_NLOCAL            6
00030 #  define PSEUDO_SAVE_GP    mov loc5 = gp
00031 #  define PSEUDO_RESTORE_GP mov gp = loc5
00032 #  define PSEUDO_SAVE_GP_1
00033 #  define PSEUDO_RESTORE_GP_1      mov gp = loc5
00034 # else
00035 #  define PSEUDO_NLOCAL            5
00036 #  define PSEUDO_SAVE_GP
00037 #  define PSEUDO_RESTORE_GP
00038 #  define PSEUDO_SAVE_GP_1  mov loc4 = gp;;
00039 #  define PSEUDO_RESTORE_GP_1      mov gp = loc4
00040 # endif
00041 
00042 # undef PSEUDO
00043 # define PSEUDO(name, syscall_name, args)                            \
00044 .text;                                                               \
00045 ENTRY (name)                                                         \
00046      adds r14 = MULTIPLE_THREADS_OFFSET, r13;;                              \
00047      ld4 r14 = [r14];                                                       \
00048      mov r15 = SYS_ify(syscall_name);;                                      \
00049      cmp4.ne p6, p7 = 0, r14;                                               \
00050 (p6) br.cond.spnt .Lpseudo_cancel;;                                         \
00051      break __BREAK_SYSCALL;;                                                \
00052      cmp.eq p6,p0=-1,r10;                                            \
00053 (p6) br.cond.spnt.few __syscall_error;                                      \
00054      ret;;                                                           \
00055      .endp name;                                                     \
00056      .proc __GC_##name;                                                     \
00057      .globl __GC_##name;                                             \
00058      .hidden __GC_##name;                                            \
00059 __GC_##name:                                                         \
00060 .Lpseudo_cancel:                                                     \
00061      .prologue;                                                             \
00062      .regstk args, PSEUDO_NLOCAL, args, 0;                                  \
00063      .save ar.pfs, loc0;                                             \
00064      alloc loc0 = ar.pfs, args, PSEUDO_NLOCAL, args, 0;                     \
00065      .save rp, loc1;                                                 \
00066      mov loc1 = rp;                                                  \
00067      PSEUDO_SAVE_GP;;                                                       \
00068      .body;                                                          \
00069      CENABLE;;                                                              \
00070      PSEUDO_RESTORE_GP;                                                     \
00071      mov loc2 = r8;                                                  \
00072      COPY_ARGS_##args                                                       \
00073      mov r15 = SYS_ify(syscall_name);                                       \
00074      break __BREAK_SYSCALL;;                                                \
00075      mov loc3 = r8;                                                  \
00076      mov loc4 = r10;                                                 \
00077      mov out0 = loc2;                                                       \
00078      CDISABLE;;                                                             \
00079      PSEUDO_RESTORE_GP;                                                     \
00080      cmp.eq p6,p0=-1,loc4;                                           \
00081 (p6) br.cond.spnt.few __syscall_error_##args;                               \
00082      mov r8 = loc3;                                                  \
00083      mov rp = loc1;                                                  \
00084      mov ar.pfs = loc0;                                                     \
00085 .Lpseudo_end:                                                        \
00086      ret;                                                            \
00087      .endp __GC_##name;                                                     \
00088 .section .gnu.linkonce.t.__syscall_error_##args, "ax";                      \
00089      .align 32;                                                             \
00090      .proc __syscall_error_##args;                                   \
00091      .global __syscall_error_##args;                                        \
00092      .hidden __syscall_error_##args;                                        \
00093      .size __syscall_error_##args, 64;                                      \
00094 __syscall_error_##args:                                                     \
00095      .prologue;                                                             \
00096      .regstk args, PSEUDO_NLOCAL, args, 0;                                  \
00097      .save ar.pfs, loc0;                                             \
00098      .save rp, loc1;                                                 \
00099      .body;                                                          \
00100      PSEUDO_SAVE_GP_1;                                                      \
00101      br.call.sptk.many b0 = __errno_location;;                              \
00102      st4 [r8] = loc3;                                                       \
00103      PSEUDO_RESTORE_GP_1;                                            \
00104      mov rp = loc1;                                                  \
00105      mov r8 = -1;                                                    \
00106      mov ar.pfs = loc0
00107 
00108 #undef PSEUDO_END
00109 #define PSEUDO_END(name) .endp
00110 
00111 # ifdef IS_IN_libpthread
00112 #  define CENABLE    br.call.sptk.many b0 = __pthread_enable_asynccancel
00113 #  define CDISABLE   br.call.sptk.many b0 = __pthread_disable_asynccancel
00114 # elif !defined NOT_IN_libc
00115 #  define CENABLE    br.call.sptk.many b0 = __libc_enable_asynccancel
00116 #  define CDISABLE   br.call.sptk.many b0 = __libc_disable_asynccancel
00117 # else
00118 #  define CENABLE    br.call.sptk.many b0 = __librt_enable_asynccancel
00119 #  define CDISABLE   br.call.sptk.many b0 = __librt_disable_asynccancel
00120 # endif
00121 
00122 #define COPY_ARGS_0  /* Nothing */
00123 #define COPY_ARGS_1  COPY_ARGS_0 mov out0 = in0;
00124 #define COPY_ARGS_2  COPY_ARGS_1 mov out1 = in1;
00125 #define COPY_ARGS_3  COPY_ARGS_2 mov out2 = in2;
00126 #define COPY_ARGS_4  COPY_ARGS_3 mov out3 = in3;
00127 #define COPY_ARGS_5  COPY_ARGS_4 mov out4 = in4;
00128 #define COPY_ARGS_6  COPY_ARGS_5 mov out5 = in5;
00129 #define COPY_ARGS_7  COPY_ARGS_6 mov out6 = in6;
00130 
00131 # ifndef __ASSEMBLER__
00132 #  define SINGLE_THREAD_P \
00133   __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
00134 # else
00135 #  define SINGLE_THREAD_P \
00136   adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
00137 # endif
00138 
00139 #elif !defined __ASSEMBLER__
00140 
00141 /* This code should never be used but we define it anyhow.  */
00142 # define SINGLE_THREAD_P (1)
00143 
00144 #endif