blob: 0eb83a3d9d11252e660410048f82bddc1179440a [file]
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Syscall wrapper for getcpu.
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_WRAPPERS_GETCPU_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_WRAPPERS_GETCPU_H
#include "src/__support/OSUtil/linux/syscall.h" // syscall_checked
#include "src/__support/common.h"
#include "src/__support/error_or.h"
#include "src/__support/macros/config.h"
#include <sys/syscall.h> // For syscall numbers
namespace LIBC_NAMESPACE_DECL {
namespace linux_syscalls {
// The third argument of the raw syscall (the obsolete tcache pointer) is left
// out: per getcpu(2), it is unused since Linux 2.6.24 and should be specified
// as NULL when invoking the system call directly.
// https://man7.org/linux/man-pages/man2/getcpu.2.html
LIBC_INLINE ErrorOr<int> getcpu(unsigned int *cpu, unsigned int *node) {
return syscall_checked<int>(SYS_getcpu, cpu, node, nullptr);
}
} // namespace linux_syscalls
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_SYSCALL_WRAPPERS_GETCPU_H