summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/fs/file.h11
-rw-r--r--src/common/page_table.cpp1
-rw-r--r--src/common/page_table.h6
-rw-r--r--src/common/point.h57
5 files changed, 72 insertions, 4 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index eafb96b0b..7a4d9e354 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -154,6 +154,7 @@ add_library(common STATIC
154 param_package.cpp 154 param_package.cpp
155 param_package.h 155 param_package.h
156 parent_of_member.h 156 parent_of_member.h
157 point.h
157 quaternion.h 158 quaternion.h
158 ring_buffer.h 159 ring_buffer.h
159 scm_rev.cpp 160 scm_rev.cpp
diff --git a/src/common/fs/file.h b/src/common/fs/file.h
index 209f9664b..50e270c5b 100644
--- a/src/common/fs/file.h
+++ b/src/common/fs/file.h
@@ -117,7 +117,7 @@ template <typename Path>
117} 117}
118#endif 118#endif
119 119
120class IOFile final : NonCopyable { 120class IOFile final {
121public: 121public:
122 IOFile(); 122 IOFile();
123 123
@@ -142,7 +142,10 @@ public:
142 FileType type = FileType::BinaryFile, 142 FileType type = FileType::BinaryFile,
143 FileShareFlag flag = FileShareFlag::ShareReadOnly); 143 FileShareFlag flag = FileShareFlag::ShareReadOnly);
144 144
145 virtual ~IOFile(); 145 ~IOFile();
146
147 IOFile(const IOFile&) = delete;
148 IOFile& operator=(const IOFile&) = delete;
146 149
147 IOFile(IOFile&& other) noexcept; 150 IOFile(IOFile&& other) noexcept;
148 IOFile& operator=(IOFile&& other) noexcept; 151 IOFile& operator=(IOFile&& other) noexcept;
@@ -441,8 +444,8 @@ public:
441 444
442private: 445private:
443 std::filesystem::path file_path; 446 std::filesystem::path file_path;
444 FileAccessMode file_access_mode; 447 FileAccessMode file_access_mode{};
445 FileType file_type; 448 FileType file_type{};
446 449
447 std::FILE* file = nullptr; 450 std::FILE* file = nullptr;
448}; 451};
diff --git a/src/common/page_table.cpp b/src/common/page_table.cpp
index 8fd8620fd..9fffd816f 100644
--- a/src/common/page_table.cpp
+++ b/src/common/page_table.cpp
@@ -14,6 +14,7 @@ void PageTable::Resize(size_t address_space_width_in_bits, size_t page_size_in_b
14 const size_t num_page_table_entries{1ULL << (address_space_width_in_bits - page_size_in_bits)}; 14 const size_t num_page_table_entries{1ULL << (address_space_width_in_bits - page_size_in_bits)};
15 pointers.resize(num_page_table_entries); 15 pointers.resize(num_page_table_entries);
16 backing_addr.resize(num_page_table_entries); 16 backing_addr.resize(num_page_table_entries);
17 current_address_space_width_in_bits = address_space_width_in_bits;
17} 18}
18 19
19} // namespace Common 20} // namespace Common
diff --git a/src/common/page_table.h b/src/common/page_table.h
index 61c5552e0..e92b66b2b 100644
--- a/src/common/page_table.h
+++ b/src/common/page_table.h
@@ -98,6 +98,10 @@ struct PageTable {
98 */ 98 */
99 void Resize(size_t address_space_width_in_bits, size_t page_size_in_bits); 99 void Resize(size_t address_space_width_in_bits, size_t page_size_in_bits);
100 100
101 size_t GetAddressSpaceBits() const {
102 return current_address_space_width_in_bits;
103 }
104
101 /** 105 /**
102 * Vector of memory pointers backing each page. An entry can only be non-null if the 106 * Vector of memory pointers backing each page. An entry can only be non-null if the
103 * corresponding attribute element is of type `Memory`. 107 * corresponding attribute element is of type `Memory`.
@@ -105,6 +109,8 @@ struct PageTable {
105 VirtualBuffer<PageInfo> pointers; 109 VirtualBuffer<PageInfo> pointers;
106 110
107 VirtualBuffer<u64> backing_addr; 111 VirtualBuffer<u64> backing_addr;
112
113 size_t current_address_space_width_in_bits;
108}; 114};
109 115
110} // namespace Common 116} // namespace Common
diff --git a/src/common/point.h b/src/common/point.h
new file mode 100644
index 000000000..c0a52ad8d
--- /dev/null
+++ b/src/common/point.h
@@ -0,0 +1,57 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <type_traits>
8
9namespace Common {
10
11// Represents a point within a 2D space.
12template <typename T>
13struct Point {
14 static_assert(std::is_arithmetic_v<T>, "T must be an arithmetic type!");
15
16 T x{};
17 T y{};
18
19#define ARITHMETIC_OP(op, compound_op) \
20 friend constexpr Point operator op(const Point& lhs, const Point& rhs) noexcept { \
21 return { \
22 .x = static_cast<T>(lhs.x op rhs.x), \
23 .y = static_cast<T>(lhs.y op rhs.y), \
24 }; \
25 } \
26 friend constexpr Point operator op(const Point& lhs, T value) noexcept { \
27 return { \
28 .x = static_cast<T>(lhs.x op value), \
29 .y = static_cast<T>(lhs.y op value), \
30 }; \
31 } \
32 friend constexpr Point operator op(T value, const Point& rhs) noexcept { \
33 return { \
34 .x = static_cast<T>(value op rhs.x), \
35 .y = static_cast<T>(value op rhs.y), \
36 }; \
37 } \
38 friend constexpr Point& operator compound_op(Point& lhs, const Point& rhs) noexcept { \
39 lhs.x = static_cast<T>(lhs.x op rhs.x); \
40 lhs.y = static_cast<T>(lhs.y op rhs.y); \
41 return lhs; \
42 } \
43 friend constexpr Point& operator compound_op(Point& lhs, T value) noexcept { \
44 lhs.x = static_cast<T>(lhs.x op value); \
45 lhs.y = static_cast<T>(lhs.y op value); \
46 return lhs; \
47 }
48 ARITHMETIC_OP(+, +=)
49 ARITHMETIC_OP(-, -=)
50 ARITHMETIC_OP(*, *=)
51 ARITHMETIC_OP(/, /=)
52#undef ARITHMETIC_OP
53
54 friend constexpr bool operator==(const Point&, const Point&) = default;
55};
56
57} // namespace Common