summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/avr32/syscall.S
blob: 55c1b1fa29d5f890ff9b87f8dc48d755584644ec (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
/*
 * Copyright (C) 2004-2007 Atmel Corporation
 *
 * This file is subject to the terms and conditions of the GNU Lesser General
 * Public License.  See the file "COPYING.LIB" in the main directory of this
 * archive for more details.
 */
#include <features.h>

	.text

	/*
	 * long int syscall(long int sysno, ...)
	 */
	.global	syscall
	.type	syscall, @function
	.align	2
syscall:
	stm	--sp, r3,r5,r6,lr
	sub	lr, sp, -16
	mov	r8, r12
	ldm	lr, r3,r5,r9-r12
	scall
	cp.w	r12, -4095
	brlo	.Ldone

#ifdef __PIC__
	lddpc	r6, .Lgot
.Lgotcalc:
	rsub	r6, pc
# ifdef __UCLIBC_HAS_THREADS__
	rsub	r3, r12, 0
	mcall	r6[__errno_location@got]
	st.w	r12[0], r3
# else
	ld.w	r3, r6[errno@got]
	neg	r12
	st.w	r3[0], r12
# endif
#else
# ifdef __UCLIBC_HAS_THREADS__
	rsub	r3, r12, 0
	mcall	.Lerrno_location
	st.w	r12[0], r3
# else
	lddpc	r3, .Lerrno
	neg	r12
	st.w	r3[0], r12
# endif
#endif
	mov	r12, -1

.Ldone:
	ldm	sp++, r3,r5,r6,pc

	.align	2
#ifdef __PIC__
.Lgot:
	.long	.Lgotcalc - _GLOBAL_OFFSET_TABLE_
#else
# ifdef __UCLIBC_HAS_THREADS__
.Lerrno_location:
	.long	__errno_location
# else
.Lerrno:
	.long	errno
# endif
#endif


	.size	syscall, . - syscall