[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / libc / src / threads / linux / Futex.h
blobe7fde14629d53db7bafe292df244ce9dd435236e
1 //===-- Linux futex related definitions -------------------------*- 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_THREADS_LINUX_FUTEX_H
10 #define LLVM_LIBC_SRC_THREADS_LINUX_FUTEX_H
12 #include "src/__support/macros/config.h"
13 #include "src/__support/macros/properties/architectures.h" // Architecture macros
15 namespace LIBC_NAMESPACE_DECL {
17 #if (defined(LIBC_TARGET_ARCH_IS_AARCH64) || \
18 defined(LIBC_TARGET_ARCH_IS_X86_64))
19 // The futex data has to be exactly 4 bytes long. However, we use a uint type
20 // here as we do not want to use `uint32_t` type to match the public definitions
21 // of types which include a field for a futex word. With public definitions, we
22 // cannot include <stdint.h> so we stick to the `unsigned int` type for x86_64
23 // and aarch64
24 using FutexWordType = unsigned int;
25 static_assert(sizeof(FutexWordType) == 4,
26 "Unexpected size of unsigned int type.");
27 #else
28 #error "Futex word base type not defined for the target architecture."
29 #endif
31 } // namespace LIBC_NAMESPACE_DECL
33 #endif // LLVM_LIBC_SRC_THREADS_LINUX_FUTEX_H