mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-12 17:01:55 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user