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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_SRC_THREADS_LINUX_FUTEX_H
10 #define LLVM_LIBC_SRC_THREADS_LINUX_FUTEX_H
11 
12 #include "src/__support/architectures.h" // Architecture macros
13 
14 namespace __llvm_libc {
15 
16 #if (defined(LLVM_LIBC_ARCH_AARCH64) || defined(LLVM_LIBC_ARCH_X86_64))
17 // The futex data has to be exactly 4 bytes long. However, we use a uint type
18 // here as we do not want to use `uint32_t` type to match the public definitions
19 // of types which include a field for a futex word. With public definitions, we
20 // cannot include <stdint.h> so we stick to the `unsigned int` type for x86_64
21 // and aarch64
22 using FutexWordType = unsigned int;
23 static_assert(sizeof(FutexWordType) == 4,
24               "Unexpected size of unsigned int type.");
25 #else
26 #error "Futex word base type not defined for the target architecture."
27 #endif
28 
29 } // namespace __llvm_libc
30 
31 #endif // LLVM_LIBC_SRC_THREADS_LINUX_FUTEX_H
32