blob: cf1cba8c0fa6e28285c15149973f1a43ceb953ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#ifndef THREADSPECIFICVALUE_H
#define THREADSPECIFICVALUE_H
#include "Configuration/UnityConfigure.h"
#if !SUPPORT_THREADS
class PlatformThreadSpecificValue
{
public:
PlatformThreadSpecificValue();
~PlatformThreadSpecificValue();
void* GetValue() const;
void SetValue(void* value);
private:
void* m_Value;
};
inline PlatformThreadSpecificValue::PlatformThreadSpecificValue()
{
m_Value = 0;
}
inline PlatformThreadSpecificValue::~PlatformThreadSpecificValue()
{
//do nothing
}
inline void* PlatformThreadSpecificValue::GetValue() const
{
return m_Value;
}
inline void PlatformThreadSpecificValue::SetValue(void* value)
{
m_Value = value;
}
#elif UNITY_WIN || UNITY_XENON
# include "Winapi/PlatformThreadSpecificValue.h"
#elif UNITY_OSX || UNITY_IPHONE || UNITY_ANDROID || UNITY_PEPPER || UNITY_LINUX || UNITY_BB10 || UNITY_TIZEN
# include "Posix/PlatformThreadSpecificValue.h"
#else
# include "PlatformThreadSpecificValue.h"
#endif
#if UNITY_DYNAMIC_TLS
template<class T> class ThreadSpecificValue
{
PlatformThreadSpecificValue m_TLSKey;
public:
inline operator T () const
{
return (T)GetValue ();
}
inline T operator -> () const
{
return (T)GetValue ();
}
inline T operator ++ ()
{
*this = *this + 1;
return *this;
}
inline T operator -- ()
{
*this = *this - 1;
return *this;
}
inline T operator = (T value)
{
SetValue((void*)value);
return value;
}
private:
void* GetValue() const;
void SetValue(void* value);
};
template<class T> void* ThreadSpecificValue<T>::GetValue () const
{
return m_TLSKey.GetValue();
}
template <class T> void ThreadSpecificValue<T>::SetValue (void* value)
{
m_TLSKey.SetValue(value);
}
#define UNITY_TLS_VALUE(type) ThreadSpecificValue<type>
#else
# ifndef UNITY_TLS_VALUE
# error "A static TLS mechanism is not defined for this platform"
# endif
#endif // UNITY_DYNAMIC_TLS
#endif
|