mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-21 06:33:22 +00:00
Cleanup mutex func types.
Looks like mutexes reschedule when they lock, so switch to void.
This commit is contained in:
parent
429ac9de87
commit
2613ed8806
@ -118,6 +118,11 @@ template<int func(const char *, u32, u32, u32)> void WrapI_CUUU() {
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(const char *, u32, int, u32)> void WrapI_CUIU() {
|
||||
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(const char *, u32)> void WrapU_CU() {
|
||||
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
|
||||
RETURN((u32)retval);
|
||||
@ -133,11 +138,6 @@ template<u32 func(const char *, u32, u32)> void WrapU_CUU() {
|
||||
RETURN((u32)retval);
|
||||
}
|
||||
|
||||
template<u32 func(const char *, u32, u32, u32)> void WrapU_CUUU() {
|
||||
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3));
|
||||
RETURN((u32)retval);
|
||||
}
|
||||
|
||||
template<u32 func(u32, u32, u32)> void WrapU_UUU() {
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
|
@ -339,11 +339,11 @@ const HLEFunction ThreadManForUser[] =
|
||||
|
||||
{0x60107536,0,"sceKernelDeleteLwMutex"},
|
||||
{0x19CFF145,0,"sceKernelCreateLwMutex"},
|
||||
{0xf8170fbe,&WrapU_U<sceKernelDeleteMutex>,"sceKernelDeleteMutex"},
|
||||
{0xB011B11F,&WrapU_UUU<sceKernelLockMutex>,"sceKernelLockMutex"},
|
||||
{0x5bf4dd27,&WrapU_UUU<sceKernelLockMutexCB>,"sceKernelLockMutexCB"},
|
||||
{0x6b30100f,&WrapV_UU<sceKernelUnlockMutex>,"sceKernelUnlockMutex"},
|
||||
{0xb7d098c6,&WrapU_CUUU<sceKernelCreateMutex>,"sceKernelCreateMutex"},
|
||||
{0xf8170fbe,&WrapV_I<sceKernelDeleteMutex>,"sceKernelDeleteMutex"},
|
||||
{0xB011B11F,&WrapV_IIU<sceKernelLockMutex>,"sceKernelLockMutex"},
|
||||
{0x5bf4dd27,&WrapV_IIU<sceKernelLockMutexCB>,"sceKernelLockMutexCB"},
|
||||
{0x6b30100f,&WrapV_II<sceKernelUnlockMutex>,"sceKernelUnlockMutex"},
|
||||
{0xb7d098c6,&WrapI_CUIU<sceKernelCreateMutex>,"sceKernelCreateMutex"},
|
||||
{0x0DDCD2C9, 0, "sceKernelTryLockMutex"},
|
||||
// NOTE: LockLwMutex and UnlockLwMutex are in Kernel_Library, see sceKernelInterrupt.cpp.
|
||||
|
||||
|
@ -63,16 +63,16 @@ struct LWMutex : public KernelObject
|
||||
std::vector<SceUID> waitingThreads;
|
||||
};
|
||||
|
||||
u32 sceKernelCreateMutex(const char *name, u32 attr, u32 initial_count, u32 options)
|
||||
SceUID sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optionsPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelCreateMutex(%s, %08x, %08x)", name, attr, options);
|
||||
DEBUG_LOG(HLE,"sceKernelCreateMutex(%s, %08x, %d, %08x)", name, attr, initialCount, optionsPtr);
|
||||
|
||||
Mutex *mutex = new Mutex();
|
||||
SceUID id = kernelObjects.Create(mutex);
|
||||
|
||||
mutex->nm.size = sizeof(mutex);
|
||||
mutex->nm.attr = attr;
|
||||
mutex->nm.lockLevel = initial_count;
|
||||
mutex->nm.lockLevel = initialCount;
|
||||
// TODO: Does initial_count > 0 mean lock automatically by the current thread? Would make sense.
|
||||
mutex->nm.lockThread = -1;
|
||||
|
||||
@ -80,28 +80,46 @@ u32 sceKernelCreateMutex(const char *name, u32 attr, u32 initial_count, u32 opti
|
||||
return id;
|
||||
}
|
||||
|
||||
u32 sceKernelDeleteMutex(u32 id)
|
||||
void sceKernelDeleteMutex(SceUID id)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelDeleteMutex(%i)", id);
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(id, error);
|
||||
if (!mutex)
|
||||
return PSP_MUTEX_ERROR_NO_SUCH_MUTEX;
|
||||
kernelObjects.Destroy<Mutex>(id);
|
||||
return 0;
|
||||
if (mutex)
|
||||
{
|
||||
RETURN(0);
|
||||
|
||||
kernelObjects.Destroy<Mutex>(id);
|
||||
// TODO: Almost certainly need to reschedule (sometimes?)
|
||||
}
|
||||
else
|
||||
RETURN(PSP_MUTEX_ERROR_NO_SUCH_MUTEX);
|
||||
}
|
||||
|
||||
u32 sceKernelLockMutex(u32 id, u32 count, u32 timeoutPtr)
|
||||
// int sceKernelLockMutex(SceUID id, int count, int *timeout)
|
||||
// void because it changes threads.
|
||||
void sceKernelLockMutex(SceUID id, int count, u32 timeoutPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelLockMutex(%i, %i, %08x)", id, count, timeoutPtr);
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(id, error);
|
||||
if (!mutex)
|
||||
return PSP_MUTEX_ERROR_NO_SUCH_MUTEX;
|
||||
{
|
||||
RETURN(PSP_MUTEX_ERROR_NO_SUCH_MUTEX);
|
||||
return;
|
||||
}
|
||||
if (count <= 0)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
{
|
||||
RETURN(SCE_KERNEL_ERROR_ILLEGAL_COUNT);
|
||||
return;
|
||||
}
|
||||
if (count > 1 && !(mutex->nm.attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE))
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
{
|
||||
RETURN(SCE_KERNEL_ERROR_ILLEGAL_COUNT);
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN(0);
|
||||
|
||||
if (mutex->nm.lockLevel == 0)
|
||||
{
|
||||
@ -119,20 +137,32 @@ u32 sceKernelLockMutex(u32 id, u32 count, u32 timeoutPtr)
|
||||
mutex->waitingThreads.push_back(__KernelGetCurThread());
|
||||
__KernelWaitCurThread(WAITTYPE_MUTEX, id, count, 0, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceKernelLockMutexCB(u32 id, u32 count, u32 timeoutPtr)
|
||||
// int sceKernelLockMutexCB(SceUID id, int count, int *timeout)
|
||||
// void because it changes threads.
|
||||
void sceKernelLockMutexCB(SceUID id, int count, u32 timeoutPtr)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelLockMutexCB(%i, %i, %08x)", id, count, timeoutPtr);
|
||||
u32 error;
|
||||
Mutex *mutex = kernelObjects.Get<Mutex>(id, error);
|
||||
if (!mutex)
|
||||
return PSP_MUTEX_ERROR_NO_SUCH_MUTEX;
|
||||
{
|
||||
RETURN(PSP_MUTEX_ERROR_NO_SUCH_MUTEX);
|
||||
return;
|
||||
}
|
||||
if (count <= 0)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
{
|
||||
RETURN(SCE_KERNEL_ERROR_ILLEGAL_COUNT);
|
||||
return;
|
||||
}
|
||||
if (count > 1 && !(mutex->nm.attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE))
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
{
|
||||
RETURN(SCE_KERNEL_ERROR_ILLEGAL_COUNT);
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN(0);
|
||||
|
||||
if (mutex->nm.lockLevel == 0)
|
||||
{
|
||||
@ -151,12 +181,13 @@ u32 sceKernelLockMutexCB(u32 id, u32 count, u32 timeoutPtr)
|
||||
__KernelWaitCurThread(WAITTYPE_MUTEX, id, count, 0, true);
|
||||
__KernelCheckCallbacks();
|
||||
}
|
||||
return 0;
|
||||
|
||||
__KernelReSchedule("mutex locked");
|
||||
}
|
||||
|
||||
// int sceKernelUnlockMutex(SceUID id, int count)
|
||||
// void because it changes threads.
|
||||
void sceKernelUnlockMutex(u32 id, u32 count)
|
||||
void sceKernelUnlockMutex(SceUID id, int count)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceKernelUnlockMutex(%i, %i)", id, count);
|
||||
u32 error;
|
||||
|
@ -18,11 +18,11 @@
|
||||
#pragma once
|
||||
|
||||
// TODO
|
||||
u32 sceKernelCreateMutex(const char *name, u32 attr, u32 initial_count, u32 options);
|
||||
u32 sceKernelDeleteMutex(u32 id);
|
||||
u32 sceKernelLockMutex(u32 id, u32 count, u32 timeoutPtr);
|
||||
u32 sceKernelLockMutexCB(u32 id, u32 count, u32 timeoutPtr);
|
||||
void sceKernelUnlockMutex(u32 id, u32 count);
|
||||
SceUID sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optionsPtr);
|
||||
void sceKernelDeleteMutex(SceUID id);
|
||||
void sceKernelLockMutex(SceUID id, int count, u32 timeoutPtr);
|
||||
void sceKernelLockMutexCB(SceUID id, int count, u32 timeoutPtr);
|
||||
void sceKernelUnlockMutex(SceUID id, int count);
|
||||
|
||||
void sceKernelCreateLwMutex();
|
||||
void sceKernelDeleteLwMutex();
|
||||
|
Loading…
x
Reference in New Issue
Block a user