Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Pryor <jpryor@novell.com>2004-12-30 17:30:42 +0300
committerJonathan Pryor <jpryor@novell.com>2004-12-30 17:30:42 +0300
commit38abc4f2841b5eeb589eb3fcef31949b2d5ab929 (patch)
treeb6e842aaae54db500510f9f3b5483f1e315a512e /mcs/class/Mono.Posix
parent0a052c2683666936c2b0c23d22078e5d628fa86c (diff)
* CdeclFunctions.cs: Remove warning about unused variable.
* Stdlib.cs: Make signal(2) sane and (hopefully) complete. * Syscall.cs: Fix cuserid Obsolete message to reference correct class name. * UnixProcess.cs: Remove warning about unused variable. * UnixMarshal.cs: Remove warnings about unused variables. svn path=/trunk/mcs/; revision=38182
Diffstat (limited to 'mcs/class/Mono.Posix')
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/CdeclFunction.cs2
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/ChangeLog8
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/Stdlib.cs88
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/Syscall.cs5
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs7
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/UnixProcess.cs3
6 files changed, 96 insertions, 17 deletions
diff --git a/mcs/class/Mono.Posix/Mono.Unix/CdeclFunction.cs b/mcs/class/Mono.Posix/Mono.Unix/CdeclFunction.cs
index 39d2d3a28e7..80b5d184261 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/CdeclFunction.cs
+++ b/mcs/class/Mono.Posix/Mono.Unix/CdeclFunction.cs
@@ -119,7 +119,7 @@ namespace Mono.Unix {
}
TypeBuilder tb = CreateType (typeName);
- MethodBuilder mb = tb.DefinePInvokeMethod (
+ /* MethodBuilder mb = */ tb.DefinePInvokeMethod (
method,
library,
MethodAttributes.PinvokeImpl | MethodAttributes.Static | MethodAttributes.Public,
diff --git a/mcs/class/Mono.Posix/Mono.Unix/ChangeLog b/mcs/class/Mono.Posix/Mono.Unix/ChangeLog
index acc4019eede..7fe64ae8661 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/ChangeLog
+++ b/mcs/class/Mono.Posix/Mono.Unix/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-30 Jonathan Pryor <jonpryor@vt.edu>
+
+ * CdeclFunctions.cs: Remove warning about unused variable.
+ * Stdlib.cs: Make signal(2) sane and (hopefully) complete.
+ * Syscall.cs: Fix cuserid Obsolete message to reference correct class name.
+ * UnixProcess.cs: Remove warning about unused variable.
+ * UnixMarshal.cs: Remove warnings about unused variables.
+
2004-12-29 Jonathan Pryor <jonpryor@vt.edu>
* UnixPath.cs: Add ReadSymbolicLink(), which takes an intelligent approach
diff --git a/mcs/class/Mono.Posix/Mono.Unix/Stdlib.cs b/mcs/class/Mono.Posix/Mono.Unix/Stdlib.cs
index a70852e491a..207952f0c0c 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/Stdlib.cs
+++ b/mcs/class/Mono.Posix/Mono.Unix/Stdlib.cs
@@ -34,7 +34,7 @@ using Mono.Unix;
namespace Mono.Unix {
- public delegate void sighandler_t (int value);
+ public delegate void Sighandler_t (int value);
internal class XPrintfFunctions
{
@@ -57,6 +57,25 @@ namespace Mono.Unix {
}
}
+ internal sealed class SignalWrapper {
+ private IntPtr handler;
+
+ internal SignalWrapper (IntPtr handler)
+ {
+ this.handler = handler;
+ }
+
+ private const string MPH = "MonoPosixHelper";
+
+ [DllImport (MPH, EntryPoint="Mono_Posix_Syscall_InvokeSignalHandler")]
+ private static extern void InvokeSignalHandler (int signum, IntPtr handler);
+
+ public void InvokeSignalHandler (int signum)
+ {
+ InvokeSignalHandler (signum, handler);
+ }
+ }
+
//
// Convention: Functions that are part of the C standard library go here.
//
@@ -80,19 +99,72 @@ namespace Mono.Unix {
//
// <signal.h>
//
+ [DllImport (MPH, EntryPoint="Mono_Posix_Stdlib_SIG_DFL")]
+ private static extern IntPtr GetDefaultSignal ();
+
+ [DllImport (MPH, EntryPoint="Mono_Posix_Stdlib_SIG_ERR")]
+ private static extern IntPtr GetErrorSignal ();
+
+ [DllImport (MPH, EntryPoint="Mono_Posix_Stdlib_SIG_IGN")]
+ private static extern IntPtr GetIgnoreSignal ();
+
+ private static readonly IntPtr _SIG_DFL = GetDefaultSignal ();
+ private static readonly IntPtr _SIG_ERR = GetErrorSignal ();
+ private static readonly IntPtr _SIG_IGN = GetIgnoreSignal ();
+
+ private static void _ErrorHandler (int signum)
+ {
+ Console.Error.WriteLine ("Error handler invoked for signum " +
+ signum + ". Don't do that.");
+ }
+
+ private static void _DefaultHandler (int signum)
+ {
+ Console.Error.WriteLine ("Default handler invoked for signum " +
+ signum + ". Don't do that.");
+ }
+
+ private static void _IgnoreHandler (int signum)
+ {
+ Console.Error.WriteLine ("Ignore handler invoked for signum " +
+ signum + ". Don't do that.");
+ }
+
+ public static readonly Sighandler_t SIG_DFL = _DefaultHandler;
+ public static readonly Sighandler_t SIG_ERR = _ErrorHandler;
+ public static readonly Sighandler_t SIG_IGN = _IgnoreHandler;
+
[DllImport (LIBC, SetLastError=true, EntryPoint="signal")]
- private static extern IntPtr sys_signal (int signum, sighandler_t handler);
+ private static extern IntPtr sys_signal (int signum, Sighandler_t handler);
- // FIXME: signal returns sighandler_t. What should we do?
- public static int signal (Signum signum, sighandler_t handler)
+ [DllImport (LIBC, SetLastError=true, EntryPoint="signal")]
+ private static extern IntPtr sys_signal (int signum, IntPtr handler);
+
+ public static Sighandler_t signal (Signum signum, Sighandler_t handler)
{
int _sig = UnixConvert.FromSignum (signum);
- IntPtr r = sys_signal (_sig, handler);
- // handle `r'
- return 0;
+ IntPtr r;
+ if (handler == SIG_DFL)
+ r = sys_signal (_sig, _SIG_DFL);
+ else if (handler == SIG_ERR)
+ r = sys_signal (_sig, _SIG_ERR);
+ else if (handler == SIG_IGN)
+ r = sys_signal (_sig, _SIG_IGN);
+ else
+ r = sys_signal (_sig, handler);
+ return TranslateHandler (r);
}
- // TODO: Need access to SIG_IGN, SIG_DFL, and SIG_ERR values.
+ private static Sighandler_t TranslateHandler (IntPtr handler)
+ {
+ if (handler == _SIG_DFL)
+ return SIG_DFL;
+ if (handler == _SIG_ERR)
+ return SIG_ERR;
+ if (handler == _SIG_IGN)
+ return SIG_IGN;
+ return new Sighandler_t (new SignalWrapper (handler).InvokeSignalHandler);
+ }
//
// <stdio.h>
diff --git a/mcs/class/Mono.Posix/Mono.Unix/Syscall.cs b/mcs/class/Mono.Posix/Mono.Unix/Syscall.cs
index 43d9f33b4af..3a7aa4d535c 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/Syscall.cs
+++ b/mcs/class/Mono.Posix/Mono.Unix/Syscall.cs
@@ -1659,8 +1659,9 @@ namespace Mono.Unix {
[DllImport (LIBC, SetLastError=true, EntryPoint="cuserid")]
private static extern IntPtr sys_cuserid ([Out] StringBuilder @string);
- [Obsolete ("\"Nobody knows precisely what cuserid() does... DO NOT USE cuserid()." +
- "`string' must hold L_cuserid characters. Use Unistd.getlogin_r instead.")]
+ [Obsolete ("\"Nobody knows precisely what cuserid() does... " +
+ "DO NOT USE cuserid().\n" +
+ "`string' must hold L_cuserid characters. Use getlogin_r instead.")]
public static string cuserid (StringBuilder @string)
{
if (@string.Capacity < L_cuserid) {
diff --git a/mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs b/mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs
index ec013013cfd..302cc59f580 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs
+++ b/mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs
@@ -67,6 +67,7 @@ namespace Mono.Unix {
try {
Translate = new ErrorTranslator (strerror_r);
string ignore = Translate (Error.EPERM);
+ ignore = ignore;
HaveStrerror_r = true;
}
catch (EntryPointNotFoundException e) {
@@ -161,11 +162,9 @@ namespace Mono.Unix {
private static int CountStrings (IntPtr stringArray)
{
- int count = -1;
- IntPtr item = Marshal.ReadIntPtr (stringArray, count * IntPtr.Size);
- do {
+ int count = 0;
+ while (Marshal.ReadIntPtr (stringArray, count*IntPtr.Size) != IntPtr.Zero)
++count;
- } while (Marshal.ReadIntPtr (stringArray, count * IntPtr.Size) != IntPtr.Zero);
return count;
}
diff --git a/mcs/class/Mono.Posix/Mono.Unix/UnixProcess.cs b/mcs/class/Mono.Posix/Mono.Unix/UnixProcess.cs
index e3f52922061..d8b4318e501 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/UnixProcess.cs
+++ b/mcs/class/Mono.Posix/Mono.Unix/UnixProcess.cs
@@ -145,10 +145,9 @@ namespace Mono.Unix {
{
int status;
int r;
- Error e;
do {
r = Syscall.waitpid (pid, out status, (WaitOptions) 0);
- } while (r == -1 && (e = Syscall.GetLastError()) == Error.EINTR);
+ } while (UnixMarshal.ShouldRetrySyscall (r));
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
}