Skip to content

Commit ff9d180

Browse files
committed
Code cleanup
1 parent 9523993 commit ff9d180

26 files changed

+105
-131
lines changed

CMakeSettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"generator": "Ninja",
1515
"inheritEnvironments": [ "msvc_x64_x64" ],
1616
"buildRoot": "${projectDir}\\out\\build\\${name}",
17-
"installRoot": "${projectDir}\\out\\install\\${name}",
17+
"installRoot": "${projectDir}\\out\\install\\${name}"
1818
},
1919
{
2020
"name": "Debug",

src/Cafe/CafeSystem.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,6 @@ void InfoLog_PrintActiveSettings()
254254
cemuLog_log(LogType::Force, "Console language: {}", config.console_language);
255255
}
256256

257-
void PPCCore_setupSPR(PPCInterpreter_t* hCPU, uint32 coreIndex)
258-
{
259-
hCPU->sprExtended.PVR = 0x70010001;
260-
hCPU->spr.UPIR = coreIndex;
261-
hCPU->sprExtended.msr |= MSR_FP; // enable floating point
262-
}
263-
264257
struct SharedDataEntry
265258
{
266259
/* +0x00 */ uint32be name;

src/Cafe/GamePatch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef struct
5252
void hleExport_xcx_enterCriticalSection(PPCInterpreter_t* hCPU)
5353
{
5454
ppcDefineParamStructPtr(xcxCS, xcxCS_t, 0);
55-
uint32 threadId = coreinitThread_getCurrentThreadMPTRDepr(hCPU);
55+
uint32 threadId = MEMPTR<OSThread_t>(coreinit::OSGetCurrentThread()).GetMPTR();
5656
cemu_assert_debug(xcxCS->ukn08 != 0);
5757
cemu_assert_debug(threadId);
5858
if (xcxCS->ownerThreadId == (uint32be)threadId)

src/Cafe/HW/Espresso/Debugger/Debugger.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,10 @@ void debugger_enterTW(PPCInterpreter_t* hCPU)
513513
if (bp->bpType == DEBUGGER_BP_T_LOGGING && bp->enabled)
514514
{
515515
std::string logName = !bp->comment.empty() ? "Breakpoint '"+boost::nowide::narrow(bp->comment)+"'" : fmt::format("Breakpoint at 0x{:08X} (no comment)", bp->address);
516-
std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", coreinitThread_getCurrentThreadMPTRDepr(hCPU), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : "");
516+
std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", MEMPTR<OSThread_t>(coreinit::OSGetCurrentThread()).GetMPTR(), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : "");
517517
cemuLog_log(LogType::Force, "[Debugger] {} was executed! {}", logName, logContext);
518518
if (cemuLog_advancedPPCLoggingEnabled())
519-
DebugLogStackTrace(coreinitThread_getCurrentThreadDepr(hCPU), hCPU->gpr[1]);
519+
DebugLogStackTrace(coreinit::OSGetCurrentThread(), hCPU->gpr[1]);
520520
break;
521521
}
522522
bp = bp->next;
@@ -535,7 +535,7 @@ void debugger_enterTW(PPCInterpreter_t* hCPU)
535535

536536
// handle breakpoints
537537
debuggerState.debugSession.isTrapped = true;
538-
debuggerState.debugSession.debuggedThreadMPTR = coreinitThread_getCurrentThreadMPTRDepr(hCPU);
538+
debuggerState.debugSession.debuggedThreadMPTR = MEMPTR<OSThread_t>(coreinit::OSGetCurrentThread()).GetMPTR();
539539
debuggerState.debugSession.instructionPointer = hCPU->instructionPointer;
540540
debuggerState.debugSession.hCPU = hCPU;
541541
debugger_createPPCStateSnapshot(hCPU);

src/Cafe/HW/Espresso/Debugger/GDBStub.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ void GDBServer::HandleTrapInstruction(PPCInterpreter_t* hCPU)
900900
return cemu_assert_suspicious();
901901

902902
// Secondly, delete one-shot breakpoints but also temporarily delete patched instruction to run original instruction
903-
OSThread_t* currThread = coreinitThread_getCurrentThreadDepr(hCPU);
903+
OSThread_t* currThread = coreinit::OSGetCurrentThread();
904904
std::string pauseReason = fmt::format("T05thread:{:08X};core:{:02X};{}", GET_THREAD_ID(currThread), PPCInterpreter_getCoreIndex(hCPU), patchedBP->second.GetReason());
905905
bool pauseThreads = patchedBP->second.ShouldBreakThreads() || patchedBP->second.ShouldBreakThreadsOnNextInterrupt();
906906
if (patchedBP->second.IsPersistent())
@@ -939,7 +939,7 @@ void GDBServer::HandleTrapInstruction(PPCInterpreter_t* hCPU)
939939
ThreadPool::FireAndForget(&waitForBrokenThreads, std::move(m_resumed_context), pauseReason);
940940
}
941941

942-
breakThreads(GET_THREAD_ID(coreinitThread_getCurrentThreadDepr(hCPU)));
942+
breakThreads(GET_THREAD_ID(coreinit::OSGetCurrentThread()));
943943
cemuLog_logDebug(LogType::Force, "[GDBStub] Resumed from a breakpoint!");
944944
}
945945
}

