source: trunk/essentials/dev-lang/perl/win32/win32thread.c

Last change on this file was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 2.7 KB
Line 
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
8void
9Perl_set_context(void *t)
10{
11#if defined(USE_5005THREADS) || defined(USE_ITHREADS)
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
22void *
23Perl_get_context(void)
24{
25#if defined(USE_5005THREADS) || defined(USE_ITHREADS)
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