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
This commit is contained in:
Tropical 2026-03-02 18:28:06 -06:00
parent 70c8a010e8
commit 006dba0602

View file

@ -6,6 +6,7 @@
#include <cstdint>
#include <cstring>
#include <string>
#include <pthread.h>
#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