Merge pull request #2216 from akoeplinger/fix-array-sort
[mono.git] / mcs / class / corlib / System / IntPtr.cs
index e8ca505de18e06bdaa06e9fad7c63672b0a9d95c..c449de83997a3b308b1df8fbe881eb053f166dc3 100644 (file)
@@ -45,6 +45,7 @@
 using System.Globalization;
 using System.Runtime.Serialization;
 using System.Runtime.ConstrainedExecution;
+using System.Diagnostics.Contracts;
 
 namespace System
 {
@@ -148,9 +149,9 @@ namespace System
                public string ToString (string format)
                {
                        if (Size == 4)
-                               return ((int) m_value).ToString (format);
+                               return ((int) m_value).ToString (format, null);
                        else
-                               return ((long) m_value).ToString (format);
+                               return ((long) m_value).ToString (format, null);
                }
 
                [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
@@ -200,7 +201,6 @@ namespace System
                        return value.m_value;
                }
 
-#if NET_4_0
                [ReliabilityContract (Consistency.MayCorruptInstance, Cer.MayFail)]
                public static IntPtr Add (IntPtr pointer, int offset)
                {
@@ -224,12 +224,13 @@ namespace System
                {
                        return (IntPtr) (unchecked (((byte *) pointer) - offset));
                }
-#else
-               /* Needed by Marshal.cs */
-               internal static IntPtr Add (IntPtr pointer, int offset)
+
+               // fast way to compare IntPtr to (IntPtr)0 while IntPtr.Zero doesn't work due to slow statics access
+               [Pure]
+               [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
+               internal unsafe bool IsNull()
                {
-                       return (IntPtr) (unchecked (((byte *) pointer) + offset));
+                       return m_value == null;
                }
-#endif
        }
 }