xref: /aosp_15_r20/external/llvm-libc/src/__support/OSUtil/darwin/syscall.h (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===---------------------- Darwin 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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_DARWIN_SYSCALL_H
10 #define LLVM_LIBC_SRC___SUPPORT_OSUTIL_DARWIN_SYSCALL_H
11 
12 #include "src/__support/CPP/bit.h"
13 #include "src/__support/common.h"
14 #include "src/__support/macros/config.h"
15 #include "src/__support/macros/properties/architectures.h"
16 
17 #ifdef LIBC_TARGET_ARCH_IS_ANY_ARM
18 #include "arm/syscall.h"
19 #else
20 #error "Unsupported architecture"
21 #endif
22 
23 namespace LIBC_NAMESPACE_DECL {
24 
25 template <typename R, typename... Ts>
syscall_impl(long __number,Ts...ts)26 LIBC_INLINE R syscall_impl(long __number, Ts... ts) {
27   static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall");
28   return cpp::bit_or_static_cast<R>(syscall_impl(__number, (long)ts...));
29 }
30 
31 } // namespace LIBC_NAMESPACE_DECL
32 
33 #endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_DARWIN_SYSCALL_H
34