* Makefile: Build the make-map.exe in Mono.Unix.Native; add /nowarn:0618 to
[mono.git] / mcs / class / Mono.Posix / Mono.Unix / Stdlib.cs
index 5ff2e253eb16ba663092ffbe069d22251c6b0250..0eda499976ac5cef2b5905c3e5b6f0361663fee4 100644 (file)
@@ -5,6 +5,20 @@
 //   Jonathan Pryor (jonpryor@vt.edu)
 //
 // (C) 2004-2005 Jonathan Pryor
+//
+
+// Deprecated Warning:
+//
+//    This class is deprecated, and exists only for backward compatibility
+//    with development versions of Mono 1.1.x.  It will be removed with 
+//    Mono 1.2.  Migrate to the Mono.Unix.Native types, or use the Unix*
+//    wrapper classes instead.
+//
+//    The [Map] attributes have been removed.  However, since the type names
+//    are identical to those in Mono.Unix.Native, the MonoPosixHelper methods
+//    will continue to exist and function correctly.
+//
+
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,6 +41,7 @@
 //
 
 using System;
+using System.Collections;
 using System.IO;
 using System.Runtime.InteropServices;
 using System.Text;
@@ -36,6 +51,7 @@ namespace Mono.Unix {
 
        #region Enumerations
 
+       [Obsolete ("Use Mono.Unix.Native.Errno")]
        [Map]
        public enum Error : int {
                // errors & their values liberally copied from
@@ -174,6 +190,7 @@ namespace Mono.Unix {
 
        #region Classes
 
+       [Obsolete ("Use Mono.Unix.Native.FilePosition")]
        public sealed class FilePosition : IDisposable {
 
                private static readonly int FilePositionDumpSize = 
@@ -261,8 +278,10 @@ namespace Mono.Unix {
 #if NET_2_0 && UNMANAGED_FN_PTR_SUPPORT_FIXED
        [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
 #endif
+       [Obsolete ("Use Mono.Unix.Native.SignalHandler")]
        public delegate void SignalHandler (int signal);
 
+#if !NET_2_0
        internal sealed class SignalWrapper {
                private IntPtr handler;
 
@@ -276,6 +295,7 @@ namespace Mono.Unix {
                        Stdlib.InvokeSignalHandler (signum, handler);
                }
        }
+#endif
 
        internal class XPrintfFunctions
        {
@@ -316,6 +336,8 @@ namespace Mono.Unix {
        // anything from Syscall is non-portable, but restricting yourself to just
        // Stdlib is intended to be portable.
        //
+       [CLSCompliant (false)]
+       [Obsolete ("Use Mono.Unix.Native.Stdlib")]
        public class Stdlib
        {
                internal const string LIBC = "msvcrt";
@@ -390,6 +412,14 @@ namespace Mono.Unix {
                public static readonly SignalHandler SIG_ERR = new SignalHandler (_ErrorHandler);
                public static readonly SignalHandler SIG_IGN = new SignalHandler (_IgnoreHandler);
 
+               private static readonly SignalHandler[] registered_signals;
+
+               static Stdlib ()
+               {
+                       Array signals = Enum.GetValues(typeof(Signum));
+                       registered_signals = new SignalHandler [(int) signals.GetValue (signals.Length-1)];
+               }
+
                [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
                                SetLastError=true, EntryPoint="signal")]
                private static extern IntPtr sys_signal (int signum, SignalHandler handler);
@@ -401,6 +431,11 @@ namespace Mono.Unix {
                public static SignalHandler signal (Signum signum, SignalHandler handler)
                {
                        int _sig = UnixConvert.FromSignum (signum);
+
+                       lock (registered_signals) {
+                               registered_signals [(int) signum] = handler;
+                       }
+
                        IntPtr r;
                        if (handler == SIG_DFL)
                                r = sys_signal (_sig, _SIG_DFL);
@@ -421,7 +456,11 @@ namespace Mono.Unix {
                                return SIG_ERR;
                        if (handler == _SIG_IGN)
                                return SIG_IGN;
+#if NET_2_0
+                       return (SignalHandler) Marshal.GetDelegateForFunctionPointer (handler, typeof(SignalHandler));
+#else
                        return new SignalHandler (new SignalWrapper (handler).InvokeSignalHandler);
+#endif
                }
 
                [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, EntryPoint="raise")]