2009-02-11 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / support.cs
index d207520d8102bc620610e043b478077865c60301..ef0545ea0b5b9e7d2d8f9ef7cbfba9ae49e670ed 100644 (file)
@@ -80,7 +80,11 @@ namespace Mono.CSharp {
 #endif
 
        class PtrHashtable : Hashtable {
-               sealed class PtrComparer : IComparer {
+               sealed class PtrComparer : IComparer
+#if NET_2_0
+                       , IEqualityComparer
+#endif
+               {
                        private PtrComparer () {}
 
                        public static PtrComparer Instance = new PtrComparer ();
@@ -92,12 +96,28 @@ namespace Mono.CSharp {
                                else
                                        return 1;
                        }
+#if NET_2_0
+                       bool IEqualityComparer.Equals (object x, object y)
+                       {
+                               return x == y;
+                       }
+                       
+                       int IEqualityComparer.GetHashCode (object obj)
+                       {
+                               return obj.GetHashCode ();
+                       }
+#endif
+                       
                }
 
-               public PtrHashtable ()
+#if NET_2_0
+               public PtrHashtable () : base (PtrComparer.Instance) {}
+#else
+               public PtrHashtable () 
                {
                        comparer = PtrComparer.Instance;
                }
+#endif
 
 #if MS_COMPATIBLE
                //
@@ -446,4 +466,17 @@ namespace Mono.CSharp {
                }
        }
 
+       public class UnixUtils {
+               [System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty")]
+               extern static int _isatty (int fd);
+                       
+               public static bool isatty (int fd)
+               {
+                       try {
+                               return _isatty (fd) == 1;
+                       } catch {
+                               return false;
+                       }
+               }
+       }
 }