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