1 /* Copyright (C) 1997-2022 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <https://www.gnu.org/licenses/>. */ 17 18 #ifndef _LINUX_SPARC64_SYSDEP_H 19 #define _LINUX_SPARC64_SYSDEP_H 1 20 21 #include <sysdeps/unix/sysv/linux/sparc/sysdep.h> 22 23 #if IS_IN (rtld) 24 # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */ 25 #endif 26 #include <tls.h> 27 28 #undef SYS_ify 29 #define SYS_ify(syscall_name) __NR_##syscall_name 30 31 #ifdef __ASSEMBLER__ 32 33 #define LOADSYSCALL(x) mov __NR_##x, %g1 34 35 #undef PSEUDO 36 #define PSEUDO(name, syscall_name, args) \ 37 .text; \ 38 ENTRY(name); \ 39 LOADSYSCALL(syscall_name); \ 40 ta 0x6d; \ 41 bcc,pt %xcc, 1f; \ 42 nop; \ 43 SYSCALL_ERROR_HANDLER \ 44 1: 45 46 #undef PSEUDO_NOERRNO 47 #define PSEUDO_NOERRNO(name, syscall_name, args)\ 48 .text; \ 49 ENTRY(name); \ 50 LOADSYSCALL(syscall_name); \ 51 ta 0x6d; 52 53 #undef PSEUDO_ERRVAL 54 #define PSEUDO_ERRVAL(name, syscall_name, args) \ 55 .text; \ 56 ENTRY(name); \ 57 LOADSYSCALL(syscall_name); \ 58 ta 0x6d; 59 60 #undef PSEUDO_END 61 #define PSEUDO_END(name) \ 62 END(name) 63 64 #ifndef PIC 65 # define SYSCALL_ERROR_HANDLER \ 66 mov %o7, %g1; \ 67 call __syscall_error; \ 68 mov %g1, %o7; 69 #else 70 # if RTLD_PRIVATE_ERRNO 71 # define SYSCALL_ERROR_HANDLER \ 72 0: SETUP_PIC_REG_LEAF(o2,g1) \ 73 sethi %gdop_hix22(rtld_errno), %g1; \ 74 xor %g1, %gdop_lox10(rtld_errno), %g1;\ 75 ldx [%o2 + %g1], %g1, %gdop(rtld_errno); \ 76 st %o0, [%g1]; \ 77 jmp %o7 + 8; \ 78 mov -1, %o0; 79 # elif defined _LIBC_REENTRANT 80 81 # if IS_IN (libc) 82 # define SYSCALL_ERROR_ERRNO __libc_errno 83 # else 84 # define SYSCALL_ERROR_ERRNO errno 85 # endif 86 # define SYSCALL_ERROR_HANDLER \ 87 0: SETUP_PIC_REG_LEAF(o2,g1) \ 88 sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \ 89 add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \ 90 ldx [%o2 + %g1], %g1, %tie_ldx(SYSCALL_ERROR_ERRNO);\ 91 st %o0, [%g7 + %g1]; \ 92 jmp %o7 + 8; \ 93 mov -1, %o0; 94 # else 95 # define SYSCALL_ERROR_HANDLER \ 96 0: SETUP_PIC_REG_LEAF(o2,g1) \ 97 sethi %gdop_hix22(errno), %g1;\ 98 xor %g1, %gdop_lox10(errno), %g1;\ 99 ldx [%o2 + %g1], %g1, %gdop(errno);\ 100 st %o0, [%g1]; \ 101 jmp %o7 + 8; \ 102 mov -1, %o0; 103 # endif /* _LIBC_REENTRANT */ 104 #endif /* PIC */ 105 106 #else /* __ASSEMBLER__ */ 107 108 #define __SYSCALL_STRING \ 109 "ta 0x6d;" \ 110 "bcc,pt %%xcc, 1f;" \ 111 " nop;" \ 112 "sub %%g0, %%o0, %%o0;" \ 113 "1:" 114 115 #define __SYSCALL_CLOBBERS \ 116 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ 117 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ 118 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ 119 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ 120 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \ 121 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \ 122 "cc", "memory" 123 124 #endif /* __ASSEMBLER__ */ 125 126 /* This is the offset from the %sp to the backing store above the 127 register windows. So if you poke stack memory directly you add this. */ 128 #define STACK_BIAS 2047 129 130 /* Pointer mangling support. */ 131 #if IS_IN (rtld) 132 /* We cannot use the thread descriptor because in ld.so we use setjmp 133 earlier than the descriptor is initialized. */ 134 #else 135 # ifdef __ASSEMBLER__ 136 # define PTR_MANGLE(dreg, reg, tmpreg) \ 137 ldx [%g7 + POINTER_GUARD], tmpreg; \ 138 xor reg, tmpreg, dreg 139 # define PTR_DEMANGLE(dreg, reg, tmpreg) PTR_MANGLE (dreg, reg, tmpreg) 140 # define PTR_MANGLE2(dreg, reg, tmpreg) \ 141 xor reg, tmpreg, dreg 142 # define PTR_DEMANGLE2(dreg, reg, tmpreg) PTR_MANGLE2 (dreg, reg, tmpreg) 143 # else 144 # define PTR_MANGLE(var) \ 145 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ()) 146 # define PTR_DEMANGLE(var) PTR_MANGLE (var) 147 # endif 148 #endif 149 150 #endif /* linux/sparc64/sysdep.h */ 151