1 #include "EXTERN.h" 2 #include "perl.h" 3 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 { 11 #if defined(USE_ITHREADS) 12 # ifdef USE_DECLSPEC_THREAD 13 Perl_current_context = t; 14 PERL_SET_NON_tTHX_CONTEXT(t); 15 # else 16 DWORD err = GetLastError(); 17 TlsSetValue(PL_thr_key,t); 18 SetLastError(err); 19 # endif 20 #endif 21 } 22 23 void * 24 Perl_get_context(void) 25 { 26 #if defined(USE_ITHREADS) 27 # ifdef USE_DECLSPEC_THREAD 28 return Perl_current_context; 29 # else 30 DWORD err = GetLastError(); 31 void *result = TlsGetValue(PL_thr_key); 32 SetLastError(err); 33 return result; 34 # endif 35 #else 36 return NULL; 37 #endif 38 } 39