| 1 | /* Copyright (C) 2000-2026 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, "p", name, args) |
| 54 | |
| 55 | #define _internal_syscall0(string,nc,name,dummy...)	\ |
| 56 | ({									\ |
| 57 | 	register long __o0 __asm__ ("o0");				\ |
| 58 | 	long int _name = (long int) (name);				\ |
| 59 | 	__asm __volatile (string : "=r" (__o0) :			\ |
| 60 | 			 [scn] nc (_name) :				\ |
| 61 | 			 __SYSCALL_CLOBBERS);				\ |
| 62 | 	__o0;								\ |
| 63 | }) |
| 64 | #define internal_syscall0(string,name,args...)				\ |
| 65 | _internal_syscall0(string, "i", name, args) |
| 66 | |
| 67 | #define _internal_syscall1(string,nc,name,arg1)				\ |
| 68 | ({									\ |
| 69 | 	long int _arg1 = (long int) (arg1);				\ |
| 70 | 	long int _name = (long int) (name);				\ |
| 71 | 	register long int __o0 __asm__ ("o0") = _arg1;			\ |
| 72 | 	__asm __volatile (string : "+r" (__o0) :			\ |
| 73 | 			 [scn] nc (_name) :				\ |
| 74 | 			 __SYSCALL_CLOBBERS);				\ |
| 75 | 	__o0;								\ |
| 76 | }) |
| 77 | #define internal_syscall1(string,name,args...)				\ |
| 78 | _internal_syscall1(string, "i", name, args) |
| 79 | |
| 80 | #define _internal_syscall2(string,nc,name,arg1,arg2)			\ |
| 81 | ({									\ |
| 82 | 	long int _arg1 = (long int) (arg1);				\ |
| 83 | 	long int _arg2 = (long int) (arg2);				\ |
| 84 | 	long int _name = (long int) (name);				\ |
| 85 | 	register long int __o0 __asm__ ("o0") = _arg1;			\ |
| 86 | 	register long int __o1 __asm__ ("o1") = _arg2;			\ |
| 87 | 	__asm __volatile (string : "+r" (__o0) :			\ |
| 88 | 			 [scn] nc (_name), "r" (__o1) :		\ |
| 89 | 			 __SYSCALL_CLOBBERS);				\ |
| 90 | 	__o0;								\ |
| 91 | }) |
| 92 | #define internal_syscall2(string,name,args...)				\ |
| 93 | _internal_syscall2(string, "i", name, args) |
| 94 | |
| 95 | #define _internal_syscall3(string,nc,name,arg1,arg2,arg3)		\ |
| 96 | ({									\ |
| 97 | 	long int _arg1 = (long int) (arg1);				\ |
| 98 | 	long int _arg2 = (long int) (arg2);				\ |
| 99 | 	long int _arg3 = (long int) (arg3);				\ |
| 100 | 	long int _name = (long int) (name);				\ |
| 101 | 	register long int __o0 __asm__ ("o0") = _arg1;			\ |
| 102 | 	register long int __o1 __asm__ ("o1") = _arg2;			\ |
| 103 | 	register long int __o2 __asm__ ("o2") = _arg3;			\ |
| 104 | 	__asm __volatile (string : "+r" (__o0) :			\ |
| 105 | 			 [scn] nc (_name), "r" (__o1),			\ |
| 106 | 			 "r" (__o2) :					\ |
| 107 | 			 __SYSCALL_CLOBBERS);				\ |
| 108 | 	__o0;								\ |
| 109 | }) |
| 110 | #define internal_syscall3(string,name,args...)				\ |
| 111 | _internal_syscall3(string, "i", name, args) |
| 112 | |
| 113 | #define _internal_syscall4(string,nc,name,arg1,arg2,arg3,arg4)		\ |
| 114 | ({									\ |
| 115 | 	long int _arg1 = (long int) (arg1);				\ |
| 116 | 	long int _arg2 = (long int) (arg2);				\ |
| 117 | 	long int _arg3 = (long int) (arg3);				\ |
| 118 | 	long int _arg4 = (long int) (arg4);				\ |
| 119 | 	long int _name = (long int) (name);				\ |
| 120 | 	register long int __o0 __asm__ ("o0") = _arg1;			\ |
| 121 | 	register long int __o1 __asm__ ("o1") = _arg2;			\ |
| 122 | 	register long int __o2 __asm__ ("o2") = _arg3;			\ |
| 123 | 	register long int __o3 __asm__ ("o3") = _arg4;			\ |
| 124 | 	__asm __volatile (string : "+r" (__o0) :			\ |
| 125 | 			 [scn] nc (_name), "r" (__o1),			\ |
| 126 | 			 "r" (__o2), "r" (__o3) :			\ |
| 127 | 			 __SYSCALL_CLOBBERS);				\ |
| 128 | 	__o0;								\ |
| 129 | }) |
| 130 | #define internal_syscall4(string,name,args...)				\ |
| 131 | _internal_syscall4(string, "i", name, args) |
| 132 | |
| 133 | #define _internal_syscall5(string,nc,name,arg1,arg2,arg3,arg4,arg5)	\ |
| 134 | ({									\ |
| 135 | 	long int _arg1 = (long int) (arg1);				\ |
| 136 | 	long int _arg2 = (long int) (arg2);				\ |
| 137 | 	long int _arg3 = (long int) (arg3);				\ |
| 138 | 	long int _arg4 = (long int) (arg4);				\ |
| 139 | 	long int _arg5 = (long int) (arg5);				\ |
| 140 | 	long int _name = (long int) (name);				\ |
| 141 | 	register long int __o0 __asm__ ("o0") = _arg1;			\ |
| 142 | 	register long int __o1 __asm__ ("o1") = _arg2;			\ |
| 143 | 	register long int __o2 __asm__ ("o2") = _arg3;			\ |
| 144 | 	register long int __o3 __asm__ ("o3") = _arg4;			\ |
| 145 | 	register long int __o4 __asm__ ("o4") = _arg5;			\ |
| 146 | 	__asm __volatile (string : "+r" (__o0) :			\ |
| 147 | 			 [scn] nc (_name), "r" (__o1),			\ |
| 148 | 			 "r" (__o2), "r" (__o3), "r" (__o4) :		\ |
| 149 | 			 __SYSCALL_CLOBBERS);				\ |
| 150 | 	__o0;								\ |
| 151 | }) |
| 152 | #define internal_syscall5(string,name,args...)				\ |
| 153 | _internal_syscall5(string, "i", name, args) |
| 154 | |
| 155 | #define _internal_syscall6(string,nc,name,arg1,arg2,arg3,arg4,arg5,arg6)\ |
| 156 | ({									\ |
| 157 | 	long int _arg1 = (long int) (arg1);				\ |
| 158 | 	long int _arg2 = (long int) (arg2);				\ |
| 159 | 	long int _arg3 = (long int) (arg3);				\ |
| 160 | 	long int _arg4 = (long int) (arg4);				\ |
| 161 | 	long int _arg5 = (long int) (arg5);				\ |
| 162 | 	long int _arg6 = (long int) (arg6);				\ |
| 163 | 	long int _name = (long int) (name);				\ |
| 164 | 	register long int __o0 __asm__ ("o0") = _arg1;			\ |
| 165 | 	register long int __o1 __asm__ ("o1") = _arg2;			\ |
| 166 | 	register long int __o2 __asm__ ("o2") = _arg3;			\ |
| 167 | 	register long int __o3 __asm__ ("o3") = _arg4;			\ |
| 168 | 	register long int __o4 __asm__ ("o4") = _arg5;			\ |
| 169 | 	register long int __o5 __asm__ ("o5") = _arg6;			\ |
| 170 | 	__asm __volatile (string : "+r" (__o0) :			\ |
| 171 | 			 [scn] nc (_name), "r" (__o1),			\ |
| 172 | 			 "r" (__o2), "r" (__o3), "r" (__o4),		\ |
| 173 | 			 "r" (__o5) :					\ |
| 174 | 			 __SYSCALL_CLOBBERS);				\ |
| 175 | 	__o0;								\ |
| 176 | }) |
| 177 | #define internal_syscall6(string,name,args...)				\ |
| 178 | _internal_syscall6(string, "i", name, args) |
| 179 | |
| 180 | #define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5)			\ |
| 181 | ({									\ |
| 182 | 	long int _arg1 = (long int) (arg1);				\ |
| 183 | 	long int _arg2 = (long int) (arg2);				\ |
| 184 | 	long int _arg3 = (long int) (arg3);				\ |
| 185 | 	long int _arg4 = (long int) (arg4);				\ |
| 186 | 	long int _arg5 = (long int) (arg5);				\ |
| 187 | 	long int _name = __NR_clone;					\ |
| 188 | 	register long int __o0 __asm__ ("o0") = _arg1;			\ |
| 189 | 	register long int __o1 __asm__ ("o1") = _arg2;			\ |
| 190 | 	register long int __o2 __asm__ ("o2") = _arg3;			\ |
| 191 | 	register long int __o3 __asm__ ("o3") = _arg4;			\ |
| 192 | 	register long int __o4 __asm__ ("o4") = _arg5;			\ |
| 193 | 	__asm __volatile (__SYSCALL_STRING :				\ |
| 194 | 			 "=r" (__o0), "=r" (__o1) :			\ |
| 195 | 			 [scn] "i" (_name), "0" (__o0), "1" (__o1),	\ |
| 196 | 			 "r" (__o2), "r" (__o3), "r" (__o4) :		\ |
| 197 | 			 __SYSCALL_CLOBBERS);				\ |
| 198 | 	if (__glibc_unlikely ((unsigned long int) (__o0) > -4096UL))	\ |
| 199 | 	 {		 			 		 	\ |
| 200 | 	 __set_errno (-__o0);					\ |
| 201 | 	 __o0 = -1L;			 				\ |
| 202 | 	 } 	 							\ |
| 203 | 	else								\ |
| 204 | 	 { 	 							\ |
| 205 | 	 __o0 &= (__o1 - 1);						\ |
| 206 | 	 } 	 	 						\ |
| 207 | 	__o0;								\ |
| 208 | }) |
| 209 | |
| 210 | #endif	/* __ASSEMBLER__ */ |
| 211 | |
| 212 | #endif /* _LINUX_SPARC_SYSDEP_H */ |