src/Cafe/HW/Latte/Core/LatteConst.h

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
#pragma once
22
#include "Cafe/HW/Latte/ISA/LatteReg.h"
33

4-
// this file contains legacy C-style defines, modernize and merge into LatteReg.h
4+
// todo - this file contains legacy C-style defines, modernize and merge into LatteReg.h
55

66
// GPU7/Latte hardware info
77

8-
#define LATTE_NUM_GPR (128)
9-
#define LATTE_NUM_STREAMOUT_BUFFER (4)
10-
#define LATTE_NUM_COLOR_TARGET (8)
8+
#define LATTE_NUM_GPR 128
9+
#define LATTE_NUM_STREAMOUT_BUFFER 4
10+
#define LATTE_NUM_COLOR_TARGET 8
1111

12-
#define LATTE_NUM_MAX_TEX_UNITS (18) // number of available texture units per shader stage (this might be higher than 18? BotW is the only game which uses more than 16?)
13-
#define LATTE_NUM_MAX_UNIFORM_BUFFERS (16) // number of supported uniform buffer binding locations
12+
#define LATTE_NUM_MAX_TEX_UNITS 18 // number of available texture units per shader stage (this might be higher than 18? BotW is the only game which uses more than 16?)
13+
#define LATTE_NUM_MAX_UNIFORM_BUFFERS 16 // number of supported uniform buffer binding locations
1414

15-
#define LATTE_VS_ATTRIBUTE_LIMIT (32) // todo: verify
16-
#define LATTE_NUM_MAX_ATTRIBUTE_LOCATIONS (256) // should this be 128 since there are only 128 GPRs?
15+
#define LATTE_VS_ATTRIBUTE_LIMIT 32 // todo: verify
16+
#define LATTE_NUM_MAX_ATTRIBUTE_LOCATIONS 256 // should this be 128 since there are only 128 GPRs?
1717

18-
#define LATTE_MAX_VERTEX_BUFFERS (16)
18+
#define LATTE_MAX_VERTEX_BUFFERS 16
19+
20+
// Cemu-specific constants
21+
22+
#define LATTE_CEMU_PS_TEX_UNIT_BASE 0
23+
#define LATTE_CEMU_VS_TEX_UNIT_BASE 32
24+
#define LATTE_CEMU_GS_TEX_UNIT_BASE 64
1925

2026
// vertex formats
2127

