1 /* Copyright (C) 2000-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_SPARC_SYSDEP_H 19 #define _LINUX_SPARC_SYSDEP_H 1 20 21 #include <sysdeps/unix/sysdep.h> 22 #include <sysdeps/unix/sysv/linux/sysdep.h> 23 #include <sysdeps/sparc/sysdep.h> 24 25 #ifdef __ASSEMBLER__ 26 27 #define ret retl; nop 28 #define ret_NOERRNO retl; nop 29 #define ret_ERRVAL retl; nop 30 #define r0 %o0 31 #define r1 %o1 32 #define MOVE(x,y) mov x, y 33 34 #else /* __ASSEMBLER__ */ 35 36 # define VDSO_NAME "LINUX_2.6" 37 # define VDSO_HASH 61765110 38 39 /* List of system calls which are supported as vsyscalls. */ 40 # ifdef __arch64__ 41 # define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime" 42 # else 43 # define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" 44 # endif 45 # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" 46 47 #undef INTERNAL_SYSCALL 48 #define INTERNAL_SYSCALL(name, nr, args...) \ 49 internal_syscall##nr(__SYSCALL_STRING, __NR_##name, args) 50 51 #undef INTERNAL_SYSCALL_NCS 52 #define INTERNAL_SYSCALL_NCS(name, nr, args...) \ 53 internal_syscall##nr(__SYSCALL_STRING, name, args) 54 55 #define internal_syscall0(string,name,dummy...) \ 56 ({ \ 57 register long int __g1 __asm__ ("g1") = (name); \ 58 register long __o0 __asm__ ("o0"); \ 59 __asm __volatile (string : "=r" (__o0) : \ 60 "r" (__g1) : \ 61 __SYSCALL_CLOBBERS); \ 62 __o0; \ 63 }) 64 65 #define internal_syscall1(string,name,arg1) \ 66 ({ \ 67 long int _arg1 = (long int) (arg1); \ 68 register long int __g1 __asm__("g1") = (name); \ 69 register long int __o0 __asm__ ("o0") = _arg1; \ 70 __asm __volatile (string : "=r" (__o0) : \ 71 "r" (__g1), "0" (__o0) : \ 72 __SYSCALL_CLOBBERS); \ 73 __o0; \ 74 }) 75 76 #define internal_syscall2(string,name,arg1,arg2) \ 77 ({ \ 78 long int _arg1 = (long int) (arg1); \ 79 long int _arg2 = (long int) (arg2); \ 80 register long int __g1 __asm__("g1") = (name); \ 81 register long int __o0 __asm__ ("o0") = _arg1; \ 82 register long int __o1 __asm__ ("o1") = _arg2; \ 83 __asm __volatile (string : "=r" (__o0) : \ 84 "r" (__g1), "0" (__o0), "r" (__o1) : \ 85 __SYSCALL_CLOBBERS); \ 86 __o0; \ 87 }) 88 89 #define internal_syscall3(string,name,arg1,arg2,arg3) \ 90 ({ \ 91 long int _arg1 = (long int) (arg1); \ 92 long int _arg2 = (long int) (arg2); \ 93 long int _arg3 = (long int) (arg3); \ 94 register long int __g1 __asm__("g1") = (name); \ 95 register long int __o0 __asm__ ("o0") = _arg1; \ 96 register long int __o1 __asm__ ("o1") = _arg2; \ 97 register long int __o2 __asm__ ("o2") = _arg3; \ 98 __asm __volatile (string : "=r" (__o0) : \ 99 "r" (__g1), "0" (__o0), "r" (__o1), \ 100 "r" (__o2) : \ 101 __SYSCALL_CLOBBERS); \ 102 __o0; \ 103 }) 104 105 #define internal_syscall4(string,name,arg1,arg2,arg3,arg4) \ 106 ({ \ 107 long int _arg1 = (long int) (arg1); \ 108 long int _arg2 = (long int) (arg2); \ 109 long int _arg3 = (long int) (arg3); \ 110 long int _arg4 = (long int) (arg4); \ 111 register long int __g1 __asm__("g1") = (name); \ 112 register long int __o0 __asm__ ("o0") = _arg1; \ 113 register long int __o1 __asm__ ("o1") = _arg2; \ 114 register long int __o2 __asm__ ("o2") = _arg3; \ 115 register long int __o3 __asm__ ("o3") = _arg4; \ 116 __asm __volatile (string : "=r" (__o0) : \ 117 "r" (__g1), "0" (__o0), "r" (__o1), \ 118 "r" (__o2), "r" (__o3) : \ 119 __SYSCALL_CLOBBERS); \ 120 __o0; \ 121 }) 122 123 #define internal_syscall5(string,name,arg1,arg2,arg3,arg4,arg5) \ 124 ({ \ 125 long int _arg1 = (long int) (arg1); \ 126 long int _arg2 = (long int) (arg2); \ 127 long int _arg3 = (long int) (arg3); \ 128 long int _arg4 = (long int) (arg4); \ 129 long int _arg5 = (long int) (arg5); \ 130 register long int __g1 __asm__("g1") = (name); \ 131 register long int __o0 __asm__ ("o0") = _arg1; \ 132 register long int __o1 __asm__ ("o1") = _arg2; \ 133 register long int __o2 __asm__ ("o2") = _arg3; \ 134 register long int __o3 __asm__ ("o3") = _arg4; \ 135 register long int __o4 __asm__ ("o4") = _arg5; \ 136 __asm __volatile (string : "=r" (__o0) : \ 137 "r" (__g1), "0" (__o0), "r" (__o1), \ 138 "r" (__o2), "r" (__o3), "r" (__o4) : \ 139 __SYSCALL_CLOBBERS); \ 140 __o0; \ 141 }) 142 143 #define internal_syscall6(string,name,arg1,arg2,arg3,arg4,arg5,arg6) \ 144 ({ \ 145 long int _arg1 = (long int) (arg1); \ 146 long int _arg2 = (long int) (arg2); \ 147 long int _arg3 = (long int) (arg3); \ 148 long int _arg4 = (long int) (arg4); \ 149 long int _arg5 = (long int) (arg5); \ 150 long int _arg6 = (long int) (arg6); \ 151 register long int __g1 __asm__("g1") = (name); \ 152 register long int __o0 __asm__ ("o0") = _arg1; \ 153 register long int __o1 __asm__ ("o1") = _arg2; \ 154 register long int __o2 __asm__ ("o2") = _arg3; \ 155 register long int __o3 __asm__ ("o3") = _arg4; \ 156 register long int __o4 __asm__ ("o4") = _arg5; \ 157 register long int __o5 __asm__ ("o5") = _arg6; \ 158 __asm __volatile (string : "=r" (__o0) : \ 159 "r" (__g1), "0" (__o0), "r" (__o1), \ 160 "r" (__o2), "r" (__o3), "r" (__o4), \ 161 "r" (__o5) : \ 162 __SYSCALL_CLOBBERS); \ 163 __o0; \ 164 }) 165 166 #define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5) \ 167 ({ \ 168 long int _arg1 = (long int) (arg1); \ 169 long int _arg2 = (long int) (arg2); \ 170 long int _arg3 = (long int) (arg3); \ 171 long int _arg4 = (long int) (arg4); \ 172 long int _arg5 = (long int) (arg5); \ 173 register long int __o0 __asm__ ("o0") = _arg1; \ 174 register long int __o1 __asm__ ("o1") = _arg2; \ 175 register long int __o2 __asm__ ("o2") = _arg3; \ 176 register long int __o3 __asm__ ("o3") = _arg4; \ 177 register long int __o4 __asm__ ("o4") = _arg5; \ 178 register long int __g1 __asm__ ("g1") = __NR_clone; \ 179 __asm __volatile (__SYSCALL_STRING : \ 180 "=r" (__o0), "=r" (__o1) : \ 181 "r" (__g1), "0" (__o0), "1" (__o1), \ 182 "r" (__o2), "r" (__o3), "r" (__o4) : \ 183 __SYSCALL_CLOBBERS); \ 184 if (__glibc_unlikely ((unsigned long int) (__o0) > -4096UL)) \ 185 { \ 186 __set_errno (-__o0); \ 187 __o0 = -1L; \ 188 } \ 189 else \ 190 { \ 191 __o0 &= (__o1 - 1); \ 192 } \ 193 __o0; \ 194 }) 195 196 #endif /* __ASSEMBLER__ */ 197 198 #endif /* _LINUX_SPARC_SYSDEP_H */ 199