[Mono-list] First attempt at a POSIX wrapper

Juli Mallett jmallett@FreeBSD.ORG
Thu, 28 Nov 2002 01:48:18 -0800


* De: Adam Keys <akeys@post.cis.smu.edu> [ Data: 2002-11-27 ]
	[ Subjecte: [Mono-list] First attempt at a POSIX wrapper ]
> o Things like uid_t, pid_t, time_t, etc. are aliased to System.Int32. 
> It's my understanding that these are usually kernel specific items. 
> Should we attempt to generate a file that defines these properly on a
> per-platform basis?

Any implementation details should be done based on the backing system.
However, since we don't have time_t constraints, as in there's no existing
software using it, I'd advise going straight for Int64, unless the system
uses something even higher.

> o The only place I could find info on what is in POSIX and what's not is
> http://j4p.sourceforge.net/.  I checked the POSIX man page and it has
> stuff like cos and asin which I wouldn't think are in the POSIX
> standards.  So, I need some canonical source from which I can determine
> which functions to include.

The Single UNIX Specification is available online, and has merged with POSIX
and you really want to work from that.

There's lots of stuff you'd like it to not include, believe me, but sigh.
What would be neat is to see a POSIX getopt(3) in C# and a small number of
the userland utilities implemented :)

> //
> // Author:
> //    Adam Keys (adam@trmk.org)
> //
> // (C) 2002 Adam Keys
> //
> 
> using System.Runtime.InteropServices;
> 
> namespace POSIX {
> class POSIX {
> 	[DllImport ("libc.so.6", EntryPoint="getpid")]
> 	public static extern int getpid();

Eeek!  You want to use libc.so, AFAICT.  Also, getpid returns pid_t.

> 	[DllImport ("libc.so.6", EntryPoint="getppid")]
> 	public static extern int getppid();

Ditto pid_t.

> 	[DllImport ("libc.so.6", EntryPoint="chown")]
> 	public static extern int chown (string path, int owner, int group);

uid_t owner, gid_t group

> 	[DllImport ("libc.so.6", EntryPoint="execv")]
> 	public static extern int execv (string path, string[] argv);
> }
> }
-- 
Juli Mallett <jmallett@FreeBSD.org>
OpenDarwin, Mono, FreeBSD Developer.
ircd-hybrid Developer, EFnet addict.
FreeBSD on MIPS-Anything on FreeBSD.