src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#include "Cafe/HW/Latte/ISA/RegDefines.h"
2-
#include "Cafe/OS/libs/gx2/GX2.h" // todo - remove this dependency
32
#include "Cafe/HW/Latte/Core/Latte.h"
43
#include "Cafe/HW/Latte/Core/LatteShader.h"
54

65
#include "Cafe/HW/Latte/Renderer/Renderer.h"
7-
#include "Cafe/GraphicPack/GraphicPack2.h"
86

97
#include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h"
108
#include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h"
@@ -330,15 +328,15 @@ void LatteTexture_updateTextures()
330328
// pixel shader
331329
LatteDecompilerShader* pixelShader = LatteSHRC_GetActivePixelShader();
332330
if (pixelShader)
333-
LatteTexture_updateTexturesForStage(pixelShader, CEMU_PS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_PS);
331+
LatteTexture_updateTexturesForStage(pixelShader, LATTE_CEMU_PS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_PS);
334332
// vertex shader
335333
LatteDecompilerShader* vertexShader = LatteSHRC_GetActiveVertexShader();
336334
cemu_assert_debug(vertexShader != nullptr);
337-
LatteTexture_updateTexturesForStage(vertexShader, CEMU_VS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_VS);
335+
LatteTexture_updateTexturesForStage(vertexShader, LATTE_CEMU_VS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_VS);
338336
// geometry shader
339337
LatteDecompilerShader* geometryShader = LatteSHRC_GetActiveGeometryShader();
340338
if (geometryShader)
341-
LatteTexture_updateTexturesForStage(geometryShader, CEMU_GS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_GS);
339+
LatteTexture_updateTexturesForStage(geometryShader, LATTE_CEMU_GS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_GS);
342340
}
343341

344342
// returns the width, height, depth of the texture

src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#include "Cafe/HW/Latte/Core/LatteConst.h"
22
#include "Cafe/HW/Latte/Core/LatteShaderAssembly.h"
33
#include "Cafe/HW/Latte/ISA/RegDefines.h"
4-
#include "Cafe/OS/libs/gx2/GX2.h" // todo - remove this dependency
54
#include "Cafe/HW/Latte/Core/Latte.h"
6-
#include "Cafe/HW/Latte/Core/LatteDraw.h"
75
#include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h"
86
#include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h"
97
#include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h"
@@ -477,11 +475,11 @@ namespace LatteDecompiler
477475
continue;
478476
sint32 textureBindingPoint;
479477
if (decompilerContext->shaderType == LatteConst::ShaderType::Vertex)
480-
textureBindingPoint = i + CEMU_VS_TEX_UNIT_BASE;
478+
textureBindingPoint = i + LATTE_CEMU_VS_TEX_UNIT_BASE;
481479
else if (decompilerContext->shaderType == LatteConst::ShaderType::Geometry)
482-
textureBindingPoint = i + CEMU_GS_TEX_UNIT_BASE;
480+
textureBindingPoint = i + LATTE_CEMU_GS_TEX_UNIT_BASE;
483481
else if (decompilerContext->shaderType == LatteConst::ShaderType::Pixel)
484-
textureBindingPoint = i + CEMU_PS_TEX_UNIT_BASE;
482+
textureBindingPoint = i + LATTE_CEMU_PS_TEX_UNIT_BASE;
485483

486484
decompilerContext->output->resourceMappingGL.textureUnitToBindingPoint[i] = textureBindingPoint;
487485
}

src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.h

-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ class CachedFBOVk : public LatteCachedFBO
7575
VkRenderingAttachmentInfoKHR m_vkColorAttachments[8];
7676
VkRenderingAttachmentInfoKHR m_vkDepthAttachment;
7777
VkRenderingAttachmentInfoKHR m_vkStencilAttachment;
78-
//uint8 m_vkColorAttachmentsCount{0};
79-
bool m_vkHasDepthAttachment{ false };
80-
bool m_vkHasStencilAttachment{ false };
81-
8278

8379
std::vector<class PipelineInfo*> m_usedByPipelines; // PipelineInfo objects which use this renderpass/framebuffer
8480
};

