Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Copyright (C) 1997, 2002, 2003, 2004, 2006, 2008
00002    Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, January 1997.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef _LINUX_SPARC32_SYSDEP_H
00022 #define _LINUX_SPARC32_SYSDEP_H 1
00023 
00024 #include <sysdeps/unix/sparc/sysdep.h>
00025 
00026 #ifdef IS_IN_rtld
00027 # include <dl-sysdep.h>            /* Defines RTLD_PRIVATE_ERRNO.  */
00028 #endif
00029 #include <tls.h>
00030 
00031 #undef SYS_ify
00032 #define SYS_ify(syscall_name) __NR_##syscall_name
00033 
00034 #ifdef __ASSEMBLER__
00035 
00036 #define LOADSYSCALL(x) mov __NR_##x, %g1
00037 
00038 /* Linux/SPARC uses a different trap number */
00039 #undef PSEUDO
00040 #undef PSEUDO_NOERRNO
00041 #undef PSEUDO_ERRVAL
00042 #undef PSEUDO_END
00043 #undef ENTRY
00044 #undef END
00045 #undef LOC
00046 
00047 #define ENTRY(name)                \
00048        .align 4;                   \
00049        .global       C_SYMBOL_NAME(name); \
00050        .type  name, @function;     \
00051 C_LABEL(name)                      \
00052        cfi_startproc;
00053 
00054 #define END(name)                  \
00055        cfi_endproc;                \
00056        .size name, . - name
00057 
00058 #define LOC(name)  .L##name
00059 
00060        /* If the offset to __syscall_error fits into a signed 22-bit
00061         * immediate branch offset, the linker will relax the call into
00062         * a normal branch.
00063         */
00064 #define PSEUDO(name, syscall_name, args)  \
00065        .text;                             \
00066        .globl        __syscall_error;     \
00067 ENTRY(name);                              \
00068        LOADSYSCALL(syscall_name);         \
00069        ta            0x10;                \
00070        bcc           1f;                  \
00071         mov          %o7, %g1;            \
00072        call          __syscall_error;     \
00073         mov          %g1, %o7;            \
00074 1:
00075 
00076 #define PSEUDO_NOERRNO(name, syscall_name, args)\
00077        .text;                             \
00078 ENTRY(name);                              \
00079        LOADSYSCALL(syscall_name);         \
00080        ta            0x10;
00081 
00082 #define PSEUDO_ERRVAL(name, syscall_name, args)  \
00083        .text;                             \
00084 ENTRY(name);                              \
00085        LOADSYSCALL(syscall_name);         \
00086        ta            0x10;
00087 
00088 #define PSEUDO_END(name)                  \
00089        END(name)
00090 
00091 #else  /* __ASSEMBLER__ */
00092 
00093 #if defined SHARED && defined DO_VERSIONING && defined PIC \
00094     && !defined NO_HIDDEN && !defined NOT_IN_libc
00095 # define CALL_ERRNO_LOCATION "call   __GI___errno_location;"
00096 #else
00097 # define CALL_ERRNO_LOCATION "call   __errno_location;"
00098 #endif
00099 
00100 #define __SYSCALL_STRING                                       \
00101        "ta    0x10;"                                           \
00102        "bcs   2f;"                                             \
00103        " nop;"                                                        \
00104        "1:"                                                    \
00105        ".subsection 2;"                                        \
00106        "2:"                                                    \
00107        "save  %%sp, -192, %%sp;"                               \
00108        CALL_ERRNO_LOCATION                                     \
00109        " nop;"                                                        \
00110        "st    %%i0,[%%o0];"                                    \
00111        "ba    1b;"                                             \
00112        " restore %%g0, -1, %%o0;"                              \
00113        ".previous;"
00114 
00115 #define __CLONE_SYSCALL_STRING                                        \
00116        "ta    0x10;"                                           \
00117        "bcs   2f;"                                             \
00118        " sub  %%o1, 1, %%o1;"                                         \
00119        "and   %%o0, %%o1, %%o0;"                               \
00120        "1:"                                                    \
00121        ".subsection 2;"                                        \
00122        "2:"                                                    \
00123        "save  %%sp, -192, %%sp;"                               \
00124        CALL_ERRNO_LOCATION                                     \
00125        " nop;"                                                        \
00126        "st    %%i0, [%%o0];"                                          \
00127        "ba    1b;"                                             \
00128        " restore %%g0, -1, %%o0;"                              \
00129        ".previous;"
00130 
00131 #define __INTERNAL_SYSCALL_STRING                              \
00132        "ta    0x10;"                                           \
00133        "bcs,a 1f;"                                             \
00134        " sub  %%g0, %%o0, %%o0;"                               \
00135        "1:"
00136 
00137 #define __SYSCALL_CLOBBERS                                     \
00138        "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",                \
00139        "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",          \
00140        "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",        \
00141        "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",        \
00142        "cc", "memory"
00143 
00144 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
00145 
00146 #endif /* __ASSEMBLER__ */
00147 
00148 /* Pointer mangling support.  */
00149 #if defined NOT_IN_libc && defined IS_IN_rtld
00150 /* We cannot use the thread descriptor because in ld.so we use setjmp
00151    earlier than the descriptor is initialized.  */
00152 #else
00153 # ifdef __ASSEMBLER__
00154 #  define PTR_MANGLE(dreg, reg, tmpreg) \
00155   ld   [%g7 + POINTER_GUARD], tmpreg; \
00156   xor  reg, tmpreg, dreg
00157 #  define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
00158 #  define PTR_MANGLE2(dreg, reg, tmpreg) \
00159   xor  reg, tmpreg, dreg
00160 #  define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
00161 # else
00162 #  define PTR_MANGLE(var) \
00163   (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
00164 #  define PTR_DEMANGLE(var)     PTR_MANGLE (var)
00165 # endif
00166 #endif
00167 
00168 #endif /* linux/sparc/sysdep.h */