summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2019-10-06 13:51:31 -0400
committerGravatar Lioncash2019-10-06 13:53:12 -0400
commitf1382cf0e7180cd31505ee89e774cc93bde6211e (patch)
treec732e422a882f0e40e42094533546b32e61d56c2 /src
parenthle/service: Replace global system instance calls with instance-based ones (diff)
downloadyuzu-f1382cf0e7180cd31505ee89e774cc93bde6211e.tar.gz
yuzu-f1382cf0e7180cd31505ee89e774cc93bde6211e.tar.xz
yuzu-f1382cf0e7180cd31505ee89e774cc93bde6211e.zip
core: Remove Core::CurrentProcess()
This only encourages the use of the global system instance (which will be phased out long-term). Instead, we use the direct system function call directly to remove the appealing but discouraged short-hand.
Diffstat (limited to 'src')
-rw-r--r--src/core/core.h4
-rw-r--r--src/core/file_sys/savedata_factory.cpp5
-rw-r--r--src/core/gdbstub/gdbstub.cpp3
-rw-r--r--src/core/hle/kernel/handle_table.cpp2
-rw-r--r--src/core/memory.cpp10
5 files changed, 11 insertions, 13 deletions
diff --git a/src/core/core.h b/src/core/core.h
index fecfdb959..97944c366 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -359,8 +359,4 @@ private:
359 static System s_instance; 359 static System s_instance;
360}; 360};
361 361
362inline Kernel::Process* CurrentProcess() {
363 return System::GetInstance().CurrentProcess();
364}
365
366} // namespace Core 362} // namespace Core
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index f77cc02ac..fc8755c78 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -127,8 +127,9 @@ std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType typ
127 u128 user_id, u64 save_id) { 127 u128 user_id, u64 save_id) {
128 // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should 128 // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should
129 // be interpreted as the title id of the current process. 129 // be interpreted as the title id of the current process.
130 if (type == SaveDataType::SaveData && title_id == 0) 130 if (type == SaveDataType::SaveData && title_id == 0) {
131 title_id = Core::CurrentProcess()->GetTitleID(); 131 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();
132 }
132 133
133 std::string out = GetSaveDataSpaceIdPath(space); 134 std::string out = GetSaveDataSpaceIdPath(space);
134 135
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp
index afa812598..db51d722f 100644
--- a/src/core/gdbstub/gdbstub.cpp
+++ b/src/core/gdbstub/gdbstub.cpp
@@ -641,7 +641,8 @@ static void HandleQuery() {
641 strlen("Xfer:features:read:target.xml:")) == 0) { 641 strlen("Xfer:features:read:target.xml:")) == 0) {
642 SendReply(target_xml); 642 SendReply(target_xml);
643 } else if (strncmp(query, "Offsets", strlen("Offsets")) == 0) { 643 } else if (strncmp(query, "Offsets", strlen("Offsets")) == 0) {
644 const VAddr base_address = Core::CurrentProcess()->VMManager().GetCodeRegionBaseAddress(); 644 const VAddr base_address =
645 Core::System::GetInstance().CurrentProcess()->VMManager().GetCodeRegionBaseAddress();
645 std::string buffer = fmt::format("TextSeg={:0x}", base_address); 646 std::string buffer = fmt::format("TextSeg={:0x}", base_address);
646 SendReply(buffer.c_str()); 647 SendReply(buffer.c_str());
647 } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) { 648 } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) {
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp
index bdfaa977f..2cc5d536b 100644
--- a/src/core/hle/kernel/handle_table.cpp
+++ b/src/core/hle/kernel/handle_table.cpp
@@ -103,7 +103,7 @@ SharedPtr<Object> HandleTable::GetGeneric(Handle handle) const {
103 if (handle == CurrentThread) { 103 if (handle == CurrentThread) {
104 return GetCurrentThread(); 104 return GetCurrentThread();
105 } else if (handle == CurrentProcess) { 105 } else if (handle == CurrentProcess) {
106 return Core::CurrentProcess(); 106 return Core::System::GetInstance().CurrentProcess();
107 } 107 }
108 108
109 if (!IsValid(handle)) { 109 if (!IsValid(handle)) {
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 9e030789d..fa49f3dd0 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -146,7 +146,7 @@ static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) {
146 * using a VMA from the current process. 146 * using a VMA from the current process.
147 */ 147 */
148static u8* GetPointerFromVMA(VAddr vaddr) { 148static u8* GetPointerFromVMA(VAddr vaddr) {
149 return GetPointerFromVMA(*Core::CurrentProcess(), vaddr); 149 return GetPointerFromVMA(*Core::System::GetInstance().CurrentProcess(), vaddr);
150} 150}
151 151
152template <typename T> 152template <typename T>
@@ -226,7 +226,7 @@ bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) {
226} 226}
227 227
228bool IsValidVirtualAddress(const VAddr vaddr) { 228bool IsValidVirtualAddress(const VAddr vaddr) {
229 return IsValidVirtualAddress(*Core::CurrentProcess(), vaddr); 229 return IsValidVirtualAddress(*Core::System::GetInstance().CurrentProcess(), vaddr);
230} 230}
231 231
232bool IsKernelVirtualAddress(const VAddr vaddr) { 232bool IsKernelVirtualAddress(const VAddr vaddr) {
@@ -387,7 +387,7 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_
387} 387}
388 388
389void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) { 389void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) {
390 ReadBlock(*Core::CurrentProcess(), src_addr, dest_buffer, size); 390 ReadBlock(*Core::System::GetInstance().CurrentProcess(), src_addr, dest_buffer, size);
391} 391}
392 392
393void Write8(const VAddr addr, const u8 data) { 393void Write8(const VAddr addr, const u8 data) {
@@ -450,7 +450,7 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi
450} 450}
451 451
452void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { 452void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) {
453 WriteBlock(*Core::CurrentProcess(), dest_addr, src_buffer, size); 453 WriteBlock(*Core::System::GetInstance().CurrentProcess(), dest_addr, src_buffer, size);
454} 454}
455 455
456void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) { 456void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) {
@@ -539,7 +539,7 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr,
539} 539}
540 540
541void CopyBlock(VAddr dest_addr, VAddr src_addr, std::size_t size) { 541void CopyBlock(VAddr dest_addr, VAddr src_addr, std::size_t size) {
542 CopyBlock(*Core::CurrentProcess(), dest_addr, src_addr, size); 542 CopyBlock(*Core::System::GetInstance().CurrentProcess(), dest_addr, src_addr, size);
543} 543}
544 544
545} // namespace Memory 545} // namespace Memory