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:
authorJan Kotas <jkotas@microsoft.com>2017-03-25 05:50:59 +0300
committerJan Kotas <jkotas@microsoft.com>2017-03-25 05:50:59 +0300
commita4b1c236fa21e98a5bebec4db75736feccacf028 (patch)
treebff850b7dc05aeb93c190b72f47095ef537bb548
parent683c5fc4d157fe637b36aae931dfa0285ae8ebc6 (diff)
Add Interlocked.MemoryBarrierProcessWide
Contributes to https://github.com/dotnet/corefx/issues/16799 [tfs-changeset: 1652035]
-rw-r--r--src/Native/Runtime/MiscHelpers.cpp9
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs3
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Interlocked.cs5
3 files changed, 17 insertions, 0 deletions
diff --git a/src/Native/Runtime/MiscHelpers.cpp b/src/Native/Runtime/MiscHelpers.cpp
index ecc131bbf..0db61bcf4 100644
--- a/src/Native/Runtime/MiscHelpers.cpp
+++ b/src/Native/Runtime/MiscHelpers.cpp
@@ -62,6 +62,15 @@ EXTERN_C REDHAWK_API UInt32_BOOL __cdecl RhYield()
return PalSwitchToThread();
}
+EXTERN_C REDHAWK_API void __cdecl RhFlushProcessWriteBuffers()
+{
+ // This must be called via p/invoke -- it's a wait operation and we don't want to block thread suspension on this.
+ ASSERT_MSG(!ThreadStore::GetCurrentThread()->IsCurrentThreadInCooperativeMode(),
+ "You must p/invoke to RhFlushProcessWriteBuffers");
+
+ PalFlushProcessWriteBuffers();
+}
+
// Return the DispatchMap pointer of a type
COOP_PINVOKE_HELPER(DispatchMap*, RhGetDispatchMapForType, (EEType * pEEType))
{
diff --git a/src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs
index 4ec05b07b..9424e17d9 100644
--- a/src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs
+++ b/src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs
@@ -325,6 +325,9 @@ namespace System.Runtime
private static extern int _RhYield();
internal static bool RhYield() { return (_RhYield() != 0); }
+ [DllImport(RuntimeLibrary, EntryPoint = "RhFlushProcessWriteBuffers", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ internal static extern void RhFlushProcessWriteBuffers();
+
// Wait for any object to be signalled, in a way that's compatible with the CLR's behavior in an STA.
// ExactSpelling = 'true' to force MCG to resolve it to default
[DllImport(RuntimeLibrary, ExactSpelling = true)]
diff --git a/src/System.Private.CoreLib/src/System/Threading/Interlocked.cs b/src/System.Private.CoreLib/src/System/Threading/Interlocked.cs
index 303e40249..5cce895c0 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Interlocked.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Interlocked.cs
@@ -495,5 +495,10 @@ namespace System.Threading
#endregion
#endif // CORERT
+
+ public static void MemoryBarrierProcessWide()
+ {
+ RuntimeImports.RhFlushProcessWriteBuffers();
+ }
}
}