Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libc / src / __support / OSUtil / linux / x86_64 / syscall.h
blobebd77980af6a416bf6c1da9df9ff210659814b85
1 //===---------- inline implementation of x86_64 syscalls ----------* C++ *-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H
10 #define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
15 #define SYSCALL_CLOBBER_LIST "rcx", "r11", "memory"
17 namespace LIBC_NAMESPACE_DECL {
19 LIBC_INLINE long syscall_impl(long __number) {
20 long retcode;
21 LIBC_INLINE_ASM("syscall"
22 : "=a"(retcode)
23 : "a"(__number)
24 : SYSCALL_CLOBBER_LIST);
25 return retcode;
28 LIBC_INLINE long syscall_impl(long __number, long __arg1) {
29 long retcode;
30 LIBC_INLINE_ASM("syscall"
31 : "=a"(retcode)
32 : "a"(__number), "D"(__arg1)
33 : SYSCALL_CLOBBER_LIST);
34 return retcode;
37 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2) {
38 long retcode;
39 LIBC_INLINE_ASM("syscall"
40 : "=a"(retcode)
41 : "a"(__number), "D"(__arg1), "S"(__arg2)
42 : SYSCALL_CLOBBER_LIST);
43 return retcode;
46 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
47 long __arg3) {
48 long retcode;
49 LIBC_INLINE_ASM("syscall"
50 : "=a"(retcode)
51 : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3)
52 : SYSCALL_CLOBBER_LIST);
53 return retcode;
56 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
57 long __arg3, long __arg4) {
58 long retcode;
59 register long r10 __asm__("r10") = __arg4;
60 LIBC_INLINE_ASM("syscall"
61 : "=a"(retcode)
62 : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
63 "r"(r10)
64 : SYSCALL_CLOBBER_LIST);
65 return retcode;
68 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
69 long __arg3, long __arg4, long __arg5) {
70 long retcode;
71 register long r10 __asm__("r10") = __arg4;
72 register long r8 __asm__("r8") = __arg5;
73 LIBC_INLINE_ASM("syscall"
74 : "=a"(retcode)
75 : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
76 "r"(r10), "r"(r8)
77 : SYSCALL_CLOBBER_LIST);
78 return retcode;
81 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
82 long __arg3, long __arg4, long __arg5,
83 long __arg6) {
84 long retcode;
85 register long r10 __asm__("r10") = __arg4;
86 register long r8 __asm__("r8") = __arg5;
87 register long r9 __asm__("r9") = __arg6;
88 LIBC_INLINE_ASM("syscall"
89 : "=a"(retcode)
90 : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
91 "r"(r10), "r"(r8), "r"(r9)
92 : SYSCALL_CLOBBER_LIST);
93 return retcode;
96 #undef SYSCALL_CLOBBER_LIST
97 } // namespace LIBC_NAMESPACE_DECL
99 #endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H