aboutsummaryrefslogtreecommitdiff
blob: dcabb57fe28e5717bf54315eee6c3173d32e4d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/* Copyright (C) 2000-2024 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <https://www.gnu.org/licenses/>.  */

#ifndef _LINUX_SPARC_SYSDEP_H
#define _LINUX_SPARC_SYSDEP_H 1

#include <sysdeps/unix/sysdep.h>
#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/sparc/sysdep.h>

#ifdef __ASSEMBLER__

#define	ret		retl; nop
#define	ret_NOERRNO	retl; nop
#define	ret_ERRVAL	retl; nop
#define	r0		%o0
#define	r1		%o1
#define	MOVE(x,y)	mov x, y

#else	/* __ASSEMBLER__ */

# define VDSO_NAME  "LINUX_2.6"
# define VDSO_HASH  61765110

/* List of system calls which are supported as vsyscalls.  */
# ifdef __arch64__
#  define HAVE_CLOCK_GETTIME64_VSYSCALL	"__vdso_clock_gettime"
# else
#  define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_clock_gettime"
# endif
# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"

#undef INTERNAL_SYSCALL
#define INTERNAL_SYSCALL(name, nr, args...) \
  internal_syscall##nr(__SYSCALL_STRING, __NR_##name, args)

#undef INTERNAL_SYSCALL_NCS
#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
  internal_syscall##nr(__SYSCALL_STRING, name, args)

#define internal_syscall0(string,name,dummy...)			\
({									\
	register long int __g1 __asm__ ("g1") = (name);			\
	register long __o0 __asm__ ("o0");				\
	__asm __volatile (string : "=r" (__o0) :			\
			  "r" (__g1) :					\
			  __SYSCALL_CLOBBERS);				\
	__o0;								\
})

#define internal_syscall1(string,name,arg1)				\
({									\
	long int _arg1 = (long int) (arg1);				\
	register long int __g1 __asm__("g1") = (name);			\
	register long int  __o0 __asm__ ("o0") = _arg1;			\
	__asm __volatile (string : "=r" (__o0) :			\
			  "r" (__g1), "0" (__o0) :			\
			  __SYSCALL_CLOBBERS);				\
	__o0;								\
})

#define internal_syscall2(string,name,arg1,arg2)			\
({									\
	long int _arg1 = (long int) (arg1);				\
	long int _arg2 = (long int) (arg2);				\
	register long int __g1 __asm__("g1") = (name);			\
	register long int __o0 __asm__ ("o0") = _arg1;			\
	register long int __o1 __asm__ ("o1") = _arg2;			\
	__asm __volatile (string : "=r" (__o0) :			\
			  "r" (__g1), "0" (__o0), "r" (__o1) :		\
			  __SYSCALL_CLOBBERS);				\
	__o0;								\
})

#define internal_syscall3(string,name,arg1,arg2,arg3)			\
({									\
	long int _arg1 = (long int) (arg1);				\
	long int _arg2 = (long int) (arg2);				\
	long int _arg3 = (long int) (arg3);				\
	register long int __g1 __asm__("g1") = (name);			\
	register long int __o0 __asm__ ("o0") = _arg1;			\
	register long int __o1 __asm__ ("o1") = _arg2;			\
	register long int __o2 __asm__ ("o2") = _arg3;			\
	__asm __volatile (string : "=r" (__o0) :			\
			  "r" (__g1), "0" (__o0), "r" (__o1),		\
			  "r" (__o2) :					\
			  __SYSCALL_CLOBBERS);				\
	__o0;								\
})

#define internal_syscall4(string,name,arg1,arg2,arg3,arg4)		\
({									\
	long int _arg1 = (long int) (arg1);				\
	long int _arg2 = (long int) (arg2);				\
	long int _arg3 = (long int) (arg3);				\
	long int _arg4 = (long int) (arg4);				\
	register long int __g1 __asm__("g1") = (name);			\
	register long int __o0 __asm__ ("o0") = _arg1;			\
	register long int __o1 __asm__ ("o1") = _arg2;			\
	register long int __o2 __asm__ ("o2") = _arg3;			\
	register long int __o3 __asm__ ("o3") = _arg4;			\
	__asm __volatile (string : "=r" (__o0) :			\
			  "r" (__g1), "0" (__o0), "r" (__o1),		\
			  "r" (__o2), "r" (__o3) :			\
			  __SYSCALL_CLOBBERS);				\
	__o0;								\
})

