mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
29 lines
753 B
C
29 lines
753 B
C
#pragma once
|
|
#include "arm.h"
|
|
#include "types.h"
|
|
#include "kernel/thread.h"
|
|
|
|
#define THREADVARS_MAGIC 0x21545624 // !TV$
|
|
|
|
// This structure is exactly 0x20 bytes, if more is needed modify getThreadVars() below
|
|
typedef struct {
|
|
// Magic value used to check if the struct is initialized
|
|
u32 magic;
|
|
|
|
// Thread handle, for mutexes
|
|
Handle handle;
|
|
|
|
// Pointer to the current thread (if exists)
|
|
Thread* thread_ptr;
|
|
|
|
// Pointer to this thread's newlib state
|
|
struct _reent* reent;
|
|
|
|
// Pointer to this thread's thread-local segment
|
|
void* tls_tp; // !! Offset needs to be TLS+0x1F8 for __aarch64_read_tp !!
|
|
} ThreadVars;
|
|
|
|
static inline ThreadVars* getThreadVars(void) {
|
|
return (ThreadVars*)((u8*)armGetTls() + 0x1E0);
|
|
}
|