Final move from meta-3.0 to meta-3.5
[p5sagit/p5-mst-13.2.git] / win32 / win32thread.c
CommitLineData
ea0efc06 1#include "EXTERN.h"
2#include "perl.h"
d55594ae 3
c69f112c 4#ifdef USE_DECLSPEC_THREAD
ba869deb 5__declspec(thread) void *PL_current_context = NULL;
c69f112c 6#endif
9811a7d7 7
8void
ba869deb 9Perl_set_context(void *t)
9811a7d7 10{
3db8f154 11#if defined(USE_ITHREADS)
ba869deb 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
4c36ecb7 19#endif
9811a7d7 20}
21
ba869deb 22void *
23Perl_get_context(void)
9811a7d7 24{
3db8f154 25#if defined(USE_ITHREADS)
ba869deb 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
4c36ecb7 34#else
ba869deb 35 return NULL;
4c36ecb7 36#endif
9811a7d7 37}