mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-15 23:32:36 +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:
parent
70c8a010e8
commit
006dba0602
|
|
@ -6,6 +6,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#define TRUE true
|
#define TRUE true
|
||||||
#define FALSE false
|
#define FALSE false
|
||||||
|
|
@ -65,4 +66,31 @@ typedef VOID* XMEMDECOMPRESSION_CONTEXT;
|
||||||
|
|
||||||
typedef float FLOAT;
|
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
|
#endif // WLINUX_H
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue