1 //===------------ inline implementation of x86_64 syscalls --------------*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 #include "src/__support/common.h"
13 #define SYSCALL_CLOBBER_LIST "rcx", "r11", "memory"
15 namespace __llvm_libc {
17 inline long syscall(long __number) {
19 LIBC_INLINE_ASM("syscall" :
22 SYSCALL_CLOBBER_LIST);
26 inline long syscall(long __number, long __arg1) {
28 LIBC_INLINE_ASM("syscall" :
30 "a"(__number), "D"(__arg1) :
31 SYSCALL_CLOBBER_LIST);
35 inline long syscall(long __number, long __arg1, long __arg2) {
37 LIBC_INLINE_ASM("syscall" :
39 "a"(__number), "D"(__arg1), "S"(__arg2) :
40 SYSCALL_CLOBBER_LIST);
44 inline long syscall(long __number, long __arg1, long __arg2, long __arg3) {
46 LIBC_INLINE_ASM("syscall" :
48 "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3) :
49 SYSCALL_CLOBBER_LIST);
54 long __number, long __arg1, long __arg2, long __arg3, long __arg4) {
56 register long r10 __asm__("r10") = __arg4;
57 LIBC_INLINE_ASM("syscall" :
59 "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10) :
60 SYSCALL_CLOBBER_LIST);
64 inline long syscall(long __number, long __arg1, long __arg2, long __arg3,
65 long __arg4, long __arg5) {
67 register long r10 __asm__("r10") = __arg4;
68 register long r8 __asm__("r8") = __arg5;
72 "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10), "r"(r8) :
73 SYSCALL_CLOBBER_LIST);
77 inline long syscall(long __number, long __arg1, long __arg2, long __arg3,
78 long __arg4, long __arg5, long __arg6) {
80 register long r10 __asm__("r10") = __arg4;
81 register long r8 __asm__("r8") = __arg5;
82 register long r9 __asm__("r9") = __arg6;
86 "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10), "r"(r8), "r"(r9) :
87 SYSCALL_CLOBBER_LIST);
91 #undef SYSCALL_CLOBBER_LIST
93 } // namespace __llvm_libc