summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2014-08-17 23:03:22 -0400
committerGravatar Lioncash2014-08-17 23:12:20 -0400
commit98fa3f7cba22997aef8ec4d121584c2488389c38 (patch)
tree40585fc835fa8fc27882923a4439d88e7ae171de /src
parentMerge pull request #52 from lioncash/memory (diff)
downloadyuzu-98fa3f7cba22997aef8ec4d121584c2488389c38.tar.gz
yuzu-98fa3f7cba22997aef8ec4d121584c2488389c38.tar.xz
yuzu-98fa3f7cba22997aef8ec4d121584c2488389c38.zip
Core: Alter the kernel string functions to use std::string instead of const char*.
Most functions already operate on std::strings. This also removes the need to manually null terminate thread names.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp4
-rw-r--r--src/core/hle/kernel/archive.cpp6
-rw-r--r--src/core/hle/kernel/event.cpp4
-rw-r--r--src/core/hle/kernel/kernel.cpp4
-rw-r--r--src/core/hle/kernel/kernel.h6
-rw-r--r--src/core/hle/kernel/mutex.cpp4
-rw-r--r--src/core/hle/kernel/shared_memory.cpp2
-rw-r--r--src/core/hle/kernel/thread.cpp17
-rw-r--r--src/core/hle/service/apt.h2
-rw-r--r--src/core/hle/service/fs.h2
-rw-r--r--src/core/hle/service/gsp.h2
-rw-r--r--src/core/hle/service/hid.h2
-rw-r--r--src/core/hle/service/ndm.h2
-rw-r--r--src/core/hle/service/service.h10
-rw-r--r--src/core/hle/service/srv.h2
-rw-r--r--src/core/hle/svc.cpp10
16 files changed, 38 insertions, 41 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index bdf76e0c2..174d4cd6e 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -17,8 +17,8 @@ namespace Kernel {
17 17
18class AddressArbiter : public Object { 18class AddressArbiter : public Object {
19public: 19public:
20 const char* GetTypeName() const { return "Arbiter"; } 20 std::string GetTypeName() const { return "Arbiter"; }
21 const char* GetName() const { return name.c_str(); } 21 std::string GetName() const { return name; }
22 22
23 static Kernel::HandleType GetStaticHandleType() { return HandleType::AddressArbiter; } 23 static Kernel::HandleType GetStaticHandleType() { return HandleType::AddressArbiter; }
24 Kernel::HandleType GetHandleType() const { return HandleType::AddressArbiter; } 24 Kernel::HandleType GetHandleType() const { return HandleType::AddressArbiter; }
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp
index 76b2520da..5079fcb84 100644
--- a/src/core/hle/kernel/archive.cpp
+++ b/src/core/hle/kernel/archive.cpp
@@ -31,8 +31,8 @@ enum class FileCommand : u32 {
31 31
32class Archive : public Object { 32class Archive : public Object {
33public: 33public:
34 const char* GetTypeName() const { return "Archive"; } 34 std::string GetTypeName() const { return "Archive"; }
35 const char* GetName() const { return name.c_str(); } 35 std::string GetName() const { return name; }
36 36
37 static Kernel::HandleType GetStaticHandleType() { return HandleType::Archive; } 37 static Kernel::HandleType GetStaticHandleType() { return HandleType::Archive; }
38 Kernel::HandleType GetHandleType() const { return HandleType::Archive; } 38 Kernel::HandleType GetHandleType() const { return HandleType::Archive; }
@@ -110,7 +110,7 @@ Result MountArchive(Archive* archive) {
110 return -1; 110 return -1;
111 } 111 }
112 g_archive_map[id_code] = archive->GetHandle(); 112 g_archive_map[id_code] = archive->GetHandle();
113 INFO_LOG(KERNEL, "Mounted archive %s", archive->GetName()); 113 INFO_LOG(KERNEL, "Mounted archive %s", archive->GetName().c_str());
114 return 0; 114 return 0;
115} 115}
116 116
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp
index 1e417e09c..64f6a9649 100644
--- a/src/core/hle/kernel/event.cpp
+++ b/src/core/hle/kernel/event.cpp
@@ -16,8 +16,8 @@ namespace Kernel {
16 16
17class Event : public Object { 17class Event : public Object {
18public: 18public:
19 const char* GetTypeName() const { return "Event"; } 19 std::string GetTypeName() const { return "Event"; }
20 const char* GetName() const { return name.c_str(); } 20 std::string GetName() const { return name; }
21 21
22 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Event; } 22 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Event; }
23 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Event; } 23 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Event; }
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 7d9bd261e..96bc63a53 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -71,8 +71,8 @@ void ObjectPool::List() {
71 for (int i = 0; i < MAX_COUNT; i++) { 71 for (int i = 0; i < MAX_COUNT; i++) {
72 if (occupied[i]) { 72 if (occupied[i]) {
73 if (pool[i]) { 73 if (pool[i]) {
74 INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName(), 74 INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(),
75 pool[i]->GetName()); 75 pool[i]->GetName().c_str());
76 } 76 }
77 } 77 }
78 } 78 }
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index d9afcdd25..6a2e395ed 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <string>
7#include "common/common.h" 8#include "common/common.h"
8 9
9typedef u32 Handle; 10typedef u32 Handle;
@@ -33,7 +34,6 @@ enum class HandleType : u32 {
33}; 34};
34 35
35enum { 36enum {
36 MAX_NAME_LENGTH = 0x100,
37 DEFAULT_STACK_SIZE = 0x4000, 37 DEFAULT_STACK_SIZE = 0x4000,
38}; 38};
39 39
@@ -45,8 +45,8 @@ class Object : NonCopyable {
45public: 45public:
46 virtual ~Object() {} 46 virtual ~Object() {}
47 Handle GetHandle() const { return handle; } 47 Handle GetHandle() const { return handle; }
48 virtual const char* GetTypeName() const { return "[BAD KERNEL OBJECT TYPE]"; } 48 virtual std::string GetTypeName() const { return "[BAD KERNEL OBJECT TYPE]"; }
49 virtual const char* GetName() const { return "[UNKNOWN KERNEL OBJECT]"; } 49 virtual std::string GetName() const { return "[UNKNOWN KERNEL OBJECT]"; }
50 virtual Kernel::HandleType GetHandleType() const = 0; 50 virtual Kernel::HandleType GetHandleType() const = 0;
51 51
52 /** 52 /**
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 055f503f9..5d7d65dd9 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -15,8 +15,8 @@ namespace Kernel {
15 15
16class Mutex : public Object { 16class Mutex : public Object {
17public: 17public:
18 const char* GetTypeName() const { return "Mutex"; } 18 std::string GetTypeName() const { return "Mutex"; }
19 const char* GetName() const { return name.c_str(); } 19 std::string GetName() const { return name; }
20 20
21 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Mutex; } 21 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Mutex; }
22 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Mutex; } 22 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Mutex; }
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 52823048f..2a6a483a1 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -11,7 +11,7 @@ namespace Kernel {
11 11
12class SharedMemory : public Object { 12class SharedMemory : public Object {
13public: 13public:
14 const char* GetTypeName() const { return "SharedMemory"; } 14 std::string GetTypeName() const { return "SharedMemory"; }
15 15
16 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::SharedMemory; } 16 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::SharedMemory; }
17 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::SharedMemory; } 17 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::SharedMemory; }
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 1d7ded6f6..554ec9756 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -2,13 +2,12 @@
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <stdio.h>
6
7#include <list>
8#include <algorithm> 5#include <algorithm>
9#include <vector> 6#include <cstdio>
7#include <list>
10#include <map> 8#include <map>
11#include <string> 9#include <string>
10#include <vector>
12 11
13#include "common/common.h" 12#include "common/common.h"
14#include "common/thread_queue_list.h" 13#include "common/thread_queue_list.h"
@@ -25,8 +24,8 @@ namespace Kernel {
25class Thread : public Kernel::Object { 24class Thread : public Kernel::Object {
26public: 25public:
27 26
28 const char* GetName() const { return name; } 27 std::string GetName() const { return name; }
29 const char* GetTypeName() const { return "Thread"; } 28 std::string GetTypeName() const { return "Thread"; }
30 29
31 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Thread; } 30 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Thread; }
32 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Thread; } 31 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Thread; }
@@ -71,7 +70,7 @@ public:
71 70
72 std::vector<Handle> waiting_threads; 71 std::vector<Handle> waiting_threads;
73 72
74 char name[Kernel::MAX_NAME_LENGTH + 1]; 73 std::string name;
75}; 74};
76 75
77// Lists all thread ids that aren't deleted/etc. 76// Lists all thread ids that aren't deleted/etc.
@@ -336,9 +335,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
336 thread->processor_id = processor_id; 335 thread->processor_id = processor_id;
337 thread->wait_type = WAITTYPE_NONE; 336 thread->wait_type = WAITTYPE_NONE;
338 thread->wait_handle = 0; 337 thread->wait_handle = 0;
339 338 thread->name = name;
340 strncpy(thread->name, name, Kernel::MAX_NAME_LENGTH);
341 thread->name[Kernel::MAX_NAME_LENGTH] = '\0';
342 339
343 return thread; 340 return thread;
344} 341}
diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h
index dca3097ed..4c7dd07e7 100644
--- a/src/core/hle/service/apt.h
+++ b/src/core/hle/service/apt.h
@@ -29,7 +29,7 @@ public:
29 * Gets the string port name used by CTROS for the service 29 * Gets the string port name used by CTROS for the service
30 * @return Port name of service 30 * @return Port name of service
31 */ 31 */
32 const char *GetPortName() const { 32 std::string GetPortName() const {
33 return "APT:U"; 33 return "APT:U";
34 } 34 }
35}; 35};
diff --git a/src/core/hle/service/fs.h b/src/core/hle/service/fs.h
index fabf5ac7e..36f3697d3 100644
--- a/src/core/hle/service/fs.h
+++ b/src/core/hle/service/fs.h
@@ -23,7 +23,7 @@ public:
23 * Gets the string port name used by CTROS for the service 23 * Gets the string port name used by CTROS for the service
24 * @return Port name of service 24 * @return Port name of service
25 */ 25 */
26 const char *GetPortName() const { 26 std::string GetPortName() const {
27 return "fs:USER"; 27 return "fs:USER";
28 } 28 }
29}; 29};
diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h
index fccebef7e..b25dbb7bc 100644
--- a/src/core/hle/service/gsp.h
+++ b/src/core/hle/service/gsp.h
@@ -137,7 +137,7 @@ public:
137 * Gets the string port name used by CTROS for the service 137 * Gets the string port name used by CTROS for the service
138 * @return Port name of service 138 * @return Port name of service
139 */ 139 */
140 const char *GetPortName() const { 140 std::string GetPortName() const {
141 return "gsp::Gpu"; 141 return "gsp::Gpu";
142 } 142 }
143 143
diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h
index 81c29eb2e..b17fcfa86 100644
--- a/src/core/hle/service/hid.h
+++ b/src/core/hle/service/hid.h
@@ -25,7 +25,7 @@ public:
25 * Gets the string port name used by CTROS for the service 25 * Gets the string port name used by CTROS for the service
26 * @return Port name of service 26 * @return Port name of service
27 */ 27 */
28 const char *GetPortName() const { 28 std::string GetPortName() const {
29 return "hid:USER"; 29 return "hid:USER";
30 } 30 }
31 31
diff --git a/src/core/hle/service/ndm.h b/src/core/hle/service/ndm.h
index fbe88fb8f..d5ec28f5b 100644
--- a/src/core/hle/service/ndm.h
+++ b/src/core/hle/service/ndm.h
@@ -24,7 +24,7 @@ public:
24 * Gets the string port name used by CTROS for the service 24 * Gets the string port name used by CTROS for the service
25 * @return Port name of service 25 * @return Port name of service
26 */ 26 */
27 const char *GetPortName() const { 27 std::string GetPortName() const {
28 return "ndm:u"; 28 return "ndm:u";
29 } 29 }
30 30
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index dcd525727..cb1ecde31 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -39,8 +39,8 @@ class Interface : public Kernel::Object {
39 friend class Manager; 39 friend class Manager;
40public: 40public:
41 41
42 const char *GetName() const { return GetPortName(); } 42 std::string GetName() const { return GetPortName(); }
43 const char *GetTypeName() const { return GetPortName(); } 43 std::string GetTypeName() const { return GetPortName(); }
44 44
45 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Service; } 45 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Service; }
46 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Service; } 46 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Service; }
@@ -57,7 +57,7 @@ public:
57 * Gets the string name used by CTROS for a service 57 * Gets the string name used by CTROS for a service
58 * @return Port name of service 58 * @return Port name of service
59 */ 59 */
60 virtual const char *GetPortName() const { 60 virtual std::string GetPortName() const {
61 return "[UNKNOWN SERVICE PORT]"; 61 return "[UNKNOWN SERVICE PORT]";
62 } 62 }
63 63
@@ -86,7 +86,7 @@ public:
86 86
87 if (itr == m_functions.end()) { 87 if (itr == m_functions.end()) {
88 ERROR_LOG(OSHLE, "unknown/unimplemented function: port=%s, command=0x%08X", 88 ERROR_LOG(OSHLE, "unknown/unimplemented function: port=%s, command=0x%08X",
89 GetPortName(), cmd_buff[0]); 89 GetPortName().c_str(), cmd_buff[0]);
90 90
91 // TODO(bunnei): Hack - ignore error 91 // TODO(bunnei): Hack - ignore error
92 u32* cmd_buff = Service::GetCommandBuffer(); 92 u32* cmd_buff = Service::GetCommandBuffer();
@@ -95,7 +95,7 @@ public:
95 } 95 }
96 if (itr->second.func == nullptr) { 96 if (itr->second.func == nullptr) {
97 ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s", 97 ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s",
98 GetPortName(), itr->second.name.c_str()); 98 GetPortName().c_str(), itr->second.name.c_str());
99 99
100 // TODO(bunnei): Hack - ignore error 100 // TODO(bunnei): Hack - ignore error
101 u32* cmd_buff = Service::GetCommandBuffer(); 101 u32* cmd_buff = Service::GetCommandBuffer();
diff --git a/src/core/hle/service/srv.h b/src/core/hle/service/srv.h
index 81109a2a8..9451472de 100644
--- a/src/core/hle/service/srv.h
+++ b/src/core/hle/service/srv.h
@@ -22,7 +22,7 @@ public:
22 * Gets the string name used by CTROS for the service 22 * Gets the string name used by CTROS for the service
23 * @return Port name of service 23 * @return Port name of service
24 */ 24 */
25 const char *GetPortName() const { 25 std::string GetPortName() const {
26 return "srv:"; 26 return "srv:";
27 } 27 }
28 28
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 8720bed31..28f2844eb 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -92,7 +92,7 @@ Result SendSyncRequest(Handle handle) {
92 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle); 92 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
93 93
94 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); 94 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!");
95 DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName()); 95 DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName().c_str());
96 96
97 bool wait = false; 97 bool wait = false;
98 Result res = object->SyncRequest(&wait); 98 Result res = object->SyncRequest(&wait);
@@ -118,8 +118,8 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) {
118 118
119 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle); 119 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
120 120
121 DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%d", handle, object->GetTypeName(), 121 DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%d", handle, object->GetTypeName().c_str(),
122 object->GetName(), nano_seconds); 122 object->GetName().c_str(), nano_seconds);
123 123
124 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); 124 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!");
125 125
@@ -152,8 +152,8 @@ Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wa
152 _assert_msg_(KERNEL, (object != nullptr), "called handle=0x%08X, but kernel object " 152 _assert_msg_(KERNEL, (object != nullptr), "called handle=0x%08X, but kernel object "
153 "is nullptr!", handles[i]); 153 "is nullptr!", handles[i]);
154 154
155 DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName(), 155 DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(),
156 object->GetName()); 156 object->GetName().c_str());
157 157
158 Result res = object->WaitSynchronization(&wait); 158 Result res = object->WaitSynchronization(&wait);
159 159