Back to index

glibc  2.9
sysdep-cancel.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002, 2003, 2004, 2005, 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   ENTRY (name)                                                              \
00032     cmpl $0, %gs:MULTIPLE_THREADS_OFFSET;                            \
00033     jne L(pseudo_cancel);                                            \
00034   .type __##syscall_name##_nocancel,@function;                              \
00035   .globl __##syscall_name##_nocancel;                                       \
00036   __##syscall_name##_nocancel:                                              \
00037     DO_CALL (syscall_name, args);                                    \
00038     cmpl $-4095, %eax;                                                      \
00039     jae SYSCALL_ERROR_LABEL;                                                \
00040     ret;                                                             \
00041   .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;          \
00042   L(pseudo_cancel):                                                  \
00043     CENABLE                                                          \
00044     SAVE_OLDTYPE_##args                                                     \
00045     PUSHCARGS_##args                                                 \
00046     DOCARGS_##args                                                   \
00047     movl $SYS_ify (syscall_name), %eax;                                     \
00048     ENTER_KERNEL;                                                    \
00049     POPCARGS_##args;                                                 \
00050     POPSTATE_##args                                                  \
00051     cmpl $-4095, %eax;                                                      \
00052     jae SYSCALL_ERROR_LABEL;                                                \
00053   L(pseudo_end):
00054 
00055 # define SAVE_OLDTYPE_0     movl %eax, %ecx;
00056 # define SAVE_OLDTYPE_1     SAVE_OLDTYPE_0
00057 # define SAVE_OLDTYPE_2     pushl %eax; cfi_adjust_cfa_offset (4);
00058 # define SAVE_OLDTYPE_3     SAVE_OLDTYPE_2
00059 # define SAVE_OLDTYPE_4     SAVE_OLDTYPE_2
00060 # define SAVE_OLDTYPE_5     SAVE_OLDTYPE_2
00061 # define SAVE_OLDTYPE_6     SAVE_OLDTYPE_2
00062 
00063 # define PUSHCARGS_0 /* No arguments to push.  */
00064 # define DOCARGS_0   /* No arguments to frob.  */
00065 # define POPCARGS_0  /* No arguments to pop.  */
00066 # define _PUSHCARGS_0       /* No arguments to push.  */
00067 # define _POPCARGS_0 /* No arguments to pop.  */
00068 
00069 # define PUSHCARGS_1 movl %ebx, %edx; cfi_register (ebx, edx); PUSHCARGS_0
00070 # define DOCARGS_1   _DOARGS_1 (4)
00071 # define POPCARGS_1  POPCARGS_0; movl %edx, %ebx; cfi_restore (ebx);
00072 # define _PUSHCARGS_1       pushl %ebx; cfi_adjust_cfa_offset (4); \
00073                      cfi_rel_offset (ebx, 0); _PUSHCARGS_0
00074 # define _POPCARGS_1 _POPCARGS_0; popl %ebx; \
00075                      cfi_adjust_cfa_offset (-4); cfi_restore (ebx);
00076 
00077 # define PUSHCARGS_2 PUSHCARGS_1
00078 # define DOCARGS_2   _DOARGS_2 (12)
00079 # define POPCARGS_2  POPCARGS_1
00080 # define _PUSHCARGS_2       _PUSHCARGS_1
00081 # define _POPCARGS_2 _POPCARGS_1
00082 
00083 # define PUSHCARGS_3 _PUSHCARGS_2
00084 # define DOCARGS_3   _DOARGS_3 (20)
00085 # define POPCARGS_3  _POPCARGS_3
00086 # define _PUSHCARGS_3       _PUSHCARGS_2
00087 # define _POPCARGS_3 _POPCARGS_2
00088 
00089 # define PUSHCARGS_4 _PUSHCARGS_4
00090 # define DOCARGS_4   _DOARGS_4 (28)
00091 # define POPCARGS_4  _POPCARGS_4
00092 # define _PUSHCARGS_4       pushl %esi; cfi_adjust_cfa_offset (4); \
00093                      cfi_rel_offset (esi, 0); _PUSHCARGS_3
00094 # define _POPCARGS_4 _POPCARGS_3; popl %esi; \
00095                      cfi_adjust_cfa_offset (-4); cfi_restore (esi);
00096 
00097 # define PUSHCARGS_5 _PUSHCARGS_5
00098 # define DOCARGS_5   _DOARGS_5 (36)
00099 # define POPCARGS_5  _POPCARGS_5
00100 # define _PUSHCARGS_5       pushl %edi; cfi_adjust_cfa_offset (4); \
00101                      cfi_rel_offset (edi, 0); _PUSHCARGS_4
00102 # define _POPCARGS_5 _POPCARGS_4; popl %edi; \
00103                      cfi_adjust_cfa_offset (-4); cfi_restore (edi);
00104 
00105 # define PUSHCARGS_6 _PUSHCARGS_6
00106 # define DOCARGS_6   _DOARGS_6 (44)
00107 # define POPCARGS_6  _POPCARGS_6
00108 # define _PUSHCARGS_6       pushl %ebp; cfi_adjust_cfa_offset (4); \
00109                      cfi_rel_offset (ebp, 0); _PUSHCARGS_5
00110 # define _POPCARGS_6 _POPCARGS_5; popl %ebp; \
00111                      cfi_adjust_cfa_offset (-4); cfi_restore (ebp);
00112 
00113 # ifdef IS_IN_libpthread
00114 #  define CENABLE    call __pthread_enable_asynccancel;
00115 #  define CDISABLE   call __pthread_disable_asynccancel
00116 # elif !defined NOT_IN_libc
00117 #  define CENABLE    call __libc_enable_asynccancel;
00118 #  define CDISABLE   call __libc_disable_asynccancel
00119 # elif defined IS_IN_librt
00120 #  define CENABLE    call __librt_enable_asynccancel;
00121 #  define CDISABLE   call __librt_disable_asynccancel
00122 # else
00123 #  error Unsupported library
00124 # endif
00125 # define POPSTATE_0 \
00126  pushl %eax; cfi_adjust_cfa_offset (4); movl %ecx, %eax; \
00127  CDISABLE; popl %eax; cfi_adjust_cfa_offset (-4);
00128 # define POPSTATE_1  POPSTATE_0
00129 # define POPSTATE_2  xchgl (%esp), %eax; CDISABLE; popl %eax; \
00130                      cfi_adjust_cfa_offset (-4);
00131 # define POPSTATE_3  POPSTATE_2
00132 # define POPSTATE_4  POPSTATE_3
00133 # define POPSTATE_5  POPSTATE_4
00134 # define POPSTATE_6  POPSTATE_5
00135 
00136 # ifndef __ASSEMBLER__
00137 #  define SINGLE_THREAD_P \
00138   __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
00139                                header.multiple_threads) == 0, 1)
00140 # else
00141 #  define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
00142 # endif
00143 
00144 #elif !defined __ASSEMBLER__
00145 
00146 # define SINGLE_THREAD_P (1)
00147 # define NO_CANCELLATION 1
00148 
00149 #endif
00150 
00151 #ifndef __ASSEMBLER__
00152 # define RTLD_SINGLE_THREAD_P \
00153   __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
00154                                header.multiple_threads) == 0, 1)
00155 #endif