blob: 611ed5fb349ef3bd8655da9be647f7b4ade88b34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* tsd.c
*
* Description:
* POSIX thread functions which implement thread-specific data (TSD).
*/
#include "pthread.h"
int
pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
{
DWORD index;
/* FIXME: the destructor function is ignored for now. This needs to
be managed via the same cleanup handler mechanism as user-define
cleanup handlers during a thread exit. */
if (destructor != NULL)
{
return EINVAL;
}
index = TlsAlloc();
if (index == 0xFFFFFFFF)
{
return EAGAIN;
}
/* Only modify the `key' parameter if allocation was successful. */
*key = index;
return 0;
}
int
pthread_setspecific(pthread_key_t key, void *value)
{
return (TlsSetValue(key, value) == FALSE) ? EINVAL : 0;
}
void *
pthread_getspecific(pthread_key_t key)
{
return TlsGetValue(key);
}
int
pthread_key_delete(pthread_key_t key)
{
return (TlsFree(key) == FALSE) ? EINVAL : 0;
}
|