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 __attribute__((always_inline)) inline long syscall(long __number) {
19 LIBC_INLINE_ASM("syscall" :
22 SYSCALL_CLOBBER_LIST);
26 __attribute__((always_inline)) inline long syscall(long __number, long __arg1) {
28 LIBC_INLINE_ASM("syscall" :
30 "a"(__number), "D"(__arg1) :
31 SYSCALL_CLOBBER_LIST);
35 __attribute__((always_inline)) inline long syscall(
36 long __number, long __arg1, long __arg2) {
38 LIBC_INLINE_ASM("syscall" :
40 "a"(__number), "D"(__arg1), "S"(__arg2) :
41 SYSCALL_CLOBBER_LIST);
45 __attribute__((always_inline)) inline long syscall(
46 long __number, long __arg1, long __arg2, long __arg3) {
48 LIBC_INLINE_ASM("syscall" :
50 "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3) :
51 SYSCALL_CLOBBER_LIST);
55 __attribute__((always_inline)) inline long syscall(
56 long __number, long __arg1, long __arg2, long __arg3, long __arg4) {
58 register long r10 __asm__("r10") = __arg4;
59 LIBC_INLINE_ASM("syscall" :
61 "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10) :
62 SYSCALL_CLOBBER_LIST);
66 __attribute__((always_inline)) inline long syscall(
67 long __number, long __arg1, long __arg2, long __arg3, long __arg4,
70 register long r10 __asm__("r10") = __arg4;
71 register long r8 __asm__("r8") = __arg5;
75 "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10), "r"(r8) :
76 SYSCALL_CLOBBER_LIST);
80 __attribute__((always_inline)) inline long syscall(
81 long __number, long __arg1, long __arg2, long __arg3, long __arg4,
82 long __arg5, long __arg6) {
84 register long r10 __asm__("r10") = __arg4;
85 register long r8 __asm__("r8") = __arg5;
86 register long r9 __asm__("r9") = __arg6;
90 "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10), "r"(r8), "r"(r9) :
91 SYSCALL_CLOBBER_LIST);
95 #undef SYSCALL_CLOBBER_LIST
97 } // namespace __llvm_libc