#define internal_syscall5(string,name,arg1,arg2,arg3,arg4,arg5)		\
({									\
	long int _arg1 = (long int) (arg1);				\
	long int _arg2 = (long int) (arg2);				\
	long int _arg3 = (long int) (arg3);				\
	long int _arg4 = (long int) (arg4);				\
	long int _arg5 = (long int) (arg5);				\
	register long int __g1 __asm__("g1") = (name);			\
	register long int __o0 __asm__ ("o0") = _arg1;			\
	register long int __o1 __asm__ ("o1") = _arg2;			\
	register long int __o2 __asm__ ("o2") = _arg3;			\
	register long int __o3 __asm__ ("o3") = _arg4;			\
	register long int __o4 __asm__ ("o4") = _arg5;			\
	__asm __volatile (string : "=r" (__o0) :			\
			  "r" (__g1), "0" (__o0), "r" (__o1),		\
			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
			  __SYSCALL_CLOBBERS);				\
	__o0;								\
})

#define internal_syscall6(string,name,arg1,arg2,arg3,arg4,arg5,arg6)	\
({									\
	long int _arg1 = (long int) (arg1);				\
	long int _arg2 = (long int) (arg2);				\
	long int _arg3 = (long int) (arg3);				\
	long int _arg4 = (long int) (arg4);				\
	long int _arg5 = (long int) (arg5);				\
	long int _arg6 = (long int) (arg6);				\
	register long int __g1 __asm__("g1") = (name);			\
	register long int __o0 __asm__ ("o0") = _arg1;			\
	register long int __o1 __asm__ ("o1") = _arg2;			\
	register long int __o2 __asm__ ("o2") = _arg3;			\
	register long int __o3 __asm__ ("o3") = _arg4;			\
	register long int __o4 __asm__ ("o4") = _arg5;			\
	register long int __o5 __asm__ ("o5") = _arg6;			\
	__asm __volatile (string : "=r" (__o0) :			\
			  "r" (__g1), "0" (__o0), "r" (__o1),		\
			  "r" (__o2), "r" (__o3), "r" (__o4),		\
			  "r" (__o5) :					\
			  __SYSCALL_CLOBBERS);				\
	__o0;								\
})

#define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5)			\
({									\
	long int _arg1 = (long int) (arg1);				\
	long int _arg2 = (long int) (arg2);				\
	long int _arg3 = (long int) (arg3);				\
	long int _arg4 = (long int) (arg4);				\
	long int _arg5 = (long int) (arg5);				\
	register long int __o0 __asm__ ("o0") = _arg1;			\
	register long int __o1 __asm__ ("o1") = _arg2;			\
	register long int __o2 __asm__ ("o2") = _arg3;			\
	register long int __o3 __asm__ ("o3") = _arg4;			\
	register long int __o4 __asm__ ("o4") = _arg5;			\
	register long int __g1 __asm__ ("g1") = __NR_clone;		\
	__asm __volatile (__SYSCALL_STRING :				\
			  "=r" (__o0), "=r" (__o1) :			\
			  "r" (__g1), "0" (__o0), "1" (__o1),		\
			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
			  __SYSCALL_CLOBBERS);				\
	if (__glibc_unlikely ((unsigned long int) (__o0) > -4096UL))	\
	  {		     			       		   	\
	    __set_errno (-__o0);					\
	    __o0 = -1L;			    				\
	  } 	      							\
	else								\
	  { 	      							\
	    __o0 &= (__o1 - 1);						\
	  } 	    	    						\
	__o0;								\
})

#endif	/* __ASSEMBLER__ */

#endif /* _LINUX_SPARC_SYSDEP_H */