summaryrefslogtreecommitdiff
path: root/klibc/klibc/arch/x86_64/syscall.S
blob: f2c74ae974d8c5a9ef4726d4f55a1d190b88a158 (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
/*
 * arch/x86-64/syscall.S
 *
 * Common tail-handling code for system calls.
 *
 * The arguments are in the standard argument registers; the system
 * call number in %eax.
 */
	.text
	.align	4
	.globl	__syscall_common
	.type	__syscall_common,@function
__syscall_common:
	movq	%rcx,%r10		# The kernel uses %r10 istf %rcx
	syscall

	cmpq	$-4095,%rax
	jb	1f

	# Error return, must set errno
	negl	%eax
	movl	%eax,errno(%rip)	# errno is type int, so 32 bits
	orq	$-1,%rax		# orq $-1 smaller than movq $-1

1:
	ret

	.size	__syscall_common,.-__syscall_common