blob: 5887dd785251b2d4207fec0793e9bbf99e15baa2 (
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#ifndef __GCENV_STRUCTS_INCLUDED__
#define __GCENV_STRUCTS_INCLUDED__
//
// Structs shared between the GC and the environment
//
struct GCSystemInfo
{
uint32_t dwNumberOfProcessors;
uint32_t dwPageSize;
uint32_t dwAllocationGranularity;
};
typedef void * HANDLE;
#ifdef PLATFORM_UNIX
typedef char TCHAR;
#define _T(s) s
#else
#ifndef _INC_WINDOWS
typedef wchar_t TCHAR;
#define _T(s) L##s
#endif
#endif
#ifdef PLATFORM_UNIX
class EEThreadId
{
pthread_t m_id;
// Indicates whether the m_id is valid or not. pthread_t doesn't have any
// portable "invalid" value.
bool m_isValid;
public:
bool IsCurrentThread()
{
return m_isValid && pthread_equal(m_id, pthread_self());
}
void SetToCurrentThread()
{
m_id = pthread_self();
m_isValid = true;
}
void Clear()
{
m_isValid = false;
}
};
#else // PLATFORM_UNIX
#ifndef _INC_WINDOWS
extern "C" uint32_t __stdcall GetCurrentThreadId();
#endif
class EEThreadId
{
uint32_t m_uiId;
public:
bool IsCurrentThread()
{
return m_uiId == ::GetCurrentThreadId();
}
void SetToCurrentThread()
{
m_uiId = ::GetCurrentThreadId();
}
void Clear()
{
m_uiId = 0;
}
};
#endif // PLATFORM_UNIX
#ifndef _INC_WINDOWS
#ifdef PLATFORM_UNIX
typedef struct _RTL_CRITICAL_SECTION {
pthread_mutex_t mutex;
} CRITICAL_SECTION, RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
#else
#pragma pack(push, 8)
typedef struct _RTL_CRITICAL_SECTION {
void* DebugInfo;
//
// The following three fields control entering and exiting the critical
// section for the resource
//
int32_t LockCount;
int32_t RecursionCount;
HANDLE OwningThread; // from the thread's ClientId->UniqueThread
HANDLE LockSemaphore;
uintptr_t SpinCount; // force size on 64-bit systems when packed
} CRITICAL_SECTION, RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
#pragma pack(pop)
#endif
#endif // _INC_WINDOWS
#endif // __GCENV_STRUCTS_INCLUDED__
|