[Mono-bugs] [Bug 51849][Nor] New - Mono.POSIX implementation strategy.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 7 Dec 2003 23:48:33 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=51849

--- shadow/51849	2003-12-07 23:48:33.000000000 -0500
+++ shadow/51849.tmp.25404	2003-12-07 23:48:33.000000000 -0500
@@ -0,0 +1,74 @@
+Bug#: 51849
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Mono.POSIX
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: miguel@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mono.POSIX implementation strategy.
+
+The Mono.POSIX assembly is a project to create a binding to
+	the various low-level calls in Unix which are not available
+	thought he regular assemblies in .NET.
+
+	The work should be done in two steps: one step is doing the
+	low-level binding for the system call, and another possibly is
+	to expose .NET-level objects like Streams for common patterns:
+	for example Streams for socketpairs. 
+-----
+
+Details.  
+
+One issue is that structure layout and C-level definitions are not the same
+across operating systems or ports.  Even across Linux on the sam version
+will differ given the architecture.
+
+To solve this problem, we should define our own set of definitions in C#
+that mimic the Posix ones, and then with a tool generate the glue to the OS.
+
+For example:
+
+[Name ("stat")]
+struct Stat {
+     int  st_ino;
+     long st_ize;
+     [PosixType ("time_t")]
+     IntPtr st_atime;
+}
+[DllImport ("mono_posix")]
+int mono_stat (string file, out struct Stat);
+
+A small tool would generate the C code:
+
+struct CSharp_Stat {
+    int st_ino;
+    long st_size;
+    void *st_atime;
+}
+
+wrap_stat (CSharp_Stat output, struct stat input){
+     output->st_ino = input->st_ino;
+     output->st_atime = input->st_atime;
+     etc.
+}
+
+int mono_stat (string file, Csharp_Stat *output)
+{
+     struct stat o;
+     stat (file, &o);
+     return mono_map_errno (wrap_stat (output, &o));
+}
+
+
+The same applies to constant definitions.
+
+Some things can be done automatically, some others are better done manually.