Match osDestroyThread

This commit is contained in:
Alejandro Javier Asenjo Nitti
2024-02-07 17:27:48 -03:00
parent 52a8a12bea
commit 04291937f3
2 changed files with 56 additions and 3 deletions
+2 -1
View File
@@ -198,7 +198,7 @@ COMMON_DEFINES := -D_MIPS_SZLONG=32
GBI_DEFINES := -DF3DEX_GBI
RELEASE_DEFINES := -DNDEBUG -D_FINALROM
AS_DEFINES := -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64
C_DEFINES := -DLANGUAGE_C -D_LANGUAGE_C
C_DEFINES := -DLANGUAGE_C -D_LANGUAGE_C -DBUILD_VERSION=VERSION_H
ENDIAN := -EB
OPTFLAGS := -O2 -g3
@@ -274,6 +274,7 @@ build/src/libultra/libc/ll.o: OPTFLAGS := -O1 -g0
build/src/libultra/libc/ll.o: MIPS_VERSION := -mips3 -32
build/src/libultra/os/createmesgqueue.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/destroythread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/getactivequeue.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/stopthread.o: OPTFLAGS := -O1 -g0
+54 -2
View File
@@ -1,3 +1,55 @@
#include "common.h"
#include "PR/os_internal.h"
#include "osint.h"
#include "PR/os_version.h"
#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/os/destroythread/osDestroyThread.s")
// this is not supposed to be here, but the def check below is broken I guess.
#ifdef __sgi
#define __GNUC__ 0
#endif
void osDestroyThread(OSThread* t) {
register u32 saveMask;
register OSThread* pred;
register OSThread* succ;
saveMask = __osDisableInt();
if (t == NULL) {
t = __osRunningThread;
} else if (t->state != OS_STATE_STOPPED) {
__osDequeueThread(t->queue, t);
}
if (__osActiveQueue == t) {
__osActiveQueue = __osActiveQueue->tlnext;
} else {
#if BUILD_VERSION >= VERSION_J || !defined(__GNUC__)
pred = __osActiveQueue;
while (pred->priority != -1) {
succ = pred->tlnext;
if (succ == t) {
pred->tlnext = t->tlnext;
break;
}
pred = succ;
}
#else
pred = __osActiveQueue;
succ = pred->tlnext;
while (succ != NULL) {
if (succ == t) {
pred->tlnext = t->tlnext;
break;
}
pred = succ;
succ = pred->tlnext;
}
#endif
}
if (t == __osRunningThread) {
__osDispatchThread();
}
__osRestoreInt(saveMask);
}