src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,15 @@ uint64 VulkanRenderer::GetDescriptorSetStateHash(LatteDecompilerShader* shader)
513513
switch (shader->shaderType)
514514
{
515515
case LatteConst::ShaderType::Vertex:
516-
hostTextureUnit += CEMU_VS_TEX_UNIT_BASE;
516+
hostTextureUnit += LATTE_CEMU_VS_TEX_UNIT_BASE;
517517
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS;
518518
break;
519519
case LatteConst::ShaderType::Pixel:
520-
hostTextureUnit += CEMU_PS_TEX_UNIT_BASE;
520+
hostTextureUnit += LATTE_CEMU_PS_TEX_UNIT_BASE;
521521
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS;
522522
break;
523523
case LatteConst::ShaderType::Geometry:
524-
hostTextureUnit += CEMU_GS_TEX_UNIT_BASE;
524+
hostTextureUnit += LATTE_CEMU_GS_TEX_UNIT_BASE;
525525
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS;
526526
break;
527527
default:
@@ -631,15 +631,15 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo*
631631
switch (shader->shaderType)
632632
{
633633
case LatteConst::ShaderType::Vertex:
634-
hostTextureUnit += CEMU_VS_TEX_UNIT_BASE;
634+
hostTextureUnit += LATTE_CEMU_VS_TEX_UNIT_BASE;
635635
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS;
636636
break;
637637
case LatteConst::ShaderType::Pixel:
638-
hostTextureUnit += CEMU_PS_TEX_UNIT_BASE;
638+
hostTextureUnit += LATTE_CEMU_PS_TEX_UNIT_BASE;
639639
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS;
640640
break;
641641
case LatteConst::ShaderType::Geometry:
642-
hostTextureUnit += CEMU_GS_TEX_UNIT_BASE;
642+
hostTextureUnit += LATTE_CEMU_GS_TEX_UNIT_BASE;
643643
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS;
644644
break;
645645
default:

src/Cafe/IOSU/legacy/iosu_ioctl.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "Cafe/OS/common/OSCommon.h"
22
#include "Cafe/OS/libs/coreinit/coreinit_Thread.h"
3-
#include "Cafe/OS/libs/coreinit/coreinit.h"
43
#include "iosu_ioctl.h"
54
#include "util/helpers/ringbuffer.h"
65

@@ -23,7 +22,7 @@ sint32 iosuIoctl_pushAndWait(uint32 ioctlHandle, ioQueueEntry_t* ioQueueEntry)
2322
}
2423
__OSLockScheduler();
2524
ioctlMutex.lock();
26-
ioQueueEntry->ppcThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance());
25+
ioQueueEntry->ppcThread = coreinit::OSGetCurrentThread();
2726

2827
_ioctlRingbuffer[ioctlHandle].Push(ioQueueEntry);
2928
ioctlMutex.unlock();

src/Cafe/OS/libs/coreinit/coreinit.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "Cafe/OS/libs/coreinit/coreinit_MEM_BlockHeap.h"
3636
#include "Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.h"
3737

38-
coreinitData_t* gCoreinitData = NULL;
38+
CoreinitSharedData* gCoreinitData = NULL;
3939

