mirror of
https://github.com/zeldaret/st
synced 2026-07-07 22:10:51 -04:00
Match MSL_C (#8)
* match wstring.c * match math_api.c, mbstring.c, mem.c and mem_funcs.c * more progress * build issues * fix non-matching issues * reorganise files * match fdlibm (+ libc progress) * fix jp build * solved some non-matchings and progress * removed types.h usage in libc * match data and add missing delinks for jp
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#ifndef NITROSDK_OS_CONTEXT_H
|
||||
#define NITROSDK_OS_CONTEXT_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
typedef struct OSContext {
|
||||
/* 0x00 */ u32 cpsr;
|
||||
/* 0x04 */ u32 r[13];
|
||||
/* 0x38 */ u32 sp;
|
||||
/* 0x3C */ u32 lr;
|
||||
/* 0x40 */ u32 pc;
|
||||
/* 0x44 */ char unk_40[0x20];
|
||||
} OSContext; // Size: 0x64
|
||||
|
||||
#endif // NITROSDK_OS_CONTEXT_H
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef NITROSDK_OS_MUTEX_H
|
||||
#define NITROSDK_OS_MUTEX_H
|
||||
|
||||
#include <nitro/os/thread.h>
|
||||
#include <types.h>
|
||||
|
||||
typedef struct OSMutex {
|
||||
/* 0x00 */ OSThreadQueue queue;
|
||||
/* 0x08 */ OSThread *thread;
|
||||
/* 0x0C */ s32 count;
|
||||
/* 0x10 */ OSMutexLinkedList list;
|
||||
} OSMutex; // Size: 0x18
|
||||
|
||||
void OS_InitMutex(OSMutex *mutex);
|
||||
void OS_LockMutex(OSMutex *mutex);
|
||||
void OS_UnlockMutex(OSMutex *mutex);
|
||||
void OS_UnlockAllQueuedThreadMutex(OSThread *thread);
|
||||
bool OS_TryLockMutex(OSMutex *mutex);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,98 @@
|
||||
#ifndef NITROSDK_OS_THREAD_H
|
||||
#define NITROSDK_OS_THREAD_H
|
||||
|
||||
#include <nitro/os/context.h>
|
||||
|
||||
/// MARK: Types
|
||||
|
||||
typedef struct OSThread OSThread;
|
||||
typedef struct OSMutex OSMutex;
|
||||
|
||||
typedef void (*OSThreadSwitchCallback)(OSThread *oldThread, OSThread *newThread);
|
||||
typedef void (*OSThreadDestructor)(void *);
|
||||
|
||||
typedef struct OSThreadLinkedList {
|
||||
/* 0x04 */ OSThread *prev;
|
||||
/* 0x00 */ OSThread *next;
|
||||
} OSThreadLinkedList;
|
||||
|
||||
typedef struct OSMutexQueue {
|
||||
/* 0x00 */ OSMutex *head;
|
||||
/* 0x04 */ OSMutex *tail;
|
||||
} OSMutexQueue;
|
||||
|
||||
typedef struct OSMutexLinkedList {
|
||||
/* 0x00 */ OSMutex *next;
|
||||
/* 0x04 */ OSMutex *prev;
|
||||
} OSMutexLinkedList;
|
||||
|
||||
typedef struct OSThreadQueue {
|
||||
/* 0x00 */ OSThread *head;
|
||||
/* 0x04 */ OSThread *tail;
|
||||
} OSThreadQueue;
|
||||
|
||||
typedef struct OSThreadInfo {
|
||||
/* 0x00 */ u16 isSchedulerWaiting;
|
||||
/* 0x02 */ u16 irqDepth;
|
||||
/* 0x10 */ OSThread *current;
|
||||
/* 0x14 */ OSThread *list;
|
||||
/* 0x18 */ OSThreadSwitchCallback callback;
|
||||
} OSThreadInfo;
|
||||
|
||||
typedef struct OSThread {
|
||||
/* 0x00 */ OSContext context;
|
||||
/* 0x64 */ s32 state;
|
||||
/* 0x68 */ OSThread *next;
|
||||
/* 0x6C */ u32 id;
|
||||
/* 0x70 */ u32 priority;
|
||||
/* 0x74 */ void *profiler;
|
||||
/* 0x78 */ OSThreadQueue *queue;
|
||||
/* 0x7C */ OSThreadLinkedList list;
|
||||
/* 0x84 */ OSMutex *mutex;
|
||||
/* 0x88 */ OSMutexQueue mutexQueue;
|
||||
/* 0x90 */ u32 stackTop;
|
||||
/* 0x94 */ u32 stackBottom;
|
||||
/* 0x98 */ u32 stackOffset;
|
||||
/* 0x9C */ OSThreadQueue joinQueue;
|
||||
/* 0xA4 */ void *unk_A4[3];
|
||||
/* 0xB0 */ void *unk_B0;
|
||||
/* 0xB4 */ OSThreadDestructor destructor;
|
||||
/* 0xB8 */ void *userParam;
|
||||
/* 0xBC */ s32 error;
|
||||
} OSThread; // Size: 0xC0
|
||||
|
||||
extern OSThreadInfo ThreadInfo;
|
||||
|
||||
/// MARK: Functions
|
||||
|
||||
void OS_PauseThread(OSThreadQueue *queue);
|
||||
void OS_UnpauseThread(OSThreadQueue *queue);
|
||||
OSMutex *OS_RemoveMutexFromQueue(OSMutexQueue *queue);
|
||||
OSThread *OS_SelectThread(void);
|
||||
void OS_CreateThread(OSThread *thread, void (*func)(void *), void *arg, void *stack, u32 stackSize, u32 priority);
|
||||
void OS_ExitThread(void);
|
||||
|
||||
/// MARK: Inlines
|
||||
|
||||
static inline void OS_InitThreadQueue(OSThreadQueue *queue) {
|
||||
queue->tail = NULL;
|
||||
queue->head = NULL;
|
||||
}
|
||||
|
||||
static inline OSThreadInfo *OS_GetThreadInfo(void) {
|
||||
return &ThreadInfo;
|
||||
}
|
||||
|
||||
static inline OSThread *OS_GetCurrentThread(void) {
|
||||
return OS_GetThreadInfo()->current;
|
||||
}
|
||||
|
||||
static inline void OS_SetCurrentThread(OSThread *thread) {
|
||||
OS_GetThreadInfo()->current = thread;
|
||||
}
|
||||
|
||||
static inline u32 OS_GetThreadId(OSThread *thread) {
|
||||
return thread->id;
|
||||
}
|
||||
|
||||
#endif // NITROSDK_OS_THREAD_H
|
||||
+3
-4
@@ -13,14 +13,13 @@ typedef int s32;
|
||||
typedef short s16;
|
||||
typedef char s8;
|
||||
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
|
||||
typedef s8 unk8;
|
||||
typedef s16 unk16;
|
||||
typedef s32 unk32;
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef s32 bool;
|
||||
#endif
|
||||
|
||||
#define CEIL_DIV(a, b) (((a) + (b) - 1) / (b))
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user