Commit | Line | Data |
---|---|---|
e1caacb4 JH |
1 | #include "EXTERN.h" |
2 | #include "perl.h" | |
3 | ||
e1caacb4 JH |
4 | #ifdef USE_DECLSPEC_THREAD |
5 | __declspec(thread) void *PL_current_context = NULL; | |
6 | #endif | |
7 | ||
8 | void | |
9 | Perl_set_context(void *t) | |
10 | { | |
3db8f154 | 11 | #if defined(USE_ITHREADS) |
e1caacb4 JH |
12 | # ifdef USE_DECLSPEC_THREAD |
13 | Perl_current_context = t; | |
14 | # else | |
15 | DWORD err = GetLastError(); | |
16 | TlsSetValue(PL_thr_key,t); | |
17 | SetLastError(err); | |
18 | # endif | |
19 | #endif | |
20 | } | |
21 | ||
22 | void * | |
23 | Perl_get_context(void) | |
24 | { | |
3db8f154 | 25 | #if defined(USE_ITHREADS) |
e1caacb4 JH |
26 | # ifdef USE_DECLSPEC_THREAD |
27 | return Perl_current_context; | |
28 | # else | |
29 | DWORD err = GetLastError(); | |
30 | void *result = TlsGetValue(PL_thr_key); | |
31 | SetLastError(err); | |
32 | return result; | |
33 | # endif | |
34 | #else | |
35 | return NULL; | |
36 | #endif | |
37 | } |