//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Threading;
using System.Runtime.CompilerServices;

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
/// <summary>
/// </summary>
public static partial class HVolatile {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static int Write([HVolatileAccess] ref int location,int value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

[CLSCompliant(false)]
public static uint Write([HVolatileAccess] ref uint location,uint value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

//--------------------------------------------------------------------------------------------------

public static short Write([HVolatileAccess] ref short location,short value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

[CLSCompliant(false)]
public static ushort Write([HVolatileAccess] ref ushort location,ushort value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

//--------------------------------------------------------------------------------------------------

public static long Write([HVolatileAccess] ref long location,long value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

[CLSCompliant(false)]
public static ulong Write([HVolatileAccess] ref ulong location,ulong value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

//--------------------------------------------------------------------------------------------------

public static byte Write([HVolatileAccess] ref byte location,byte value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

[CLSCompliant(false)]
public static sbyte Write([HVolatileAccess] ref sbyte location,sbyte value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

//--------------------------------------------------------------------------------------------------

public static double Write([HVolatileAccess] ref double location,double value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

public static float Write([HVolatileAccess] ref float location,float value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

//--------------------------------------------------------------------------------------------------

public static IntPtr Write([HVolatileAccess] ref IntPtr location,IntPtr value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

[CLSCompliant(false)]
public static UIntPtr Write([HVolatileAccess] ref UIntPtr location,UIntPtr value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

//--------------------------------------------------------------------------------------------------

public static object Write([HVolatileAccess] ref object location,object value)
{
   Thread.VolatileWrite(ref location,value); return value;
}

//==================================================================================================

static HVolatile()
{
   CommonHelpers_Core.Access();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HVolatile
//**************************************************************************************************

} // CommonHelpers (.WASM)
