mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-12 05:50:29 +02:00
Correct sceKernelGetThreadStackFreeSize().
It was always returning 0.
This commit is contained in:
1 parent
0f7ac377cd
commit
b898e397aa
4 files changed
+18
-23
No files matched your search
@@ -1852,7 +1852,7 @@ int sceKernelCheckThreadStack()
|
||||
Thread *t = kernelObjects.Get<Thread>(__KernelGetCurThread(), error);
|
||||
if (t) {
|
||||
u32 diff = labs((long)((s64)currentMIPS->r[MIPS_REG_SP] - (s64)t->currentStack.start));
|
||||
WARN_LOG(SCEKERNEL, "%i=sceKernelCheckThreadStack()", diff);
|
||||
DEBUG_LOG(SCEKERNEL, "%i=sceKernelCheckThreadStack()", diff);
|
||||
return diff;
|
||||
} else {
|
||||
ERROR_LOG_REPORT(SCEKERNEL, "sceKernelCheckThreadStack() - not on thread");
|
||||
@@ -2148,37 +2148,32 @@ int sceKernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceKernelGetThreadStackFreeSize()
|
||||
int sceKernelGetThreadStackFreeSize(SceUID threadID)
|
||||
{
|
||||
SceUID threadID = PARAM(0);
|
||||
Thread *thread;
|
||||
|
||||
INFO_LOG(SCEKERNEL,"sceKernelGetThreadStackFreeSize(%i)", threadID);
|
||||
DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadStackFreeSize(%i)", threadID);
|
||||
|
||||
if (threadID == 0)
|
||||
thread = __GetCurrentThread();
|
||||
else
|
||||
threadID = currentThread;
|
||||
|
||||
u32 error;
|
||||
Thread *thread = kernelObjects.Get<Thread>(threadID, error);
|
||||
if (thread == 0)
|
||||
{
|
||||
u32 error;
|
||||
thread = kernelObjects.Get<Thread>(threadID, error);
|
||||
if (thread == 0)
|
||||
{
|
||||
ERROR_LOG(SCEKERNEL,"sceKernelGetThreadStackFreeSize: invalid thread id %i", threadID);
|
||||
RETURN(error);
|
||||
return;
|
||||
}
|
||||
ERROR_LOG(SCEKERNEL, "sceKernelGetThreadStackFreeSize: invalid thread id %i", threadID);
|
||||
return error;
|
||||
}
|
||||
|
||||
// Scan the stack for 0xFF
|
||||
// Scan the stack for 0xFF, starting after 0x10 (the thread id is written there.)
|
||||
// Obviously this doesn't work great if PSP_THREAD_ATTR_NO_FILLSTACK is used.
|
||||
int sz = 0;
|
||||
for (u32 addr = thread->currentStack.start; addr < thread->currentStack.start + thread->nt.stackSize; addr++)
|
||||
for (u32 offset = 0x10; offset < thread->nt.stackSize; ++offset)
|
||||
{
|
||||
if (Memory::Read_U8(addr) != 0xFF)
|
||||
if (Memory::Read_U8(thread->currentStack.start + offset) != 0xFF)
|
||||
break;
|
||||
sz++;
|
||||
}
|
||||
|
||||
RETURN(sz & ~3);
|
||||
return sz & ~3;
|
||||
}
|
||||
|
||||
void __KernelReturnFromThread()
|
||||
|
||||
Reference in new issue
Block a user