Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Copyright (C) 1997, 2000, 2002, 2003, 2004, 2006, 2008
00002    Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 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_SPARC64_SYSDEP_H
00022 #define _LINUX_SPARC64_SYSDEP_H 1
00023 
00024 #include <sysdeps/unix/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 /* This is a kludge to make syscalls.list find these under the names
00035    pread and pwrite, since some kernel headers define those names
00036    and some define the *64 names for the same system calls.  */
00037 #if !defined __NR_pread && defined __NR_pread64
00038 # define __NR_pread __NR_pread64
00039 #endif
00040 #if !defined __NR_pwrite && defined __NR_pwrite64
00041 # define __NR_pwrite __NR_pwrite64
00042 #endif
00043 
00044 #ifdef __ASSEMBLER__
00045 
00046 #define LOADSYSCALL(x) mov __NR_##x, %g1
00047 
00048 /* Linux/SPARC uses a different trap number */
00049 #undef PSEUDO
00050 #undef PSEUDO_NOERRNO
00051 #undef PSEUDO_ERRVAL
00052 #undef PSEUDO_END
00053 #undef ENTRY
00054 #undef END
00055 
00056 #define ENTRY(name)                \
00057        .align 4;                   \
00058        .global       C_SYMBOL_NAME(name); \
00059        .type  name, @function;     \
00060 C_LABEL(name)                      \
00061        cfi_startproc;
00062 
00063 #define END(name)                  \
00064        cfi_endproc;                \
00065        .size name, . - name
00066 
00067        /* If the offset to __syscall_error fits into a signed 22-bit
00068         * immediate branch offset, the linker will relax the call into
00069         * a normal branch.
00070         */
00071 #define PSEUDO(name, syscall_name, args)  \
00072        .text;                             \
00073        .globl        __syscall_error;     \
00074 ENTRY(name);                              \
00075        LOADSYSCALL(syscall_name);         \
00076        ta            0x6d;                \
00077        bcc,pt        %xcc, 1f;            \
00078         mov          %o7, %g1;            \
00079        call          __syscall_error;     \
00080         mov          %g1, %o7;            \
00081 1:
00082 
00083 #define       PSEUDO_NOERRNO(name, syscall_name, args)\
00084        .text;                             \
00085 ENTRY(name);                              \
00086        LOADSYSCALL(syscall_name);         \
00087        ta            0x6d;
00088 
00089 #define       PSEUDO_ERRVAL(name, syscall_name, args) \
00090        .text;                             \
00091 ENTRY(name);                              \
00092        LOADSYSCALL(syscall_name);         \
00093        ta            0x6d;
00094 
00095 #define PSEUDO_END(name)                  \
00096        END(name)
00097 
00098 
00099 /* Careful here!  This "ret" define can interfere; use jmpl if unsure.  */
00100 #define ret          retl; nop
00101 #define ret_NOERRNO  retl; nop
00102 #define ret_ERRVAL   retl; nop
00103 #define r0              %o0
00104 #define r1              %o1
00105 #define MOVE(x,y)       mov x, y
00106 
00107 #else  /* __ASSEMBLER__ */
00108 
00109 #if defined SHARED && defined DO_VERSIONING && defined PIC \
00110     && !defined NO_HIDDEN && !defined NOT_IN_libc
00111 # define CALL_ERRNO_LOCATION "call   __GI___errno_location;"
00112 #else
00113 # define CALL_ERRNO_LOCATION "call   __errno_location;"
00114 #endif
00115 
00116 #define __SYSCALL_STRING                                       \
00117        "ta    0x6d;"                                           \
00118        "bcc,pt       %%xcc, 1f;"                                      \
00119        " nop;"                                                        \
00120        "save  %%sp, -192, %%sp;"                               \
00121        CALL_ERRNO_LOCATION                                     \
00122        " nop;"                                                        \
00123        "st    %%i0,[%%o0];"                                    \
00124        "restore %%g0, -1, %%o0;"                               \
00125        "1:"
00126 
00127 #define __CLONE_SYSCALL_STRING                                        \
00128        "ta    0x6d;"                                           \
00129        "bcc,pt       %%xcc, 1f;"                                      \
00130        " sub  %%o1, 1, %%o1;"                                         \
00131        "save  %%sp, -192, %%sp;"                               \
00132        CALL_ERRNO_LOCATION                                     \
00133        " mov  -1, %%i1;"                                       \
00134        "st    %%i0,[%%o0];"                                    \
00135        "restore %%g0, -1, %%o0;"                               \
00136        "1:"                                                    \
00137        "and   %%o0, %%o1, %%o0"
00138 
00139 #define __INTERNAL_SYSCALL_STRING                              \
00140        "ta    0x6d;"                                           \
00141        "bcs,a,pt %%xcc, 1f;"                                          \
00142        " sub  %%g0, %%o0, %%o0;"                               \
00143        "1:"
00144 
00145 #define __SYSCALL_CLOBBERS                                     \
00146        "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",                \
00147        "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",          \
00148        "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",        \
00149        "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",        \
00150        "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46",        \
00151        "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",        \
00152        "cc", "memory"
00153 
00154 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h>
00155 
00156 #endif /* __ASSEMBLER__ */
00157 
00158 /* This is the offset from the %sp to the backing store above the
00159    register windows.  So if you poke stack memory directly you add this.  */
00160 #define STACK_BIAS   2047
00161 
00162 /* Pointer mangling support.  */
00163 #if defined NOT_IN_libc && defined IS_IN_rtld
00164 /* We cannot use the thread descriptor because in ld.so we use setjmp
00165    earlier than the descriptor is initialized.  */
00166 #else
00167 # ifdef __ASSEMBLER__
00168 #  define PTR_MANGLE(dreg, reg, tmpreg) \
00169   ldx  [%g7 + POINTER_GUARD], tmpreg; \
00170   xor  reg, tmpreg, dreg
00171 #  define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg)
00172 #  define PTR_MANGLE2(dreg, reg, tmpreg) \
00173   xor  reg, tmpreg, dreg
00174 #  define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg)
00175 # else
00176 #  define PTR_MANGLE(var) \
00177   (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
00178 #  define PTR_DEMANGLE(var)     PTR_MANGLE (var)
00179 # endif
00180 #endif
00181 
00182 #endif /* linux/sparc64/sysdep.h */