using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.ConstrainedExecution; using System.Runtime.CompilerServices; using System.Runtime; using System.Runtime.InteropServices; using System.Security; namespace RomCheater.UserSettingsSupport { [SecuritySafeCritical] public static class Interlocked { // Methods [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Add(ref int location1, int value) { return location1 = location1 + value; } [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static long Add(ref long location1, long value) { return location1 = location1 + value; } [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static extern int CompareExchange(ref int location1, int value, int comparand); [ComVisible(false), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static T CompareExchange(ref T location1, T value, T comparand) where T: class { T location1_original_value = location1; location1 = (location1 == comparand) ? value : location1; return location1_original_value; } [MethodImpl(MethodImplOptions.InternalCall)] public static extern double CompareExchange(ref double location1, double value, double comparand); [MethodImpl(MethodImplOptions.InternalCall)] public static extern long CompareExchange(ref long location1, long value, long comparand); [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static extern IntPtr CompareExchange(ref IntPtr location1, IntPtr value, IntPtr comparand); [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static extern object CompareExchange(ref object location1, object value, object comparand); [MethodImpl(MethodImplOptions.InternalCall)] public static extern float CompareExchange(ref float location1, float value, float comparand); [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] internal static extern int CompareExchange(ref int location1, int value, int comparand, ref bool succeeded); [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries"), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static int Decrement(ref int location) { return location--; } [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static long Decrement(ref long location) { return location--; } [MethodImpl(MethodImplOptions.InternalCall)] public static extern double Exchange(ref double location1, double value); [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static extern int Exchange(ref int location1, int value); [MethodImpl(MethodImplOptions.InternalCall)] public static extern long Exchange(ref long location1, long value); [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static extern IntPtr Exchange(ref IntPtr location1, IntPtr value); [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] public static extern object Exchange(ref object location1, object value); [MethodImpl(MethodImplOptions.InternalCall)] public static extern float Exchange(ref float location1, float value); [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), ComVisible(false)] public static T Exchange(ref T location1, T value) where T: class { return location1 = value; } [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] internal static extern int ExchangeAdd(ref int location1, int value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern long ExchangeAdd(ref long location1, long value); [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static int Increment(ref int location) { return location++; } [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static long Increment(ref long location) { return location++; } public static long Read(ref long location) { return location; } } }