Просмотр исходного кода

mutex: refactored the interface to code to return a Mutex* handle

bunnei 12 лет назад
Родитель
Сommit
eb537c560a
4 измененных файлов с 16 добавлено и 5 удалено
  1. 12 2
      src/core/hle/kernel/mutex.cpp
  2. 1 1
      src/core/hle/kernel/mutex.h
  3. 2 1
      src/core/hle/service/apt.cpp
  4. 1 1
      src/core/hle/svc.cpp

+ 12 - 2
src/core/hle/kernel/mutex.cpp

@@ -102,7 +102,7 @@ Result ReleaseMutex(Handle handle) {
  * @param handle Reference to handle for the newly created mutex
  * @param handle Reference to handle for the newly created mutex
  * @param initial_locked Specifies if the mutex should be locked initially
  * @param initial_locked Specifies if the mutex should be locked initially
  */
  */
-Result CreateMutex(Handle& handle, bool initial_locked) {
+Mutex* CreateMutex(Handle& handle, bool initial_locked) {
     Mutex* mutex = new Mutex;
     Mutex* mutex = new Mutex;
     handle = Kernel::g_object_pool.Create(mutex);
     handle = Kernel::g_object_pool.Create(mutex);
 
 
@@ -116,7 +116,17 @@ Result CreateMutex(Handle& handle, bool initial_locked) {
     } else {
     } else {
         mutex->lock_thread = -1;
         mutex->lock_thread = -1;
     }
     }
-    return 0;
+    return mutex;
+}
+
+/**
+ * Creates a mutex
+ * @param initial_locked Specifies if the mutex should be locked initially
+ */
+Handle CreateMutex(bool initial_locked) {
+    Handle handle;
+    Mutex* mutex = CreateMutex(handle, initial_locked);
+    return handle;
 }
 }
 
 
 } // namespace
 } // namespace

+ 1 - 1
src/core/hle/kernel/mutex.h

@@ -21,6 +21,6 @@ Result ReleaseMutex(Handle handle);
  * @param handle Reference to handle for the newly created mutex
  * @param handle Reference to handle for the newly created mutex
  * @param initial_locked Specifies if the mutex should be locked initially
  * @param initial_locked Specifies if the mutex should be locked initially
  */
  */
-Result CreateMutex(Handle& handle, bool initial_locked);
+Handle CreateMutex(bool initial_locked);
 
 
 } // namespace
 } // namespace

+ 2 - 1
src/core/hle/service/apt.cpp

@@ -21,7 +21,8 @@ void Initialize(Service::Interface* self) {
 void GetLockHandle(Service::Interface* self) {
 void GetLockHandle(Service::Interface* self) {
     u32* cmd_buff = Service::GetCommandBuffer();
     u32* cmd_buff = Service::GetCommandBuffer();
     u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field
     u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field
-    cmd_buff[1] = Kernel::CreateMutex(cmd_buff[5], false);
+    cmd_buff[1] = 0; // No error
+    cmd_buff[5] = Kernel::CreateMutex(false);
 }
 }
 
 
 const Interface::FunctionInfo FunctionTable[] = {
 const Interface::FunctionInfo FunctionTable[] = {

+ 1 - 1
src/core/hle/svc.cpp

@@ -188,7 +188,7 @@ Result CreateThread(void* thread, u32 priority, u32 entry_point, u32 arg, u32 st
 Result CreateMutex(void* _mutex, u32 initial_locked) {
 Result CreateMutex(void* _mutex, u32 initial_locked) {
     Handle* mutex = (Handle*)_mutex;
     Handle* mutex = (Handle*)_mutex;
     DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s", initial_locked ? "true" : "false");
     DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s", initial_locked ? "true" : "false");
-    Kernel::CreateMutex(*mutex, (bool)initial_locked);
+    *mutex = Kernel::CreateMutex((initial_locked != 0));
     Core::g_app_core->SetReg(1, *mutex);
     Core::g_app_core->SetReg(1, *mutex);
     return 0;
     return 0;
 }
 }