1 
2 /*
3  * Copyright � 2001 Novell, Inc. All Rights Reserved.
4  *
5  * You may distribute under the terms of either the GNU General Public
6  * License or the Artistic License, as specified in the README file.
7  *
8  */
9 
10 /*
11  * FILENAME		:	nw5thread.c
12  * DESCRIPTION	:	Thread related functions.
13  * Author		:	SGP
14  * Date			:	January 2001.
15  *
16  */
17 
18 
19 
20 #include "EXTERN.h"
21 #include "perl.h"
22 
23 //For Thread Local Storage
24 #include "win32ish.h"		// For "BOOL", "TRUE" and "FALSE"
25 #include "nwtinfo.h"
26 
27 #ifdef USE_DECLSPEC_THREAD
28 __declspec(thread) void *PL_current_context = NULL;
29 #endif
30 
31 
32 void
Perl_set_context(void * t)33 Perl_set_context(void *t)
34 {
35 #if defined(USE_5005THREADS) || defined(USE_ITHREADS)
36 #  ifdef USE_DECLSPEC_THREAD
37     Perl_current_context = t;
38 #  else
39 	fnAddThreadCtx(PL_thr_key, t);
40 #  endif
41 #endif
42 }
43 
44 
45 void *
Perl_get_context(void)46 Perl_get_context(void)
47 {
48 #if defined(USE_5005THREADS) || defined(USE_ITHREADS)
49 #  ifdef USE_DECLSPEC_THREAD
50     return Perl_current_context;
51 #  else
52 	return(fnGetThreadCtx(PL_thr_key));
53 #  endif
54 #else
55     return NULL;
56 #endif
57 }
58 
59 
60 //To Remove the Thread Context stored during Perl_set_context
61 BOOL
Remove_Thread_Ctx(void)62 Remove_Thread_Ctx(void)
63 {
64 #if defined(USE_5005THREADS) || defined(USE_ITHREADS)
65 #  ifdef USE_DECLSPEC_THREAD
66 	return TRUE;
67 #  else
68 	return(fnRemoveThreadCtx(PL_thr_key));
69 #  endif
70 #  else
71 	return TRUE;
72 #endif
73 }
74 
75 
76 //PL_thr_key - Not very sure if this is global or per thread.  When multiple scripts
77 //run simultaneously on NetWare, this will give problems.  Hence in nwtinfo.c, the
78 //current thread id is used as the TLS index & PL_thr_key is not used.
79 //This has to be checked???? - sgp
80 
81