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 Andreas Schwab <schwab@suse.de>, 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 #ifndef __ASSEMBLER__
00022 # include <linuxthreads/internals.h>
00023 #endif
00024 
00025 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
00026 
00027 # undef PSEUDO
00028 # define PSEUDO(name, syscall_name, args)                            \
00029   .text;                                                             \
00030   ENTRY (name)                                                              \
00031     SINGLE_THREAD_P (%a0);                                           \
00032     jne .Lpseudo_cancel;                                             \
00033     DO_CALL (syscall_name, args);                                    \
00034     cmp.l &-4095, %d0;                                                      \
00035     jcc SYSCALL_ERROR_LABEL;                                                \
00036     rts;                                                             \
00037   .Lpseudo_cancel:                                                   \
00038     CENABLE;                                                         \
00039     DOCARGS_##args                                                   \
00040     move.l %d0, -(%sp);                                                     \
00041     move.l &SYS_ify (syscall_name), %d0;                             \
00042     trap &0;                                                         \
00043     move.l %d0, %d2;                                                 \
00044     CDISABLE;                                                        \
00045     addq.l &4, %sp;                                                  \
00046     move.l %d2, %d0;                                                 \
00047     UNDOCARGS_##args                                                 \
00048     cmp.l &-4095, %d0;                                                      \
00049     jcc SYSCALL_ERROR_LABEL
00050 
00051 # define DOCARGS_0   move.l %d2, -(%sp);
00052 # define _DOCARGS_0(n)
00053 # define UNDOCARGS_0 move.l (%sp)+, %d2;
00054 
00055 # define DOCARGS_1   _DOCARGS_1 (4); DOCARGS_0
00056 # define _DOCARGS_1(n)      move.l n(%sp), %d1; _DOARGS_0 (n)
00057 # define UNDOCARGS_1 UNDOCARGS_0
00058 
00059 # define DOCARGS_2   _DOCARGS_2 (8)
00060 # define _DOCARGS_2(n)      move.l %d2, -(%sp); move.l n+4(%sp), %d2; \
00061                      _DOCARGS_1 (n)
00062 # define UNDOCARGS_2 UNDOCARGS_1
00063 
00064 # define DOCARGS_3   _DOCARGS_3 (12)
00065 # define _DOCARGS_3(n)      move.l %d3, -(%sp); move.l n+4(%sp), %d3; \
00066                      _DOCARGS_2 (n)
00067 # define UNDOCARGS_3 UNDOCARGS_2; move.l (%sp)+, %d3;
00068 
00069 # define DOCARGS_4   _DOCARGS_4 (16)
00070 # define _DOCARGS_4(n)      move.l %d4, -(%sp); move.l n+4(%sp), %d4; \
00071                      _DOCARGS_3 (n)
00072 # define UNDOCARGS_4 UNDOCARGS_3; move.l (%sp)+, %d4;
00073 
00074 # define DOCARGS_5   _DOCARGS_5 (20)
00075 # define _DOCARGS_5(n)      move.l %d5, -(%sp); move.l n+4(%sp), %d5; \
00076                      _DOCARGS_4 (n)
00077 # define UNDOCARGS_5 UNDOCARGS_4; move.l (%sp)+, %d5;
00078 
00079 # ifdef IS_IN_libpthread
00080 #  ifdef PIC
00081 #   define CENABLE   jbsr __pthread_enable_asynccancel@PLTPC
00082 #   define CDISABLE  jbsr __pthread_disable_asynccancel@PLTPC
00083 #  else
00084 #   define CENABLE   jbsr __pthread_enable_asynccancel
00085 #   define CDISABLE  jbsr __pthread_disable_asynccancel
00086 #  endif
00087 # elif !defined NOT_IN_libc
00088 #  ifdef PIC
00089 #   define CENABLE   jbsr __libc_enable_asynccancel@PLTPC
00090 #   define CDISABLE  jbsr __libc_disable_asynccancel@PLTPC
00091 #  else
00092 #   define CENABLE   jbsr __libc_enable_asynccancel
00093 #   define CDISABLE  jbsr __libc_disable_asynccancel
00094 #  endif
00095 # else
00096 #  ifdef PIC
00097 #   define CENABLE   jbsr __librt_enable_asynccancel@PLTPC
00098 #   define CDISABLE  jbsr __librt_disable_asynccancel@PLTPC
00099 #  else
00100 #   define CENABLE   jbsr __librt_enable_asynccancel
00101 #   define CDISABLE  jbsr __librt_disable_asynccancel
00102 #  endif
00103 # endif
00104 
00105 # if !defined NOT_IN_libc
00106 #  define __local_multiple_threads __libc_multiple_threads
00107 # elif defined IS_IN_libpthread
00108 #  define __local_multiple_threads __pthread_multiple_threads
00109 # else
00110 #  define __local_multiple_threads __librt_multiple_threads
00111 # endif
00112 
00113 # ifndef __ASSEMBLER__
00114 #  if !defined NOT_IN_libc || defined IS_IN_libpthread
00115 extern int __local_multiple_threads attribute_hidden;
00116 #  else
00117 extern int __local_multiple_threads;
00118 #  endif
00119 #  define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
00120 # else
00121 #  if !defined PIC
00122 #   define SINGLE_THREAD_P(ATMP) tst.l __local_multiple_threads
00123 #  elif !defined NOT_IN_libc || defined IS_IN_libpthread
00124 #   if defined __mcoldfire__
00125 #    define SINGLE_THREAD_P(ATMP) \
00126        move.l &__local_multiple_threads-., ATMP; \
00127        tst.l (-8, %pc, ATMP)
00128 #   else
00129 #    define SINGLE_THREAD_P(ATMP) tst.l (__local_multiple_threads, %pc)
00130 #   endif
00131 #  else
00132 #   if defined __mcoldfire__
00133 #    define SINGLE_THREAD_P(ATMP) \
00134        move.l &__local_multiple_threads@GOTPC, ATMP; \
00135        move.l (-6, %pc, ATMP), ATMP; \
00136        tst.l (ATMP)
00137 #   else
00138 #    define SINGLE_THREAD_P(ATMP) \
00139 #      move.l (__local_multiple_threads@GOTPC, %pc), ATMP; \
00140 #      tst.l (ATMP)
00141 #   endif
00142 #  endif
00143 # endif
00144 
00145 #elif !defined __ASSEMBLER__
00146 
00147 /* This code should never be used but we define it anyhow.  */
00148 # define SINGLE_THREAD_P (1)
00149 
00150 #endif