FreeRDP
Loading...
Searching...
No Matches
winpr/libwinpr/thread/tls.c
1
20#include <winpr/config.h>
21
22#include <winpr/handle.h>
23
24#include <winpr/thread.h>
25
33#ifndef _WIN32
34
35#include <pthread.h>
36
37DWORD TlsAlloc(void)
38{
39 pthread_key_t key = 0;
40
41 if (pthread_key_create(&key, NULL) != 0)
42 return TLS_OUT_OF_INDEXES;
43
44 return key;
45}
46
47LPVOID TlsGetValue(DWORD dwTlsIndex)
48{
49 LPVOID value = NULL;
50 pthread_key_t key = 0;
51 key = (pthread_key_t)dwTlsIndex;
52 value = (LPVOID)pthread_getspecific(key);
53 return value;
54}
55
56BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
57{
58 pthread_key_t key = 0;
59 key = (pthread_key_t)dwTlsIndex;
60 pthread_setspecific(key, lpTlsValue);
61 return TRUE;
62}
63
64BOOL TlsFree(DWORD dwTlsIndex)
65{
66 pthread_key_t key = 0;
67 key = (pthread_key_t)dwTlsIndex;
68 pthread_key_delete(key);
69 return TRUE;
70}
71
72#endif