Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2015-10-01 00:47:24 +0300
committerScott Mosier <smosier@microsoft.com>2015-10-01 00:47:24 +0300
commitad0323ab91a7b1469b42ca5457ddd631b94294fe (patch)
tree88fae57e1ec3aae90288463dc07e58f7aebc1de8 /src/Native/Runtime/Crst.cpp
parent6763d16387778f126ec510c0421783952602f8f7 (diff)
Initial population of CoreRT Runtime files.
Diffstat (limited to 'src/Native/Runtime/Crst.cpp')
-rw-r--r--src/Native/Runtime/Crst.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/Native/Runtime/Crst.cpp b/src/Native/Runtime/Crst.cpp
new file mode 100644
index 000000000..53ad5b975
--- /dev/null
+++ b/src/Native/Runtime/Crst.cpp
@@ -0,0 +1,79 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+#include "common.h"
+#ifdef DACCESS_COMPILE
+#include "gcrhenv.h"
+#endif // DACCESS_COMPILE
+
+#ifndef DACCESS_COMPILE
+#include "commontypes.h"
+#include "commonmacros.h"
+#include "palredhawkcommon.h"
+#include "palredhawk.h"
+#include "holder.h"
+#include "crst.h"
+#endif // !DACCESS_COMPILE
+
+void CrstStatic::Init(CrstType eType, CrstFlags eFlags)
+{
+#ifndef DACCESS_COMPILE
+#if defined(_DEBUG)
+ m_uiOwnerId = UNOWNED;
+#endif // _DEBUG
+ PalInitializeCriticalSectionEx(&m_sCritSec, 0, 0);
+#else
+ UNREFERENCED_PARAMETER(eType);
+ UNREFERENCED_PARAMETER(eFlags);
+#endif // !DACCESS_COMPILE
+}
+
+void CrstStatic::Destroy()
+{
+#ifndef DACCESS_COMPILE
+ PalDeleteCriticalSection(&m_sCritSec);
+#endif // !DACCESS_COMPILE
+}
+
+// static
+void CrstStatic::Enter(CrstStatic *pCrst)
+{
+#ifndef DACCESS_COMPILE
+ PalEnterCriticalSection(&pCrst->m_sCritSec);
+#if defined(_DEBUG)
+ pCrst->m_uiOwnerId = PalGetCurrentThreadId();
+#endif // _DEBUG
+#else
+ UNREFERENCED_PARAMETER(pCrst);
+#endif // !DACCESS_COMPILE
+}
+
+// static
+void CrstStatic::Leave(CrstStatic *pCrst)
+{
+#ifndef DACCESS_COMPILE
+#if defined(_DEBUG)
+ pCrst->m_uiOwnerId = UNOWNED;
+#endif // _DEBUG
+ PalLeaveCriticalSection(&pCrst->m_sCritSec);
+#else
+ UNREFERENCED_PARAMETER(pCrst);
+#endif // !DACCESS_COMPILE
+}
+
+#if defined(_DEBUG)
+bool CrstStatic::OwnedByCurrentThread()
+{
+#ifndef DACCESS_COMPILE
+ return m_uiOwnerId == PalGetCurrentThreadId();
+#else
+ return false;
+#endif
+}
+
+EEThreadId CrstStatic::GetHolderThreadId()
+{
+ return EEThreadId(m_uiOwnerId);
+}
+#endif // _DEBUG