HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
architecture.hpp
1// Copyright Take Vos 2019-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
10#pragma once
11
12#include "../macros.hpp"
13
14#include <exception>
15#include <cstddef>
16#include <type_traits>
17#if defined(__APPLE__)
18#include <TargetConditionals.h>
19#endif
20
21hi_export_module(hikogui.utility.architecture);
22
23hi_export namespace hi::inline v1 {
24
25#if HI_PROCESSOR == HI_CPU_X86
26constexpr std::size_t hardware_destructive_interference_size = 128;
27constexpr std::size_t hardware_constructive_interference_size = 64;
28using intreg_t = int32_t;
29using uintreg_t = uint32_t;
30#elif HI_PROCESSOR == HI_CPU_X64
31constexpr std::size_t hardware_destructive_interference_size = 128;
32constexpr std::size_t hardware_constructive_interference_size = 64;
33using intreg_t = int64_t;
34using uintreg_t = uint64_t;
35#elif HI_PROCESSOR == HI_CPU_ARM
36constexpr std::size_t hardware_destructive_interference_size = 128;
37constexpr std::size_t hardware_constructive_interference_size = 64;
38using intreg_t = int32_t;
39using uintreg_t = uint32_t;
40#elif HI_PROCESSOR == HI_CPU_ARM64
41constexpr std::size_t hardware_destructive_interference_size = 128;
42constexpr std::size_t hardware_constructive_interference_size = 64;
43using intreg_t = int64_t;
44using uintreg_t = uint64_t;
45#else
46#error "missing implementation for CPU specific register and cache-line sizes"
47#endif
48
49
50#if (HI_COMPILER == HI_CC_GCC || HI_COMPILER == HI_CC_CLANG) && (HI_PROCESSOR == HI_CPU_X64 || HI_PROCESSOR == HI_CPU_ARM64)
51#define HI_HAS_INT128 1
55
58using uint128_t = unsigned __int128;
59
60#endif
61
62#if HI_OPERATING_SYSTEM == HI_OS_WINDOWS
63using os_handle = void *;
64using file_handle = os_handle;
65using thread_id = uint32_t;
66constexpr std::size_t maximum_num_cpus = 64;
67
68#elif HI_OPERATING_SYSTEM == HI_OS_MACOS
69using os_handle = int;
70using file_handle = int;
71using thread_id = uint32_t;
72constexpr std::size_t maximum_num_cpus = CPU_SETSIZE;
73
74#elif HI_OPERATING_SYSTEM == HI_OS_LINUX
75using os_handle = int;
76using file_handle = int;
77using thread_id = uint32_t;
78constexpr std::size_t maximum_num_cpus = CPU_SETSIZE;
79
80#else
81#error "Not implemented."
82#endif
83
84
85} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:16
__int128 int128_t
Signed 128 bit integer.
Definition architecture.hpp:54
unsigned __int128 uint128_t
Unsigned 128 bit integer.
Definition architecture.hpp:58
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377