From 006dba0602d87de0fd93ca2fb3039f0a651e2ca1 Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:28:06 -0600 Subject: [PATCH] feat: stub winapi TLS functions with pthread keys Not sure how sound implicit casting `pthread_key_t` to `DWORD` is, but we can get away with it for now. Otherwise, we're gonna need to keep a global list of registered keys and mutex that and blah blah blah --- Minecraft.World/linux/wlinux.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Minecraft.World/linux/wlinux.h b/Minecraft.World/linux/wlinux.h index 0148a1ce4..d3842b934 100644 --- a/Minecraft.World/linux/wlinux.h +++ b/Minecraft.World/linux/wlinux.h @@ -6,6 +6,7 @@ #include #include #include +#include #define TRUE true #define FALSE false @@ -65,4 +66,31 @@ typedef VOID* XMEMDECOMPRESSION_CONTEXT; typedef float FLOAT; +#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF) + +DWORD TlsAlloc(VOID) { + pthread_key_t key; + + if (pthread_key_create(&key, NULL) == 0) { + return key; + } else { + return TLS_OUT_OF_INDEXES; + } +} + +BOOL TlsFree(DWORD dwTlsIndex) +{ + return pthread_key_delete(dwTlsIndex) == 0; +} + +LPVOID TlsGetValue(DWORD dwTlsIndex) +{ + return pthread_getspecific(dwTlsIndex); +} + +BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) +{ + return pthread_setspecific(dwTlsIndex, lpTlsValue) == 0; +} + #endif // WLINUX_H