diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/common/bit_cast.h | 22 | ||||
| -rw-r--r-- | src/common/logging/backend.cpp | 1 | ||||
| -rw-r--r-- | src/common/logging/log.h | 1 | ||||
| -rw-r--r-- | src/common/virtual_buffer.h | 7 |
5 files changed, 31 insertions, 1 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 207c7a0a6..d20e6c3b5 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -102,6 +102,7 @@ add_library(common STATIC | |||
| 102 | atomic_ops.h | 102 | atomic_ops.h |
| 103 | detached_tasks.cpp | 103 | detached_tasks.cpp |
| 104 | detached_tasks.h | 104 | detached_tasks.h |
| 105 | bit_cast.h | ||
| 105 | bit_field.h | 106 | bit_field.h |
| 106 | bit_util.h | 107 | bit_util.h |
| 107 | cityhash.cpp | 108 | cityhash.cpp |
diff --git a/src/common/bit_cast.h b/src/common/bit_cast.h new file mode 100644 index 000000000..a32a063d1 --- /dev/null +++ b/src/common/bit_cast.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | // Copyright 2020 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <cstring> | ||
| 8 | #include <type_traits> | ||
| 9 | |||
| 10 | namespace Common { | ||
| 11 | |||
| 12 | template <typename To, typename From> | ||
| 13 | [[nodiscard]] std::enable_if_t<sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> && | ||
| 14 | std::is_trivially_copyable_v<To>, | ||
| 15 | To> | ||
| 16 | BitCast(const From& src) noexcept { | ||
| 17 | To dst; | ||
| 18 | std::memcpy(&dst, &src, sizeof(To)); | ||
| 19 | return dst; | ||
| 20 | } | ||
| 21 | |||
| 22 | } // namespace Common | ||
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 90dfa22ca..7859344b9 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -222,6 +222,7 @@ void DebuggerBackend::Write(const Entry& entry) { | |||
| 222 | SUB(Service, NPNS) \ | 222 | SUB(Service, NPNS) \ |
| 223 | SUB(Service, NS) \ | 223 | SUB(Service, NS) \ |
| 224 | SUB(Service, NVDRV) \ | 224 | SUB(Service, NVDRV) \ |
| 225 | SUB(Service, OLSC) \ | ||
| 225 | SUB(Service, PCIE) \ | 226 | SUB(Service, PCIE) \ |
| 226 | SUB(Service, PCTL) \ | 227 | SUB(Service, PCTL) \ |
| 227 | SUB(Service, PCV) \ | 228 | SUB(Service, PCV) \ |
diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 13a4f1e30..835894918 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h | |||
| @@ -95,6 +95,7 @@ enum class Class : ClassType { | |||
| 95 | Service_NPNS, ///< The NPNS service | 95 | Service_NPNS, ///< The NPNS service |
| 96 | Service_NS, ///< The NS services | 96 | Service_NS, ///< The NS services |
| 97 | Service_NVDRV, ///< The NVDRV (Nvidia driver) service | 97 | Service_NVDRV, ///< The NVDRV (Nvidia driver) service |
| 98 | Service_OLSC, ///< The OLSC service | ||
| 98 | Service_PCIE, ///< The PCIe service | 99 | Service_PCIE, ///< The PCIe service |
| 99 | Service_PCTL, ///< The PCTL (Parental control) service | 100 | Service_PCTL, ///< The PCTL (Parental control) service |
| 100 | Service_PCV, ///< The PCV service | 101 | Service_PCV, ///< The PCV service |
diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index 078e61c77..91d430036 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h | |||
| @@ -43,9 +43,14 @@ public: | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | void resize(std::size_t count) { | 45 | void resize(std::size_t count) { |
| 46 | const auto new_size = count * sizeof(T); | ||
| 47 | if (new_size == alloc_size) { | ||
| 48 | return; | ||
| 49 | } | ||
| 50 | |||
| 46 | FreeMemoryPages(base_ptr, alloc_size); | 51 | FreeMemoryPages(base_ptr, alloc_size); |
| 47 | 52 | ||
| 48 | alloc_size = count * sizeof(T); | 53 | alloc_size = new_size; |
| 49 | base_ptr = reinterpret_cast<T*>(AllocateMemoryPages(alloc_size)); | 54 | base_ptr = reinterpret_cast<T*>(AllocateMemoryPages(alloc_size)); |
| 50 | } | 55 | } |
| 51 | 56 | ||