1 //===----------------------- Linux syscalls ---------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_H
10 #define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_H
12 #include "src/__support/CPP/bit.h"
13 #include "src/__support/common.h"
14 #include "src/__support/macros/properties/architectures.h"
16 #ifdef LIBC_TARGET_ARCH_IS_X86_64
17 #include "x86_64/syscall.h"
18 #elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
19 #include "aarch64/syscall.h"
20 #elif defined(LIBC_TARGET_ARCH_IS_ARM)
21 #include "arm/syscall.h"
22 #elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
23 #include "riscv/syscall.h"
26 namespace LIBC_NAMESPACE
{
28 template <typename R
, typename
... Ts
>
29 LIBC_INLINE R
syscall_impl(long __number
, Ts
... ts
) {
30 static_assert(sizeof...(Ts
) <= 6, "Too many arguments for syscall");
31 return cpp::bit_or_static_cast
<R
>(syscall_impl(__number
, (long)ts
...));
34 } // namespace LIBC_NAMESPACE
36 #endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_H