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:
authorMiguel de Icaza <miguel@gnome.org>2004-01-02 21:43:52 +0300
committerMiguel de Icaza <miguel@gnome.org>2004-01-02 21:43:52 +0300
commit542cedba47007257f8f4be42ffa45a9df3e503bf (patch)
treef2ea3b7225f3bed3a18d2b2c3e61364aae55394b
parentf97ebd4d45d513da0eb54d26fba82dfb7aaa89cb (diff)
Add bunch of Posix calls
svn path=/trunk/mcs/; revision=21599
-rw-r--r--mcs/class/Mono.Posix/Makefile23
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix.dll.sources2
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix/IncludeAttribute.cs46
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix/MapAttribute.cs15
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix/Syscall.cs342
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix/macros.c32
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix/map.c166
-rw-r--r--mcs/class/Mono.Posix/Mono.Posix/map.h71
8 files changed, 693 insertions, 4 deletions
diff --git a/mcs/class/Mono.Posix/Makefile b/mcs/class/Mono.Posix/Makefile
index 4022cec5e82..5cd2f6dc057 100644
--- a/mcs/class/Mono.Posix/Makefile
+++ b/mcs/class/Mono.Posix/Makefile
@@ -5,5 +5,28 @@ include ../../build/rules.make
LIBRARY = Mono.Posix.dll
LIB_MCS_FLAGS = /unsafe /r:$(corlib) /r:System.dll
NO_TEST = yes
+MonoPosixHelper = $(topdir)/class/lib/libMonoPosixHelper.dll.so
include ../../build/library.make
+
+all-local: Mono.Posix/map.h ../lib/libMonoPosixHelper.so
+
+Mono.Posix/map.h Mono.Posix/map.c: Mono.Posix/make-map.exe ../lib/Mono.Posix.dll
+ MONO_PATH=../lib/ $(RUNTIME) Mono.Posix/make-map.exe ../lib/Mono.Posix.dll Mono.Posix/map
+
+Mono.Posix/make-map.exe: Mono.Posix/make-map.cs ../lib/Mono.Posix.dll
+ $(CSCOMPILE) Mono.Posix/make-map.cs -out:Mono.Posix/make-map.exe -r:../lib/Mono.Posix.dll
+
+local_sources = \
+ Mono.Posix/map.c \
+ Mono.Posix/macros.c
+
+local_objs = \
+ Mono.Posix/map.o \
+ Mono.Posix/macros.o
+
+%.o: %.c
+ $(CCOMPILE) -fPIC -c -o $@ $^
+
+../lib/libMonoPosixHelper.so: $(local_objs)
+ gcc -shared -Wl,-soname,libMonoPosixHelper.dll.so -o $(MonoPosixHelper) $(local_objs) $(LOCAL_LDFLAGS) \ No newline at end of file
diff --git a/mcs/class/Mono.Posix/Mono.Posix.dll.sources b/mcs/class/Mono.Posix/Mono.Posix.dll.sources
index e0f23fa5e82..bd755f28ad7 100644
--- a/mcs/class/Mono.Posix/Mono.Posix.dll.sources
+++ b/mcs/class/Mono.Posix/Mono.Posix.dll.sources
@@ -1,2 +1,4 @@
./Mono.Posix/UnixEndPoint.cs
./Mono.Posix/Syscall.cs
+./Mono.Posix/MapAttribute.cs
+./Mono.Posix/IncludeAttribute.cs
diff --git a/mcs/class/Mono.Posix/Mono.Posix/IncludeAttribute.cs b/mcs/class/Mono.Posix/Mono.Posix/IncludeAttribute.cs
new file mode 100644
index 00000000000..e70ba748183
--- /dev/null
+++ b/mcs/class/Mono.Posix/Mono.Posix/IncludeAttribute.cs
@@ -0,0 +1,46 @@
+//
+// IncludeAttribute.cs
+//
+// Author:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) Novell, Inc.
+//
+using System;
+
+namespace Mono.Posix {
+
+ [AttributeUsage (AttributeTargets.Assembly)]
+ public class IncludeAttribute : Attribute {
+ string [] includes;
+ string [] defines;
+
+ public IncludeAttribute (string [] includes)
+ {
+ this.includes = includes;
+ }
+
+ public IncludeAttribute (string [] includes, string [] defines)
+ {
+ this.includes = includes;
+ this.defines = defines;
+ }
+
+ public string [] Includes {
+ get {
+ if (includes == null)
+ return new string [0];
+ return includes;
+ }
+ }
+
+ public string [] Defines {
+ get {
+ if (defines == null)
+ return new string [0];
+ return defines;
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/Mono.Posix/Mono.Posix/MapAttribute.cs b/mcs/class/Mono.Posix/Mono.Posix/MapAttribute.cs
new file mode 100644
index 00000000000..029c60a76fc
--- /dev/null
+++ b/mcs/class/Mono.Posix/Mono.Posix/MapAttribute.cs
@@ -0,0 +1,15 @@
+//
+// MapAttribute.cs
+//
+// Author:
+// Miguel de Icaza (miguel@gnome.org)
+//
+// (C) Novell, Inc.
+//
+using System;
+namespace Mono.Posix {
+
+ [AttributeUsage (AttributeTargets.Enum)]
+ public class MapAttribute : Attribute {
+ }
+}
diff --git a/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs b/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs
index 274c792bf52..af8f4cf8383 100644
--- a/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs
+++ b/mcs/class/Mono.Posix/Mono.Posix/Syscall.cs
@@ -1,6 +1,34 @@
//
// Mono.Posix.Syscall.cs: System calls to Posix subsystem features
//
+// Author:
+// Miguel de Icaza (miguel@novell.com)
+//
+// (C) 2003 Novell, Inc.
+//
+// This file implements the low-level syscall interface to the POSIX
+// subsystem.
+//
+// This file tries to stay close to the low-level API as much as possible
+// using enumerations, structures and in a few cases, using existing .NET
+// data types.
+//
+// Implementation notes:
+//
+// Since the values for the various constants on the API changes
+// from system to system (even Linux on different architectures will
+// have different values), we define our own set of values, and we
+// use a set of C helper routines to map from the constants we define
+// to the values of the native OS.
+//
+// Bitfields are flagged with the [Map] attribute, and a helper program
+// generates a set of map_XXXX routines that we can call to convert
+// from our value definitions to the value definitions expected by the
+// OS.
+//
+// Methods that require tuning are bound as `internal syscal_NAME' methods
+// and then a `NAME' method is exposed.
+//
using System;
using System.Text;
@@ -8,8 +36,312 @@ using System.Runtime.InteropServices;
namespace Mono.Posix {
+ [assembly:Mono.Posix.IncludeAttribute (new string [] {"sys/types.h", "sys/stat.h", "sys/wait.h", "unistd.h", "fcntl.h"},
+ new string [] {"_GNU_SOURCE"})]
+ [Map][Flags]
+ public enum OpenFlags {
+ //
+ // One of these
+ //
+ O_RDONLY = 0,
+ O_WRONLY = 1,
+ O_RDWR = 2,
+
+ //
+ // Or-ed with zero or more of these
+ //
+ O_CREAT = 4,
+ O_EXCL = 8,
+ O_NOCTTY = 16,
+ O_TRUNC = 32,
+ O_APPEND = 64,
+ O_NONBLOCK = 128,
+ O_SYNC = 256,
+ O_NOFOLLOW = 512,
+ O_DIRECTORY = 1024,
+ O_DIRECT = 2048,
+ O_ASYNC = 4096,
+ O_LARGEFILE = 8192
+ }
+
+ [Flags][Map]
+ public enum FileMode {
+ S_ISUID = 04000,
+ S_ISGID = 02000,
+ S_ISVTX = 01000,
+ S_IRUSR = 00400,
+ S_IWUSR = 00200,
+ S_IXUSR = 00100,
+ S_IRGRP = 00040,
+ S_IWGRP = 00020,
+ S_IXGRP = 00010,
+ S_IROTH = 00004,
+ S_IWOTH = 00002,
+ S_IXOTH = 00001
+ }
+
+ [Flags][Map]
+ public enum WaitOptions {
+ WNOHANG,
+ WUNTRACED
+ }
+
+ [Flags][Map]
+ public enum AccessMode {
+ R_OK = 1,
+ W_OK = 2,
+ X_OK = 4,
+ F_OK = 8
+ }
+
+ [Map]
+ public enum Signals {
+ SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT, SIGBUS,
+ SIGFPE, SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2, SIGPIPE,
+ SIGALRM, SIGTERM, SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP,
+ SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, SIGXFSZ, SIGVTALRM,
+ SIGPROF, SIGWINCH, SIGIO, SIGPWR, SIGSYS, SIGRTMIN
+ }
+
public class Syscall {
- [DllImport ("libc", EntryPoint="gethostname")]
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int exit (int status);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int fork ();
+
+ [DllImport ("libc", SetLastError=true)]
+ public unsafe static extern IntPtr read (int fileDescriptor, void *buf, IntPtr count);
+
+ [DllImport ("libc", SetLastError=true)]
+ public unsafe static extern IntPtr write (int fileDescriptor, void *buf, IntPtr count);
+
+ [DllImport ("libc", EntryPoint="open", SetLastError=true)]
+ internal static extern int syscall_open (string pathname, int flags, int mode);
+
+ [DllImport ("MonoPosixHelper")]
+ internal extern static int map_Mono_Posix_OpenFlags (OpenFlags flags);
+ [DllImport ("MonoPosixHelper")]
+ internal extern static int map_Mono_Posix_FileMode (FileMode mode);
+
+ public static int open (string pathname, OpenFlags flags)
+ {
+ if ((flags & OpenFlags.O_CREAT) != 0)
+ throw new ArgumentException ("If you pass O_CREAT, you must call the method with the mode flag");
+
+ int posix_flags = map_Mono_Posix_OpenFlags (flags);
+ return syscall_open (pathname, posix_flags, 0);
+ }
+
+ public static int open (string pathname, OpenFlags flags, FileMode mode)
+ {
+ int posix_flags = map_Mono_Posix_OpenFlags (flags);
+ int posix_mode = map_Mono_Posix_FileMode (mode);
+
+ return syscall_open (pathname, posix_flags, posix_mode);
+ }
+
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int close (int fileDescriptor);
+
+ [DllImport ("libc", EntryPoint="waitpid", SetLastError=true)]
+ unsafe internal static extern int syscall_waitpid (int pid, int * status, int options);
+
+ [DllImport ("MonoPosixHelper")]
+ internal extern static int map_Mono_Posix_WaitOptions (WaitOptions wait_options);
+
+ public static int waitpid (int pid, out int status, WaitOptions options)
+ {
+ unsafe {
+ int s = 0;
+ int r = syscall_waitpid (pid, &s, map_Mono_Posix_WaitOptions (options));
+ status = s;
+ return r;
+ }
+ }
+
+ public static int waitpid (int pid, WaitOptions options)
+ {
+ return syscall_waitpid (pid, null, map_Mono_Posix_WaitOptions (options));
+ }
+
+ [DllImport ("MonoPosixHelper", EntryPoint="wifexited")]
+ public static extern int WIFEXITED (int status);
+ [DllImport ("MonoPosixHelper", EntryPoint="wexitstatus")]
+ public static extern int WEXITSTATUS (int status);
+ [DllImport ("MonoPosixHelper", EntryPoint="wifsignaled")]
+ public static extern int WIFSIGNALED (int status);
+ [DllImport ("MonoPosixHelper", EntryPoint="wtermsig")]
+ public static extern int WTERMSIG (int status);
+ [DllImport ("MonoPosixHelper", EntryPoint="wifstopped")]
+ public static extern int WIFSTOPPED (int status);
+ [DllImport ("MonoPosixHelper", EntryPoint="wstopsig")]
+ public static extern int WSTOPSIG (int status);
+
+ [DllImport ("libc", SetLastError=true)]
+ internal static extern int syscall_creat (string pathname, int flags);
+
+ public static int creat (string pathname, FileMode flags)
+ {
+ return syscall_creat (pathname, map_Mono_Posix_FileMode (flags));
+ }
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int link (string oldPath, string newPath);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int unlink (string path);
+
+ // TODO: execve
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int chdir (string path);
+
+ // TODO: time
+ // TODO: mknod
+
+
+ [DllImport ("libc", EntryPoint="chmod", SetLastError=true)]
+ internal static extern int syscall_chmod (string path, int mode);
+
+ public static int chmod (string path, FileMode mode)
+ {
+ return syscall_chmod (path, map_Mono_Posix_FileMode (mode));
+ }
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int chown (string path, int owner, int group);
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int lchown (string path, int owner, int group);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int lseek (int fileDescriptor, int offset, int whence);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int getpid ();
+
+ // TODO: mount
+ // TODO: umount
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int setuid (int uid);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int getuid ();
+
+ // TODO: stime
+ // TODO: ptrace
+
+ [DllImport ("libc")]
+ public static extern uint alarm (uint seconds);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int pause ();
+
+ // TODO: utime
+
+ [DllImport ("libc")]
+ internal extern static int syscall_access (string pathname, int mode);
+
+ [DllImport ("MonoPosixHelper")]
+ internal extern static int map_Mono_Posix_AccessMode (AccessMode mode);
+
+ public static int access (string pathname, AccessMode mode)
+ {
+ return syscall_access (pathname, map_Mono_Posix_AccessMode (mode));
+ }
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int nice (int increment);
+
+ // TODO: ftime
+
+ [DllImport ("libc")]
+ public static extern void sync ();
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern void kill (int pid, int sig);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int rename (string oldPath, string newPath);
+
+ [DllImport ("libc", SetLastError=true)]
+ internal extern static int syscall_mkdir (string pathname, int mode);
+
+ public static int mkdir (string pathname, FileMode mode)
+ {
+ return syscall_mkdir (pathname, map_Mono_Posix_FileMode (mode));
+ }
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int rmdir (string path);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int dup (int fileDescriptor);
+
+ // TODO: pipe
+ // TODO: times
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int setgid (int gid);
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int getgid (int gid);
+
+
+ public delegate void sighandler_t (int v);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int signal (int signum, sighandler_t handler);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int geteuid ();
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int getegid ();
+
+ // TODO: fcntl
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int setpgid (int pid, int pgid);
+
+ // TODO: ulimit
+
+ [DllImport ("libc")]
+ public static extern int umask (int umask);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int chroot (string path);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int dup2 (int oldFileDescriptor, int newFileDescriptor);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int getppid ();
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int getpgrp ();
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int setsid ();
+
+ // TODO: sigaction
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int setreuid (int ruid, int euid);
+
+ [DllImport ("libc", SetLastError=true)]
+ public static extern int setregid (int rgid, int egid);
+
+ // TODO: sigsuspend
+ // TODO: sigpending
+ // TODO: setrlimit
+ // TODO: getrlimit
+ // TODO: getrusage
+ // TODO: gettimeofday
+ // TODO: settimeofday
+
+ [DllImport ("libc", EntryPoint="gethostname", SetLastError=true)]
static extern int syscall_gethostname (byte[] p, int len);
public static string GetHostName ()
@@ -26,6 +358,11 @@ namespace Mono.Posix {
return Encoding.UTF8.GetString (buf, 0, res);
}
+ public static string gethostname ()
+ {
+ return GetHostName ();
+ }
+
[Flags]
public enum FileMode {
S_ISUID = 04000,
@@ -42,9 +379,6 @@ namespace Mono.Posix {
S_IXOTH = 00001
}
- [DllImport ("libc")]
- public static extern int chmod (string file, FileMode mode);
-
[DllImport ("libc", EntryPoint="isatty")]
static extern int syscall_isatty (int desc);
diff --git a/mcs/class/Mono.Posix/Mono.Posix/macros.c b/mcs/class/Mono.Posix/Mono.Posix/macros.c
new file mode 100644
index 00000000000..fbde3bc1b87
--- /dev/null
+++ b/mcs/class/Mono.Posix/Mono.Posix/macros.c
@@ -0,0 +1,32 @@
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int wifexited (int status)
+{
+ return WIFEXITED (status);
+}
+
+int wexitstatus (int status)
+{
+ return WEXITSTATUS (status);
+}
+
+int wifsignaled (int status)
+{
+ return WIFSIGNALED (status);
+}
+
+int wtermsig (int status)
+{
+ return WTERMSIG (status);
+}
+
+int wifstopped (int status)
+{
+ return WIFSTOPPED (status);
+}
+
+int wstopsig (int status)
+{
+ return WSTOPSIG (status);
+}
diff --git a/mcs/class/Mono.Posix/Mono.Posix/map.c b/mcs/class/Mono.Posix/Mono.Posix/map.c
new file mode 100644
index 00000000000..1801e10ad67
--- /dev/null
+++ b/mcs/class/Mono.Posix/Mono.Posix/map.c
@@ -0,0 +1,166 @@
+/* This file was automatically generated by make-map from ../lib/Mono.Posix.dll */
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "map.h"
+int map_Mono_Posix_OpenFlags (int x)
+{
+ int r = 0;
+ if ((x & Mono_Posix_OpenFlags_O_RDONLY) != 0)
+ r |= O_RDONLY;
+ if ((x & Mono_Posix_OpenFlags_O_WRONLY) != 0)
+ r |= O_WRONLY;
+ if ((x & Mono_Posix_OpenFlags_O_RDWR) != 0)
+ r |= O_RDWR;
+ if ((x & Mono_Posix_OpenFlags_O_CREAT) != 0)
+ r |= O_CREAT;
+ if ((x & Mono_Posix_OpenFlags_O_EXCL) != 0)
+ r |= O_EXCL;
+ if ((x & Mono_Posix_OpenFlags_O_NOCTTY) != 0)
+ r |= O_NOCTTY;
+ if ((x & Mono_Posix_OpenFlags_O_TRUNC) != 0)
+ r |= O_TRUNC;
+ if ((x & Mono_Posix_OpenFlags_O_APPEND) != 0)
+ r |= O_APPEND;
+ if ((x & Mono_Posix_OpenFlags_O_NONBLOCK) != 0)
+ r |= O_NONBLOCK;
+ if ((x & Mono_Posix_OpenFlags_O_SYNC) != 0)
+ r |= O_SYNC;
+ if ((x & Mono_Posix_OpenFlags_O_NOFOLLOW) != 0)
+ r |= O_NOFOLLOW;
+ if ((x & Mono_Posix_OpenFlags_O_DIRECTORY) != 0)
+ r |= O_DIRECTORY;
+ if ((x & Mono_Posix_OpenFlags_O_DIRECT) != 0)
+ r |= O_DIRECT;
+ if ((x & Mono_Posix_OpenFlags_O_ASYNC) != 0)
+ r |= O_ASYNC;
+ if ((x & Mono_Posix_OpenFlags_O_LARGEFILE) != 0)
+ r |= O_LARGEFILE;
+ return r;
+}
+
+int map_Mono_Posix_FileMode (int x)
+{
+ int r = 0;
+ if ((x & Mono_Posix_FileMode_S_ISUID) != 0)
+ r |= S_ISUID;
+ if ((x & Mono_Posix_FileMode_S_ISGID) != 0)
+ r |= S_ISGID;
+ if ((x & Mono_Posix_FileMode_S_ISVTX) != 0)
+ r |= S_ISVTX;
+ if ((x & Mono_Posix_FileMode_S_IRUSR) != 0)
+ r |= S_IRUSR;
+ if ((x & Mono_Posix_FileMode_S_IWUSR) != 0)
+ r |= S_IWUSR;
+ if ((x & Mono_Posix_FileMode_S_IXUSR) != 0)
+ r |= S_IXUSR;
+ if ((x & Mono_Posix_FileMode_S_IRGRP) != 0)
+ r |= S_IRGRP;
+ if ((x & Mono_Posix_FileMode_S_IWGRP) != 0)
+ r |= S_IWGRP;
+ if ((x & Mono_Posix_FileMode_S_IXGRP) != 0)
+ r |= S_IXGRP;
+ if ((x & Mono_Posix_FileMode_S_IROTH) != 0)
+ r |= S_IROTH;
+ if ((x & Mono_Posix_FileMode_S_IWOTH) != 0)
+ r |= S_IWOTH;
+ if ((x & Mono_Posix_FileMode_S_IXOTH) != 0)
+ r |= S_IXOTH;
+ return r;
+}
+
+int map_Mono_Posix_WaitOptions (int x)
+{
+ int r = 0;
+ if ((x & Mono_Posix_WaitOptions_WNOHANG) != 0)
+ r |= WNOHANG;
+ if ((x & Mono_Posix_WaitOptions_WUNTRACED) != 0)
+ r |= WUNTRACED;
+ return r;
+}
+
+int map_Mono_Posix_AccessMode (int x)
+{
+ int r = 0;
+ if ((x & Mono_Posix_AccessMode_R_OK) != 0)
+ r |= R_OK;
+ if ((x & Mono_Posix_AccessMode_W_OK) != 0)
+ r |= W_OK;
+ if ((x & Mono_Posix_AccessMode_X_OK) != 0)
+ r |= X_OK;
+ if ((x & Mono_Posix_AccessMode_F_OK) != 0)
+ r |= F_OK;
+ return r;
+}
+
+int map_Mono_Posix_Signals (int x)
+{
+ if (x == Mono_Posix_Signals_SIGHUP)
+ return SIGHUP;
+ if (x == Mono_Posix_Signals_SIGINT)
+ return SIGINT;
+ if (x == Mono_Posix_Signals_SIGQUIT)
+ return SIGQUIT;
+ if (x == Mono_Posix_Signals_SIGILL)
+ return SIGILL;
+ if (x == Mono_Posix_Signals_SIGTRAP)
+ return SIGTRAP;
+ if (x == Mono_Posix_Signals_SIGABRT)
+ return SIGABRT;
+ if (x == Mono_Posix_Signals_SIGBUS)
+ return SIGBUS;
+ if (x == Mono_Posix_Signals_SIGFPE)
+ return SIGFPE;
+ if (x == Mono_Posix_Signals_SIGKILL)
+ return SIGKILL;
+ if (x == Mono_Posix_Signals_SIGUSR1)
+ return SIGUSR1;
+ if (x == Mono_Posix_Signals_SIGSEGV)
+ return SIGSEGV;
+ if (x == Mono_Posix_Signals_SIGUSR2)
+ return SIGUSR2;
+ if (x == Mono_Posix_Signals_SIGPIPE)
+ return SIGPIPE;
+ if (x == Mono_Posix_Signals_SIGALRM)
+ return SIGALRM;
+ if (x == Mono_Posix_Signals_SIGTERM)
+ return SIGTERM;
+ if (x == Mono_Posix_Signals_SIGCHLD)
+ return SIGCHLD;
+ if (x == Mono_Posix_Signals_SIGCONT)
+ return SIGCONT;
+ if (x == Mono_Posix_Signals_SIGSTOP)
+ return SIGSTOP;
+ if (x == Mono_Posix_Signals_SIGTSTP)
+ return SIGTSTP;
+ if (x == Mono_Posix_Signals_SIGTTIN)
+ return SIGTTIN;
+ if (x == Mono_Posix_Signals_SIGTTOU)
+ return SIGTTOU;
+ if (x == Mono_Posix_Signals_SIGURG)
+ return SIGURG;
+ if (x == Mono_Posix_Signals_SIGXCPU)
+ return SIGXCPU;
+ if (x == Mono_Posix_Signals_SIGXFSZ)
+ return SIGXFSZ;
+ if (x == Mono_Posix_Signals_SIGVTALRM)
+ return SIGVTALRM;
+ if (x == Mono_Posix_Signals_SIGPROF)
+ return SIGPROF;
+ if (x == Mono_Posix_Signals_SIGWINCH)
+ return SIGWINCH;
+ if (x == Mono_Posix_Signals_SIGIO)
+ return SIGIO;
+ if (x == Mono_Posix_Signals_SIGPWR)
+ return SIGPWR;
+ if (x == Mono_Posix_Signals_SIGSYS)
+ return SIGSYS;
+ if (x == Mono_Posix_Signals_SIGRTMIN)
+ return SIGRTMIN;
+ return -1;
+}
+
diff --git a/mcs/class/Mono.Posix/Mono.Posix/map.h b/mcs/class/Mono.Posix/Mono.Posix/map.h
new file mode 100644
index 00000000000..717d9f1814f
--- /dev/null
+++ b/mcs/class/Mono.Posix/Mono.Posix/map.h
@@ -0,0 +1,71 @@
+/* This file was automatically generated by make-map from ../lib/Mono.Posix.dll */
+
+#define Mono_Posix_OpenFlags_O_RDONLY O_RDONLY
+#define Mono_Posix_OpenFlags_O_WRONLY O_WRONLY
+#define Mono_Posix_OpenFlags_O_RDWR O_RDWR
+#define Mono_Posix_OpenFlags_O_CREAT O_CREAT
+#define Mono_Posix_OpenFlags_O_EXCL O_EXCL
+#define Mono_Posix_OpenFlags_O_NOCTTY O_NOCTTY
+#define Mono_Posix_OpenFlags_O_TRUNC O_TRUNC
+#define Mono_Posix_OpenFlags_O_APPEND O_APPEND
+#define Mono_Posix_OpenFlags_O_NONBLOCK O_NONBLOCK
+#define Mono_Posix_OpenFlags_O_SYNC O_SYNC
+#define Mono_Posix_OpenFlags_O_NOFOLLOW O_NOFOLLOW
+#define Mono_Posix_OpenFlags_O_DIRECTORY O_DIRECTORY
+#define Mono_Posix_OpenFlags_O_DIRECT O_DIRECT
+#define Mono_Posix_OpenFlags_O_ASYNC O_ASYNC
+#define Mono_Posix_OpenFlags_O_LARGEFILE O_LARGEFILE
+
+#define Mono_Posix_FileMode_S_ISUID S_ISUID
+#define Mono_Posix_FileMode_S_ISGID S_ISGID
+#define Mono_Posix_FileMode_S_ISVTX S_ISVTX
+#define Mono_Posix_FileMode_S_IRUSR S_IRUSR
+#define Mono_Posix_FileMode_S_IWUSR S_IWUSR
+#define Mono_Posix_FileMode_S_IXUSR S_IXUSR
+#define Mono_Posix_FileMode_S_IRGRP S_IRGRP
+#define Mono_Posix_FileMode_S_IWGRP S_IWGRP
+#define Mono_Posix_FileMode_S_IXGRP S_IXGRP
+#define Mono_Posix_FileMode_S_IROTH S_IROTH
+#define Mono_Posix_FileMode_S_IWOTH S_IWOTH
+#define Mono_Posix_FileMode_S_IXOTH S_IXOTH
+
+#define Mono_Posix_WaitOptions_WNOHANG WNOHANG
+#define Mono_Posix_WaitOptions_WUNTRACED WUNTRACED
+
+#define Mono_Posix_AccessMode_R_OK R_OK
+#define Mono_Posix_AccessMode_W_OK W_OK
+#define Mono_Posix_AccessMode_X_OK X_OK
+#define Mono_Posix_AccessMode_F_OK F_OK
+
+#define Mono_Posix_Signals_SIGHUP SIGHUP
+#define Mono_Posix_Signals_SIGINT SIGINT
+#define Mono_Posix_Signals_SIGQUIT SIGQUIT
+#define Mono_Posix_Signals_SIGILL SIGILL
+#define Mono_Posix_Signals_SIGTRAP SIGTRAP
+#define Mono_Posix_Signals_SIGABRT SIGABRT
+#define Mono_Posix_Signals_SIGBUS SIGBUS
+#define Mono_Posix_Signals_SIGFPE SIGFPE
+#define Mono_Posix_Signals_SIGKILL SIGKILL
+#define Mono_Posix_Signals_SIGUSR1 SIGUSR1
+#define Mono_Posix_Signals_SIGSEGV SIGSEGV
+#define Mono_Posix_Signals_SIGUSR2 SIGUSR2
+#define Mono_Posix_Signals_SIGPIPE SIGPIPE
+#define Mono_Posix_Signals_SIGALRM SIGALRM
+#define Mono_Posix_Signals_SIGTERM SIGTERM
+#define Mono_Posix_Signals_SIGCHLD SIGCHLD
+#define Mono_Posix_Signals_SIGCONT SIGCONT
+#define Mono_Posix_Signals_SIGSTOP SIGSTOP
+#define Mono_Posix_Signals_SIGTSTP SIGTSTP
+#define Mono_Posix_Signals_SIGTTIN SIGTTIN
+#define Mono_Posix_Signals_SIGTTOU SIGTTOU
+#define Mono_Posix_Signals_SIGURG SIGURG
+#define Mono_Posix_Signals_SIGXCPU SIGXCPU
+#define Mono_Posix_Signals_SIGXFSZ SIGXFSZ
+#define Mono_Posix_Signals_SIGVTALRM SIGVTALRM
+#define Mono_Posix_Signals_SIGPROF SIGPROF
+#define Mono_Posix_Signals_SIGWINCH SIGWINCH
+#define Mono_Posix_Signals_SIGIO SIGIO
+#define Mono_Posix_Signals_SIGPWR SIGPWR
+#define Mono_Posix_Signals_SIGSYS SIGSYS
+#define Mono_Posix_Signals_SIGRTMIN SIGRTMIN
+