4040
sint32 ScoreStackTrace(OSThread_t* thread, MPTR sp)
4141
{
@@ -323,8 +323,8 @@ void coreinit_load()
323323
coreinit::InitializeSysHeap();
324324

325325
// allocate coreinit global data
326-
gCoreinitData = (coreinitData_t*)memory_getPointerFromVirtualOffset(coreinit_allocFromSysArea(sizeof(coreinitData_t), 32));
327-
memset(gCoreinitData, 0x00, sizeof(coreinitData_t));
326+
gCoreinitData = (CoreinitSharedData*)memory_getPointerFromVirtualOffset(coreinit_allocFromSysArea(sizeof(CoreinitSharedData), 32));
327+
memset(gCoreinitData, 0x00, sizeof(CoreinitSharedData));
328328

329329
// coreinit weak links
330330
osLib_addVirtualPointer("coreinit", "MEMAllocFromDefaultHeap", memory_getVirtualOffsetFromPointer(&gCoreinitData->MEMAllocFromDefaultHeap));

src/Cafe/OS/libs/coreinit/coreinit.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ void coreinitAsyncCallback_addWithLock(MPTR functionMPTR, uint32 numParameters,
1616
void coreinit_load();
1717

1818
// coreinit shared memory
19-
20-
typedef struct
19+
struct CoreinitSharedData
2120
{
2221
MEMPTR<void> MEMAllocFromDefaultHeap;
2322
MEMPTR<void> MEMAllocFromDefaultHeapEx;
@@ -26,11 +25,9 @@ typedef struct
2625
MPTR __cpp_exception_init_ptr;
2726
MPTR __cpp_exception_cleanup_ptr;
2827
MPTR __stdio_cleanup;
29-
}coreinitData_t;
30-
31-
extern coreinitData_t* gCoreinitData;
28+
};
3229

33-
#include "Cafe/OS/libs/coreinit/coreinit_Spinlock.h"
30+
extern CoreinitSharedData* gCoreinitData;
3431

3532
// coreinit init
3633
void coreinit_start(PPCInterpreter_t* hCPU);

src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ sint32 MCP_GetSysProdSettings(MCPHANDLE mcpHandle, SysProdSettings* sysProdSetti
7171

7272
void coreinitExport_MCP_GetSysProdSettings(PPCInterpreter_t* hCPU)
7373
{
74-
cemuLog_logDebug(LogType::Force, "MCP_GetSysProdSettings(0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4]);
7574
sint32 result = MCP_GetSysProdSettings(hCPU->gpr[3], (SysProdSettings*)memory_getPointerFromVirtualOffset(hCPU->gpr[4]));
7675
osLib_returnFromFunction(hCPU, result);
7776
}

src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp

+21-27
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace coreinit
198198

199199
void threadEntry(PPCInterpreter_t* hCPU)
200200
{
201-
OSThread_t* currentThread = coreinitThread_getCurrentThreadDepr(hCPU);
201+
OSThread_t* currentThread = coreinit::OSGetCurrentThread();
202202
uint32 r3 = hCPU->gpr[3];
203203
uint32 r4 = hCPU->gpr[4];
204204
uint32 lr = hCPU->spr.LR;
@@ -368,39 +368,38 @@ namespace coreinit
368368
{
369369
PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance();
370370
hCPU->gpr[3] = exitValue;
371-
OSThread_t* threadBE = coreinitThread_getCurrentThreadDepr(hCPU);
372-
MPTR t = memory_getVirtualOffsetFromPointer(threadBE);
371+
OSThread_t* currentThread = coreinit::OSGetCurrentThread();
373372

374373
// thread cleanup callback
375-
if (!threadBE->cleanupCallback2.IsNull())
374+
if (!currentThread->cleanupCallback2.IsNull())
376375
{
377-
threadBE->stateFlags = _swapEndianU32(_swapEndianU32(threadBE->stateFlags) | 0x00000001);
378-
PPCCoreCallback(threadBE->cleanupCallback2.GetMPTR(), threadBE, _swapEndianU32(threadBE->stackEnd));
376+
currentThread->stateFlags = _swapEndianU32(_swapEndianU32(currentThread->stateFlags) | 0x00000001);
377+
PPCCoreCallback(currentThread->cleanupCallback2.GetMPTR(), currentThread, _swapEndianU32(currentThread->stackEnd));
379378
}
380379
// cpp exception cleanup
381-
if (gCoreinitData->__cpp_exception_cleanup_ptr != 0 && threadBE->crt.eh_globals != nullptr)
380+
if (gCoreinitData->__cpp_exception_cleanup_ptr != 0 && currentThread->crt.eh_globals != nullptr)
382381
{
383-
PPCCoreCallback(_swapEndianU32(gCoreinitData->__cpp_exception_cleanup_ptr), &threadBE->crt.eh_globals);
384-
threadBE->crt.eh_globals = nullptr;
382+
PPCCoreCallback(_swapEndianU32(gCoreinitData->__cpp_exception_cleanup_ptr), &currentThread->crt.eh_globals);
383+
currentThread->crt.eh_globals = nullptr;
385384
}
386385
// set exit code
387-
threadBE->exitValue = exitValue;
386+
currentThread->exitValue = exitValue;
388387

389388
__OSLockScheduler();
390389

391390
// release held synchronization primitives
392-
if (!threadBE->mutexQueue.isEmpty())
391+
if (!currentThread->mutexQueue.isEmpty())
393392
{
394393
cemuLog_log(LogType::Force, "OSExitThread: Thread is holding mutexes");
395394
while (true)
396395
{
397-
OSMutex* mutex = threadBE->mutexQueue.getFirst();
396+
OSMutex* mutex = currentThread->mutexQueue.getFirst();
398397
if (!mutex)
399398
break;
400-
if (mutex->owner != threadBE)
399+
if (mutex->owner != currentThread)
401400
{
402401
cemuLog_log(LogType::Force, "OSExitThread: Thread is holding mutex which it doesn't own");
403-
threadBE->mutexQueue.removeMutex(mutex);
402+
currentThread->mutexQueue.removeMutex(mutex);
404403
continue;
405404
}
406405
coreinit::OSUnlockMutexInternal(mutex);
@@ -409,22 +408,22 @@ namespace coreinit
409408
// todo - release all fast mutexes
410409

411410
// handle join queue
412-
if (!threadBE->joinQueue.isEmpty())
413-
threadBE->joinQueue.wakeupEntireWaitQueue(false);
411+
if (!currentThread->joinQueue.isEmpty())
412+
currentThread->joinQueue.wakeupEntireWaitQueue(false);
414413

415-
if ((threadBE->attr & 8) != 0)
414+
if ((currentThread->attr & 8) != 0)
416415
{
417416
// deactivate thread since it is detached
418-
threadBE->state = OSThread_t::THREAD_STATE::STATE_NONE;
419-
coreinit::__OSDeactivateThread(threadBE);
417+
currentThread->state = OSThread_t::THREAD_STATE::STATE_NONE;
418+
coreinit::__OSDeactivateThread(currentThread);
420419
// queue call to thread deallocator if set
421-
if (!threadBE->deallocatorFunc.IsNull())
422-
__OSQueueThreadDeallocation(threadBE);
420+
if (!currentThread->deallocatorFunc.IsNull())
421+
__OSQueueThreadDeallocation(currentThread);
423422
}
424423
else
425424
{
426425
// non-detached threads remain active
427-
threadBE->state = OSThread_t::THREAD_STATE::STATE_MORIBUND;
426+
currentThread->state = OSThread_t::THREAD_STATE::STATE_MORIBUND;
428427
}
429428
PPCCore_switchToSchedulerWithLock();
430429
}
@@ -1401,11 +1400,6 @@ void coreinit_resumeThread(OSThread_t* OSThreadBE, sint32 count)
14011400
__OSUnlockScheduler();
14021401
}
14031402

1404-
MPTR coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_t* hCPU)
1405-
{
1406-
return memory_getVirtualOffsetFromPointer(coreinit::__currentCoreThread[PPCInterpreter_getCoreIndex(hCPU)]);
1407-
}
1408-
14091403
OSThread_t* coreinitThread_getCurrentThreadDepr(PPCInterpreter_t* hCPU)
14101404
{
14111405
return coreinit::__currentCoreThread[PPCInterpreter_getCoreIndex(hCPU)];

0 commit comments

Comments
 (0)