MCPcopy Create free account
hub / github.com/devkitPro/libctru / initThreadVars

Function initThreadVars

libctru/source/system/syscalls.c:237–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237void initThreadVars(struct Thread_tag *thread)
238{
239 ThreadVars* tv = getThreadVars();
240 tv->magic = THREADVARS_MAGIC;
241 tv->reent = thread != NULL ? &thread->reent : _impure_ptr;
242 tv->thread_ptr = thread;
243#pragma GCC diagnostic push
244#pragma GCC diagnostic ignored "-Warray-bounds"
245 tv->tls_tp = (thread != NULL ? (u8*)thread->stacktop : __tls_start) - 8; // Arm ELF TLS ABI mandates an 8-byte header
246#pragma GCC diagnostic pop
247 tv->srv_blocking_policy = false;
248
249 // Kernel does not initialize fpscr at all, so we must do it ourselves
250 // https://developer.arm.com/documentation/ddi0360/f/vfp-programmers-model/vfp11-system-registers/floating-point-status-and-control-register--fpscr
251
252 // All flags clear, all interrupts disabled, all instruction scalar.
253 // As for the 3 below fields: default NaN mode, flush-to-zero both enabled & round to nearest.
254 __builtin_arm_set_fpscr(BIT(25) | BIT(24) | (0u << 22));
255}
256
257void __system_initSyscalls(void)
258{

Callers 2

_thread_beginFunction · 0.85
__system_initSyscallsFunction · 0.85

Calls 1

getThreadVarsFunction · 0.85

Tested by

no test coverage detected