Integrate Mono.Posix OEE with Mono.
authorJonathan Pryor <jpryor@novell.com>
Fri, 5 Nov 2004 12:32:30 +0000 (12:32 -0000)
committerJonathan Pryor <jpryor@novell.com>
Fri, 5 Nov 2004 12:32:30 +0000 (12:32 -0000)
  * support/.cvsignore: Ignore generated files.
  * support/Makefile.am: Add new INCLUDE directives (for glib headers),
    source; bump library version (so we don't clobber previous versions of
    libMonoPosixHelper.so).
  * support/dirent.c: New file; <dirent.h> wrapper functions
  * support/errno.c: New file; <errno.h> wrapper functions
  * support/fcntl.c: New file; <fcntl.h> wrapper functions
  * support/grp.c: New file; <grp.h> wrapper functions
  * support/map.c: Updated macro mapping functions (more enums mapped, more
    error checking, etc.).
  * support/map.h: Updated macro mapping functions
  * support/old-map.c: Previous map.c implementation, for backward compatibility
  * support/old-map.h: Previous map.h implementation, for backward compatibility
  * support/mph.h: New file; Utility types, macros
  * support/pwd.c: New file; <pwd.h> wrapper functions
  * support/stdio.c: New file; <stdio.h> wrapper functions
  * support/stdlib.c: New file; <stdlib.h> wrapper functions
  * support/sys-mman.c: New file; <sys/mman.h> wrapper functions
  * support/sys-mount.c: New file; <sys/mount.h> wrapper functions
  * support/sys-sendfile.c: New file; <sys/sendfile.h> wrapper functions
  * support/sys-stat.c: New file; <sys/stat.h> wrapper functions
  * support/sys-wait.c: New file; <sys/wait.h> wrapper functions
  * support/time.c: New file; <time.h> wrapper functions
  * support/unistd.c: New file; <unistd.h> wrapper functions

svn path=/trunk/mono/; revision=35689

22 files changed:
ChangeLog
support/.cvsignore
support/Makefile.am
support/dirent.c [new file with mode: 0644]
support/errno.c [new file with mode: 0644]
support/fcntl.c [new file with mode: 0644]
support/grp.c [new file with mode: 0644]
support/map.c
support/map.h
support/mph.h [new file with mode: 0644]
support/old-map.c [new file with mode: 0644]
support/old-map.h [new file with mode: 0644]
support/pwd.c [new file with mode: 0644]
support/stdio.c [new file with mode: 0644]
support/stdlib.c [new file with mode: 0644]
support/sys-mman.c [new file with mode: 0644]
support/sys-mount.c [new file with mode: 0644]
support/sys-sendfile.c [new file with mode: 0644]
support/sys-stat.c [new file with mode: 0644]
support/sys-wait.c [new file with mode: 0644]
support/time.c [new file with mode: 0644]
support/unistd.c [new file with mode: 0644]

index 2b74e4b7f01589710d4910913aaa48093178ef60..bfe6bff57af7b9fb6157277db3a4ee0baf923690 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2004-11-05  Jonathan Pryor <jonpryor@vt.edu>
+
+       * support/.cvsignore: Ignore generated files.
+       * support/Makefile.am: Add new INCLUDE directives (for glib headers),
+         source; bump library version (so we don't clobber previous versions of
+         libMonoPosixHelper.so).
+       * support/dirent.c: New file; <dirent.h> wrapper functions
+       * support/errno.c: New file; <errno.h> wrapper functions
+       * support/fcntl.c: New file; <fcntl.h> wrapper functions
+       * support/grp.c: New file; <grp.h> wrapper functions
+       * support/map.c: Updated macro mapping functions (more enums mapped, more
+         error checking, etc.).
+       * support/map.h: Updated macro mapping functions
+       * support/old-map.c: Previous map.c implementation, for backward compatibility
+       * support/old-map.h: Previous map.h implementation, for backward compatibility
+       * support/mph.h: New file; Utility types, macros
+       * support/pwd.c: New file; <pwd.h> wrapper functions
+       * support/stdio.c: New file; <stdio.h> wrapper functions
+       * support/stdlib.c: New file; <stdlib.h> wrapper functions
+       * support/sys-mman.c: New file; <sys/mman.h> wrapper functions
+       * support/sys-mount.c: New file; <sys/mount.h> wrapper functions
+       * support/sys-sendfile.c: New file; <sys/sendfile.h> wrapper functions
+       * support/sys-stat.c: New file; <sys/stat.h> wrapper functions
+       * support/sys-wait.c: New file; <sys/wait.h> wrapper functions
+       * support/time.c: New file; <time.h> wrapper functions
+       * support/unistd.c: New file; <unistd.h> wrapper functions
+
 2004-10-31  Zoltan Varga  <vargaz@freemail.hu>
 
        * configure.in: Fix up --with-jit=no so it actually works. Fixes 
index b2626333ae736fa85fd1b3af4904a8b026c15711..6c01cd0408422d2a7867e2a678d151c97fefa799 100644 (file)
@@ -5,3 +5,19 @@ Makefile
 libMonoPosixHelper.la
 macros.lo
 map.lo
+dirent.lo
+errno.lo
+fcntl.lo
+grp.lo
+map.lo
+old-map.lo
+pwd.lo
+stdio.lo
+stdlib.lo
+sys-mman.lo
+sys-mount.lo
+sys-stat.lo
+sys-wait.lo
+time.lo
+unistd.lo
+zlib_macros.lo
index d627f4447e25aa000388b11534e963b2175eaca9..9666ce4c5c4a59280f5e4683c87e4716fb569c9b 100644 (file)
@@ -4,15 +4,43 @@ else
 lib_LTLIBRARIES= libMonoPosixHelper.la
 endif
 
+INCLUDES = \
+       $(GLIB_CFLAGS) \
+       -I$(top_srcdir)
+
+MPH_H = mph.h
+
+MPH_SOURCE = \
+       dirent.c \
+       errno.c \
+       fcntl.c \
+       grp.c \
+       map.c \
+       pwd.c \
+       old-map.c \
+       stdio.c \
+       stdlib.c \
+       sys-mman.c \
+       sys-mount.c \
+       sys-stat.c \
+       sys-wait.c \
+       time.c \
+       unistd.c
+
 if HAVE_ZLIB
 libMonoPosixHelper_la_SOURCES = \
-       map.c map.h macros.c zlib_macros.c
+       $(MPH_SOURCE) zlib_macros.c
 
 libMonoPosixHelper_la_LIBADD = -lz
 else
-libMonoPosixHelper_la_SOURCES = map.c map.h macros.c
+libMonoPosixHelper_la_SOURCES = $(MPH_SOURCE)
 endif
 
+libMonoPosixHelper_la_LDFLAGS = -no-undefined -version-info 1:0:1
+
+EXTRA_DIST = \
+       $(MPH_H)
+
 # 
 # Use this target to refresh the values in map.[ch]
 #
diff --git a/support/dirent.c b/support/dirent.c
new file mode 100644 (file)
index 0000000..999a341
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * <dirent.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <dirent.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+struct Mono_Posix_Syscall__Dirent {
+       /* ino_t  */ mph_ino_t      d_ino;
+       /* off_t  */ mph_off_t      d_off;
+       /* ushort */ unsigned short d_reclen;
+       /* byte   */ unsigned char  d_type;
+       /* string */ char          *d_name;
+};
+
+gint32
+Mono_Posix_Syscall_seekdir (DIR *dir, mph_off_t offset)
+{
+       mph_return_if_off_t_overflow (offset);
+
+       errno = 0;
+
+       seekdir (dir, (off_t) offset);
+
+       return errno != 0;
+}
+
+mph_off_t
+Mono_Posix_Syscall_telldir (DIR *dir)
+{
+       return telldir (dir);
+}
+
+static void
+copy_dirent (
+       struct Mono_Posix_Syscall__Dirent *to, 
+#ifdef MPH_USE_64_API
+       struct dirent64 *from
+#else
+       struct dirent *from
+#endif
+       )
+{
+       to->d_ino    = from->d_ino;
+       to->d_off    = from->d_off;
+       to->d_reclen = from->d_reclen;
+       to->d_type   = from->d_type;
+       to->d_name   = strdup (from->d_name);
+}
+
+gint32
+Mono_Posix_Syscall_readdir (DIR *dirp, struct Mono_Posix_Syscall__Dirent *entry)
+{
+#ifdef MPH_USE_64_API
+       struct dirent64 *d;
+#else
+       struct dirent *d;
+#endif
+
+       if (entry == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+#ifdef MPH_USE_64_API
+       d = readdir64 (dirp);
+#else
+       d = readdir (dirp);
+#endif
+       if (d == NULL) {
+               return -1;
+       }
+
+       copy_dirent (entry, d);
+
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_readdir_r (DIR *dirp, struct Mono_Posix_Syscall__Dirent *entry, void **result)
+{
+#ifdef MPH_USE_64_API
+       struct dirent64 _entry;
+#else
+       struct dirent _entry;
+#endif
+       int r;
+
+#ifdef MPH_USE_64_API
+       r = readdir64_r (dirp, &_entry, (struct dirent64**) result);
+#else
+       r = readdir_r (dirp, &_entry, (struct dirent**) result);
+#endif
+
+       if (r == 0 && result != NULL) {
+               copy_dirent (entry, &_entry);
+       }
+
+       return r;
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/errno.c b/support/errno.c
new file mode 100644 (file)
index 0000000..9794fec
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * <errno.h> wrapper functions.
+ */
+
+/* to get XPG's strerror_r declaration */
+#undef _GNU_SOURCE
+#undef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 600
+
+#include <errno.h>
+#include <string.h>
+#include "mph.h"
+#include <stdio.h>
+
+G_BEGIN_DECLS
+
+void
+Mono_Posix_Syscall_SetLastError (int error_number)
+{
+       errno = error_number;
+}
+
+gint32
+Mono_Posix_Syscall_strerror_r (int errnum, char *buf, mph_size_t n)
+{
+       mph_return_if_size_t_overflow (n);
+       return strerror_r (errnum, buf, (size_t) n);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/fcntl.c b/support/fcntl.c
new file mode 100644 (file)
index 0000000..4fd8f19
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * <fcntl.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "map.h"
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+struct Mono_Posix_Flock {
+       gint16    l_type;
+       gint16    l_whence;
+       mph_off_t l_start;
+       mph_off_t l_len;
+       mph_pid_t l_pid;
+};
+
+gint32
+Mono_Posix_Syscall_fcntl (gint32 fd, gint32 cmd)
+{
+       if (Mono_Posix_FromFcntlCommand (cmd, &cmd) == -1)
+               return -1;
+       return fcntl (fd, cmd);
+}
+
+gint32
+Mono_Posix_Syscall_fcntl_arg (gint32 fd, gint32 cmd, gint64 arg)
+{
+       long _arg;
+       int _argi;
+       gint32 _cmd;
+
+       mph_return_if_long_overflow (arg);
+
+#ifdef F_NOTIFY
+       if (cmd == F_NOTIFY) {
+               if (Mono_Posix_FromDirectoryNotifyFlags (arg, &_argi) == -1) {
+                       return -1;
+               }
+               _arg = _argi;
+       }
+       else
+#endif
+               _arg = (long) arg;
+
+       if (Mono_Posix_FromFcntlCommand (cmd, &_cmd) == -1)
+               return -1;
+       return fcntl (fd, cmd, _arg);
+}
+
+gint32
+Mono_Posix_Syscall_fcntl_lock (gint32 fd, gint32 cmd, struct Mono_Posix_Flock *lock)
+{
+#ifdef MPH_USE_64_API
+       struct flock64 _lock;
+#else
+       struct flock _lock;
+#endif
+       int r;
+
+       if (lock == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       mph_return_if_off_t_overflow (lock->l_start);
+       mph_return_if_off_t_overflow (lock->l_len);
+
+       if (Mono_Posix_FromLockType (lock->l_type, &lock->l_type) == -1)
+               return -1;
+       _lock.l_type   = lock->l_type;
+       _lock.l_whence = lock->l_whence;
+       _lock.l_start  = lock->l_start;
+       _lock.l_len    = lock->l_len;
+       _lock.l_pid    = lock->l_pid;
+
+       r = fcntl (fd, cmd, &_lock);
+
+       if (Mono_Posix_ToLockType (_lock.l_type, &_lock.l_type) == -1)
+               r = -1;
+       lock->l_type   = _lock.l_type;
+       lock->l_whence = _lock.l_whence;
+       lock->l_start  = _lock.l_start;
+       lock->l_len    = _lock.l_len;
+       lock->l_pid    = _lock.l_pid;
+
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_open (const char *pathname, gint32 flags)
+{
+       if (Mono_Posix_FromOpenFlags (flags, &flags) == -1)
+               return -1;
+#ifdef MPH_USE_64_API
+       return open64 (pathname, flags);
+#else
+       return open (pathname, flags);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_open_mode (const char *pathname, gint32 flags, guint32 mode)
+{
+       if (Mono_Posix_FromOpenFlags (flags, &flags) == -1)
+               return -1;
+       if (Mono_Posix_FromFilePermissions (mode, &mode) == -1)
+               return -1;
+#ifdef MPH_USE_64_API
+       return open64 (pathname, flags, mode);
+#else
+       return open (pathname, flags, mode);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_creat (const char *pathname, guint32 mode)
+{
+       if (Mono_Posix_FromFilePermissions (mode, &mode) == -1)
+               return -1;
+#ifdef MPH_USE_64_API
+       return creat64 (pathname, mode);
+#else
+       return creat (pathname, mode);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_posix_fadvise (gint32 fd, mph_off_t offset, mph_off_t len, 
+       gint32 advice)
+{
+       mph_return_if_off_t_overflow (offset);
+       mph_return_if_off_t_overflow (len);
+
+       if (Mono_Posix_FromPosixFadviseAdvice (advice, &advice) == -1)
+               return -1;
+
+#ifdef MPH_USE_64_API
+       return posix_fadvise64 (fd, offset, len, advice);
+#else
+       return posix_fadvise (fd, (off_t) offset, (off_t) len, advice);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_posix_fallocate (gint32 fd, mph_off_t offset, mph_size_t len)
+{
+       mph_return_if_off_t_overflow (offset);
+       mph_return_if_size_t_overflow (len);
+
+#ifdef MPH_USE_64_API
+       return posix_fallocate64 (fd, offset, len);
+#else
+       return posix_fadvise (fd, (off_t) offset, (size_t) len);
+#endif
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/grp.c b/support/grp.c
new file mode 100644 (file)
index 0000000..ff49aa1
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * <grp.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <grp.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+struct Mono_Posix_Syscall__Group {
+       /* string */  char     *gr_name;
+       /* string */  char     *gr_passwd;
+       /* gid_t  */  mph_gid_t gr_gid;
+       /* int    */  int       _gr_nmem_;
+       /* string */  char    **gr_mem;
+       /* string */  char     *_gr_buf_;  /* holds all but gr_mem */
+};
+
+static void
+count_members (char **gr_mem, int *count, size_t *mem)
+{
+       char *cur;
+       *count = 0;
+
+       // ensure that later (*mem)+1 doesn't result in integer overflow
+       if (*mem > INT_MAX - 1)
+               return;
+
+       for (cur = *gr_mem; cur != NULL; cur = *++gr_mem) {
+               size_t len;
+               len = strlen (cur);
+
+               if (!(len < INT_MAX - ((*mem) + 1)))
+                       break;
+
+               ++(*count);
+               *mem += (len + 1);
+       }
+}
+
+static int
+copy_group (struct Mono_Posix_Syscall__Group *to, struct group *from)
+{
+       size_t nlen, plen, buflen;
+       int i, count;
+       char *cur;
+
+       to->gr_gid    = from->gr_gid;
+
+       to->gr_name   = NULL;
+       to->gr_passwd = NULL;
+       to->gr_mem    = NULL;
+       to->_gr_buf_  = NULL;
+
+       nlen = strlen (from->gr_name);
+       plen = strlen (from->gr_passwd);
+
+       buflen = 2;
+
+       if (!(nlen < INT_MAX - buflen))
+               return -1;
+       buflen += nlen;
+
+       if (!(plen < INT_MAX - buflen))
+               return -1;
+       buflen += plen;
+
+       count = 0;
+       count_members (from->gr_mem, &count, &buflen);
+
+       to->_gr_nmem_ = count;
+       cur = to->_gr_buf_ = (char*) malloc (buflen);
+       to->gr_mem = (char **) malloc (sizeof(char*)*(count+1));
+       if (to->_gr_buf_ == NULL || to->gr_mem == NULL) {
+               free (to->_gr_buf_);
+               free (to->gr_mem);
+               return -1;
+       }
+
+       to->gr_name = strcpy (cur, from->gr_name);
+       cur += (nlen + 1);
+       to->gr_passwd = strcpy (cur, from->gr_passwd);
+       cur += (plen + 1);
+
+       for (i = 0; i != count; ++i) {
+               to->gr_mem[i] = strcpy (cur, from->gr_mem[i]);
+               cur += (strlen (from->gr_mem[i])+1);
+       }
+       to->gr_mem[i] = NULL;
+
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_getgrnam (const char *name, struct Mono_Posix_Syscall__Group *gbuf)
+{
+       struct group *_gbuf;
+
+       if (gbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       _gbuf = getgrnam (name);
+       if (_gbuf == NULL)
+               return -1;
+
+       if (copy_group (gbuf, _gbuf) == -1) {
+               errno = ENOMEM;
+               return -1;
+       }
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_getgrgid (mph_gid_t gid, struct Mono_Posix_Syscall__Group *gbuf)
+{
+       struct group *_gbuf;
+
+       if (gbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       _gbuf = getgrgid (gid);
+       if (_gbuf == NULL)
+               return -1;
+
+       if (copy_group (gbuf, _gbuf) == -1) {
+               errno = ENOMEM;
+               return -1;
+       }
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_getgrnam_r (const char *name, 
+       struct Mono_Posix_Syscall__Group *gbuf,
+       struct group **gbufp)
+{
+       char *buf, *buf2;
+       size_t buflen;
+       int r;
+       struct group _grbuf;
+
+       if (gbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       buf = buf2 = NULL;
+       buflen = 2;
+
+       do {
+               buf2 = realloc (buf, buflen *= 2);
+               if (buf2 == NULL) {
+                       free (buf);
+                       errno = ENOMEM;
+                       return -1;
+               }
+               buf = buf2;
+       } while ((r = getgrnam_r (name, &_grbuf, buf, buflen, gbufp)) && r == ERANGE);
+
+       if (r == 0 && copy_group (gbuf, &_grbuf) == -1)
+               r = errno = ENOMEM;
+       free (buf);
+
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_getgrgid_r (mph_gid_t gid,
+       struct Mono_Posix_Syscall__Group *gbuf,
+       struct group **gbufp)
+{
+       char *buf, *buf2;
+       size_t buflen;
+       int r;
+       struct group _grbuf;
+
+       if (gbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       buf = buf2 = NULL;
+       buflen = 2;
+
+       do {
+               buf2 = realloc (buf, buflen *= 2);
+               if (buf2 == NULL) {
+                       free (buf);
+                       errno = ENOMEM;
+                       return -1;
+               }
+               buf = buf2;
+       } while ((r = getgrgid_r (gid, &_grbuf, buf, buflen, gbufp)) && r == ERANGE);
+
+       if (r == 0 && copy_group (gbuf, &_grbuf) == -1)
+               r = errno = ENOMEM;
+       free (buf);
+
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_getgrent (struct Mono_Posix_Syscall__Group *grbuf)
+{
+       struct group *gr;
+
+       if (grbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       gr = getgrent ();
+       if (gr == NULL)
+               return -1;
+
+       if (copy_group (grbuf, gr) == -1) {
+               errno = ENOMEM;
+               return -1;
+       }
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_fgetgrent (FILE *stream, struct Mono_Posix_Syscall__Group *grbuf)
+{
+       struct group *gr;
+
+       if (grbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       gr = fgetgrent (stream);
+       if (gr == NULL)
+               return -1;
+
+       if (copy_group (grbuf, gr) == -1) {
+               errno = ENOMEM;
+               return -1;
+       }
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_setgroups (mph_size_t size, mph_gid_t *list)
+{
+       mph_return_if_size_t_overflow (size);
+       return setgroups ((size_t) size, list);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
index 8f9d97504fdece2f2068c05c36ec754040e2b56e..dfc2ad0a88d324ce9b0703a797df0cd46c2f9c1f 100644 (file)
-/* This file was automatically generated by make-map from Mono.Posix.dll */
+/*
+ * This file was automatically generated by make-map from Mono.Posix.dll.
+ *
+ * DO NOT MODIFY.
+ */
 
+#include "map.h"
+
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif /* ndef _GNU_SOURCE */
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE
+#endif /* ndef _XOPEN_SOURCE */
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/poll.h>
 #include <sys/wait.h>
+#include <sys/mount.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <poll.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;
+#include <grp.h>
+#include <errno.h>
+
+int Mono_Posix_FromError (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_Error_EPERM)
+#ifdef EPERM
+               {*r = EPERM; return 0;}
+#else /* def EPERM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPERM */
+       if (x == Mono_Posix_Error_ENOENT)
+#ifdef ENOENT
+               {*r = ENOENT; return 0;}
+#else /* def ENOENT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOENT */
+       if (x == Mono_Posix_Error_ESRCH)
+#ifdef ESRCH
+               {*r = ESRCH; return 0;}
+#else /* def ESRCH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ESRCH */
+       if (x == Mono_Posix_Error_EINTR)
+#ifdef EINTR
+               {*r = EINTR; return 0;}
+#else /* def EINTR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EINTR */
+       if (x == Mono_Posix_Error_EIO)
+#ifdef EIO
+               {*r = EIO; return 0;}
+#else /* def EIO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EIO */
+       if (x == Mono_Posix_Error_ENXIO)
+#ifdef ENXIO
+               {*r = ENXIO; return 0;}
+#else /* def ENXIO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENXIO */
+       if (x == Mono_Posix_Error_E2BIG)
+#ifdef E2BIG
+               {*r = E2BIG; return 0;}
+#else /* def E2BIG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef E2BIG */
+       if (x == Mono_Posix_Error_ENOEXEC)
+#ifdef ENOEXEC
+               {*r = ENOEXEC; return 0;}
+#else /* def ENOEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOEXEC */
+       if (x == Mono_Posix_Error_EBADF)
+#ifdef EBADF
+               {*r = EBADF; return 0;}
+#else /* def EBADF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADF */
+       if (x == Mono_Posix_Error_ECHILD)
+#ifdef ECHILD
+               {*r = ECHILD; return 0;}
+#else /* def ECHILD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ECHILD */
+       if (x == Mono_Posix_Error_EAGAIN)
+#ifdef EAGAIN
+               {*r = EAGAIN; return 0;}
+#else /* def EAGAIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EAGAIN */
+       if (x == Mono_Posix_Error_ENOMEM)
+#ifdef ENOMEM
+               {*r = ENOMEM; return 0;}
+#else /* def ENOMEM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOMEM */
+       if (x == Mono_Posix_Error_EACCES)
+#ifdef EACCES
+               {*r = EACCES; return 0;}
+#else /* def EACCES */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EACCES */
+       if (x == Mono_Posix_Error_EFAULT)
+#ifdef EFAULT
+               {*r = EFAULT; return 0;}
+#else /* def EFAULT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EFAULT */
+       if (x == Mono_Posix_Error_ENOTBLK)
+#ifdef ENOTBLK
+               {*r = ENOTBLK; return 0;}
+#else /* def ENOTBLK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTBLK */
+       if (x == Mono_Posix_Error_EBUSY)
+#ifdef EBUSY
+               {*r = EBUSY; return 0;}
+#else /* def EBUSY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBUSY */
+       if (x == Mono_Posix_Error_EEXIST)
+#ifdef EEXIST
+               {*r = EEXIST; return 0;}
+#else /* def EEXIST */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EEXIST */
+       if (x == Mono_Posix_Error_EXDEV)
+#ifdef EXDEV
+               {*r = EXDEV; return 0;}
+#else /* def EXDEV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EXDEV */
+       if (x == Mono_Posix_Error_ENODEV)
+#ifdef ENODEV
+               {*r = ENODEV; return 0;}
+#else /* def ENODEV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENODEV */
+       if (x == Mono_Posix_Error_ENOTDIR)
+#ifdef ENOTDIR
+               {*r = ENOTDIR; return 0;}
+#else /* def ENOTDIR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTDIR */
+       if (x == Mono_Posix_Error_EISDIR)
+#ifdef EISDIR
+               {*r = EISDIR; return 0;}
+#else /* def EISDIR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EISDIR */
+       if (x == Mono_Posix_Error_EINVAL)
+#ifdef EINVAL
+               {*r = EINVAL; return 0;}
+#else /* def EINVAL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EINVAL */
+       if (x == Mono_Posix_Error_ENFILE)
+#ifdef ENFILE
+               {*r = ENFILE; return 0;}
+#else /* def ENFILE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENFILE */
+       if (x == Mono_Posix_Error_EMFILE)
+#ifdef EMFILE
+               {*r = EMFILE; return 0;}
+#else /* def EMFILE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EMFILE */
+       if (x == Mono_Posix_Error_ENOTTY)
+#ifdef ENOTTY
+               {*r = ENOTTY; return 0;}
+#else /* def ENOTTY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTTY */
+       if (x == Mono_Posix_Error_ETXTBSY)
+#ifdef ETXTBSY
+               {*r = ETXTBSY; return 0;}
+#else /* def ETXTBSY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ETXTBSY */
+       if (x == Mono_Posix_Error_EFBIG)
+#ifdef EFBIG
+               {*r = EFBIG; return 0;}
+#else /* def EFBIG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EFBIG */
+       if (x == Mono_Posix_Error_ENOSPC)
+#ifdef ENOSPC
+               {*r = ENOSPC; return 0;}
+#else /* def ENOSPC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOSPC */
+       if (x == Mono_Posix_Error_ESPIPE)
+#ifdef ESPIPE
+               {*r = ESPIPE; return 0;}
+#else /* def ESPIPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ESPIPE */
+       if (x == Mono_Posix_Error_EROFS)
+#ifdef EROFS
+               {*r = EROFS; return 0;}
+#else /* def EROFS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EROFS */
+       if (x == Mono_Posix_Error_EMLINK)
+#ifdef EMLINK
+               {*r = EMLINK; return 0;}
+#else /* def EMLINK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EMLINK */
+       if (x == Mono_Posix_Error_EPIPE)
+#ifdef EPIPE
+               {*r = EPIPE; return 0;}
+#else /* def EPIPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPIPE */
+       if (x == Mono_Posix_Error_EDOM)
+#ifdef EDOM
+               {*r = EDOM; return 0;}
+#else /* def EDOM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EDOM */
+       if (x == Mono_Posix_Error_ERANGE)
+#ifdef ERANGE
+               {*r = ERANGE; return 0;}
+#else /* def ERANGE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ERANGE */
+       if (x == Mono_Posix_Error_EDEADLK)
+#ifdef EDEADLK
+               {*r = EDEADLK; return 0;}
+#else /* def EDEADLK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EDEADLK */
+       if (x == Mono_Posix_Error_ENAMETOOLONG)
+#ifdef ENAMETOOLONG
+               {*r = ENAMETOOLONG; return 0;}
+#else /* def ENAMETOOLONG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENAMETOOLONG */
+       if (x == Mono_Posix_Error_ENOLCK)
+#ifdef ENOLCK
+               {*r = ENOLCK; return 0;}
+#else /* def ENOLCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOLCK */
+       if (x == Mono_Posix_Error_ENOSYS)
+#ifdef ENOSYS
+               {*r = ENOSYS; return 0;}
+#else /* def ENOSYS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOSYS */
+       if (x == Mono_Posix_Error_ENOTEMPTY)
+#ifdef ENOTEMPTY
+               {*r = ENOTEMPTY; return 0;}
+#else /* def ENOTEMPTY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTEMPTY */
+       if (x == Mono_Posix_Error_ELOOP)
+#ifdef ELOOP
+               {*r = ELOOP; return 0;}
+#else /* def ELOOP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ELOOP */
+       if (x == Mono_Posix_Error_EWOULDBLOCK)
+#ifdef EWOULDBLOCK
+               {*r = EWOULDBLOCK; return 0;}
+#else /* def EWOULDBLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EWOULDBLOCK */
+       if (x == Mono_Posix_Error_ENOMSG)
+#ifdef ENOMSG
+               {*r = ENOMSG; return 0;}
+#else /* def ENOMSG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOMSG */
+       if (x == Mono_Posix_Error_EIDRM)
+#ifdef EIDRM
+               {*r = EIDRM; return 0;}
+#else /* def EIDRM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EIDRM */
+       if (x == Mono_Posix_Error_ECHRNG)
+#ifdef ECHRNG
+               {*r = ECHRNG; return 0;}
+#else /* def ECHRNG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ECHRNG */
+       if (x == Mono_Posix_Error_EL2NSYNC)
+#ifdef EL2NSYNC
+               {*r = EL2NSYNC; return 0;}
+#else /* def EL2NSYNC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EL2NSYNC */
+       if (x == Mono_Posix_Error_EL3HLT)
+#ifdef EL3HLT
+               {*r = EL3HLT; return 0;}
+#else /* def EL3HLT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EL3HLT */
+       if (x == Mono_Posix_Error_EL3RST)
+#ifdef EL3RST
+               {*r = EL3RST; return 0;}
+#else /* def EL3RST */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EL3RST */
+       if (x == Mono_Posix_Error_ELNRNG)
+#ifdef ELNRNG
+               {*r = ELNRNG; return 0;}
+#else /* def ELNRNG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ELNRNG */
+       if (x == Mono_Posix_Error_EUNATCH)
+#ifdef EUNATCH
+               {*r = EUNATCH; return 0;}
+#else /* def EUNATCH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EUNATCH */
+       if (x == Mono_Posix_Error_ENOCSI)
+#ifdef ENOCSI
+               {*r = ENOCSI; return 0;}
+#else /* def ENOCSI */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOCSI */
+       if (x == Mono_Posix_Error_EL2HLT)
+#ifdef EL2HLT
+               {*r = EL2HLT; return 0;}
+#else /* def EL2HLT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EL2HLT */
+       if (x == Mono_Posix_Error_EBADE)
+#ifdef EBADE
+               {*r = EBADE; return 0;}
+#else /* def EBADE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADE */
+       if (x == Mono_Posix_Error_EBADR)
+#ifdef EBADR
+               {*r = EBADR; return 0;}
+#else /* def EBADR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADR */
+       if (x == Mono_Posix_Error_EXFULL)
+#ifdef EXFULL
+               {*r = EXFULL; return 0;}
+#else /* def EXFULL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EXFULL */
+       if (x == Mono_Posix_Error_ENOANO)
+#ifdef ENOANO
+               {*r = ENOANO; return 0;}
+#else /* def ENOANO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOANO */
+       if (x == Mono_Posix_Error_EBADRQC)
+#ifdef EBADRQC
+               {*r = EBADRQC; return 0;}
+#else /* def EBADRQC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADRQC */
+       if (x == Mono_Posix_Error_EBADSLT)
+#ifdef EBADSLT
+               {*r = EBADSLT; return 0;}
+#else /* def EBADSLT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADSLT */
+       if (x == Mono_Posix_Error_EDEADLOCK)
+#ifdef EDEADLOCK
+               {*r = EDEADLOCK; return 0;}
+#else /* def EDEADLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EDEADLOCK */
+       if (x == Mono_Posix_Error_EBFONT)
+#ifdef EBFONT
+               {*r = EBFONT; return 0;}
+#else /* def EBFONT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBFONT */
+       if (x == Mono_Posix_Error_ENOSTR)
+#ifdef ENOSTR
+               {*r = ENOSTR; return 0;}
+#else /* def ENOSTR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOSTR */
+       if (x == Mono_Posix_Error_ENODATA)
+#ifdef ENODATA
+               {*r = ENODATA; return 0;}
+#else /* def ENODATA */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENODATA */
+       if (x == Mono_Posix_Error_ETIME)
+#ifdef ETIME
+               {*r = ETIME; return 0;}
+#else /* def ETIME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ETIME */
+       if (x == Mono_Posix_Error_ENOSR)
+#ifdef ENOSR
+               {*r = ENOSR; return 0;}
+#else /* def ENOSR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOSR */
+       if (x == Mono_Posix_Error_ENONET)
+#ifdef ENONET
+               {*r = ENONET; return 0;}
+#else /* def ENONET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENONET */
+       if (x == Mono_Posix_Error_ENOPKG)
+#ifdef ENOPKG
+               {*r = ENOPKG; return 0;}
+#else /* def ENOPKG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOPKG */
+       if (x == Mono_Posix_Error_EREMOTE)
+#ifdef EREMOTE
+               {*r = EREMOTE; return 0;}
+#else /* def EREMOTE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EREMOTE */
+       if (x == Mono_Posix_Error_ENOLINK)
+#ifdef ENOLINK
+               {*r = ENOLINK; return 0;}
+#else /* def ENOLINK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOLINK */
+       if (x == Mono_Posix_Error_EADV)
+#ifdef EADV
+               {*r = EADV; return 0;}
+#else /* def EADV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EADV */
+       if (x == Mono_Posix_Error_ESRMNT)
+#ifdef ESRMNT
+               {*r = ESRMNT; return 0;}
+#else /* def ESRMNT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ESRMNT */
+       if (x == Mono_Posix_Error_ECOMM)
+#ifdef ECOMM
+               {*r = ECOMM; return 0;}
+#else /* def ECOMM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ECOMM */
+       if (x == Mono_Posix_Error_EPROTO)
+#ifdef EPROTO
+               {*r = EPROTO; return 0;}
+#else /* def EPROTO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPROTO */
+       if (x == Mono_Posix_Error_EMULTIHOP)
+#ifdef EMULTIHOP
+               {*r = EMULTIHOP; return 0;}
+#else /* def EMULTIHOP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EMULTIHOP */
+       if (x == Mono_Posix_Error_EDOTDOT)
+#ifdef EDOTDOT
+               {*r = EDOTDOT; return 0;}
+#else /* def EDOTDOT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EDOTDOT */
+       if (x == Mono_Posix_Error_EBADMSG)
+#ifdef EBADMSG
+               {*r = EBADMSG; return 0;}
+#else /* def EBADMSG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADMSG */
+       if (x == Mono_Posix_Error_EOVERFLOW)
+#ifdef EOVERFLOW
+               {*r = EOVERFLOW; return 0;}
+#else /* def EOVERFLOW */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EOVERFLOW */
+       if (x == Mono_Posix_Error_ENOTUNIQ)
+#ifdef ENOTUNIQ
+               {*r = ENOTUNIQ; return 0;}
+#else /* def ENOTUNIQ */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTUNIQ */
+       if (x == Mono_Posix_Error_EBADFD)
+#ifdef EBADFD
+               {*r = EBADFD; return 0;}
+#else /* def EBADFD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADFD */
+       if (x == Mono_Posix_Error_EREMCHG)
+#ifdef EREMCHG
+               {*r = EREMCHG; return 0;}
+#else /* def EREMCHG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EREMCHG */
+       if (x == Mono_Posix_Error_ELIBACC)
+#ifdef ELIBACC
+               {*r = ELIBACC; return 0;}
+#else /* def ELIBACC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ELIBACC */
+       if (x == Mono_Posix_Error_ELIBBAD)
+#ifdef ELIBBAD
+               {*r = ELIBBAD; return 0;}
+#else /* def ELIBBAD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ELIBBAD */
+       if (x == Mono_Posix_Error_ELIBSCN)
+#ifdef ELIBSCN
+               {*r = ELIBSCN; return 0;}
+#else /* def ELIBSCN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ELIBSCN */
+       if (x == Mono_Posix_Error_ELIBMAX)
+#ifdef ELIBMAX
+               {*r = ELIBMAX; return 0;}
+#else /* def ELIBMAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ELIBMAX */
+       if (x == Mono_Posix_Error_ELIBEXEC)
+#ifdef ELIBEXEC
+               {*r = ELIBEXEC; return 0;}
+#else /* def ELIBEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ELIBEXEC */
+       if (x == Mono_Posix_Error_EILSEQ)
+#ifdef EILSEQ
+               {*r = EILSEQ; return 0;}
+#else /* def EILSEQ */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EILSEQ */
+       if (x == Mono_Posix_Error_ERESTART)
+#ifdef ERESTART
+               {*r = ERESTART; return 0;}
+#else /* def ERESTART */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ERESTART */
+       if (x == Mono_Posix_Error_ESTRPIPE)
+#ifdef ESTRPIPE
+               {*r = ESTRPIPE; return 0;}
+#else /* def ESTRPIPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ESTRPIPE */
+       if (x == Mono_Posix_Error_EUSERS)
+#ifdef EUSERS
+               {*r = EUSERS; return 0;}
+#else /* def EUSERS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EUSERS */
+       if (x == Mono_Posix_Error_ENOTSOCK)
+#ifdef ENOTSOCK
+               {*r = ENOTSOCK; return 0;}
+#else /* def ENOTSOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTSOCK */
+       if (x == Mono_Posix_Error_EDESTADDRREQ)
+#ifdef EDESTADDRREQ
+               {*r = EDESTADDRREQ; return 0;}
+#else /* def EDESTADDRREQ */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EDESTADDRREQ */
+       if (x == Mono_Posix_Error_EMSGSIZE)
+#ifdef EMSGSIZE
+               {*r = EMSGSIZE; return 0;}
+#else /* def EMSGSIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EMSGSIZE */
+       if (x == Mono_Posix_Error_EPROTOTYPE)
+#ifdef EPROTOTYPE
+               {*r = EPROTOTYPE; return 0;}
+#else /* def EPROTOTYPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPROTOTYPE */
+       if (x == Mono_Posix_Error_ENOPROTOOPT)
+#ifdef ENOPROTOOPT
+               {*r = ENOPROTOOPT; return 0;}
+#else /* def ENOPROTOOPT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOPROTOOPT */
+       if (x == Mono_Posix_Error_EPROTONOSUPPORT)
+#ifdef EPROTONOSUPPORT
+               {*r = EPROTONOSUPPORT; return 0;}
+#else /* def EPROTONOSUPPORT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPROTONOSUPPORT */
+       if (x == Mono_Posix_Error_ESOCKTNOSUPPORT)
+#ifdef ESOCKTNOSUPPORT
+               {*r = ESOCKTNOSUPPORT; return 0;}
+#else /* def ESOCKTNOSUPPORT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ESOCKTNOSUPPORT */
+       if (x == Mono_Posix_Error_EOPNOTSUPP)
+#ifdef EOPNOTSUPP
+               {*r = EOPNOTSUPP; return 0;}
+#else /* def EOPNOTSUPP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EOPNOTSUPP */
+       if (x == Mono_Posix_Error_EPFNOSUPPORT)
+#ifdef EPFNOSUPPORT
+               {*r = EPFNOSUPPORT; return 0;}
+#else /* def EPFNOSUPPORT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPFNOSUPPORT */
+       if (x == Mono_Posix_Error_EAFNOSUPPORT)
+#ifdef EAFNOSUPPORT
+               {*r = EAFNOSUPPORT; return 0;}
+#else /* def EAFNOSUPPORT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EAFNOSUPPORT */
+       if (x == Mono_Posix_Error_EADDRINUSE)
+#ifdef EADDRINUSE
+               {*r = EADDRINUSE; return 0;}
+#else /* def EADDRINUSE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EADDRINUSE */
+       if (x == Mono_Posix_Error_EADDRNOTAVAIL)
+#ifdef EADDRNOTAVAIL
+               {*r = EADDRNOTAVAIL; return 0;}
+#else /* def EADDRNOTAVAIL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EADDRNOTAVAIL */
+       if (x == Mono_Posix_Error_ENETDOWN)
+#ifdef ENETDOWN
+               {*r = ENETDOWN; return 0;}
+#else /* def ENETDOWN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENETDOWN */
+       if (x == Mono_Posix_Error_ENETUNREACH)
+#ifdef ENETUNREACH
+               {*r = ENETUNREACH; return 0;}
+#else /* def ENETUNREACH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENETUNREACH */
+       if (x == Mono_Posix_Error_ENETRESET)
+#ifdef ENETRESET
+               {*r = ENETRESET; return 0;}
+#else /* def ENETRESET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENETRESET */
+       if (x == Mono_Posix_Error_ECONNABORTED)
+#ifdef ECONNABORTED
+               {*r = ECONNABORTED; return 0;}
+#else /* def ECONNABORTED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ECONNABORTED */
+       if (x == Mono_Posix_Error_ECONNRESET)
+#ifdef ECONNRESET
+               {*r = ECONNRESET; return 0;}
+#else /* def ECONNRESET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ECONNRESET */
+       if (x == Mono_Posix_Error_ENOBUFS)
+#ifdef ENOBUFS
+               {*r = ENOBUFS; return 0;}
+#else /* def ENOBUFS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOBUFS */
+       if (x == Mono_Posix_Error_EISCONN)
+#ifdef EISCONN
+               {*r = EISCONN; return 0;}
+#else /* def EISCONN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EISCONN */
+       if (x == Mono_Posix_Error_ENOTCONN)
+#ifdef ENOTCONN
+               {*r = ENOTCONN; return 0;}
+#else /* def ENOTCONN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTCONN */
+       if (x == Mono_Posix_Error_ESHUTDOWN)
+#ifdef ESHUTDOWN
+               {*r = ESHUTDOWN; return 0;}
+#else /* def ESHUTDOWN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ESHUTDOWN */
+       if (x == Mono_Posix_Error_ETOOMANYREFS)
+#ifdef ETOOMANYREFS
+               {*r = ETOOMANYREFS; return 0;}
+#else /* def ETOOMANYREFS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ETOOMANYREFS */
+       if (x == Mono_Posix_Error_ETIMEDOUT)
+#ifdef ETIMEDOUT
+               {*r = ETIMEDOUT; return 0;}
+#else /* def ETIMEDOUT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ETIMEDOUT */
+       if (x == Mono_Posix_Error_ECONNREFUSED)
+#ifdef ECONNREFUSED
+               {*r = ECONNREFUSED; return 0;}
+#else /* def ECONNREFUSED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ECONNREFUSED */
+       if (x == Mono_Posix_Error_EHOSTDOWN)
+#ifdef EHOSTDOWN
+               {*r = EHOSTDOWN; return 0;}
+#else /* def EHOSTDOWN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EHOSTDOWN */
+       if (x == Mono_Posix_Error_EHOSTUNREACH)
+#ifdef EHOSTUNREACH
+               {*r = EHOSTUNREACH; return 0;}
+#else /* def EHOSTUNREACH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EHOSTUNREACH */
+       if (x == Mono_Posix_Error_EALREADY)
+#ifdef EALREADY
+               {*r = EALREADY; return 0;}
+#else /* def EALREADY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EALREADY */
+       if (x == Mono_Posix_Error_EINPROGRESS)
+#ifdef EINPROGRESS
+               {*r = EINPROGRESS; return 0;}
+#else /* def EINPROGRESS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EINPROGRESS */
+       if (x == Mono_Posix_Error_ESTALE)
+#ifdef ESTALE
+               {*r = ESTALE; return 0;}
+#else /* def ESTALE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ESTALE */
+       if (x == Mono_Posix_Error_EUCLEAN)
+#ifdef EUCLEAN
+               {*r = EUCLEAN; return 0;}
+#else /* def EUCLEAN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EUCLEAN */
+       if (x == Mono_Posix_Error_ENOTNAM)
+#ifdef ENOTNAM
+               {*r = ENOTNAM; return 0;}
+#else /* def ENOTNAM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTNAM */
+       if (x == Mono_Posix_Error_ENAVAIL)
+#ifdef ENAVAIL
+               {*r = ENAVAIL; return 0;}
+#else /* def ENAVAIL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENAVAIL */
+       if (x == Mono_Posix_Error_EISNAM)
+#ifdef EISNAM
+               {*r = EISNAM; return 0;}
+#else /* def EISNAM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EISNAM */
+       if (x == Mono_Posix_Error_EREMOTEIO)
+#ifdef EREMOTEIO
+               {*r = EREMOTEIO; return 0;}
+#else /* def EREMOTEIO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EREMOTEIO */
+       if (x == Mono_Posix_Error_EDQUOT)
+#ifdef EDQUOT
+               {*r = EDQUOT; return 0;}
+#else /* def EDQUOT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EDQUOT */
+       if (x == Mono_Posix_Error_ENOMEDIUM)
+#ifdef ENOMEDIUM
+               {*r = ENOMEDIUM; return 0;}
+#else /* def ENOMEDIUM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOMEDIUM */
+       if (x == Mono_Posix_Error_EMEDIUMTYPE)
+#ifdef EMEDIUMTYPE
+               {*r = EMEDIUMTYPE; return 0;}
+#else /* def EMEDIUMTYPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EMEDIUMTYPE */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToError (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef EPERM
+       if (x == EPERM)
+               {*r = Mono_Posix_Error_EPERM; return 0;}
+#endif /* ndef EPERM */
+#ifdef ENOENT
+       if (x == ENOENT)
+               {*r = Mono_Posix_Error_ENOENT; return 0;}
+#endif /* ndef ENOENT */
+#ifdef ESRCH
+       if (x == ESRCH)
+               {*r = Mono_Posix_Error_ESRCH; return 0;}
+#endif /* ndef ESRCH */
+#ifdef EINTR
+       if (x == EINTR)
+               {*r = Mono_Posix_Error_EINTR; return 0;}
+#endif /* ndef EINTR */
+#ifdef EIO
+       if (x == EIO)
+               {*r = Mono_Posix_Error_EIO; return 0;}
+#endif /* ndef EIO */
+#ifdef ENXIO
+       if (x == ENXIO)
+               {*r = Mono_Posix_Error_ENXIO; return 0;}
+#endif /* ndef ENXIO */
+#ifdef E2BIG
+       if (x == E2BIG)
+               {*r = Mono_Posix_Error_E2BIG; return 0;}
+#endif /* ndef E2BIG */
+#ifdef ENOEXEC
+       if (x == ENOEXEC)
+               {*r = Mono_Posix_Error_ENOEXEC; return 0;}
+#endif /* ndef ENOEXEC */
+#ifdef EBADF
+       if (x == EBADF)
+               {*r = Mono_Posix_Error_EBADF; return 0;}
+#endif /* ndef EBADF */
+#ifdef ECHILD
+       if (x == ECHILD)
+               {*r = Mono_Posix_Error_ECHILD; return 0;}
+#endif /* ndef ECHILD */
+#ifdef EAGAIN
+       if (x == EAGAIN)
+               {*r = Mono_Posix_Error_EAGAIN; return 0;}
+#endif /* ndef EAGAIN */
+#ifdef ENOMEM
+       if (x == ENOMEM)
+               {*r = Mono_Posix_Error_ENOMEM; return 0;}
+#endif /* ndef ENOMEM */
+#ifdef EACCES
+       if (x == EACCES)
+               {*r = Mono_Posix_Error_EACCES; return 0;}
+#endif /* ndef EACCES */
+#ifdef EFAULT
+       if (x == EFAULT)
+               {*r = Mono_Posix_Error_EFAULT; return 0;}
+#endif /* ndef EFAULT */
+#ifdef ENOTBLK
+       if (x == ENOTBLK)
+               {*r = Mono_Posix_Error_ENOTBLK; return 0;}
+#endif /* ndef ENOTBLK */
+#ifdef EBUSY
+       if (x == EBUSY)
+               {*r = Mono_Posix_Error_EBUSY; return 0;}
+#endif /* ndef EBUSY */
+#ifdef EEXIST
+       if (x == EEXIST)
+               {*r = Mono_Posix_Error_EEXIST; return 0;}
+#endif /* ndef EEXIST */
+#ifdef EXDEV
+       if (x == EXDEV)
+               {*r = Mono_Posix_Error_EXDEV; return 0;}
+#endif /* ndef EXDEV */
+#ifdef ENODEV
+       if (x == ENODEV)
+               {*r = Mono_Posix_Error_ENODEV; return 0;}
+#endif /* ndef ENODEV */
+#ifdef ENOTDIR
+       if (x == ENOTDIR)
+               {*r = Mono_Posix_Error_ENOTDIR; return 0;}
+#endif /* ndef ENOTDIR */
+#ifdef EISDIR
+       if (x == EISDIR)
+               {*r = Mono_Posix_Error_EISDIR; return 0;}
+#endif /* ndef EISDIR */
+#ifdef EINVAL
+       if (x == EINVAL)
+               {*r = Mono_Posix_Error_EINVAL; return 0;}
+#endif /* ndef EINVAL */
+#ifdef ENFILE
+       if (x == ENFILE)
+               {*r = Mono_Posix_Error_ENFILE; return 0;}
+#endif /* ndef ENFILE */
+#ifdef EMFILE
+       if (x == EMFILE)
+               {*r = Mono_Posix_Error_EMFILE; return 0;}
+#endif /* ndef EMFILE */
+#ifdef ENOTTY
+       if (x == ENOTTY)
+               {*r = Mono_Posix_Error_ENOTTY; return 0;}
+#endif /* ndef ENOTTY */
+#ifdef ETXTBSY
+       if (x == ETXTBSY)
+               {*r = Mono_Posix_Error_ETXTBSY; return 0;}
+#endif /* ndef ETXTBSY */
+#ifdef EFBIG
+       if (x == EFBIG)
+               {*r = Mono_Posix_Error_EFBIG; return 0;}
+#endif /* ndef EFBIG */
+#ifdef ENOSPC
+       if (x == ENOSPC)
+               {*r = Mono_Posix_Error_ENOSPC; return 0;}
+#endif /* ndef ENOSPC */
+#ifdef ESPIPE
+       if (x == ESPIPE)
+               {*r = Mono_Posix_Error_ESPIPE; return 0;}
+#endif /* ndef ESPIPE */
+#ifdef EROFS
+       if (x == EROFS)
+               {*r = Mono_Posix_Error_EROFS; return 0;}
+#endif /* ndef EROFS */
+#ifdef EMLINK
+       if (x == EMLINK)
+               {*r = Mono_Posix_Error_EMLINK; return 0;}
+#endif /* ndef EMLINK */
+#ifdef EPIPE
+       if (x == EPIPE)
+               {*r = Mono_Posix_Error_EPIPE; return 0;}
+#endif /* ndef EPIPE */
+#ifdef EDOM
+       if (x == EDOM)
+               {*r = Mono_Posix_Error_EDOM; return 0;}
+#endif /* ndef EDOM */
+#ifdef ERANGE
+       if (x == ERANGE)
+               {*r = Mono_Posix_Error_ERANGE; return 0;}
+#endif /* ndef ERANGE */
+#ifdef EDEADLK
+       if (x == EDEADLK)
+               {*r = Mono_Posix_Error_EDEADLK; return 0;}
+#endif /* ndef EDEADLK */
+#ifdef ENAMETOOLONG
+       if (x == ENAMETOOLONG)
+               {*r = Mono_Posix_Error_ENAMETOOLONG; return 0;}
+#endif /* ndef ENAMETOOLONG */
+#ifdef ENOLCK
+       if (x == ENOLCK)
+               {*r = Mono_Posix_Error_ENOLCK; return 0;}
+#endif /* ndef ENOLCK */
+#ifdef ENOSYS
+       if (x == ENOSYS)
+               {*r = Mono_Posix_Error_ENOSYS; return 0;}
+#endif /* ndef ENOSYS */
+#ifdef ENOTEMPTY
+       if (x == ENOTEMPTY)
+               {*r = Mono_Posix_Error_ENOTEMPTY; return 0;}
+#endif /* ndef ENOTEMPTY */
+#ifdef ELOOP
+       if (x == ELOOP)
+               {*r = Mono_Posix_Error_ELOOP; return 0;}
+#endif /* ndef ELOOP */
+#ifdef EWOULDBLOCK
+       if (x == EWOULDBLOCK)
+               {*r = Mono_Posix_Error_EWOULDBLOCK; return 0;}
+#endif /* ndef EWOULDBLOCK */
+#ifdef ENOMSG
+       if (x == ENOMSG)
+               {*r = Mono_Posix_Error_ENOMSG; return 0;}
+#endif /* ndef ENOMSG */
+#ifdef EIDRM
+       if (x == EIDRM)
+               {*r = Mono_Posix_Error_EIDRM; return 0;}
+#endif /* ndef EIDRM */
+#ifdef ECHRNG
+       if (x == ECHRNG)
+               {*r = Mono_Posix_Error_ECHRNG; return 0;}
+#endif /* ndef ECHRNG */
+#ifdef EL2NSYNC
+       if (x == EL2NSYNC)
+               {*r = Mono_Posix_Error_EL2NSYNC; return 0;}
+#endif /* ndef EL2NSYNC */
+#ifdef EL3HLT
+       if (x == EL3HLT)
+               {*r = Mono_Posix_Error_EL3HLT; return 0;}
+#endif /* ndef EL3HLT */
+#ifdef EL3RST
+       if (x == EL3RST)
+               {*r = Mono_Posix_Error_EL3RST; return 0;}
+#endif /* ndef EL3RST */
+#ifdef ELNRNG
+       if (x == ELNRNG)
+               {*r = Mono_Posix_Error_ELNRNG; return 0;}
+#endif /* ndef ELNRNG */
+#ifdef EUNATCH
+       if (x == EUNATCH)
+               {*r = Mono_Posix_Error_EUNATCH; return 0;}
+#endif /* ndef EUNATCH */
+#ifdef ENOCSI
+       if (x == ENOCSI)
+               {*r = Mono_Posix_Error_ENOCSI; return 0;}
+#endif /* ndef ENOCSI */
+#ifdef EL2HLT
+       if (x == EL2HLT)
+               {*r = Mono_Posix_Error_EL2HLT; return 0;}
+#endif /* ndef EL2HLT */
+#ifdef EBADE
+       if (x == EBADE)
+               {*r = Mono_Posix_Error_EBADE; return 0;}
+#endif /* ndef EBADE */
+#ifdef EBADR
+       if (x == EBADR)
+               {*r = Mono_Posix_Error_EBADR; return 0;}
+#endif /* ndef EBADR */
+#ifdef EXFULL
+       if (x == EXFULL)
+               {*r = Mono_Posix_Error_EXFULL; return 0;}
+#endif /* ndef EXFULL */
+#ifdef ENOANO
+       if (x == ENOANO)
+               {*r = Mono_Posix_Error_ENOANO; return 0;}
+#endif /* ndef ENOANO */
+#ifdef EBADRQC
+       if (x == EBADRQC)
+               {*r = Mono_Posix_Error_EBADRQC; return 0;}
+#endif /* ndef EBADRQC */
+#ifdef EBADSLT
+       if (x == EBADSLT)
+               {*r = Mono_Posix_Error_EBADSLT; return 0;}
+#endif /* ndef EBADSLT */
+#ifdef EDEADLOCK
+       if (x == EDEADLOCK)
+               {*r = Mono_Posix_Error_EDEADLOCK; return 0;}
+#endif /* ndef EDEADLOCK */
+#ifdef EBFONT
+       if (x == EBFONT)
+               {*r = Mono_Posix_Error_EBFONT; return 0;}
+#endif /* ndef EBFONT */
+#ifdef ENOSTR
+       if (x == ENOSTR)
+               {*r = Mono_Posix_Error_ENOSTR; return 0;}
+#endif /* ndef ENOSTR */
+#ifdef ENODATA
+       if (x == ENODATA)
+               {*r = Mono_Posix_Error_ENODATA; return 0;}
+#endif /* ndef ENODATA */
+#ifdef ETIME
+       if (x == ETIME)
+               {*r = Mono_Posix_Error_ETIME; return 0;}
+#endif /* ndef ETIME */
+#ifdef ENOSR
+       if (x == ENOSR)
+               {*r = Mono_Posix_Error_ENOSR; return 0;}
+#endif /* ndef ENOSR */
+#ifdef ENONET
+       if (x == ENONET)
+               {*r = Mono_Posix_Error_ENONET; return 0;}
+#endif /* ndef ENONET */
+#ifdef ENOPKG
+       if (x == ENOPKG)
+               {*r = Mono_Posix_Error_ENOPKG; return 0;}
+#endif /* ndef ENOPKG */
+#ifdef EREMOTE
+       if (x == EREMOTE)
+               {*r = Mono_Posix_Error_EREMOTE; return 0;}
+#endif /* ndef EREMOTE */
+#ifdef ENOLINK
+       if (x == ENOLINK)
+               {*r = Mono_Posix_Error_ENOLINK; return 0;}
+#endif /* ndef ENOLINK */
+#ifdef EADV
+       if (x == EADV)
+               {*r = Mono_Posix_Error_EADV; return 0;}
+#endif /* ndef EADV */
+#ifdef ESRMNT
+       if (x == ESRMNT)
+               {*r = Mono_Posix_Error_ESRMNT; return 0;}
+#endif /* ndef ESRMNT */
+#ifdef ECOMM
+       if (x == ECOMM)
+               {*r = Mono_Posix_Error_ECOMM; return 0;}
+#endif /* ndef ECOMM */
+#ifdef EPROTO
+       if (x == EPROTO)
+               {*r = Mono_Posix_Error_EPROTO; return 0;}
+#endif /* ndef EPROTO */
+#ifdef EMULTIHOP
+       if (x == EMULTIHOP)
+               {*r = Mono_Posix_Error_EMULTIHOP; return 0;}
+#endif /* ndef EMULTIHOP */
+#ifdef EDOTDOT
+       if (x == EDOTDOT)
+               {*r = Mono_Posix_Error_EDOTDOT; return 0;}
+#endif /* ndef EDOTDOT */
+#ifdef EBADMSG
+       if (x == EBADMSG)
+               {*r = Mono_Posix_Error_EBADMSG; return 0;}
+#endif /* ndef EBADMSG */
+#ifdef EOVERFLOW
+       if (x == EOVERFLOW)
+               {*r = Mono_Posix_Error_EOVERFLOW; return 0;}
+#endif /* ndef EOVERFLOW */
+#ifdef ENOTUNIQ
+       if (x == ENOTUNIQ)
+               {*r = Mono_Posix_Error_ENOTUNIQ; return 0;}
+#endif /* ndef ENOTUNIQ */
+#ifdef EBADFD
+       if (x == EBADFD)
+               {*r = Mono_Posix_Error_EBADFD; return 0;}
+#endif /* ndef EBADFD */
+#ifdef EREMCHG
+       if (x == EREMCHG)
+               {*r = Mono_Posix_Error_EREMCHG; return 0;}
+#endif /* ndef EREMCHG */
+#ifdef ELIBACC
+       if (x == ELIBACC)
+               {*r = Mono_Posix_Error_ELIBACC; return 0;}
+#endif /* ndef ELIBACC */
+#ifdef ELIBBAD
+       if (x == ELIBBAD)
+               {*r = Mono_Posix_Error_ELIBBAD; return 0;}
+#endif /* ndef ELIBBAD */
+#ifdef ELIBSCN
+       if (x == ELIBSCN)
+               {*r = Mono_Posix_Error_ELIBSCN; return 0;}
+#endif /* ndef ELIBSCN */
+#ifdef ELIBMAX
+       if (x == ELIBMAX)
+               {*r = Mono_Posix_Error_ELIBMAX; return 0;}
+#endif /* ndef ELIBMAX */
+#ifdef ELIBEXEC
+       if (x == ELIBEXEC)
+               {*r = Mono_Posix_Error_ELIBEXEC; return 0;}
+#endif /* ndef ELIBEXEC */
+#ifdef EILSEQ
+       if (x == EILSEQ)
+               {*r = Mono_Posix_Error_EILSEQ; return 0;}
+#endif /* ndef EILSEQ */
+#ifdef ERESTART
+       if (x == ERESTART)
+               {*r = Mono_Posix_Error_ERESTART; return 0;}
+#endif /* ndef ERESTART */
+#ifdef ESTRPIPE
+       if (x == ESTRPIPE)
+               {*r = Mono_Posix_Error_ESTRPIPE; return 0;}
+#endif /* ndef ESTRPIPE */
+#ifdef EUSERS
+       if (x == EUSERS)
+               {*r = Mono_Posix_Error_EUSERS; return 0;}
+#endif /* ndef EUSERS */
+#ifdef ENOTSOCK
+       if (x == ENOTSOCK)
+               {*r = Mono_Posix_Error_ENOTSOCK; return 0;}
+#endif /* ndef ENOTSOCK */
+#ifdef EDESTADDRREQ
+       if (x == EDESTADDRREQ)
+               {*r = Mono_Posix_Error_EDESTADDRREQ; return 0;}
+#endif /* ndef EDESTADDRREQ */
+#ifdef EMSGSIZE
+       if (x == EMSGSIZE)
+               {*r = Mono_Posix_Error_EMSGSIZE; return 0;}
+#endif /* ndef EMSGSIZE */
+#ifdef EPROTOTYPE
+       if (x == EPROTOTYPE)
+               {*r = Mono_Posix_Error_EPROTOTYPE; return 0;}
+#endif /* ndef EPROTOTYPE */
+#ifdef ENOPROTOOPT
+       if (x == ENOPROTOOPT)
+               {*r = Mono_Posix_Error_ENOPROTOOPT; return 0;}
+#endif /* ndef ENOPROTOOPT */
+#ifdef EPROTONOSUPPORT
+       if (x == EPROTONOSUPPORT)
+               {*r = Mono_Posix_Error_EPROTONOSUPPORT; return 0;}
+#endif /* ndef EPROTONOSUPPORT */
+#ifdef ESOCKTNOSUPPORT
+       if (x == ESOCKTNOSUPPORT)
+               {*r = Mono_Posix_Error_ESOCKTNOSUPPORT; return 0;}
+#endif /* ndef ESOCKTNOSUPPORT */
+#ifdef EOPNOTSUPP
+       if (x == EOPNOTSUPP)
+               {*r = Mono_Posix_Error_EOPNOTSUPP; return 0;}
+#endif /* ndef EOPNOTSUPP */
+#ifdef EPFNOSUPPORT
+       if (x == EPFNOSUPPORT)
+               {*r = Mono_Posix_Error_EPFNOSUPPORT; return 0;}
+#endif /* ndef EPFNOSUPPORT */
+#ifdef EAFNOSUPPORT
+       if (x == EAFNOSUPPORT)
+               {*r = Mono_Posix_Error_EAFNOSUPPORT; return 0;}
+#endif /* ndef EAFNOSUPPORT */
+#ifdef EADDRINUSE
+       if (x == EADDRINUSE)
+               {*r = Mono_Posix_Error_EADDRINUSE; return 0;}
+#endif /* ndef EADDRINUSE */
+#ifdef EADDRNOTAVAIL
+       if (x == EADDRNOTAVAIL)
+               {*r = Mono_Posix_Error_EADDRNOTAVAIL; return 0;}
+#endif /* ndef EADDRNOTAVAIL */
+#ifdef ENETDOWN
+       if (x == ENETDOWN)
+               {*r = Mono_Posix_Error_ENETDOWN; return 0;}
+#endif /* ndef ENETDOWN */
+#ifdef ENETUNREACH
+       if (x == ENETUNREACH)
+               {*r = Mono_Posix_Error_ENETUNREACH; return 0;}
+#endif /* ndef ENETUNREACH */
+#ifdef ENETRESET
+       if (x == ENETRESET)
+               {*r = Mono_Posix_Error_ENETRESET; return 0;}
+#endif /* ndef ENETRESET */
+#ifdef ECONNABORTED
+       if (x == ECONNABORTED)
+               {*r = Mono_Posix_Error_ECONNABORTED; return 0;}
+#endif /* ndef ECONNABORTED */
+#ifdef ECONNRESET
+       if (x == ECONNRESET)
+               {*r = Mono_Posix_Error_ECONNRESET; return 0;}
+#endif /* ndef ECONNRESET */
+#ifdef ENOBUFS
+       if (x == ENOBUFS)
+               {*r = Mono_Posix_Error_ENOBUFS; return 0;}
+#endif /* ndef ENOBUFS */
+#ifdef EISCONN
+       if (x == EISCONN)
+               {*r = Mono_Posix_Error_EISCONN; return 0;}
+#endif /* ndef EISCONN */
+#ifdef ENOTCONN
+       if (x == ENOTCONN)
+               {*r = Mono_Posix_Error_ENOTCONN; return 0;}
+#endif /* ndef ENOTCONN */
+#ifdef ESHUTDOWN
+       if (x == ESHUTDOWN)
+               {*r = Mono_Posix_Error_ESHUTDOWN; return 0;}
+#endif /* ndef ESHUTDOWN */
+#ifdef ETOOMANYREFS
+       if (x == ETOOMANYREFS)
+               {*r = Mono_Posix_Error_ETOOMANYREFS; return 0;}
+#endif /* ndef ETOOMANYREFS */
+#ifdef ETIMEDOUT
+       if (x == ETIMEDOUT)
+               {*r = Mono_Posix_Error_ETIMEDOUT; return 0;}
+#endif /* ndef ETIMEDOUT */
+#ifdef ECONNREFUSED
+       if (x == ECONNREFUSED)
+               {*r = Mono_Posix_Error_ECONNREFUSED; return 0;}
+#endif /* ndef ECONNREFUSED */
+#ifdef EHOSTDOWN
+       if (x == EHOSTDOWN)
+               {*r = Mono_Posix_Error_EHOSTDOWN; return 0;}
+#endif /* ndef EHOSTDOWN */
+#ifdef EHOSTUNREACH
+       if (x == EHOSTUNREACH)
+               {*r = Mono_Posix_Error_EHOSTUNREACH; return 0;}
+#endif /* ndef EHOSTUNREACH */
+#ifdef EALREADY
+       if (x == EALREADY)
+               {*r = Mono_Posix_Error_EALREADY; return 0;}
+#endif /* ndef EALREADY */
+#ifdef EINPROGRESS
+       if (x == EINPROGRESS)
+               {*r = Mono_Posix_Error_EINPROGRESS; return 0;}
+#endif /* ndef EINPROGRESS */
+#ifdef ESTALE
+       if (x == ESTALE)
+               {*r = Mono_Posix_Error_ESTALE; return 0;}
+#endif /* ndef ESTALE */
+#ifdef EUCLEAN
+       if (x == EUCLEAN)
+               {*r = Mono_Posix_Error_EUCLEAN; return 0;}
+#endif /* ndef EUCLEAN */
+#ifdef ENOTNAM
+       if (x == ENOTNAM)
+               {*r = Mono_Posix_Error_ENOTNAM; return 0;}
+#endif /* ndef ENOTNAM */
+#ifdef ENAVAIL
+       if (x == ENAVAIL)
+               {*r = Mono_Posix_Error_ENAVAIL; return 0;}
+#endif /* ndef ENAVAIL */
+#ifdef EISNAM
+       if (x == EISNAM)
+               {*r = Mono_Posix_Error_EISNAM; return 0;}
+#endif /* ndef EISNAM */
+#ifdef EREMOTEIO
+       if (x == EREMOTEIO)
+               {*r = Mono_Posix_Error_EREMOTEIO; return 0;}
+#endif /* ndef EREMOTEIO */
+#ifdef EDQUOT
+       if (x == EDQUOT)
+               {*r = Mono_Posix_Error_EDQUOT; return 0;}
+#endif /* ndef EDQUOT */
+#ifdef ENOMEDIUM
+       if (x == ENOMEDIUM)
+               {*r = Mono_Posix_Error_ENOMEDIUM; return 0;}
+#endif /* ndef ENOMEDIUM */
+#ifdef EMEDIUMTYPE
+       if (x == EMEDIUMTYPE)
+               {*r = Mono_Posix_Error_EMEDIUMTYPE; return 0;}
+#endif /* ndef EMEDIUMTYPE */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromOpenFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_OpenFlags_O_RDONLY) == Mono_Posix_OpenFlags_O_RDONLY)
+#ifdef O_RDONLY
+               *r |= O_RDONLY;
+#else /* def O_RDONLY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_RDONLY */
+       if ((x & Mono_Posix_OpenFlags_O_WRONLY) == Mono_Posix_OpenFlags_O_WRONLY)
+#ifdef O_WRONLY
+               *r |= O_WRONLY;
+#else /* def O_WRONLY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_WRONLY */
+       if ((x & Mono_Posix_OpenFlags_O_RDWR) == Mono_Posix_OpenFlags_O_RDWR)
+#ifdef O_RDWR
+               *r |= O_RDWR;
+#else /* def O_RDWR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_RDWR */
+       if ((x & Mono_Posix_OpenFlags_O_CREAT) == Mono_Posix_OpenFlags_O_CREAT)
+#ifdef O_CREAT
+               *r |= O_CREAT;
+#else /* def O_CREAT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_CREAT */
+       if ((x & Mono_Posix_OpenFlags_O_EXCL) == Mono_Posix_OpenFlags_O_EXCL)
+#ifdef O_EXCL
+               *r |= O_EXCL;
+#else /* def O_EXCL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_EXCL */
+       if ((x & Mono_Posix_OpenFlags_O_NOCTTY) == Mono_Posix_OpenFlags_O_NOCTTY)
+#ifdef O_NOCTTY
+               *r |= O_NOCTTY;
+#else /* def O_NOCTTY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_NOCTTY */
+       if ((x & Mono_Posix_OpenFlags_O_TRUNC) == Mono_Posix_OpenFlags_O_TRUNC)
+#ifdef O_TRUNC
+               *r |= O_TRUNC;
+#else /* def O_TRUNC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_TRUNC */
+       if ((x & Mono_Posix_OpenFlags_O_APPEND) == Mono_Posix_OpenFlags_O_APPEND)
+#ifdef O_APPEND
+               *r |= O_APPEND;
+#else /* def O_APPEND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_APPEND */
+       if ((x & Mono_Posix_OpenFlags_O_NONBLOCK) == Mono_Posix_OpenFlags_O_NONBLOCK)
+#ifdef O_NONBLOCK
+               *r |= O_NONBLOCK;
+#else /* def O_NONBLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_NONBLOCK */
+       if ((x & Mono_Posix_OpenFlags_O_SYNC) == Mono_Posix_OpenFlags_O_SYNC)
+#ifdef O_SYNC
+               *r |= O_SYNC;
+#else /* def O_SYNC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_SYNC */
+       if ((x & Mono_Posix_OpenFlags_O_NOFOLLOW) == Mono_Posix_OpenFlags_O_NOFOLLOW)
+#ifdef O_NOFOLLOW
+               *r |= O_NOFOLLOW;
+#else /* def O_NOFOLLOW */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_NOFOLLOW */
+       if ((x & Mono_Posix_OpenFlags_O_DIRECTORY) == Mono_Posix_OpenFlags_O_DIRECTORY)
+#ifdef O_DIRECTORY
+               *r |= O_DIRECTORY;
+#else /* def O_DIRECTORY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_DIRECTORY */
+       if ((x & Mono_Posix_OpenFlags_O_DIRECT) == Mono_Posix_OpenFlags_O_DIRECT)
+#ifdef O_DIRECT
+               *r |= O_DIRECT;
+#else /* def O_DIRECT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_DIRECT */
+       if ((x & Mono_Posix_OpenFlags_O_ASYNC) == Mono_Posix_OpenFlags_O_ASYNC)
+#ifdef O_ASYNC
+               *r |= O_ASYNC;
+#else /* def O_ASYNC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_ASYNC */
+       if ((x & Mono_Posix_OpenFlags_O_LARGEFILE) == Mono_Posix_OpenFlags_O_LARGEFILE)
+#ifdef O_LARGEFILE
+               *r |= O_LARGEFILE;
+#else /* def O_LARGEFILE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_LARGEFILE */
+       return 0;
+}
+
+int Mono_Posix_ToOpenFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef O_RDONLY
+       if ((x & O_RDONLY) == O_RDONLY)
+               *r |= Mono_Posix_OpenFlags_O_RDONLY;
+#endif /* ndef O_RDONLY */
+#ifdef O_WRONLY
+       if ((x & O_WRONLY) == O_WRONLY)
+               *r |= Mono_Posix_OpenFlags_O_WRONLY;
+#endif /* ndef O_WRONLY */
+#ifdef O_RDWR
+       if ((x & O_RDWR) == O_RDWR)
+               *r |= Mono_Posix_OpenFlags_O_RDWR;
+#endif /* ndef O_RDWR */
+#ifdef O_CREAT
+       if ((x & O_CREAT) == O_CREAT)
+               *r |= Mono_Posix_OpenFlags_O_CREAT;
+#endif /* ndef O_CREAT */
+#ifdef O_EXCL
+       if ((x & O_EXCL) == O_EXCL)
+               *r |= Mono_Posix_OpenFlags_O_EXCL;
+#endif /* ndef O_EXCL */
+#ifdef O_NOCTTY
+       if ((x & O_NOCTTY) == O_NOCTTY)
+               *r |= Mono_Posix_OpenFlags_O_NOCTTY;
+#endif /* ndef O_NOCTTY */
+#ifdef O_TRUNC
+       if ((x & O_TRUNC) == O_TRUNC)
+               *r |= Mono_Posix_OpenFlags_O_TRUNC;
+#endif /* ndef O_TRUNC */
+#ifdef O_APPEND
+       if ((x & O_APPEND) == O_APPEND)
+               *r |= Mono_Posix_OpenFlags_O_APPEND;
+#endif /* ndef O_APPEND */
+#ifdef O_NONBLOCK
+       if ((x & O_NONBLOCK) == O_NONBLOCK)
+               *r |= Mono_Posix_OpenFlags_O_NONBLOCK;
+#endif /* ndef O_NONBLOCK */
 #ifdef O_SYNC
-       if ((x & Mono_Posix_OpenFlags_O_SYNC) != 0)
-               r |= O_SYNC;
-#endif
-       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_SIGSYS)
-                return SIGSYS;
-       return -1;
-}
-
-int map_Mono_Posix_PollEvents (int x)
-{
-       int r = 0;
-       if ((x & Mono_Posix_PollEvents_POLLIN) != 0)
-               r |= POLLIN;
-       if ((x & Mono_Posix_PollEvents_POLLPRI) != 0)
-               r |= POLLPRI;
-       if ((x & Mono_Posix_PollEvents_POLLOUT) != 0)
-               r |= POLLOUT;
-       if ((x & Mono_Posix_PollEvents_POLLERR) != 0)
-               r |= POLLERR;
-       if ((x & Mono_Posix_PollEvents_POLLHUP) != 0)
-               r |= POLLHUP;
-       if ((x & Mono_Posix_PollEvents_POLLNVAL) != 0)
-               r |= POLLNVAL;
-       return r;
+       if ((x & O_SYNC) == O_SYNC)
+               *r |= Mono_Posix_OpenFlags_O_SYNC;
+#endif /* ndef O_SYNC */
+#ifdef O_NOFOLLOW
+       if ((x & O_NOFOLLOW) == O_NOFOLLOW)
+               *r |= Mono_Posix_OpenFlags_O_NOFOLLOW;
+#endif /* ndef O_NOFOLLOW */
+#ifdef O_DIRECTORY
+       if ((x & O_DIRECTORY) == O_DIRECTORY)
+               *r |= Mono_Posix_OpenFlags_O_DIRECTORY;
+#endif /* ndef O_DIRECTORY */
+#ifdef O_DIRECT
+       if ((x & O_DIRECT) == O_DIRECT)
+               *r |= Mono_Posix_OpenFlags_O_DIRECT;
+#endif /* ndef O_DIRECT */
+#ifdef O_ASYNC
+       if ((x & O_ASYNC) == O_ASYNC)
+               *r |= Mono_Posix_OpenFlags_O_ASYNC;
+#endif /* ndef O_ASYNC */
+#ifdef O_LARGEFILE
+       if ((x & O_LARGEFILE) == O_LARGEFILE)
+               *r |= Mono_Posix_OpenFlags_O_LARGEFILE;
+#endif /* ndef O_LARGEFILE */
+       return 0;
+}
+
+int Mono_Posix_FromFilePermissions (unsigned int x, unsigned int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_FilePermissions_S_ISUID) == Mono_Posix_FilePermissions_S_ISUID)
+#ifdef S_ISUID
+               *r |= S_ISUID;
+#else /* def S_ISUID */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_ISUID */
+       if ((x & Mono_Posix_FilePermissions_S_ISGID) == Mono_Posix_FilePermissions_S_ISGID)
+#ifdef S_ISGID
+               *r |= S_ISGID;
+#else /* def S_ISGID */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_ISGID */
+       if ((x & Mono_Posix_FilePermissions_S_ISVTX) == Mono_Posix_FilePermissions_S_ISVTX)
+#ifdef S_ISVTX
+               *r |= S_ISVTX;
+#else /* def S_ISVTX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_ISVTX */
+       if ((x & Mono_Posix_FilePermissions_S_IRUSR) == Mono_Posix_FilePermissions_S_IRUSR)
+#ifdef S_IRUSR
+               *r |= S_IRUSR;
+#else /* def S_IRUSR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IRUSR */
+       if ((x & Mono_Posix_FilePermissions_S_IWUSR) == Mono_Posix_FilePermissions_S_IWUSR)
+#ifdef S_IWUSR
+               *r |= S_IWUSR;
+#else /* def S_IWUSR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IWUSR */
+       if ((x & Mono_Posix_FilePermissions_S_IXUSR) == Mono_Posix_FilePermissions_S_IXUSR)
+#ifdef S_IXUSR
+               *r |= S_IXUSR;
+#else /* def S_IXUSR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IXUSR */
+       if ((x & Mono_Posix_FilePermissions_S_IRGRP) == Mono_Posix_FilePermissions_S_IRGRP)
+#ifdef S_IRGRP
+               *r |= S_IRGRP;
+#else /* def S_IRGRP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IRGRP */
+       if ((x & Mono_Posix_FilePermissions_S_IWGRP) == Mono_Posix_FilePermissions_S_IWGRP)
+#ifdef S_IWGRP
+               *r |= S_IWGRP;
+#else /* def S_IWGRP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IWGRP */
+       if ((x & Mono_Posix_FilePermissions_S_IXGRP) == Mono_Posix_FilePermissions_S_IXGRP)
+#ifdef S_IXGRP
+               *r |= S_IXGRP;
+#else /* def S_IXGRP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IXGRP */
+       if ((x & Mono_Posix_FilePermissions_S_IROTH) == Mono_Posix_FilePermissions_S_IROTH)
+#ifdef S_IROTH
+               *r |= S_IROTH;
+#else /* def S_IROTH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IROTH */
+       if ((x & Mono_Posix_FilePermissions_S_IWOTH) == Mono_Posix_FilePermissions_S_IWOTH)
+#ifdef S_IWOTH
+               *r |= S_IWOTH;
+#else /* def S_IWOTH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IWOTH */
+       if ((x & Mono_Posix_FilePermissions_S_IXOTH) == Mono_Posix_FilePermissions_S_IXOTH)
+#ifdef S_IXOTH
+               *r |= S_IXOTH;
+#else /* def S_IXOTH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IXOTH */
+       if ((x & Mono_Posix_FilePermissions_S_IRWXG) == Mono_Posix_FilePermissions_S_IRWXG)
+#ifdef S_IRWXG
+               *r |= S_IRWXG;
+#else /* def S_IRWXG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IRWXG */
+       if ((x & Mono_Posix_FilePermissions_S_IRWXU) == Mono_Posix_FilePermissions_S_IRWXU)
+#ifdef S_IRWXU
+               *r |= S_IRWXU;
+#else /* def S_IRWXU */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IRWXU */
+       if ((x & Mono_Posix_FilePermissions_S_IRWXO) == Mono_Posix_FilePermissions_S_IRWXO)
+#ifdef S_IRWXO
+               *r |= S_IRWXO;
+#else /* def S_IRWXO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IRWXO */
+       if ((x & Mono_Posix_FilePermissions_ACCESSPERMS) == Mono_Posix_FilePermissions_ACCESSPERMS)
+#ifdef ACCESSPERMS
+               *r |= ACCESSPERMS;
+#else /* def ACCESSPERMS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ACCESSPERMS */
+       if ((x & Mono_Posix_FilePermissions_ALLPERMS) == Mono_Posix_FilePermissions_ALLPERMS)
+#ifdef ALLPERMS
+               *r |= ALLPERMS;
+#else /* def ALLPERMS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ALLPERMS */
+       if ((x & Mono_Posix_FilePermissions_DEFFILEMODE) == Mono_Posix_FilePermissions_DEFFILEMODE)
+#ifdef DEFFILEMODE
+               *r |= DEFFILEMODE;
+#else /* def DEFFILEMODE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef DEFFILEMODE */
+       if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFMT)
+#ifdef S_IFMT
+               *r |= S_IFMT;
+#else /* def S_IFMT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IFMT */
+       if ((x & Mono_Posix_FilePermissions_S_IFDIR) == Mono_Posix_FilePermissions_S_IFDIR)
+#ifdef S_IFDIR
+               *r |= S_IFDIR;
+#else /* def S_IFDIR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IFDIR */
+       if ((x & Mono_Posix_FilePermissions_S_IFCHR) == Mono_Posix_FilePermissions_S_IFCHR)
+#ifdef S_IFCHR
+               *r |= S_IFCHR;
+#else /* def S_IFCHR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IFCHR */
+       if ((x & Mono_Posix_FilePermissions_S_IFBLK) == Mono_Posix_FilePermissions_S_IFBLK)
+#ifdef S_IFBLK
+               *r |= S_IFBLK;
+#else /* def S_IFBLK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IFBLK */
+       if ((x & Mono_Posix_FilePermissions_S_IFREG) == Mono_Posix_FilePermissions_S_IFREG)
+#ifdef S_IFREG
+               *r |= S_IFREG;
+#else /* def S_IFREG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IFREG */
+       if ((x & Mono_Posix_FilePermissions_S_IFIFO) == Mono_Posix_FilePermissions_S_IFIFO)
+#ifdef S_IFIFO
+               *r |= S_IFIFO;
+#else /* def S_IFIFO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IFIFO */
+       if ((x & Mono_Posix_FilePermissions_S_IFLNK) == Mono_Posix_FilePermissions_S_IFLNK)
+#ifdef S_IFLNK
+               *r |= S_IFLNK;
+#else /* def S_IFLNK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IFLNK */
+       if ((x & Mono_Posix_FilePermissions_S_IFSOCK) == Mono_Posix_FilePermissions_S_IFSOCK)
+#ifdef S_IFSOCK
+               *r |= S_IFSOCK;
+#else /* def S_IFSOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IFSOCK */
+       return 0;
+}
+
+int Mono_Posix_ToFilePermissions (unsigned int x, unsigned int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef S_ISUID
+       if ((x & S_ISUID) == S_ISUID)
+               *r |= Mono_Posix_FilePermissions_S_ISUID;
+#endif /* ndef S_ISUID */
+#ifdef S_ISGID
+       if ((x & S_ISGID) == S_ISGID)
+               *r |= Mono_Posix_FilePermissions_S_ISGID;
+#endif /* ndef S_ISGID */
+#ifdef S_ISVTX
+       if ((x & S_ISVTX) == S_ISVTX)
+               *r |= Mono_Posix_FilePermissions_S_ISVTX;
+#endif /* ndef S_ISVTX */
+#ifdef S_IRUSR
+       if ((x & S_IRUSR) == S_IRUSR)
+               *r |= Mono_Posix_FilePermissions_S_IRUSR;
+#endif /* ndef S_IRUSR */
+#ifdef S_IWUSR
+       if ((x & S_IWUSR) == S_IWUSR)
+               *r |= Mono_Posix_FilePermissions_S_IWUSR;
+#endif /* ndef S_IWUSR */
+#ifdef S_IXUSR
+       if ((x & S_IXUSR) == S_IXUSR)
+               *r |= Mono_Posix_FilePermissions_S_IXUSR;
+#endif /* ndef S_IXUSR */
+#ifdef S_IRGRP
+       if ((x & S_IRGRP) == S_IRGRP)
+               *r |= Mono_Posix_FilePermissions_S_IRGRP;
+#endif /* ndef S_IRGRP */
+#ifdef S_IWGRP
+       if ((x & S_IWGRP) == S_IWGRP)
+               *r |= Mono_Posix_FilePermissions_S_IWGRP;
+#endif /* ndef S_IWGRP */
+#ifdef S_IXGRP
+       if ((x & S_IXGRP) == S_IXGRP)
+               *r |= Mono_Posix_FilePermissions_S_IXGRP;
+#endif /* ndef S_IXGRP */
+#ifdef S_IROTH
+       if ((x & S_IROTH) == S_IROTH)
+               *r |= Mono_Posix_FilePermissions_S_IROTH;
+#endif /* ndef S_IROTH */
+#ifdef S_IWOTH
+       if ((x & S_IWOTH) == S_IWOTH)
+               *r |= Mono_Posix_FilePermissions_S_IWOTH;
+#endif /* ndef S_IWOTH */
+#ifdef S_IXOTH
+       if ((x & S_IXOTH) == S_IXOTH)
+               *r |= Mono_Posix_FilePermissions_S_IXOTH;
+#endif /* ndef S_IXOTH */
+#ifdef S_IRWXG
+       if ((x & S_IRWXG) == S_IRWXG)
+               *r |= Mono_Posix_FilePermissions_S_IRWXG;
+#endif /* ndef S_IRWXG */
+#ifdef S_IRWXU
+       if ((x & S_IRWXU) == S_IRWXU)
+               *r |= Mono_Posix_FilePermissions_S_IRWXU;
+#endif /* ndef S_IRWXU */
+#ifdef S_IRWXO
+       if ((x & S_IRWXO) == S_IRWXO)
+               *r |= Mono_Posix_FilePermissions_S_IRWXO;
+#endif /* ndef S_IRWXO */
+#ifdef ACCESSPERMS
+       if ((x & ACCESSPERMS) == ACCESSPERMS)
+               *r |= Mono_Posix_FilePermissions_ACCESSPERMS;
+#endif /* ndef ACCESSPERMS */
+#ifdef ALLPERMS
+       if ((x & ALLPERMS) == ALLPERMS)
+               *r |= Mono_Posix_FilePermissions_ALLPERMS;
+#endif /* ndef ALLPERMS */
+#ifdef DEFFILEMODE
+       if ((x & DEFFILEMODE) == DEFFILEMODE)
+               *r |= Mono_Posix_FilePermissions_DEFFILEMODE;
+#endif /* ndef DEFFILEMODE */
+#ifdef S_IFMT
+       if ((x & S_IFMT) == S_IFMT)
+               *r |= Mono_Posix_FilePermissions_S_IFMT;
+#endif /* ndef S_IFMT */
+#ifdef S_IFDIR
+       if ((x & S_IFDIR) == S_IFDIR)
+               *r |= Mono_Posix_FilePermissions_S_IFDIR;
+#endif /* ndef S_IFDIR */
+#ifdef S_IFCHR
+       if ((x & S_IFCHR) == S_IFCHR)
+               *r |= Mono_Posix_FilePermissions_S_IFCHR;
+#endif /* ndef S_IFCHR */
+#ifdef S_IFBLK
+       if ((x & S_IFBLK) == S_IFBLK)
+               *r |= Mono_Posix_FilePermissions_S_IFBLK;
+#endif /* ndef S_IFBLK */
+#ifdef S_IFREG
+       if ((x & S_IFREG) == S_IFREG)
+               *r |= Mono_Posix_FilePermissions_S_IFREG;
+#endif /* ndef S_IFREG */
+#ifdef S_IFIFO
+       if ((x & S_IFIFO) == S_IFIFO)
+               *r |= Mono_Posix_FilePermissions_S_IFIFO;
+#endif /* ndef S_IFIFO */
+#ifdef S_IFLNK
+       if ((x & S_IFLNK) == S_IFLNK)
+               *r |= Mono_Posix_FilePermissions_S_IFLNK;
+#endif /* ndef S_IFLNK */
+#ifdef S_IFSOCK
+       if ((x & S_IFSOCK) == S_IFSOCK)
+               *r |= Mono_Posix_FilePermissions_S_IFSOCK;
+#endif /* ndef S_IFSOCK */
+       return 0;
+}
+
+int Mono_Posix_FromFcntlCommand (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_FcntlCommand_F_DUPFD)
+#ifdef F_DUPFD
+               {*r = F_DUPFD; return 0;}
+#else /* def F_DUPFD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_DUPFD */
+       if (x == Mono_Posix_FcntlCommand_F_GETFD)
+#ifdef F_GETFD
+               {*r = F_GETFD; return 0;}
+#else /* def F_GETFD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_GETFD */
+       if (x == Mono_Posix_FcntlCommand_F_SETFD)
+#ifdef F_SETFD
+               {*r = F_SETFD; return 0;}
+#else /* def F_SETFD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_SETFD */
+       if (x == Mono_Posix_FcntlCommand_F_GETFL)
+#ifdef F_GETFL
+               {*r = F_GETFL; return 0;}
+#else /* def F_GETFL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_GETFL */
+       if (x == Mono_Posix_FcntlCommand_F_SETFL)
+#ifdef F_SETFL
+               {*r = F_SETFL; return 0;}
+#else /* def F_SETFL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_SETFL */
+       if (x == Mono_Posix_FcntlCommand_F_GETLK)
+#ifdef F_GETLK
+               {*r = F_GETLK; return 0;}
+#else /* def F_GETLK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_GETLK */
+       if (x == Mono_Posix_FcntlCommand_F_SETLK)
+#ifdef F_SETLK
+               {*r = F_SETLK; return 0;}
+#else /* def F_SETLK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_SETLK */
+       if (x == Mono_Posix_FcntlCommand_F_SETLKW)
+#ifdef F_SETLKW
+               {*r = F_SETLKW; return 0;}
+#else /* def F_SETLKW */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_SETLKW */
+       if (x == Mono_Posix_FcntlCommand_F_SETOWN)
+#ifdef F_SETOWN
+               {*r = F_SETOWN; return 0;}
+#else /* def F_SETOWN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_SETOWN */
+       if (x == Mono_Posix_FcntlCommand_F_GETOWN)
+#ifdef F_GETOWN
+               {*r = F_GETOWN; return 0;}
+#else /* def F_GETOWN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_GETOWN */
+       if (x == Mono_Posix_FcntlCommand_F_SETSIG)
+#ifdef F_SETSIG
+               {*r = F_SETSIG; return 0;}
+#else /* def F_SETSIG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_SETSIG */
+       if (x == Mono_Posix_FcntlCommand_F_GETSIG)
+#ifdef F_GETSIG
+               {*r = F_GETSIG; return 0;}
+#else /* def F_GETSIG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_GETSIG */
+       if (x == Mono_Posix_FcntlCommand_F_SETLEASE)
+#ifdef F_SETLEASE
+               {*r = F_SETLEASE; return 0;}
+#else /* def F_SETLEASE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_SETLEASE */
+       if (x == Mono_Posix_FcntlCommand_F_GETLEASE)
+#ifdef F_GETLEASE
+               {*r = F_GETLEASE; return 0;}
+#else /* def F_GETLEASE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_GETLEASE */
+       if (x == Mono_Posix_FcntlCommand_F_NOTIFY)
+#ifdef F_NOTIFY
+               {*r = F_NOTIFY; return 0;}
+#else /* def F_NOTIFY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_NOTIFY */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToFcntlCommand (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef F_DUPFD
+       if (x == F_DUPFD)
+               {*r = Mono_Posix_FcntlCommand_F_DUPFD; return 0;}
+#endif /* ndef F_DUPFD */
+#ifdef F_GETFD
+       if (x == F_GETFD)
+               {*r = Mono_Posix_FcntlCommand_F_GETFD; return 0;}
+#endif /* ndef F_GETFD */
+#ifdef F_SETFD
+       if (x == F_SETFD)
+               {*r = Mono_Posix_FcntlCommand_F_SETFD; return 0;}
+#endif /* ndef F_SETFD */
+#ifdef F_GETFL
+       if (x == F_GETFL)
+               {*r = Mono_Posix_FcntlCommand_F_GETFL; return 0;}
+#endif /* ndef F_GETFL */
+#ifdef F_SETFL
+       if (x == F_SETFL)
+               {*r = Mono_Posix_FcntlCommand_F_SETFL; return 0;}
+#endif /* ndef F_SETFL */
+#ifdef F_GETLK
+       if (x == F_GETLK)
+               {*r = Mono_Posix_FcntlCommand_F_GETLK; return 0;}
+#endif /* ndef F_GETLK */
+#ifdef F_SETLK
+       if (x == F_SETLK)
+               {*r = Mono_Posix_FcntlCommand_F_SETLK; return 0;}
+#endif /* ndef F_SETLK */
+#ifdef F_SETLKW
+       if (x == F_SETLKW)
+               {*r = Mono_Posix_FcntlCommand_F_SETLKW; return 0;}
+#endif /* ndef F_SETLKW */
+#ifdef F_SETOWN
+       if (x == F_SETOWN)
+               {*r = Mono_Posix_FcntlCommand_F_SETOWN; return 0;}
+#endif /* ndef F_SETOWN */
+#ifdef F_GETOWN
+       if (x == F_GETOWN)
+               {*r = Mono_Posix_FcntlCommand_F_GETOWN; return 0;}
+#endif /* ndef F_GETOWN */
+#ifdef F_SETSIG
+       if (x == F_SETSIG)
+               {*r = Mono_Posix_FcntlCommand_F_SETSIG; return 0;}
+#endif /* ndef F_SETSIG */
+#ifdef F_GETSIG
+       if (x == F_GETSIG)
+               {*r = Mono_Posix_FcntlCommand_F_GETSIG; return 0;}
+#endif /* ndef F_GETSIG */
+#ifdef F_SETLEASE
+       if (x == F_SETLEASE)
+               {*r = Mono_Posix_FcntlCommand_F_SETLEASE; return 0;}
+#endif /* ndef F_SETLEASE */
+#ifdef F_GETLEASE
+       if (x == F_GETLEASE)
+               {*r = Mono_Posix_FcntlCommand_F_GETLEASE; return 0;}
+#endif /* ndef F_GETLEASE */
+#ifdef F_NOTIFY
+       if (x == F_NOTIFY)
+               {*r = Mono_Posix_FcntlCommand_F_NOTIFY; return 0;}
+#endif /* ndef F_NOTIFY */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromLockType (short x, short *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_LockType_F_RDLCK)
+#ifdef F_RDLCK
+               {*r = F_RDLCK; return 0;}
+#else /* def F_RDLCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_RDLCK */
+       if (x == Mono_Posix_LockType_F_WRLCK)
+#ifdef F_WRLCK
+               {*r = F_WRLCK; return 0;}
+#else /* def F_WRLCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_WRLCK */
+       if (x == Mono_Posix_LockType_F_UNLCK)
+#ifdef F_UNLCK
+               {*r = F_UNLCK; return 0;}
+#else /* def F_UNLCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_UNLCK */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToLockType (short x, short *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef F_RDLCK
+       if (x == F_RDLCK)
+               {*r = Mono_Posix_LockType_F_RDLCK; return 0;}
+#endif /* ndef F_RDLCK */
+#ifdef F_WRLCK
+       if (x == F_WRLCK)
+               {*r = Mono_Posix_LockType_F_WRLCK; return 0;}
+#endif /* ndef F_WRLCK */
+#ifdef F_UNLCK
+       if (x == F_UNLCK)
+               {*r = Mono_Posix_LockType_F_UNLCK; return 0;}
+#endif /* ndef F_UNLCK */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromSeekFlags (short x, short *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_SeekFlags_SEEK_SET)
+#ifdef SEEK_SET
+               {*r = SEEK_SET; return 0;}
+#else /* def SEEK_SET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SEEK_SET */
+       if (x == Mono_Posix_SeekFlags_SEEK_CUR)
+#ifdef SEEK_CUR
+               {*r = SEEK_CUR; return 0;}
+#else /* def SEEK_CUR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SEEK_CUR */
+       if (x == Mono_Posix_SeekFlags_SEEK_END)
+#ifdef SEEK_END
+               {*r = SEEK_END; return 0;}
+#else /* def SEEK_END */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SEEK_END */
+       if (x == Mono_Posix_SeekFlags_L_SET)
+#ifdef L_SET
+               {*r = L_SET; return 0;}
+#else /* def L_SET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef L_SET */
+       if (x == Mono_Posix_SeekFlags_L_INCR)
+#ifdef L_INCR
+               {*r = L_INCR; return 0;}
+#else /* def L_INCR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef L_INCR */
+       if (x == Mono_Posix_SeekFlags_L_XTND)
+#ifdef L_XTND
+               {*r = L_XTND; return 0;}
+#else /* def L_XTND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef L_XTND */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToSeekFlags (short x, short *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef SEEK_SET
+       if (x == SEEK_SET)
+               {*r = Mono_Posix_SeekFlags_SEEK_SET; return 0;}
+#endif /* ndef SEEK_SET */
+#ifdef SEEK_CUR
+       if (x == SEEK_CUR)
+               {*r = Mono_Posix_SeekFlags_SEEK_CUR; return 0;}
+#endif /* ndef SEEK_CUR */
+#ifdef SEEK_END
+       if (x == SEEK_END)
+               {*r = Mono_Posix_SeekFlags_SEEK_END; return 0;}
+#endif /* ndef SEEK_END */
+#ifdef L_SET
+       if (x == L_SET)
+               {*r = Mono_Posix_SeekFlags_L_SET; return 0;}
+#endif /* ndef L_SET */
+#ifdef L_INCR
+       if (x == L_INCR)
+               {*r = Mono_Posix_SeekFlags_L_INCR; return 0;}
+#endif /* ndef L_INCR */
+#ifdef L_XTND
+       if (x == L_XTND)
+               {*r = Mono_Posix_SeekFlags_L_XTND; return 0;}
+#endif /* ndef L_XTND */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromDirectoryNotifyFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_DirectoryNotifyFlags_DN_ACCESS) == Mono_Posix_DirectoryNotifyFlags_DN_ACCESS)
+#ifdef DN_ACCESS
+               *r |= DN_ACCESS;
+#else /* def DN_ACCESS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef DN_ACCESS */
+       if ((x & Mono_Posix_DirectoryNotifyFlags_DN_MODIFY) == Mono_Posix_DirectoryNotifyFlags_DN_MODIFY)
+#ifdef DN_MODIFY
+               *r |= DN_MODIFY;
+#else /* def DN_MODIFY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef DN_MODIFY */
+       if ((x & Mono_Posix_DirectoryNotifyFlags_DN_CREATE) == Mono_Posix_DirectoryNotifyFlags_DN_CREATE)
+#ifdef DN_CREATE
+               *r |= DN_CREATE;
+#else /* def DN_CREATE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef DN_CREATE */
+       if ((x & Mono_Posix_DirectoryNotifyFlags_DN_DELETE) == Mono_Posix_DirectoryNotifyFlags_DN_DELETE)
+#ifdef DN_DELETE
+               *r |= DN_DELETE;
+#else /* def DN_DELETE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef DN_DELETE */
+       if ((x & Mono_Posix_DirectoryNotifyFlags_DN_RENAME) == Mono_Posix_DirectoryNotifyFlags_DN_RENAME)
+#ifdef DN_RENAME
+               *r |= DN_RENAME;
+#else /* def DN_RENAME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef DN_RENAME */
+       if ((x & Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB) == Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB)
+#ifdef DN_ATTRIB
+               *r |= DN_ATTRIB;
+#else /* def DN_ATTRIB */
+               {errno = EINVAL; return -1;}
+#endif /* ndef DN_ATTRIB */
+       if ((x & Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT) == Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT)
+#ifdef DN_MULTISHOT
+               *r |= DN_MULTISHOT;
+#else /* def DN_MULTISHOT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef DN_MULTISHOT */
+       return 0;
+}
+
+int Mono_Posix_ToDirectoryNotifyFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef DN_ACCESS
+       if ((x & DN_ACCESS) == DN_ACCESS)
+               *r |= Mono_Posix_DirectoryNotifyFlags_DN_ACCESS;
+#endif /* ndef DN_ACCESS */
+#ifdef DN_MODIFY
+       if ((x & DN_MODIFY) == DN_MODIFY)
+               *r |= Mono_Posix_DirectoryNotifyFlags_DN_MODIFY;
+#endif /* ndef DN_MODIFY */
+#ifdef DN_CREATE
+       if ((x & DN_CREATE) == DN_CREATE)
+               *r |= Mono_Posix_DirectoryNotifyFlags_DN_CREATE;
+#endif /* ndef DN_CREATE */
+#ifdef DN_DELETE
+       if ((x & DN_DELETE) == DN_DELETE)
+               *r |= Mono_Posix_DirectoryNotifyFlags_DN_DELETE;
+#endif /* ndef DN_DELETE */
+#ifdef DN_RENAME
+       if ((x & DN_RENAME) == DN_RENAME)
+               *r |= Mono_Posix_DirectoryNotifyFlags_DN_RENAME;
+#endif /* ndef DN_RENAME */
+#ifdef DN_ATTRIB
+       if ((x & DN_ATTRIB) == DN_ATTRIB)
+               *r |= Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB;
+#endif /* ndef DN_ATTRIB */
+#ifdef DN_MULTISHOT
+       if ((x & DN_MULTISHOT) == DN_MULTISHOT)
+               *r |= Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT;
+#endif /* ndef DN_MULTISHOT */
+       return 0;
+}
+
+int Mono_Posix_FromPosixFadviseAdvice (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NORMAL)
+#ifdef POSIX_FADV_NORMAL
+               {*r = POSIX_FADV_NORMAL; return 0;}
+#else /* def POSIX_FADV_NORMAL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_FADV_NORMAL */
+       if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_RANDOM)
+#ifdef POSIX_FADV_RANDOM
+               {*r = POSIX_FADV_RANDOM; return 0;}
+#else /* def POSIX_FADV_RANDOM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_FADV_RANDOM */
+       if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_SEQUENTIAL)
+#ifdef POSIX_FADV_SEQUENTIAL
+               {*r = POSIX_FADV_SEQUENTIAL; return 0;}
+#else /* def POSIX_FADV_SEQUENTIAL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_FADV_SEQUENTIAL */
+       if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_WILLNEED)
+#ifdef POSIX_FADV_WILLNEED
+               {*r = POSIX_FADV_WILLNEED; return 0;}
+#else /* def POSIX_FADV_WILLNEED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_FADV_WILLNEED */
+       if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_DONTNEED)
+#ifdef POSIX_FADV_DONTNEED
+               {*r = POSIX_FADV_DONTNEED; return 0;}
+#else /* def POSIX_FADV_DONTNEED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_FADV_DONTNEED */
+       if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NOREUSE)
+#ifdef POSIX_FADV_NOREUSE
+               {*r = POSIX_FADV_NOREUSE; return 0;}
+#else /* def POSIX_FADV_NOREUSE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_FADV_NOREUSE */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToPosixFadviseAdvice (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef POSIX_FADV_NORMAL
+       if (x == POSIX_FADV_NORMAL)
+               {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NORMAL; return 0;}
+#endif /* ndef POSIX_FADV_NORMAL */
+#ifdef POSIX_FADV_RANDOM
+       if (x == POSIX_FADV_RANDOM)
+               {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_RANDOM; return 0;}
+#endif /* ndef POSIX_FADV_RANDOM */
+#ifdef POSIX_FADV_SEQUENTIAL
+       if (x == POSIX_FADV_SEQUENTIAL)
+               {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_SEQUENTIAL; return 0;}
+#endif /* ndef POSIX_FADV_SEQUENTIAL */
+#ifdef POSIX_FADV_WILLNEED
+       if (x == POSIX_FADV_WILLNEED)
+               {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_WILLNEED; return 0;}
+#endif /* ndef POSIX_FADV_WILLNEED */
+#ifdef POSIX_FADV_DONTNEED
+       if (x == POSIX_FADV_DONTNEED)
+               {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_DONTNEED; return 0;}
+#endif /* ndef POSIX_FADV_DONTNEED */
+#ifdef POSIX_FADV_NOREUSE
+       if (x == POSIX_FADV_NOREUSE)
+               {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NOREUSE; return 0;}
+#endif /* ndef POSIX_FADV_NOREUSE */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromPosixMadviseAdvice (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_NORMAL)
+#ifdef POSIX_MADV_NORMAL
+               {*r = POSIX_MADV_NORMAL; return 0;}
+#else /* def POSIX_MADV_NORMAL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_MADV_NORMAL */
+       if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_RANDOM)
+#ifdef POSIX_MADV_RANDOM
+               {*r = POSIX_MADV_RANDOM; return 0;}
+#else /* def POSIX_MADV_RANDOM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_MADV_RANDOM */
+       if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_SEQUENTIAL)
+#ifdef POSIX_MADV_SEQUENTIAL
+               {*r = POSIX_MADV_SEQUENTIAL; return 0;}
+#else /* def POSIX_MADV_SEQUENTIAL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_MADV_SEQUENTIAL */
+       if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_WILLNEED)
+#ifdef POSIX_MADV_WILLNEED
+               {*r = POSIX_MADV_WILLNEED; return 0;}
+#else /* def POSIX_MADV_WILLNEED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_MADV_WILLNEED */
+       if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_DONTNEED)
+#ifdef POSIX_MADV_DONTNEED
+               {*r = POSIX_MADV_DONTNEED; return 0;}
+#else /* def POSIX_MADV_DONTNEED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POSIX_MADV_DONTNEED */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToPosixMadviseAdvice (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef POSIX_MADV_NORMAL
+       if (x == POSIX_MADV_NORMAL)
+               {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_NORMAL; return 0;}
+#endif /* ndef POSIX_MADV_NORMAL */
+#ifdef POSIX_MADV_RANDOM
+       if (x == POSIX_MADV_RANDOM)
+               {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_RANDOM; return 0;}
+#endif /* ndef POSIX_MADV_RANDOM */
+#ifdef POSIX_MADV_SEQUENTIAL
+       if (x == POSIX_MADV_SEQUENTIAL)
+               {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_SEQUENTIAL; return 0;}
+#endif /* ndef POSIX_MADV_SEQUENTIAL */
+#ifdef POSIX_MADV_WILLNEED
+       if (x == POSIX_MADV_WILLNEED)
+               {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_WILLNEED; return 0;}
+#endif /* ndef POSIX_MADV_WILLNEED */
+#ifdef POSIX_MADV_DONTNEED
+       if (x == POSIX_MADV_DONTNEED)
+               {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_DONTNEED; return 0;}
+#endif /* ndef POSIX_MADV_DONTNEED */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromSignum (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_Signum_SIGHUP)
+#ifdef SIGHUP
+               {*r = SIGHUP; return 0;}
+#else /* def SIGHUP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGHUP */
+       if (x == Mono_Posix_Signum_SIGINT)
+#ifdef SIGINT
+               {*r = SIGINT; return 0;}
+#else /* def SIGINT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGINT */
+       if (x == Mono_Posix_Signum_SIGQUIT)
+#ifdef SIGQUIT
+               {*r = SIGQUIT; return 0;}
+#else /* def SIGQUIT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGQUIT */
+       if (x == Mono_Posix_Signum_SIGILL)
+#ifdef SIGILL
+               {*r = SIGILL; return 0;}
+#else /* def SIGILL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGILL */
+       if (x == Mono_Posix_Signum_SIGTRAP)
+#ifdef SIGTRAP
+               {*r = SIGTRAP; return 0;}
+#else /* def SIGTRAP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGTRAP */
+       if (x == Mono_Posix_Signum_SIGABRT)
+#ifdef SIGABRT
+               {*r = SIGABRT; return 0;}
+#else /* def SIGABRT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGABRT */
+       if (x == Mono_Posix_Signum_SIGIOT)
+#ifdef SIGIOT
+               {*r = SIGIOT; return 0;}
+#else /* def SIGIOT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGIOT */
+       if (x == Mono_Posix_Signum_SIGBUS)
+#ifdef SIGBUS
+               {*r = SIGBUS; return 0;}
+#else /* def SIGBUS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGBUS */
+       if (x == Mono_Posix_Signum_SIGFPE)
+#ifdef SIGFPE
+               {*r = SIGFPE; return 0;}
+#else /* def SIGFPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGFPE */
+       if (x == Mono_Posix_Signum_SIGKILL)
+#ifdef SIGKILL
+               {*r = SIGKILL; return 0;}
+#else /* def SIGKILL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGKILL */
+       if (x == Mono_Posix_Signum_SIGUSR1)
+#ifdef SIGUSR1
+               {*r = SIGUSR1; return 0;}
+#else /* def SIGUSR1 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGUSR1 */
+       if (x == Mono_Posix_Signum_SIGSEGV)
+#ifdef SIGSEGV
+               {*r = SIGSEGV; return 0;}
+#else /* def SIGSEGV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGSEGV */
+       if (x == Mono_Posix_Signum_SIGUSR2)
+#ifdef SIGUSR2
+               {*r = SIGUSR2; return 0;}
+#else /* def SIGUSR2 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGUSR2 */
+       if (x == Mono_Posix_Signum_SIGPIPE)
+#ifdef SIGPIPE
+               {*r = SIGPIPE; return 0;}
+#else /* def SIGPIPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGPIPE */
+       if (x == Mono_Posix_Signum_SIGALRM)
+#ifdef SIGALRM
+               {*r = SIGALRM; return 0;}
+#else /* def SIGALRM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGALRM */
+       if (x == Mono_Posix_Signum_SIGTERM)
+#ifdef SIGTERM
+               {*r = SIGTERM; return 0;}
+#else /* def SIGTERM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGTERM */
+       if (x == Mono_Posix_Signum_SIGSTKFLT)
+#ifdef SIGSTKFLT
+               {*r = SIGSTKFLT; return 0;}
+#else /* def SIGSTKFLT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGSTKFLT */
+       if (x == Mono_Posix_Signum_SIGCHLD)
+#ifdef SIGCHLD
+               {*r = SIGCHLD; return 0;}
+#else /* def SIGCHLD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGCHLD */
+       if (x == Mono_Posix_Signum_SIGCLD)
+#ifdef SIGCLD
+               {*r = SIGCLD; return 0;}
+#else /* def SIGCLD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGCLD */
+       if (x == Mono_Posix_Signum_SIGCONT)
+#ifdef SIGCONT
+               {*r = SIGCONT; return 0;}
+#else /* def SIGCONT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGCONT */
+       if (x == Mono_Posix_Signum_SIGSTOP)
+#ifdef SIGSTOP
+               {*r = SIGSTOP; return 0;}
+#else /* def SIGSTOP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGSTOP */
+       if (x == Mono_Posix_Signum_SIGTSTP)
+#ifdef SIGTSTP
+               {*r = SIGTSTP; return 0;}
+#else /* def SIGTSTP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGTSTP */
+       if (x == Mono_Posix_Signum_SIGTTIN)
+#ifdef SIGTTIN
+               {*r = SIGTTIN; return 0;}
+#else /* def SIGTTIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGTTIN */
+       if (x == Mono_Posix_Signum_SIGTTOU)
+#ifdef SIGTTOU
+               {*r = SIGTTOU; return 0;}
+#else /* def SIGTTOU */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGTTOU */
+       if (x == Mono_Posix_Signum_SIGURG)
+#ifdef SIGURG
+               {*r = SIGURG; return 0;}
+#else /* def SIGURG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGURG */
+       if (x == Mono_Posix_Signum_SIGXCPU)
+#ifdef SIGXCPU
+               {*r = SIGXCPU; return 0;}
+#else /* def SIGXCPU */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGXCPU */
+       if (x == Mono_Posix_Signum_SIGXFSZ)
+#ifdef SIGXFSZ
+               {*r = SIGXFSZ; return 0;}
+#else /* def SIGXFSZ */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGXFSZ */
+       if (x == Mono_Posix_Signum_SIGVTALRM)
+#ifdef SIGVTALRM
+               {*r = SIGVTALRM; return 0;}
+#else /* def SIGVTALRM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGVTALRM */
+       if (x == Mono_Posix_Signum_SIGPROF)
+#ifdef SIGPROF
+               {*r = SIGPROF; return 0;}
+#else /* def SIGPROF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGPROF */
+       if (x == Mono_Posix_Signum_SIGWINCH)
+#ifdef SIGWINCH
+               {*r = SIGWINCH; return 0;}
+#else /* def SIGWINCH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGWINCH */
+       if (x == Mono_Posix_Signum_SIGIO)
+#ifdef SIGIO
+               {*r = SIGIO; return 0;}
+#else /* def SIGIO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGIO */
+       if (x == Mono_Posix_Signum_SIGPOLL)
+#ifdef SIGPOLL
+               {*r = SIGPOLL; return 0;}
+#else /* def SIGPOLL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGPOLL */
+       if (x == Mono_Posix_Signum_SIGPWR)
+#ifdef SIGPWR
+               {*r = SIGPWR; return 0;}
+#else /* def SIGPWR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGPWR */
+       if (x == Mono_Posix_Signum_SIGSYS)
+#ifdef SIGSYS
+               {*r = SIGSYS; return 0;}
+#else /* def SIGSYS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGSYS */
+       if (x == Mono_Posix_Signum_SIGUNUSED)
+#ifdef SIGUNUSED
+               {*r = SIGUNUSED; return 0;}
+#else /* def SIGUNUSED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SIGUNUSED */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToSignum (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef SIGHUP
+       if (x == SIGHUP)
+               {*r = Mono_Posix_Signum_SIGHUP; return 0;}
+#endif /* ndef SIGHUP */
+#ifdef SIGINT
+       if (x == SIGINT)
+               {*r = Mono_Posix_Signum_SIGINT; return 0;}
+#endif /* ndef SIGINT */
+#ifdef SIGQUIT
+       if (x == SIGQUIT)
+               {*r = Mono_Posix_Signum_SIGQUIT; return 0;}
+#endif /* ndef SIGQUIT */
+#ifdef SIGILL
+       if (x == SIGILL)
+               {*r = Mono_Posix_Signum_SIGILL; return 0;}
+#endif /* ndef SIGILL */
+#ifdef SIGTRAP
+       if (x == SIGTRAP)
+               {*r = Mono_Posix_Signum_SIGTRAP; return 0;}
+#endif /* ndef SIGTRAP */
+#ifdef SIGABRT
+       if (x == SIGABRT)
+               {*r = Mono_Posix_Signum_SIGABRT; return 0;}
+#endif /* ndef SIGABRT */
+#ifdef SIGIOT
+       if (x == SIGIOT)
+               {*r = Mono_Posix_Signum_SIGIOT; return 0;}
+#endif /* ndef SIGIOT */
+#ifdef SIGBUS
+       if (x == SIGBUS)
+               {*r = Mono_Posix_Signum_SIGBUS; return 0;}
+#endif /* ndef SIGBUS */
+#ifdef SIGFPE
+       if (x == SIGFPE)
+               {*r = Mono_Posix_Signum_SIGFPE; return 0;}
+#endif /* ndef SIGFPE */
+#ifdef SIGKILL
+       if (x == SIGKILL)
+               {*r = Mono_Posix_Signum_SIGKILL; return 0;}
+#endif /* ndef SIGKILL */
+#ifdef SIGUSR1
+       if (x == SIGUSR1)
+               {*r = Mono_Posix_Signum_SIGUSR1; return 0;}
+#endif /* ndef SIGUSR1 */
+#ifdef SIGSEGV
+       if (x == SIGSEGV)
+               {*r = Mono_Posix_Signum_SIGSEGV; return 0;}
+#endif /* ndef SIGSEGV */
+#ifdef SIGUSR2
+       if (x == SIGUSR2)
+               {*r = Mono_Posix_Signum_SIGUSR2; return 0;}
+#endif /* ndef SIGUSR2 */
+#ifdef SIGPIPE
+       if (x == SIGPIPE)
+               {*r = Mono_Posix_Signum_SIGPIPE; return 0;}
+#endif /* ndef SIGPIPE */
+#ifdef SIGALRM
+       if (x == SIGALRM)
+               {*r = Mono_Posix_Signum_SIGALRM; return 0;}
+#endif /* ndef SIGALRM */
+#ifdef SIGTERM
+       if (x == SIGTERM)
+               {*r = Mono_Posix_Signum_SIGTERM; return 0;}
+#endif /* ndef SIGTERM */
+#ifdef SIGSTKFLT
+       if (x == SIGSTKFLT)
+               {*r = Mono_Posix_Signum_SIGSTKFLT; return 0;}
+#endif /* ndef SIGSTKFLT */
+#ifdef SIGCHLD
+       if (x == SIGCHLD)
+               {*r = Mono_Posix_Signum_SIGCHLD; return 0;}
+#endif /* ndef SIGCHLD */
+#ifdef SIGCLD
+       if (x == SIGCLD)
+               {*r = Mono_Posix_Signum_SIGCLD; return 0;}
+#endif /* ndef SIGCLD */
+#ifdef SIGCONT
+       if (x == SIGCONT)
+               {*r = Mono_Posix_Signum_SIGCONT; return 0;}
+#endif /* ndef SIGCONT */
+#ifdef SIGSTOP
+       if (x == SIGSTOP)
+               {*r = Mono_Posix_Signum_SIGSTOP; return 0;}
+#endif /* ndef SIGSTOP */
+#ifdef SIGTSTP
+       if (x == SIGTSTP)
+               {*r = Mono_Posix_Signum_SIGTSTP; return 0;}
+#endif /* ndef SIGTSTP */
+#ifdef SIGTTIN
+       if (x == SIGTTIN)
+               {*r = Mono_Posix_Signum_SIGTTIN; return 0;}
+#endif /* ndef SIGTTIN */
+#ifdef SIGTTOU
+       if (x == SIGTTOU)
+               {*r = Mono_Posix_Signum_SIGTTOU; return 0;}
+#endif /* ndef SIGTTOU */
+#ifdef SIGURG
+       if (x == SIGURG)
+               {*r = Mono_Posix_Signum_SIGURG; return 0;}
+#endif /* ndef SIGURG */
+#ifdef SIGXCPU
+       if (x == SIGXCPU)
+               {*r = Mono_Posix_Signum_SIGXCPU; return 0;}
+#endif /* ndef SIGXCPU */
+#ifdef SIGXFSZ
+       if (x == SIGXFSZ)
+               {*r = Mono_Posix_Signum_SIGXFSZ; return 0;}
+#endif /* ndef SIGXFSZ */
+#ifdef SIGVTALRM
+       if (x == SIGVTALRM)
+               {*r = Mono_Posix_Signum_SIGVTALRM; return 0;}
+#endif /* ndef SIGVTALRM */
+#ifdef SIGPROF
+       if (x == SIGPROF)
+               {*r = Mono_Posix_Signum_SIGPROF; return 0;}
+#endif /* ndef SIGPROF */
+#ifdef SIGWINCH
+       if (x == SIGWINCH)
+               {*r = Mono_Posix_Signum_SIGWINCH; return 0;}
+#endif /* ndef SIGWINCH */
+#ifdef SIGIO
+       if (x == SIGIO)
+               {*r = Mono_Posix_Signum_SIGIO; return 0;}
+#endif /* ndef SIGIO */
+#ifdef SIGPOLL
+       if (x == SIGPOLL)
+               {*r = Mono_Posix_Signum_SIGPOLL; return 0;}
+#endif /* ndef SIGPOLL */
+#ifdef SIGPWR
+       if (x == SIGPWR)
+               {*r = Mono_Posix_Signum_SIGPWR; return 0;}
+#endif /* ndef SIGPWR */
+#ifdef SIGSYS
+       if (x == SIGSYS)
+               {*r = Mono_Posix_Signum_SIGSYS; return 0;}
+#endif /* ndef SIGSYS */
+#ifdef SIGUNUSED
+       if (x == SIGUNUSED)
+               {*r = Mono_Posix_Signum_SIGUNUSED; return 0;}
+#endif /* ndef SIGUNUSED */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromMountFlags (guint64 x, guint64 *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_MountFlags_MS_RDONLY) == Mono_Posix_MountFlags_MS_RDONLY)
+#ifdef MS_RDONLY
+               *r |= MS_RDONLY;
+#else /* def MS_RDONLY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_RDONLY */
+       if ((x & Mono_Posix_MountFlags_MS_NOSUID) == Mono_Posix_MountFlags_MS_NOSUID)
+#ifdef MS_NOSUID
+               *r |= MS_NOSUID;
+#else /* def MS_NOSUID */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_NOSUID */
+       if ((x & Mono_Posix_MountFlags_MS_NODEV) == Mono_Posix_MountFlags_MS_NODEV)
+#ifdef MS_NODEV
+               *r |= MS_NODEV;
+#else /* def MS_NODEV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_NODEV */
+       if ((x & Mono_Posix_MountFlags_MS_NOEXEC) == Mono_Posix_MountFlags_MS_NOEXEC)
+#ifdef MS_NOEXEC
+               *r |= MS_NOEXEC;
+#else /* def MS_NOEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_NOEXEC */
+       if ((x & Mono_Posix_MountFlags_MS_SYNCHRONOUS) == Mono_Posix_MountFlags_MS_SYNCHRONOUS)
+#ifdef MS_SYNCHRONOUS
+               *r |= MS_SYNCHRONOUS;
+#else /* def MS_SYNCHRONOUS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_SYNCHRONOUS */
+       if ((x & Mono_Posix_MountFlags_MS_REMOUNT) == Mono_Posix_MountFlags_MS_REMOUNT)
+#ifdef MS_REMOUNT
+               *r |= MS_REMOUNT;
+#else /* def MS_REMOUNT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_REMOUNT */
+       if ((x & Mono_Posix_MountFlags_MS_MANDLOCK) == Mono_Posix_MountFlags_MS_MANDLOCK)
+#ifdef MS_MANDLOCK
+               *r |= MS_MANDLOCK;
+#else /* def MS_MANDLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_MANDLOCK */
+       if ((x & Mono_Posix_MountFlags_S_WRITE) == Mono_Posix_MountFlags_S_WRITE)
+#ifdef S_WRITE
+               *r |= S_WRITE;
+#else /* def S_WRITE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_WRITE */
+       if ((x & Mono_Posix_MountFlags_S_APPEND) == Mono_Posix_MountFlags_S_APPEND)
+#ifdef S_APPEND
+               *r |= S_APPEND;
+#else /* def S_APPEND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_APPEND */
+       if ((x & Mono_Posix_MountFlags_S_IMMUTABLE) == Mono_Posix_MountFlags_S_IMMUTABLE)
+#ifdef S_IMMUTABLE
+               *r |= S_IMMUTABLE;
+#else /* def S_IMMUTABLE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef S_IMMUTABLE */
+       if ((x & Mono_Posix_MountFlags_MS_NOATIME) == Mono_Posix_MountFlags_MS_NOATIME)
+#ifdef MS_NOATIME
+               *r |= MS_NOATIME;
+#else /* def MS_NOATIME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_NOATIME */
+       if ((x & Mono_Posix_MountFlags_MS_NODIRATIME) == Mono_Posix_MountFlags_MS_NODIRATIME)
+#ifdef MS_NODIRATIME
+               *r |= MS_NODIRATIME;
+#else /* def MS_NODIRATIME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_NODIRATIME */
+       if ((x & Mono_Posix_MountFlags_MS_BIND) == Mono_Posix_MountFlags_MS_BIND)
+#ifdef MS_BIND
+               *r |= MS_BIND;
+#else /* def MS_BIND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_BIND */
+       if ((x & Mono_Posix_MountFlags_MS_RMT_MASK) == Mono_Posix_MountFlags_MS_RMT_MASK)
+#ifdef MS_RMT_MASK
+               *r |= MS_RMT_MASK;
+#else /* def MS_RMT_MASK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_RMT_MASK */
+       if ((x & Mono_Posix_MountFlags_MS_MGC_VAL) == Mono_Posix_MountFlags_MS_MGC_VAL)
+#ifdef MS_MGC_VAL
+               *r |= MS_MGC_VAL;
+#else /* def MS_MGC_VAL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_MGC_VAL */
+       if ((x & Mono_Posix_MountFlags_MS_MGC_MSK) == Mono_Posix_MountFlags_MS_MGC_MSK)
+#ifdef MS_MGC_MSK
+               *r |= MS_MGC_MSK;
+#else /* def MS_MGC_MSK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MS_MGC_MSK */
+       return 0;
+}
+
+int Mono_Posix_ToMountFlags (guint64 x, guint64 *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef MS_RDONLY
+       if ((x & MS_RDONLY) == MS_RDONLY)
+               *r |= Mono_Posix_MountFlags_MS_RDONLY;
+#endif /* ndef MS_RDONLY */
+#ifdef MS_NOSUID
+       if ((x & MS_NOSUID) == MS_NOSUID)
+               *r |= Mono_Posix_MountFlags_MS_NOSUID;
+#endif /* ndef MS_NOSUID */
+#ifdef MS_NODEV
+       if ((x & MS_NODEV) == MS_NODEV)
+               *r |= Mono_Posix_MountFlags_MS_NODEV;
+#endif /* ndef MS_NODEV */
+#ifdef MS_NOEXEC
+       if ((x & MS_NOEXEC) == MS_NOEXEC)
+               *r |= Mono_Posix_MountFlags_MS_NOEXEC;
+#endif /* ndef MS_NOEXEC */
+#ifdef MS_SYNCHRONOUS
+       if ((x & MS_SYNCHRONOUS) == MS_SYNCHRONOUS)
+               *r |= Mono_Posix_MountFlags_MS_SYNCHRONOUS;
+#endif /* ndef MS_SYNCHRONOUS */
+#ifdef MS_REMOUNT
+       if ((x & MS_REMOUNT) == MS_REMOUNT)
+               *r |= Mono_Posix_MountFlags_MS_REMOUNT;
+#endif /* ndef MS_REMOUNT */
+#ifdef MS_MANDLOCK
+       if ((x & MS_MANDLOCK) == MS_MANDLOCK)
+               *r |= Mono_Posix_MountFlags_MS_MANDLOCK;
+#endif /* ndef MS_MANDLOCK */
+#ifdef S_WRITE
+       if ((x & S_WRITE) == S_WRITE)
+               *r |= Mono_Posix_MountFlags_S_WRITE;
+#endif /* ndef S_WRITE */
+#ifdef S_APPEND
+       if ((x & S_APPEND) == S_APPEND)
+               *r |= Mono_Posix_MountFlags_S_APPEND;
+#endif /* ndef S_APPEND */
+#ifdef S_IMMUTABLE
+       if ((x & S_IMMUTABLE) == S_IMMUTABLE)
+               *r |= Mono_Posix_MountFlags_S_IMMUTABLE;
+#endif /* ndef S_IMMUTABLE */
+#ifdef MS_NOATIME
+       if ((x & MS_NOATIME) == MS_NOATIME)
+               *r |= Mono_Posix_MountFlags_MS_NOATIME;
+#endif /* ndef MS_NOATIME */
+#ifdef MS_NODIRATIME
+       if ((x & MS_NODIRATIME) == MS_NODIRATIME)
+               *r |= Mono_Posix_MountFlags_MS_NODIRATIME;
+#endif /* ndef MS_NODIRATIME */
+#ifdef MS_BIND
+       if ((x & MS_BIND) == MS_BIND)
+               *r |= Mono_Posix_MountFlags_MS_BIND;
+#endif /* ndef MS_BIND */
+#ifdef MS_RMT_MASK
+       if ((x & MS_RMT_MASK) == MS_RMT_MASK)
+               *r |= Mono_Posix_MountFlags_MS_RMT_MASK;
+#endif /* ndef MS_RMT_MASK */
+#ifdef MS_MGC_VAL
+       if ((x & MS_MGC_VAL) == MS_MGC_VAL)
+               *r |= Mono_Posix_MountFlags_MS_MGC_VAL;
+#endif /* ndef MS_MGC_VAL */
+#ifdef MS_MGC_MSK
+       if ((x & MS_MGC_MSK) == MS_MGC_MSK)
+               *r |= Mono_Posix_MountFlags_MS_MGC_MSK;
+#endif /* ndef MS_MGC_MSK */
+       return 0;
+}
+
+int Mono_Posix_FromUmountFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_UmountFlags_MNT_FORCE) == Mono_Posix_UmountFlags_MNT_FORCE)
+#ifdef MNT_FORCE
+               *r |= MNT_FORCE;
+#else /* def MNT_FORCE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MNT_FORCE */
+       if ((x & Mono_Posix_UmountFlags_MNT_DETACH) == Mono_Posix_UmountFlags_MNT_DETACH)
+#ifdef MNT_DETACH
+               *r |= MNT_DETACH;
+#else /* def MNT_DETACH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MNT_DETACH */
+       return 0;
+}
+
+int Mono_Posix_ToUmountFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef MNT_FORCE
+       if ((x & MNT_FORCE) == MNT_FORCE)
+               *r |= Mono_Posix_UmountFlags_MNT_FORCE;
+#endif /* ndef MNT_FORCE */
+#ifdef MNT_DETACH
+       if ((x & MNT_DETACH) == MNT_DETACH)
+               *r |= Mono_Posix_UmountFlags_MNT_DETACH;
+#endif /* ndef MNT_DETACH */
+       return 0;
+}
+
+int Mono_Posix_FromWaitOptions (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_WaitOptions_WNOHANG) == Mono_Posix_WaitOptions_WNOHANG)
+#ifdef WNOHANG
+               *r |= WNOHANG;
+#else /* def WNOHANG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef WNOHANG */
+       if ((x & Mono_Posix_WaitOptions_WUNTRACED) == Mono_Posix_WaitOptions_WUNTRACED)
+#ifdef WUNTRACED
+               *r |= WUNTRACED;
+#else /* def WUNTRACED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef WUNTRACED */
+       return 0;
+}
+
+int Mono_Posix_ToWaitOptions (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef WNOHANG
+       if ((x & WNOHANG) == WNOHANG)
+               *r |= Mono_Posix_WaitOptions_WNOHANG;
+#endif /* ndef WNOHANG */
+#ifdef WUNTRACED
+       if ((x & WUNTRACED) == WUNTRACED)
+               *r |= Mono_Posix_WaitOptions_WUNTRACED;
+#endif /* ndef WUNTRACED */
+       return 0;
+}
+
+int Mono_Posix_FromAccessMode (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_AccessMode_R_OK) == Mono_Posix_AccessMode_R_OK)
+#ifdef R_OK
+               *r |= R_OK;
+#else /* def R_OK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef R_OK */
+       if ((x & Mono_Posix_AccessMode_W_OK) == Mono_Posix_AccessMode_W_OK)
+#ifdef W_OK
+               *r |= W_OK;
+#else /* def W_OK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef W_OK */
+       if ((x & Mono_Posix_AccessMode_X_OK) == Mono_Posix_AccessMode_X_OK)
+#ifdef X_OK
+               *r |= X_OK;
+#else /* def X_OK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef X_OK */
+       if ((x & Mono_Posix_AccessMode_F_OK) == Mono_Posix_AccessMode_F_OK)
+#ifdef F_OK
+               *r |= F_OK;
+#else /* def F_OK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_OK */
+       return 0;
+}
+
+int Mono_Posix_ToAccessMode (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef R_OK
+       if ((x & R_OK) == R_OK)
+               *r |= Mono_Posix_AccessMode_R_OK;
+#endif /* ndef R_OK */
+#ifdef W_OK
+       if ((x & W_OK) == W_OK)
+               *r |= Mono_Posix_AccessMode_W_OK;
+#endif /* ndef W_OK */
+#ifdef X_OK
+       if ((x & X_OK) == X_OK)
+               *r |= Mono_Posix_AccessMode_X_OK;
+#endif /* ndef X_OK */
+#ifdef F_OK
+       if ((x & F_OK) == F_OK)
+               *r |= Mono_Posix_AccessMode_F_OK;
+#endif /* ndef F_OK */
+       return 0;
+}
+
+int Mono_Posix_FromPathConf (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_PathConf__PC_LINK_MAX)
+#ifdef _PC_LINK_MAX
+               {*r = _PC_LINK_MAX; return 0;}
+#else /* def _PC_LINK_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_LINK_MAX */
+       if (x == Mono_Posix_PathConf__PC_MAX_CANON)
+#ifdef _PC_MAX_CANON
+               {*r = _PC_MAX_CANON; return 0;}
+#else /* def _PC_MAX_CANON */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_MAX_CANON */
+       if (x == Mono_Posix_PathConf__PC_MAX_INPUT)
+#ifdef _PC_MAX_INPUT
+               {*r = _PC_MAX_INPUT; return 0;}
+#else /* def _PC_MAX_INPUT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_MAX_INPUT */
+       if (x == Mono_Posix_PathConf__PC_NAME_MAX)
+#ifdef _PC_NAME_MAX
+               {*r = _PC_NAME_MAX; return 0;}
+#else /* def _PC_NAME_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_NAME_MAX */
+       if (x == Mono_Posix_PathConf__PC_PATH_MAX)
+#ifdef _PC_PATH_MAX
+               {*r = _PC_PATH_MAX; return 0;}
+#else /* def _PC_PATH_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_PATH_MAX */
+       if (x == Mono_Posix_PathConf__PC_PIPE_BUF)
+#ifdef _PC_PIPE_BUF
+               {*r = _PC_PIPE_BUF; return 0;}
+#else /* def _PC_PIPE_BUF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_PIPE_BUF */
+       if (x == Mono_Posix_PathConf__PC_CHOWN_RESTRICTED)
+#ifdef _PC_CHOWN_RESTRICTED
+               {*r = _PC_CHOWN_RESTRICTED; return 0;}
+#else /* def _PC_CHOWN_RESTRICTED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_CHOWN_RESTRICTED */
+       if (x == Mono_Posix_PathConf__PC_NO_TRUNC)
+#ifdef _PC_NO_TRUNC
+               {*r = _PC_NO_TRUNC; return 0;}
+#else /* def _PC_NO_TRUNC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_NO_TRUNC */
+       if (x == Mono_Posix_PathConf__PC_VDISABLE)
+#ifdef _PC_VDISABLE
+               {*r = _PC_VDISABLE; return 0;}
+#else /* def _PC_VDISABLE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_VDISABLE */
+       if (x == Mono_Posix_PathConf__PC_SYNC_IO)
+#ifdef _PC_SYNC_IO
+               {*r = _PC_SYNC_IO; return 0;}
+#else /* def _PC_SYNC_IO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_SYNC_IO */
+       if (x == Mono_Posix_PathConf__PC_ASYNC_IO)
+#ifdef _PC_ASYNC_IO
+               {*r = _PC_ASYNC_IO; return 0;}
+#else /* def _PC_ASYNC_IO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_ASYNC_IO */
+       if (x == Mono_Posix_PathConf__PC_PRIO_IO)
+#ifdef _PC_PRIO_IO
+               {*r = _PC_PRIO_IO; return 0;}
+#else /* def _PC_PRIO_IO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_PRIO_IO */
+       if (x == Mono_Posix_PathConf__PC_SOCK_MAXBUF)
+#ifdef _PC_SOCK_MAXBUF
+               {*r = _PC_SOCK_MAXBUF; return 0;}
+#else /* def _PC_SOCK_MAXBUF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_SOCK_MAXBUF */
+       if (x == Mono_Posix_PathConf__PC_FILESIZEBITS)
+#ifdef _PC_FILESIZEBITS
+               {*r = _PC_FILESIZEBITS; return 0;}
+#else /* def _PC_FILESIZEBITS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_FILESIZEBITS */
+       if (x == Mono_Posix_PathConf__PC_REC_INCR_XFER_SIZE)
+#ifdef _PC_REC_INCR_XFER_SIZE
+               {*r = _PC_REC_INCR_XFER_SIZE; return 0;}
+#else /* def _PC_REC_INCR_XFER_SIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_REC_INCR_XFER_SIZE */
+       if (x == Mono_Posix_PathConf__PC_REC_MAX_XFER_SIZE)
+#ifdef _PC_REC_MAX_XFER_SIZE
+               {*r = _PC_REC_MAX_XFER_SIZE; return 0;}
+#else /* def _PC_REC_MAX_XFER_SIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_REC_MAX_XFER_SIZE */
+       if (x == Mono_Posix_PathConf__PC_REC_MIN_XFER_SIZE)
+#ifdef _PC_REC_MIN_XFER_SIZE
+               {*r = _PC_REC_MIN_XFER_SIZE; return 0;}
+#else /* def _PC_REC_MIN_XFER_SIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_REC_MIN_XFER_SIZE */
+       if (x == Mono_Posix_PathConf__PC_REC_XFER_ALIGN)
+#ifdef _PC_REC_XFER_ALIGN
+               {*r = _PC_REC_XFER_ALIGN; return 0;}
+#else /* def _PC_REC_XFER_ALIGN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_REC_XFER_ALIGN */
+       if (x == Mono_Posix_PathConf__PC_ALLOC_SIZE_MIN)
+#ifdef _PC_ALLOC_SIZE_MIN
+               {*r = _PC_ALLOC_SIZE_MIN; return 0;}
+#else /* def _PC_ALLOC_SIZE_MIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_ALLOC_SIZE_MIN */
+       if (x == Mono_Posix_PathConf__PC_SYMLINK_MAX)
+#ifdef _PC_SYMLINK_MAX
+               {*r = _PC_SYMLINK_MAX; return 0;}
+#else /* def _PC_SYMLINK_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_SYMLINK_MAX */
+       if (x == Mono_Posix_PathConf__PC_2_SYMLINKS)
+#ifdef _PC_2_SYMLINKS
+               {*r = _PC_2_SYMLINKS; return 0;}
+#else /* def _PC_2_SYMLINKS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _PC_2_SYMLINKS */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToPathConf (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef _PC_LINK_MAX
+       if (x == _PC_LINK_MAX)
+               {*r = Mono_Posix_PathConf__PC_LINK_MAX; return 0;}
+#endif /* ndef _PC_LINK_MAX */
+#ifdef _PC_MAX_CANON
+       if (x == _PC_MAX_CANON)
+               {*r = Mono_Posix_PathConf__PC_MAX_CANON; return 0;}
+#endif /* ndef _PC_MAX_CANON */
+#ifdef _PC_MAX_INPUT
+       if (x == _PC_MAX_INPUT)
+               {*r = Mono_Posix_PathConf__PC_MAX_INPUT; return 0;}
+#endif /* ndef _PC_MAX_INPUT */
+#ifdef _PC_NAME_MAX
+       if (x == _PC_NAME_MAX)
+               {*r = Mono_Posix_PathConf__PC_NAME_MAX; return 0;}
+#endif /* ndef _PC_NAME_MAX */
+#ifdef _PC_PATH_MAX
+       if (x == _PC_PATH_MAX)
+               {*r = Mono_Posix_PathConf__PC_PATH_MAX; return 0;}
+#endif /* ndef _PC_PATH_MAX */
+#ifdef _PC_PIPE_BUF
+       if (x == _PC_PIPE_BUF)
+               {*r = Mono_Posix_PathConf__PC_PIPE_BUF; return 0;}
+#endif /* ndef _PC_PIPE_BUF */
+#ifdef _PC_CHOWN_RESTRICTED
+       if (x == _PC_CHOWN_RESTRICTED)
+               {*r = Mono_Posix_PathConf__PC_CHOWN_RESTRICTED; return 0;}
+#endif /* ndef _PC_CHOWN_RESTRICTED */
+#ifdef _PC_NO_TRUNC
+       if (x == _PC_NO_TRUNC)
+               {*r = Mono_Posix_PathConf__PC_NO_TRUNC; return 0;}
+#endif /* ndef _PC_NO_TRUNC */
+#ifdef _PC_VDISABLE
+       if (x == _PC_VDISABLE)
+               {*r = Mono_Posix_PathConf__PC_VDISABLE; return 0;}
+#endif /* ndef _PC_VDISABLE */
+#ifdef _PC_SYNC_IO
+       if (x == _PC_SYNC_IO)
+               {*r = Mono_Posix_PathConf__PC_SYNC_IO; return 0;}
+#endif /* ndef _PC_SYNC_IO */
+#ifdef _PC_ASYNC_IO
+       if (x == _PC_ASYNC_IO)
+               {*r = Mono_Posix_PathConf__PC_ASYNC_IO; return 0;}
+#endif /* ndef _PC_ASYNC_IO */
+#ifdef _PC_PRIO_IO
+       if (x == _PC_PRIO_IO)
+               {*r = Mono_Posix_PathConf__PC_PRIO_IO; return 0;}
+#endif /* ndef _PC_PRIO_IO */
+#ifdef _PC_SOCK_MAXBUF
+       if (x == _PC_SOCK_MAXBUF)
+               {*r = Mono_Posix_PathConf__PC_SOCK_MAXBUF; return 0;}
+#endif /* ndef _PC_SOCK_MAXBUF */
+#ifdef _PC_FILESIZEBITS
+       if (x == _PC_FILESIZEBITS)
+               {*r = Mono_Posix_PathConf__PC_FILESIZEBITS; return 0;}
+#endif /* ndef _PC_FILESIZEBITS */
+#ifdef _PC_REC_INCR_XFER_SIZE
+       if (x == _PC_REC_INCR_XFER_SIZE)
+               {*r = Mono_Posix_PathConf__PC_REC_INCR_XFER_SIZE; return 0;}
+#endif /* ndef _PC_REC_INCR_XFER_SIZE */
+#ifdef _PC_REC_MAX_XFER_SIZE
+       if (x == _PC_REC_MAX_XFER_SIZE)
+               {*r = Mono_Posix_PathConf__PC_REC_MAX_XFER_SIZE; return 0;}
+#endif /* ndef _PC_REC_MAX_XFER_SIZE */
+#ifdef _PC_REC_MIN_XFER_SIZE
+       if (x == _PC_REC_MIN_XFER_SIZE)
+               {*r = Mono_Posix_PathConf__PC_REC_MIN_XFER_SIZE; return 0;}
+#endif /* ndef _PC_REC_MIN_XFER_SIZE */
+#ifdef _PC_REC_XFER_ALIGN
+       if (x == _PC_REC_XFER_ALIGN)
+               {*r = Mono_Posix_PathConf__PC_REC_XFER_ALIGN; return 0;}
+#endif /* ndef _PC_REC_XFER_ALIGN */
+#ifdef _PC_ALLOC_SIZE_MIN
+       if (x == _PC_ALLOC_SIZE_MIN)
+               {*r = Mono_Posix_PathConf__PC_ALLOC_SIZE_MIN; return 0;}
+#endif /* ndef _PC_ALLOC_SIZE_MIN */
+#ifdef _PC_SYMLINK_MAX
+       if (x == _PC_SYMLINK_MAX)
+               {*r = Mono_Posix_PathConf__PC_SYMLINK_MAX; return 0;}
+#endif /* ndef _PC_SYMLINK_MAX */
+#ifdef _PC_2_SYMLINKS
+       if (x == _PC_2_SYMLINKS)
+               {*r = Mono_Posix_PathConf__PC_2_SYMLINKS; return 0;}
+#endif /* ndef _PC_2_SYMLINKS */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromSysConf (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_SysConf__SC_ARG_MAX)
+#ifdef _SC_ARG_MAX
+               {*r = _SC_ARG_MAX; return 0;}
+#else /* def _SC_ARG_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_ARG_MAX */
+       if (x == Mono_Posix_SysConf__SC_CHILD_MAX)
+#ifdef _SC_CHILD_MAX
+               {*r = _SC_CHILD_MAX; return 0;}
+#else /* def _SC_CHILD_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_CHILD_MAX */
+       if (x == Mono_Posix_SysConf__SC_CLK_TCK)
+#ifdef _SC_CLK_TCK
+               {*r = _SC_CLK_TCK; return 0;}
+#else /* def _SC_CLK_TCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_CLK_TCK */
+       if (x == Mono_Posix_SysConf__SC_NGROUPS_MAX)
+#ifdef _SC_NGROUPS_MAX
+               {*r = _SC_NGROUPS_MAX; return 0;}
+#else /* def _SC_NGROUPS_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NGROUPS_MAX */
+       if (x == Mono_Posix_SysConf__SC_OPEN_MAX)
+#ifdef _SC_OPEN_MAX
+               {*r = _SC_OPEN_MAX; return 0;}
+#else /* def _SC_OPEN_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_OPEN_MAX */
+       if (x == Mono_Posix_SysConf__SC_STREAM_MAX)
+#ifdef _SC_STREAM_MAX
+               {*r = _SC_STREAM_MAX; return 0;}
+#else /* def _SC_STREAM_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_STREAM_MAX */
+       if (x == Mono_Posix_SysConf__SC_TZNAME_MAX)
+#ifdef _SC_TZNAME_MAX
+               {*r = _SC_TZNAME_MAX; return 0;}
+#else /* def _SC_TZNAME_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TZNAME_MAX */
+       if (x == Mono_Posix_SysConf__SC_JOB_CONTROL)
+#ifdef _SC_JOB_CONTROL
+               {*r = _SC_JOB_CONTROL; return 0;}
+#else /* def _SC_JOB_CONTROL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_JOB_CONTROL */
+       if (x == Mono_Posix_SysConf__SC_SAVED_IDS)
+#ifdef _SC_SAVED_IDS
+               {*r = _SC_SAVED_IDS; return 0;}
+#else /* def _SC_SAVED_IDS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SAVED_IDS */
+       if (x == Mono_Posix_SysConf__SC_REALTIME_SIGNALS)
+#ifdef _SC_REALTIME_SIGNALS
+               {*r = _SC_REALTIME_SIGNALS; return 0;}
+#else /* def _SC_REALTIME_SIGNALS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_REALTIME_SIGNALS */
+       if (x == Mono_Posix_SysConf__SC_PRIORITY_SCHEDULING)
+#ifdef _SC_PRIORITY_SCHEDULING
+               {*r = _SC_PRIORITY_SCHEDULING; return 0;}
+#else /* def _SC_PRIORITY_SCHEDULING */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PRIORITY_SCHEDULING */
+       if (x == Mono_Posix_SysConf__SC_TIMERS)
+#ifdef _SC_TIMERS
+               {*r = _SC_TIMERS; return 0;}
+#else /* def _SC_TIMERS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TIMERS */
+       if (x == Mono_Posix_SysConf__SC_ASYNCHRONOUS_IO)
+#ifdef _SC_ASYNCHRONOUS_IO
+               {*r = _SC_ASYNCHRONOUS_IO; return 0;}
+#else /* def _SC_ASYNCHRONOUS_IO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_ASYNCHRONOUS_IO */
+       if (x == Mono_Posix_SysConf__SC_PRIORITIZED_IO)
+#ifdef _SC_PRIORITIZED_IO
+               {*r = _SC_PRIORITIZED_IO; return 0;}
+#else /* def _SC_PRIORITIZED_IO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PRIORITIZED_IO */
+       if (x == Mono_Posix_SysConf__SC_SYNCHRONIZED_IO)
+#ifdef _SC_SYNCHRONIZED_IO
+               {*r = _SC_SYNCHRONIZED_IO; return 0;}
+#else /* def _SC_SYNCHRONIZED_IO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SYNCHRONIZED_IO */
+       if (x == Mono_Posix_SysConf__SC_FSYNC)
+#ifdef _SC_FSYNC
+               {*r = _SC_FSYNC; return 0;}
+#else /* def _SC_FSYNC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_FSYNC */
+       if (x == Mono_Posix_SysConf__SC_MAPPED_FILES)
+#ifdef _SC_MAPPED_FILES
+               {*r = _SC_MAPPED_FILES; return 0;}
+#else /* def _SC_MAPPED_FILES */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MAPPED_FILES */
+       if (x == Mono_Posix_SysConf__SC_MEMLOCK)
+#ifdef _SC_MEMLOCK
+               {*r = _SC_MEMLOCK; return 0;}
+#else /* def _SC_MEMLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MEMLOCK */
+       if (x == Mono_Posix_SysConf__SC_MEMLOCK_RANGE)
+#ifdef _SC_MEMLOCK_RANGE
+               {*r = _SC_MEMLOCK_RANGE; return 0;}
+#else /* def _SC_MEMLOCK_RANGE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MEMLOCK_RANGE */
+       if (x == Mono_Posix_SysConf__SC_MEMORY_PROTECTION)
+#ifdef _SC_MEMORY_PROTECTION
+               {*r = _SC_MEMORY_PROTECTION; return 0;}
+#else /* def _SC_MEMORY_PROTECTION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MEMORY_PROTECTION */
+       if (x == Mono_Posix_SysConf__SC_MESSAGE_PASSING)
+#ifdef _SC_MESSAGE_PASSING
+               {*r = _SC_MESSAGE_PASSING; return 0;}
+#else /* def _SC_MESSAGE_PASSING */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MESSAGE_PASSING */
+       if (x == Mono_Posix_SysConf__SC_SEMAPHORES)
+#ifdef _SC_SEMAPHORES
+               {*r = _SC_SEMAPHORES; return 0;}
+#else /* def _SC_SEMAPHORES */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SEMAPHORES */
+       if (x == Mono_Posix_SysConf__SC_SHARED_MEMORY_OBJECTS)
+#ifdef _SC_SHARED_MEMORY_OBJECTS
+               {*r = _SC_SHARED_MEMORY_OBJECTS; return 0;}
+#else /* def _SC_SHARED_MEMORY_OBJECTS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SHARED_MEMORY_OBJECTS */
+       if (x == Mono_Posix_SysConf__SC_AIO_LISTIO_MAX)
+#ifdef _SC_AIO_LISTIO_MAX
+               {*r = _SC_AIO_LISTIO_MAX; return 0;}
+#else /* def _SC_AIO_LISTIO_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_AIO_LISTIO_MAX */
+       if (x == Mono_Posix_SysConf__SC_AIO_MAX)
+#ifdef _SC_AIO_MAX
+               {*r = _SC_AIO_MAX; return 0;}
+#else /* def _SC_AIO_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_AIO_MAX */
+       if (x == Mono_Posix_SysConf__SC_AIO_PRIO_DELTA_MAX)
+#ifdef _SC_AIO_PRIO_DELTA_MAX
+               {*r = _SC_AIO_PRIO_DELTA_MAX; return 0;}
+#else /* def _SC_AIO_PRIO_DELTA_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_AIO_PRIO_DELTA_MAX */
+       if (x == Mono_Posix_SysConf__SC_DELAYTIMER_MAX)
+#ifdef _SC_DELAYTIMER_MAX
+               {*r = _SC_DELAYTIMER_MAX; return 0;}
+#else /* def _SC_DELAYTIMER_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_DELAYTIMER_MAX */
+       if (x == Mono_Posix_SysConf__SC_MQ_OPEN_MAX)
+#ifdef _SC_MQ_OPEN_MAX
+               {*r = _SC_MQ_OPEN_MAX; return 0;}
+#else /* def _SC_MQ_OPEN_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MQ_OPEN_MAX */
+       if (x == Mono_Posix_SysConf__SC_MQ_PRIO_MAX)
+#ifdef _SC_MQ_PRIO_MAX
+               {*r = _SC_MQ_PRIO_MAX; return 0;}
+#else /* def _SC_MQ_PRIO_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MQ_PRIO_MAX */
+       if (x == Mono_Posix_SysConf__SC_VERSION)
+#ifdef _SC_VERSION
+               {*r = _SC_VERSION; return 0;}
+#else /* def _SC_VERSION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_VERSION */
+       if (x == Mono_Posix_SysConf__SC_PAGESIZE)
+#ifdef _SC_PAGESIZE
+               {*r = _SC_PAGESIZE; return 0;}
+#else /* def _SC_PAGESIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PAGESIZE */
+       if (x == Mono_Posix_SysConf__SC_RTSIG_MAX)
+#ifdef _SC_RTSIG_MAX
+               {*r = _SC_RTSIG_MAX; return 0;}
+#else /* def _SC_RTSIG_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_RTSIG_MAX */
+       if (x == Mono_Posix_SysConf__SC_SEM_NSEMS_MAX)
+#ifdef _SC_SEM_NSEMS_MAX
+               {*r = _SC_SEM_NSEMS_MAX; return 0;}
+#else /* def _SC_SEM_NSEMS_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SEM_NSEMS_MAX */
+       if (x == Mono_Posix_SysConf__SC_SEM_VALUE_MAX)
+#ifdef _SC_SEM_VALUE_MAX
+               {*r = _SC_SEM_VALUE_MAX; return 0;}
+#else /* def _SC_SEM_VALUE_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SEM_VALUE_MAX */
+       if (x == Mono_Posix_SysConf__SC_SIGQUEUE_MAX)
+#ifdef _SC_SIGQUEUE_MAX
+               {*r = _SC_SIGQUEUE_MAX; return 0;}
+#else /* def _SC_SIGQUEUE_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SIGQUEUE_MAX */
+       if (x == Mono_Posix_SysConf__SC_TIMER_MAX)
+#ifdef _SC_TIMER_MAX
+               {*r = _SC_TIMER_MAX; return 0;}
+#else /* def _SC_TIMER_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TIMER_MAX */
+       if (x == Mono_Posix_SysConf__SC_BC_BASE_MAX)
+#ifdef _SC_BC_BASE_MAX
+               {*r = _SC_BC_BASE_MAX; return 0;}
+#else /* def _SC_BC_BASE_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_BC_BASE_MAX */
+       if (x == Mono_Posix_SysConf__SC_BC_DIM_MAX)
+#ifdef _SC_BC_DIM_MAX
+               {*r = _SC_BC_DIM_MAX; return 0;}
+#else /* def _SC_BC_DIM_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_BC_DIM_MAX */
+       if (x == Mono_Posix_SysConf__SC_BC_SCALE_MAX)
+#ifdef _SC_BC_SCALE_MAX
+               {*r = _SC_BC_SCALE_MAX; return 0;}
+#else /* def _SC_BC_SCALE_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_BC_SCALE_MAX */
+       if (x == Mono_Posix_SysConf__SC_BC_STRING_MAX)
+#ifdef _SC_BC_STRING_MAX
+               {*r = _SC_BC_STRING_MAX; return 0;}
+#else /* def _SC_BC_STRING_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_BC_STRING_MAX */
+       if (x == Mono_Posix_SysConf__SC_COLL_WEIGHTS_MAX)
+#ifdef _SC_COLL_WEIGHTS_MAX
+               {*r = _SC_COLL_WEIGHTS_MAX; return 0;}
+#else /* def _SC_COLL_WEIGHTS_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_COLL_WEIGHTS_MAX */
+       if (x == Mono_Posix_SysConf__SC_EQUIV_CLASS_MAX)
+#ifdef _SC_EQUIV_CLASS_MAX
+               {*r = _SC_EQUIV_CLASS_MAX; return 0;}
+#else /* def _SC_EQUIV_CLASS_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_EQUIV_CLASS_MAX */
+       if (x == Mono_Posix_SysConf__SC_EXPR_NEST_MAX)
+#ifdef _SC_EXPR_NEST_MAX
+               {*r = _SC_EXPR_NEST_MAX; return 0;}
+#else /* def _SC_EXPR_NEST_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_EXPR_NEST_MAX */
+       if (x == Mono_Posix_SysConf__SC_LINE_MAX)
+#ifdef _SC_LINE_MAX
+               {*r = _SC_LINE_MAX; return 0;}
+#else /* def _SC_LINE_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LINE_MAX */
+       if (x == Mono_Posix_SysConf__SC_RE_DUP_MAX)
+#ifdef _SC_RE_DUP_MAX
+               {*r = _SC_RE_DUP_MAX; return 0;}
+#else /* def _SC_RE_DUP_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_RE_DUP_MAX */
+       if (x == Mono_Posix_SysConf__SC_CHARCLASS_NAME_MAX)
+#ifdef _SC_CHARCLASS_NAME_MAX
+               {*r = _SC_CHARCLASS_NAME_MAX; return 0;}
+#else /* def _SC_CHARCLASS_NAME_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_CHARCLASS_NAME_MAX */
+       if (x == Mono_Posix_SysConf__SC_2_VERSION)
+#ifdef _SC_2_VERSION
+               {*r = _SC_2_VERSION; return 0;}
+#else /* def _SC_2_VERSION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_VERSION */
+       if (x == Mono_Posix_SysConf__SC_2_C_BIND)
+#ifdef _SC_2_C_BIND
+               {*r = _SC_2_C_BIND; return 0;}
+#else /* def _SC_2_C_BIND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_C_BIND */
+       if (x == Mono_Posix_SysConf__SC_2_C_DEV)
+#ifdef _SC_2_C_DEV
+               {*r = _SC_2_C_DEV; return 0;}
+#else /* def _SC_2_C_DEV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_C_DEV */
+       if (x == Mono_Posix_SysConf__SC_2_FORT_DEV)
+#ifdef _SC_2_FORT_DEV
+               {*r = _SC_2_FORT_DEV; return 0;}
+#else /* def _SC_2_FORT_DEV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_FORT_DEV */
+       if (x == Mono_Posix_SysConf__SC_2_FORT_RUN)
+#ifdef _SC_2_FORT_RUN
+               {*r = _SC_2_FORT_RUN; return 0;}
+#else /* def _SC_2_FORT_RUN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_FORT_RUN */
+       if (x == Mono_Posix_SysConf__SC_2_SW_DEV)
+#ifdef _SC_2_SW_DEV
+               {*r = _SC_2_SW_DEV; return 0;}
+#else /* def _SC_2_SW_DEV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_SW_DEV */
+       if (x == Mono_Posix_SysConf__SC_2_LOCALEDEF)
+#ifdef _SC_2_LOCALEDEF
+               {*r = _SC_2_LOCALEDEF; return 0;}
+#else /* def _SC_2_LOCALEDEF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_LOCALEDEF */
+       if (x == Mono_Posix_SysConf__SC_PII)
+#ifdef _SC_PII
+               {*r = _SC_PII; return 0;}
+#else /* def _SC_PII */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII */
+       if (x == Mono_Posix_SysConf__SC_PII_XTI)
+#ifdef _SC_PII_XTI
+               {*r = _SC_PII_XTI; return 0;}
+#else /* def _SC_PII_XTI */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_XTI */
+       if (x == Mono_Posix_SysConf__SC_PII_SOCKET)
+#ifdef _SC_PII_SOCKET
+               {*r = _SC_PII_SOCKET; return 0;}
+#else /* def _SC_PII_SOCKET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_SOCKET */
+       if (x == Mono_Posix_SysConf__SC_PII_INTERNET)
+#ifdef _SC_PII_INTERNET
+               {*r = _SC_PII_INTERNET; return 0;}
+#else /* def _SC_PII_INTERNET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_INTERNET */
+       if (x == Mono_Posix_SysConf__SC_PII_OSI)
+#ifdef _SC_PII_OSI
+               {*r = _SC_PII_OSI; return 0;}
+#else /* def _SC_PII_OSI */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_OSI */
+       if (x == Mono_Posix_SysConf__SC_POLL)
+#ifdef _SC_POLL
+               {*r = _SC_POLL; return 0;}
+#else /* def _SC_POLL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_POLL */
+       if (x == Mono_Posix_SysConf__SC_SELECT)
+#ifdef _SC_SELECT
+               {*r = _SC_SELECT; return 0;}
+#else /* def _SC_SELECT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SELECT */
+       if (x == Mono_Posix_SysConf__SC_UIO_MAXIOV)
+#ifdef _SC_UIO_MAXIOV
+               {*r = _SC_UIO_MAXIOV; return 0;}
+#else /* def _SC_UIO_MAXIOV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_UIO_MAXIOV */
+       if (x == Mono_Posix_SysConf__SC_IOV_MAX)
+#ifdef _SC_IOV_MAX
+               {*r = _SC_IOV_MAX; return 0;}
+#else /* def _SC_IOV_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_IOV_MAX */
+       if (x == Mono_Posix_SysConf__SC_PII_INTERNET_STREAM)
+#ifdef _SC_PII_INTERNET_STREAM
+               {*r = _SC_PII_INTERNET_STREAM; return 0;}
+#else /* def _SC_PII_INTERNET_STREAM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_INTERNET_STREAM */
+       if (x == Mono_Posix_SysConf__SC_PII_INTERNET_DGRAM)
+#ifdef _SC_PII_INTERNET_DGRAM
+               {*r = _SC_PII_INTERNET_DGRAM; return 0;}
+#else /* def _SC_PII_INTERNET_DGRAM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_INTERNET_DGRAM */
+       if (x == Mono_Posix_SysConf__SC_PII_OSI_COTS)
+#ifdef _SC_PII_OSI_COTS
+               {*r = _SC_PII_OSI_COTS; return 0;}
+#else /* def _SC_PII_OSI_COTS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_OSI_COTS */
+       if (x == Mono_Posix_SysConf__SC_PII_OSI_CLTS)
+#ifdef _SC_PII_OSI_CLTS
+               {*r = _SC_PII_OSI_CLTS; return 0;}
+#else /* def _SC_PII_OSI_CLTS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_OSI_CLTS */
+       if (x == Mono_Posix_SysConf__SC_PII_OSI_M)
+#ifdef _SC_PII_OSI_M
+               {*r = _SC_PII_OSI_M; return 0;}
+#else /* def _SC_PII_OSI_M */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PII_OSI_M */
+       if (x == Mono_Posix_SysConf__SC_T_IOV_MAX)
+#ifdef _SC_T_IOV_MAX
+               {*r = _SC_T_IOV_MAX; return 0;}
+#else /* def _SC_T_IOV_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_T_IOV_MAX */
+       if (x == Mono_Posix_SysConf__SC_THREADS)
+#ifdef _SC_THREADS
+               {*r = _SC_THREADS; return 0;}
+#else /* def _SC_THREADS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREADS */
+       if (x == Mono_Posix_SysConf__SC_THREAD_SAFE_FUNCTIONS)
+#ifdef _SC_THREAD_SAFE_FUNCTIONS
+               {*r = _SC_THREAD_SAFE_FUNCTIONS; return 0;}
+#else /* def _SC_THREAD_SAFE_FUNCTIONS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_SAFE_FUNCTIONS */
+       if (x == Mono_Posix_SysConf__SC_GETGR_R_SIZE_MAX)
+#ifdef _SC_GETGR_R_SIZE_MAX
+               {*r = _SC_GETGR_R_SIZE_MAX; return 0;}
+#else /* def _SC_GETGR_R_SIZE_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_GETGR_R_SIZE_MAX */
+       if (x == Mono_Posix_SysConf__SC_GETPW_R_SIZE_MAX)
+#ifdef _SC_GETPW_R_SIZE_MAX
+               {*r = _SC_GETPW_R_SIZE_MAX; return 0;}
+#else /* def _SC_GETPW_R_SIZE_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_GETPW_R_SIZE_MAX */
+       if (x == Mono_Posix_SysConf__SC_LOGIN_NAME_MAX)
+#ifdef _SC_LOGIN_NAME_MAX
+               {*r = _SC_LOGIN_NAME_MAX; return 0;}
+#else /* def _SC_LOGIN_NAME_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LOGIN_NAME_MAX */
+       if (x == Mono_Posix_SysConf__SC_TTY_NAME_MAX)
+#ifdef _SC_TTY_NAME_MAX
+               {*r = _SC_TTY_NAME_MAX; return 0;}
+#else /* def _SC_TTY_NAME_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TTY_NAME_MAX */
+       if (x == Mono_Posix_SysConf__SC_THREAD_DESTRUCTOR_ITERATIONS)
+#ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
+               {*r = _SC_THREAD_DESTRUCTOR_ITERATIONS; return 0;}
+#else /* def _SC_THREAD_DESTRUCTOR_ITERATIONS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_DESTRUCTOR_ITERATIONS */
+       if (x == Mono_Posix_SysConf__SC_THREAD_KEYS_MAX)
+#ifdef _SC_THREAD_KEYS_MAX
+               {*r = _SC_THREAD_KEYS_MAX; return 0;}
+#else /* def _SC_THREAD_KEYS_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_KEYS_MAX */
+       if (x == Mono_Posix_SysConf__SC_THREAD_STACK_MIN)
+#ifdef _SC_THREAD_STACK_MIN
+               {*r = _SC_THREAD_STACK_MIN; return 0;}
+#else /* def _SC_THREAD_STACK_MIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_STACK_MIN */
+       if (x == Mono_Posix_SysConf__SC_THREAD_THREADS_MAX)
+#ifdef _SC_THREAD_THREADS_MAX
+               {*r = _SC_THREAD_THREADS_MAX; return 0;}
+#else /* def _SC_THREAD_THREADS_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_THREADS_MAX */
+       if (x == Mono_Posix_SysConf__SC_THREAD_ATTR_STACKADDR)
+#ifdef _SC_THREAD_ATTR_STACKADDR
+               {*r = _SC_THREAD_ATTR_STACKADDR; return 0;}
+#else /* def _SC_THREAD_ATTR_STACKADDR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_ATTR_STACKADDR */
+       if (x == Mono_Posix_SysConf__SC_THREAD_ATTR_STACKSIZE)
+#ifdef _SC_THREAD_ATTR_STACKSIZE
+               {*r = _SC_THREAD_ATTR_STACKSIZE; return 0;}
+#else /* def _SC_THREAD_ATTR_STACKSIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_ATTR_STACKSIZE */
+       if (x == Mono_Posix_SysConf__SC_THREAD_PRIORITY_SCHEDULING)
+#ifdef _SC_THREAD_PRIORITY_SCHEDULING
+               {*r = _SC_THREAD_PRIORITY_SCHEDULING; return 0;}
+#else /* def _SC_THREAD_PRIORITY_SCHEDULING */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_PRIORITY_SCHEDULING */
+       if (x == Mono_Posix_SysConf__SC_THREAD_PRIO_INHERIT)
+#ifdef _SC_THREAD_PRIO_INHERIT
+               {*r = _SC_THREAD_PRIO_INHERIT; return 0;}
+#else /* def _SC_THREAD_PRIO_INHERIT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_PRIO_INHERIT */
+       if (x == Mono_Posix_SysConf__SC_THREAD_PRIO_PROTECT)
+#ifdef _SC_THREAD_PRIO_PROTECT
+               {*r = _SC_THREAD_PRIO_PROTECT; return 0;}
+#else /* def _SC_THREAD_PRIO_PROTECT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_PRIO_PROTECT */
+       if (x == Mono_Posix_SysConf__SC_THREAD_PROCESS_SHARED)
+#ifdef _SC_THREAD_PROCESS_SHARED
+               {*r = _SC_THREAD_PROCESS_SHARED; return 0;}
+#else /* def _SC_THREAD_PROCESS_SHARED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_PROCESS_SHARED */
+       if (x == Mono_Posix_SysConf__SC_NPROCESSORS_CONF)
+#ifdef _SC_NPROCESSORS_CONF
+               {*r = _SC_NPROCESSORS_CONF; return 0;}
+#else /* def _SC_NPROCESSORS_CONF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NPROCESSORS_CONF */
+       if (x == Mono_Posix_SysConf__SC_NPROCESSORS_ONLN)
+#ifdef _SC_NPROCESSORS_ONLN
+               {*r = _SC_NPROCESSORS_ONLN; return 0;}
+#else /* def _SC_NPROCESSORS_ONLN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NPROCESSORS_ONLN */
+       if (x == Mono_Posix_SysConf__SC_PHYS_PAGES)
+#ifdef _SC_PHYS_PAGES
+               {*r = _SC_PHYS_PAGES; return 0;}
+#else /* def _SC_PHYS_PAGES */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PHYS_PAGES */
+       if (x == Mono_Posix_SysConf__SC_AVPHYS_PAGES)
+#ifdef _SC_AVPHYS_PAGES
+               {*r = _SC_AVPHYS_PAGES; return 0;}
+#else /* def _SC_AVPHYS_PAGES */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_AVPHYS_PAGES */
+       if (x == Mono_Posix_SysConf__SC_ATEXIT_MAX)
+#ifdef _SC_ATEXIT_MAX
+               {*r = _SC_ATEXIT_MAX; return 0;}
+#else /* def _SC_ATEXIT_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_ATEXIT_MAX */
+       if (x == Mono_Posix_SysConf__SC_PASS_MAX)
+#ifdef _SC_PASS_MAX
+               {*r = _SC_PASS_MAX; return 0;}
+#else /* def _SC_PASS_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PASS_MAX */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_VERSION)
+#ifdef _SC_XOPEN_VERSION
+               {*r = _SC_XOPEN_VERSION; return 0;}
+#else /* def _SC_XOPEN_VERSION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_VERSION */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_XCU_VERSION)
+#ifdef _SC_XOPEN_XCU_VERSION
+               {*r = _SC_XOPEN_XCU_VERSION; return 0;}
+#else /* def _SC_XOPEN_XCU_VERSION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_XCU_VERSION */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_UNIX)
+#ifdef _SC_XOPEN_UNIX
+               {*r = _SC_XOPEN_UNIX; return 0;}
+#else /* def _SC_XOPEN_UNIX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_UNIX */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_CRYPT)
+#ifdef _SC_XOPEN_CRYPT
+               {*r = _SC_XOPEN_CRYPT; return 0;}
+#else /* def _SC_XOPEN_CRYPT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_CRYPT */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_ENH_I18N)
+#ifdef _SC_XOPEN_ENH_I18N
+               {*r = _SC_XOPEN_ENH_I18N; return 0;}
+#else /* def _SC_XOPEN_ENH_I18N */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_ENH_I18N */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_SHM)
+#ifdef _SC_XOPEN_SHM
+               {*r = _SC_XOPEN_SHM; return 0;}
+#else /* def _SC_XOPEN_SHM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_SHM */
+       if (x == Mono_Posix_SysConf__SC_2_CHAR_TERM)
+#ifdef _SC_2_CHAR_TERM
+               {*r = _SC_2_CHAR_TERM; return 0;}
+#else /* def _SC_2_CHAR_TERM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_CHAR_TERM */
+       if (x == Mono_Posix_SysConf__SC_2_C_VERSION)
+#ifdef _SC_2_C_VERSION
+               {*r = _SC_2_C_VERSION; return 0;}
+#else /* def _SC_2_C_VERSION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_C_VERSION */
+       if (x == Mono_Posix_SysConf__SC_2_UPE)
+#ifdef _SC_2_UPE
+               {*r = _SC_2_UPE; return 0;}
+#else /* def _SC_2_UPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_UPE */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_XPG2)
+#ifdef _SC_XOPEN_XPG2
+               {*r = _SC_XOPEN_XPG2; return 0;}
+#else /* def _SC_XOPEN_XPG2 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_XPG2 */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_XPG3)
+#ifdef _SC_XOPEN_XPG3
+               {*r = _SC_XOPEN_XPG3; return 0;}
+#else /* def _SC_XOPEN_XPG3 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_XPG3 */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_XPG4)
+#ifdef _SC_XOPEN_XPG4
+               {*r = _SC_XOPEN_XPG4; return 0;}
+#else /* def _SC_XOPEN_XPG4 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_XPG4 */
+       if (x == Mono_Posix_SysConf__SC_CHAR_BIT)
+#ifdef _SC_CHAR_BIT
+               {*r = _SC_CHAR_BIT; return 0;}
+#else /* def _SC_CHAR_BIT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_CHAR_BIT */
+       if (x == Mono_Posix_SysConf__SC_CHAR_MAX)
+#ifdef _SC_CHAR_MAX
+               {*r = _SC_CHAR_MAX; return 0;}
+#else /* def _SC_CHAR_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_CHAR_MAX */
+       if (x == Mono_Posix_SysConf__SC_CHAR_MIN)
+#ifdef _SC_CHAR_MIN
+               {*r = _SC_CHAR_MIN; return 0;}
+#else /* def _SC_CHAR_MIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_CHAR_MIN */
+       if (x == Mono_Posix_SysConf__SC_INT_MAX)
+#ifdef _SC_INT_MAX
+               {*r = _SC_INT_MAX; return 0;}
+#else /* def _SC_INT_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_INT_MAX */
+       if (x == Mono_Posix_SysConf__SC_INT_MIN)
+#ifdef _SC_INT_MIN
+               {*r = _SC_INT_MIN; return 0;}
+#else /* def _SC_INT_MIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_INT_MIN */
+       if (x == Mono_Posix_SysConf__SC_LONG_BIT)
+#ifdef _SC_LONG_BIT
+               {*r = _SC_LONG_BIT; return 0;}
+#else /* def _SC_LONG_BIT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LONG_BIT */
+       if (x == Mono_Posix_SysConf__SC_WORD_BIT)
+#ifdef _SC_WORD_BIT
+               {*r = _SC_WORD_BIT; return 0;}
+#else /* def _SC_WORD_BIT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_WORD_BIT */
+       if (x == Mono_Posix_SysConf__SC_MB_LEN_MAX)
+#ifdef _SC_MB_LEN_MAX
+               {*r = _SC_MB_LEN_MAX; return 0;}
+#else /* def _SC_MB_LEN_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MB_LEN_MAX */
+       if (x == Mono_Posix_SysConf__SC_NZERO)
+#ifdef _SC_NZERO
+               {*r = _SC_NZERO; return 0;}
+#else /* def _SC_NZERO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NZERO */
+       if (x == Mono_Posix_SysConf__SC_SSIZE_MAX)
+#ifdef _SC_SSIZE_MAX
+               {*r = _SC_SSIZE_MAX; return 0;}
+#else /* def _SC_SSIZE_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SSIZE_MAX */
+       if (x == Mono_Posix_SysConf__SC_SCHAR_MAX)
+#ifdef _SC_SCHAR_MAX
+               {*r = _SC_SCHAR_MAX; return 0;}
+#else /* def _SC_SCHAR_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SCHAR_MAX */
+       if (x == Mono_Posix_SysConf__SC_SCHAR_MIN)
+#ifdef _SC_SCHAR_MIN
+               {*r = _SC_SCHAR_MIN; return 0;}
+#else /* def _SC_SCHAR_MIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SCHAR_MIN */
+       if (x == Mono_Posix_SysConf__SC_SHRT_MAX)
+#ifdef _SC_SHRT_MAX
+               {*r = _SC_SHRT_MAX; return 0;}
+#else /* def _SC_SHRT_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SHRT_MAX */
+       if (x == Mono_Posix_SysConf__SC_SHRT_MIN)
+#ifdef _SC_SHRT_MIN
+               {*r = _SC_SHRT_MIN; return 0;}
+#else /* def _SC_SHRT_MIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SHRT_MIN */
+       if (x == Mono_Posix_SysConf__SC_UCHAR_MAX)
+#ifdef _SC_UCHAR_MAX
+               {*r = _SC_UCHAR_MAX; return 0;}
+#else /* def _SC_UCHAR_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_UCHAR_MAX */
+       if (x == Mono_Posix_SysConf__SC_UINT_MAX)
+#ifdef _SC_UINT_MAX
+               {*r = _SC_UINT_MAX; return 0;}
+#else /* def _SC_UINT_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_UINT_MAX */
+       if (x == Mono_Posix_SysConf__SC_ULONG_MAX)
+#ifdef _SC_ULONG_MAX
+               {*r = _SC_ULONG_MAX; return 0;}
+#else /* def _SC_ULONG_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_ULONG_MAX */
+       if (x == Mono_Posix_SysConf__SC_USHRT_MAX)
+#ifdef _SC_USHRT_MAX
+               {*r = _SC_USHRT_MAX; return 0;}
+#else /* def _SC_USHRT_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_USHRT_MAX */
+       if (x == Mono_Posix_SysConf__SC_NL_ARGMAX)
+#ifdef _SC_NL_ARGMAX
+               {*r = _SC_NL_ARGMAX; return 0;}
+#else /* def _SC_NL_ARGMAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NL_ARGMAX */
+       if (x == Mono_Posix_SysConf__SC_NL_LANGMAX)
+#ifdef _SC_NL_LANGMAX
+               {*r = _SC_NL_LANGMAX; return 0;}
+#else /* def _SC_NL_LANGMAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NL_LANGMAX */
+       if (x == Mono_Posix_SysConf__SC_NL_MSGMAX)
+#ifdef _SC_NL_MSGMAX
+               {*r = _SC_NL_MSGMAX; return 0;}
+#else /* def _SC_NL_MSGMAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NL_MSGMAX */
+       if (x == Mono_Posix_SysConf__SC_NL_NMAX)
+#ifdef _SC_NL_NMAX
+               {*r = _SC_NL_NMAX; return 0;}
+#else /* def _SC_NL_NMAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NL_NMAX */
+       if (x == Mono_Posix_SysConf__SC_NL_SETMAX)
+#ifdef _SC_NL_SETMAX
+               {*r = _SC_NL_SETMAX; return 0;}
+#else /* def _SC_NL_SETMAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NL_SETMAX */
+       if (x == Mono_Posix_SysConf__SC_NL_TEXTMAX)
+#ifdef _SC_NL_TEXTMAX
+               {*r = _SC_NL_TEXTMAX; return 0;}
+#else /* def _SC_NL_TEXTMAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NL_TEXTMAX */
+       if (x == Mono_Posix_SysConf__SC_XBS5_ILP32_OFF32)
+#ifdef _SC_XBS5_ILP32_OFF32
+               {*r = _SC_XBS5_ILP32_OFF32; return 0;}
+#else /* def _SC_XBS5_ILP32_OFF32 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XBS5_ILP32_OFF32 */
+       if (x == Mono_Posix_SysConf__SC_XBS5_ILP32_OFFBIG)
+#ifdef _SC_XBS5_ILP32_OFFBIG
+               {*r = _SC_XBS5_ILP32_OFFBIG; return 0;}
+#else /* def _SC_XBS5_ILP32_OFFBIG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XBS5_ILP32_OFFBIG */
+       if (x == Mono_Posix_SysConf__SC_XBS5_LP64_OFF64)
+#ifdef _SC_XBS5_LP64_OFF64
+               {*r = _SC_XBS5_LP64_OFF64; return 0;}
+#else /* def _SC_XBS5_LP64_OFF64 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XBS5_LP64_OFF64 */
+       if (x == Mono_Posix_SysConf__SC_XBS5_LPBIG_OFFBIG)
+#ifdef _SC_XBS5_LPBIG_OFFBIG
+               {*r = _SC_XBS5_LPBIG_OFFBIG; return 0;}
+#else /* def _SC_XBS5_LPBIG_OFFBIG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XBS5_LPBIG_OFFBIG */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_LEGACY)
+#ifdef _SC_XOPEN_LEGACY
+               {*r = _SC_XOPEN_LEGACY; return 0;}
+#else /* def _SC_XOPEN_LEGACY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_LEGACY */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_REALTIME)
+#ifdef _SC_XOPEN_REALTIME
+               {*r = _SC_XOPEN_REALTIME; return 0;}
+#else /* def _SC_XOPEN_REALTIME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_REALTIME */
+       if (x == Mono_Posix_SysConf__SC_XOPEN_REALTIME_THREADS)
+#ifdef _SC_XOPEN_REALTIME_THREADS
+               {*r = _SC_XOPEN_REALTIME_THREADS; return 0;}
+#else /* def _SC_XOPEN_REALTIME_THREADS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_XOPEN_REALTIME_THREADS */
+       if (x == Mono_Posix_SysConf__SC_ADVISORY_INFO)
+#ifdef _SC_ADVISORY_INFO
+               {*r = _SC_ADVISORY_INFO; return 0;}
+#else /* def _SC_ADVISORY_INFO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_ADVISORY_INFO */
+       if (x == Mono_Posix_SysConf__SC_BARRIERS)
+#ifdef _SC_BARRIERS
+               {*r = _SC_BARRIERS; return 0;}
+#else /* def _SC_BARRIERS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_BARRIERS */
+       if (x == Mono_Posix_SysConf__SC_BASE)
+#ifdef _SC_BASE
+               {*r = _SC_BASE; return 0;}
+#else /* def _SC_BASE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_BASE */
+       if (x == Mono_Posix_SysConf__SC_C_LANG_SUPPORT)
+#ifdef _SC_C_LANG_SUPPORT
+               {*r = _SC_C_LANG_SUPPORT; return 0;}
+#else /* def _SC_C_LANG_SUPPORT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_C_LANG_SUPPORT */
+       if (x == Mono_Posix_SysConf__SC_C_LANG_SUPPORT_R)
+#ifdef _SC_C_LANG_SUPPORT_R
+               {*r = _SC_C_LANG_SUPPORT_R; return 0;}
+#else /* def _SC_C_LANG_SUPPORT_R */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_C_LANG_SUPPORT_R */
+       if (x == Mono_Posix_SysConf__SC_CLOCK_SELECTION)
+#ifdef _SC_CLOCK_SELECTION
+               {*r = _SC_CLOCK_SELECTION; return 0;}
+#else /* def _SC_CLOCK_SELECTION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_CLOCK_SELECTION */
+       if (x == Mono_Posix_SysConf__SC_CPUTIME)
+#ifdef _SC_CPUTIME
+               {*r = _SC_CPUTIME; return 0;}
+#else /* def _SC_CPUTIME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_CPUTIME */
+       if (x == Mono_Posix_SysConf__SC_THREAD_CPUTIME)
+#ifdef _SC_THREAD_CPUTIME
+               {*r = _SC_THREAD_CPUTIME; return 0;}
+#else /* def _SC_THREAD_CPUTIME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_CPUTIME */
+       if (x == Mono_Posix_SysConf__SC_DEVICE_IO)
+#ifdef _SC_DEVICE_IO
+               {*r = _SC_DEVICE_IO; return 0;}
+#else /* def _SC_DEVICE_IO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_DEVICE_IO */
+       if (x == Mono_Posix_SysConf__SC_DEVICE_SPECIFIC)
+#ifdef _SC_DEVICE_SPECIFIC
+               {*r = _SC_DEVICE_SPECIFIC; return 0;}
+#else /* def _SC_DEVICE_SPECIFIC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_DEVICE_SPECIFIC */
+       if (x == Mono_Posix_SysConf__SC_DEVICE_SPECIFIC_R)
+#ifdef _SC_DEVICE_SPECIFIC_R
+               {*r = _SC_DEVICE_SPECIFIC_R; return 0;}
+#else /* def _SC_DEVICE_SPECIFIC_R */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_DEVICE_SPECIFIC_R */
+       if (x == Mono_Posix_SysConf__SC_FD_MGMT)
+#ifdef _SC_FD_MGMT
+               {*r = _SC_FD_MGMT; return 0;}
+#else /* def _SC_FD_MGMT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_FD_MGMT */
+       if (x == Mono_Posix_SysConf__SC_FIFO)
+#ifdef _SC_FIFO
+               {*r = _SC_FIFO; return 0;}
+#else /* def _SC_FIFO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_FIFO */
+       if (x == Mono_Posix_SysConf__SC_PIPE)
+#ifdef _SC_PIPE
+               {*r = _SC_PIPE; return 0;}
+#else /* def _SC_PIPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_PIPE */
+       if (x == Mono_Posix_SysConf__SC_FILE_ATTRIBUTES)
+#ifdef _SC_FILE_ATTRIBUTES
+               {*r = _SC_FILE_ATTRIBUTES; return 0;}
+#else /* def _SC_FILE_ATTRIBUTES */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_FILE_ATTRIBUTES */
+       if (x == Mono_Posix_SysConf__SC_FILE_LOCKING)
+#ifdef _SC_FILE_LOCKING
+               {*r = _SC_FILE_LOCKING; return 0;}
+#else /* def _SC_FILE_LOCKING */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_FILE_LOCKING */
+       if (x == Mono_Posix_SysConf__SC_FILE_SYSTEM)
+#ifdef _SC_FILE_SYSTEM
+               {*r = _SC_FILE_SYSTEM; return 0;}
+#else /* def _SC_FILE_SYSTEM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_FILE_SYSTEM */
+       if (x == Mono_Posix_SysConf__SC_MONOTONIC_CLOCK)
+#ifdef _SC_MONOTONIC_CLOCK
+               {*r = _SC_MONOTONIC_CLOCK; return 0;}
+#else /* def _SC_MONOTONIC_CLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MONOTONIC_CLOCK */
+       if (x == Mono_Posix_SysConf__SC_MULTI_PROCESS)
+#ifdef _SC_MULTI_PROCESS
+               {*r = _SC_MULTI_PROCESS; return 0;}
+#else /* def _SC_MULTI_PROCESS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_MULTI_PROCESS */
+       if (x == Mono_Posix_SysConf__SC_SINGLE_PROCESS)
+#ifdef _SC_SINGLE_PROCESS
+               {*r = _SC_SINGLE_PROCESS; return 0;}
+#else /* def _SC_SINGLE_PROCESS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SINGLE_PROCESS */
+       if (x == Mono_Posix_SysConf__SC_NETWORKING)
+#ifdef _SC_NETWORKING
+               {*r = _SC_NETWORKING; return 0;}
+#else /* def _SC_NETWORKING */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_NETWORKING */
+       if (x == Mono_Posix_SysConf__SC_READER_WRITER_LOCKS)
+#ifdef _SC_READER_WRITER_LOCKS
+               {*r = _SC_READER_WRITER_LOCKS; return 0;}
+#else /* def _SC_READER_WRITER_LOCKS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_READER_WRITER_LOCKS */
+       if (x == Mono_Posix_SysConf__SC_SPIN_LOCKS)
+#ifdef _SC_SPIN_LOCKS
+               {*r = _SC_SPIN_LOCKS; return 0;}
+#else /* def _SC_SPIN_LOCKS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SPIN_LOCKS */
+       if (x == Mono_Posix_SysConf__SC_REGEXP)
+#ifdef _SC_REGEXP
+               {*r = _SC_REGEXP; return 0;}
+#else /* def _SC_REGEXP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_REGEXP */
+       if (x == Mono_Posix_SysConf__SC_REGEX_VERSION)
+#ifdef _SC_REGEX_VERSION
+               {*r = _SC_REGEX_VERSION; return 0;}
+#else /* def _SC_REGEX_VERSION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_REGEX_VERSION */
+       if (x == Mono_Posix_SysConf__SC_SHELL)
+#ifdef _SC_SHELL
+               {*r = _SC_SHELL; return 0;}
+#else /* def _SC_SHELL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SHELL */
+       if (x == Mono_Posix_SysConf__SC_SIGNALS)
+#ifdef _SC_SIGNALS
+               {*r = _SC_SIGNALS; return 0;}
+#else /* def _SC_SIGNALS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SIGNALS */
+       if (x == Mono_Posix_SysConf__SC_SPAWN)
+#ifdef _SC_SPAWN
+               {*r = _SC_SPAWN; return 0;}
+#else /* def _SC_SPAWN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SPAWN */
+       if (x == Mono_Posix_SysConf__SC_SPORADIC_SERVER)
+#ifdef _SC_SPORADIC_SERVER
+               {*r = _SC_SPORADIC_SERVER; return 0;}
+#else /* def _SC_SPORADIC_SERVER */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SPORADIC_SERVER */
+       if (x == Mono_Posix_SysConf__SC_THREAD_SPORADIC_SERVER)
+#ifdef _SC_THREAD_SPORADIC_SERVER
+               {*r = _SC_THREAD_SPORADIC_SERVER; return 0;}
+#else /* def _SC_THREAD_SPORADIC_SERVER */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_THREAD_SPORADIC_SERVER */
+       if (x == Mono_Posix_SysConf__SC_SYSTEM_DATABASE)
+#ifdef _SC_SYSTEM_DATABASE
+               {*r = _SC_SYSTEM_DATABASE; return 0;}
+#else /* def _SC_SYSTEM_DATABASE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SYSTEM_DATABASE */
+       if (x == Mono_Posix_SysConf__SC_SYSTEM_DATABASE_R)
+#ifdef _SC_SYSTEM_DATABASE_R
+               {*r = _SC_SYSTEM_DATABASE_R; return 0;}
+#else /* def _SC_SYSTEM_DATABASE_R */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SYSTEM_DATABASE_R */
+       if (x == Mono_Posix_SysConf__SC_TIMEOUTS)
+#ifdef _SC_TIMEOUTS
+               {*r = _SC_TIMEOUTS; return 0;}
+#else /* def _SC_TIMEOUTS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TIMEOUTS */
+       if (x == Mono_Posix_SysConf__SC_TYPED_MEMORY_OBJECTS)
+#ifdef _SC_TYPED_MEMORY_OBJECTS
+               {*r = _SC_TYPED_MEMORY_OBJECTS; return 0;}
+#else /* def _SC_TYPED_MEMORY_OBJECTS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TYPED_MEMORY_OBJECTS */
+       if (x == Mono_Posix_SysConf__SC_USER_GROUPS)
+#ifdef _SC_USER_GROUPS
+               {*r = _SC_USER_GROUPS; return 0;}
+#else /* def _SC_USER_GROUPS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_USER_GROUPS */
+       if (x == Mono_Posix_SysConf__SC_USER_GROUPS_R)
+#ifdef _SC_USER_GROUPS_R
+               {*r = _SC_USER_GROUPS_R; return 0;}
+#else /* def _SC_USER_GROUPS_R */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_USER_GROUPS_R */
+       if (x == Mono_Posix_SysConf__SC_2_PBS)
+#ifdef _SC_2_PBS
+               {*r = _SC_2_PBS; return 0;}
+#else /* def _SC_2_PBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_PBS */
+       if (x == Mono_Posix_SysConf__SC_2_PBS_ACCOUNTING)
+#ifdef _SC_2_PBS_ACCOUNTING
+               {*r = _SC_2_PBS_ACCOUNTING; return 0;}
+#else /* def _SC_2_PBS_ACCOUNTING */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_PBS_ACCOUNTING */
+       if (x == Mono_Posix_SysConf__SC_2_PBS_LOCATE)
+#ifdef _SC_2_PBS_LOCATE
+               {*r = _SC_2_PBS_LOCATE; return 0;}
+#else /* def _SC_2_PBS_LOCATE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_PBS_LOCATE */
+       if (x == Mono_Posix_SysConf__SC_2_PBS_MESSAGE)
+#ifdef _SC_2_PBS_MESSAGE
+               {*r = _SC_2_PBS_MESSAGE; return 0;}
+#else /* def _SC_2_PBS_MESSAGE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_PBS_MESSAGE */
+       if (x == Mono_Posix_SysConf__SC_2_PBS_TRACK)
+#ifdef _SC_2_PBS_TRACK
+               {*r = _SC_2_PBS_TRACK; return 0;}
+#else /* def _SC_2_PBS_TRACK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_PBS_TRACK */
+       if (x == Mono_Posix_SysConf__SC_SYMLOOP_MAX)
+#ifdef _SC_SYMLOOP_MAX
+               {*r = _SC_SYMLOOP_MAX; return 0;}
+#else /* def _SC_SYMLOOP_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_SYMLOOP_MAX */
+       if (x == Mono_Posix_SysConf__SC_STREAMS)
+#ifdef _SC_STREAMS
+               {*r = _SC_STREAMS; return 0;}
+#else /* def _SC_STREAMS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_STREAMS */
+       if (x == Mono_Posix_SysConf__SC_2_PBS_CHECKPOINT)
+#ifdef _SC_2_PBS_CHECKPOINT
+               {*r = _SC_2_PBS_CHECKPOINT; return 0;}
+#else /* def _SC_2_PBS_CHECKPOINT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_2_PBS_CHECKPOINT */
+       if (x == Mono_Posix_SysConf__SC_V6_ILP32_OFF32)
+#ifdef _SC_V6_ILP32_OFF32
+               {*r = _SC_V6_ILP32_OFF32; return 0;}
+#else /* def _SC_V6_ILP32_OFF32 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_V6_ILP32_OFF32 */
+       if (x == Mono_Posix_SysConf__SC_V6_ILP32_OFFBIG)
+#ifdef _SC_V6_ILP32_OFFBIG
+               {*r = _SC_V6_ILP32_OFFBIG; return 0;}
+#else /* def _SC_V6_ILP32_OFFBIG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_V6_ILP32_OFFBIG */
+       if (x == Mono_Posix_SysConf__SC_V6_LP64_OFF64)
+#ifdef _SC_V6_LP64_OFF64
+               {*r = _SC_V6_LP64_OFF64; return 0;}
+#else /* def _SC_V6_LP64_OFF64 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_V6_LP64_OFF64 */
+       if (x == Mono_Posix_SysConf__SC_V6_LPBIG_OFFBIG)
+#ifdef _SC_V6_LPBIG_OFFBIG
+               {*r = _SC_V6_LPBIG_OFFBIG; return 0;}
+#else /* def _SC_V6_LPBIG_OFFBIG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_V6_LPBIG_OFFBIG */
+       if (x == Mono_Posix_SysConf__SC_HOST_NAME_MAX)
+#ifdef _SC_HOST_NAME_MAX
+               {*r = _SC_HOST_NAME_MAX; return 0;}
+#else /* def _SC_HOST_NAME_MAX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_HOST_NAME_MAX */
+       if (x == Mono_Posix_SysConf__SC_TRACE)
+#ifdef _SC_TRACE
+               {*r = _SC_TRACE; return 0;}
+#else /* def _SC_TRACE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TRACE */
+       if (x == Mono_Posix_SysConf__SC_TRACE_EVENT_FILTER)
+#ifdef _SC_TRACE_EVENT_FILTER
+               {*r = _SC_TRACE_EVENT_FILTER; return 0;}
+#else /* def _SC_TRACE_EVENT_FILTER */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TRACE_EVENT_FILTER */
+       if (x == Mono_Posix_SysConf__SC_TRACE_INHERIT)
+#ifdef _SC_TRACE_INHERIT
+               {*r = _SC_TRACE_INHERIT; return 0;}
+#else /* def _SC_TRACE_INHERIT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TRACE_INHERIT */
+       if (x == Mono_Posix_SysConf__SC_TRACE_LOG)
+#ifdef _SC_TRACE_LOG
+               {*r = _SC_TRACE_LOG; return 0;}
+#else /* def _SC_TRACE_LOG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_TRACE_LOG */
+       if (x == Mono_Posix_SysConf__SC_LEVEL1_ICACHE_SIZE)
+#ifdef _SC_LEVEL1_ICACHE_SIZE
+               {*r = _SC_LEVEL1_ICACHE_SIZE; return 0;}
+#else /* def _SC_LEVEL1_ICACHE_SIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL1_ICACHE_SIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL1_ICACHE_ASSOC)
+#ifdef _SC_LEVEL1_ICACHE_ASSOC
+               {*r = _SC_LEVEL1_ICACHE_ASSOC; return 0;}
+#else /* def _SC_LEVEL1_ICACHE_ASSOC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL1_ICACHE_ASSOC */
+       if (x == Mono_Posix_SysConf__SC_LEVEL1_ICACHE_LINESIZE)
+#ifdef _SC_LEVEL1_ICACHE_LINESIZE
+               {*r = _SC_LEVEL1_ICACHE_LINESIZE; return 0;}
+#else /* def _SC_LEVEL1_ICACHE_LINESIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL1_ICACHE_LINESIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL1_DCACHE_SIZE)
+#ifdef _SC_LEVEL1_DCACHE_SIZE
+               {*r = _SC_LEVEL1_DCACHE_SIZE; return 0;}
+#else /* def _SC_LEVEL1_DCACHE_SIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL1_DCACHE_SIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL1_DCACHE_ASSOC)
+#ifdef _SC_LEVEL1_DCACHE_ASSOC
+               {*r = _SC_LEVEL1_DCACHE_ASSOC; return 0;}
+#else /* def _SC_LEVEL1_DCACHE_ASSOC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL1_DCACHE_ASSOC */
+       if (x == Mono_Posix_SysConf__SC_LEVEL1_DCACHE_LINESIZE)
+#ifdef _SC_LEVEL1_DCACHE_LINESIZE
+               {*r = _SC_LEVEL1_DCACHE_LINESIZE; return 0;}
+#else /* def _SC_LEVEL1_DCACHE_LINESIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL1_DCACHE_LINESIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL2_CACHE_SIZE)
+#ifdef _SC_LEVEL2_CACHE_SIZE
+               {*r = _SC_LEVEL2_CACHE_SIZE; return 0;}
+#else /* def _SC_LEVEL2_CACHE_SIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL2_CACHE_SIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL2_CACHE_ASSOC)
+#ifdef _SC_LEVEL2_CACHE_ASSOC
+               {*r = _SC_LEVEL2_CACHE_ASSOC; return 0;}
+#else /* def _SC_LEVEL2_CACHE_ASSOC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL2_CACHE_ASSOC */
+       if (x == Mono_Posix_SysConf__SC_LEVEL2_CACHE_LINESIZE)
+#ifdef _SC_LEVEL2_CACHE_LINESIZE
+               {*r = _SC_LEVEL2_CACHE_LINESIZE; return 0;}
+#else /* def _SC_LEVEL2_CACHE_LINESIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL2_CACHE_LINESIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL3_CACHE_SIZE)
+#ifdef _SC_LEVEL3_CACHE_SIZE
+               {*r = _SC_LEVEL3_CACHE_SIZE; return 0;}
+#else /* def _SC_LEVEL3_CACHE_SIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL3_CACHE_SIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL3_CACHE_ASSOC)
+#ifdef _SC_LEVEL3_CACHE_ASSOC
+               {*r = _SC_LEVEL3_CACHE_ASSOC; return 0;}
+#else /* def _SC_LEVEL3_CACHE_ASSOC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL3_CACHE_ASSOC */
+       if (x == Mono_Posix_SysConf__SC_LEVEL3_CACHE_LINESIZE)
+#ifdef _SC_LEVEL3_CACHE_LINESIZE
+               {*r = _SC_LEVEL3_CACHE_LINESIZE; return 0;}
+#else /* def _SC_LEVEL3_CACHE_LINESIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL3_CACHE_LINESIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL4_CACHE_SIZE)
+#ifdef _SC_LEVEL4_CACHE_SIZE
+               {*r = _SC_LEVEL4_CACHE_SIZE; return 0;}
+#else /* def _SC_LEVEL4_CACHE_SIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL4_CACHE_SIZE */
+       if (x == Mono_Posix_SysConf__SC_LEVEL4_CACHE_ASSOC)
+#ifdef _SC_LEVEL4_CACHE_ASSOC
+               {*r = _SC_LEVEL4_CACHE_ASSOC; return 0;}
+#else /* def _SC_LEVEL4_CACHE_ASSOC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL4_CACHE_ASSOC */
+       if (x == Mono_Posix_SysConf__SC_LEVEL4_CACHE_LINESIZE)
+#ifdef _SC_LEVEL4_CACHE_LINESIZE
+               {*r = _SC_LEVEL4_CACHE_LINESIZE; return 0;}
+#else /* def _SC_LEVEL4_CACHE_LINESIZE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _SC_LEVEL4_CACHE_LINESIZE */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToSysConf (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef _SC_ARG_MAX
+       if (x == _SC_ARG_MAX)
+               {*r = Mono_Posix_SysConf__SC_ARG_MAX; return 0;}
+#endif /* ndef _SC_ARG_MAX */
+#ifdef _SC_CHILD_MAX
+       if (x == _SC_CHILD_MAX)
+               {*r = Mono_Posix_SysConf__SC_CHILD_MAX; return 0;}
+#endif /* ndef _SC_CHILD_MAX */
+#ifdef _SC_CLK_TCK
+       if (x == _SC_CLK_TCK)
+               {*r = Mono_Posix_SysConf__SC_CLK_TCK; return 0;}
+#endif /* ndef _SC_CLK_TCK */
+#ifdef _SC_NGROUPS_MAX
+       if (x == _SC_NGROUPS_MAX)
+               {*r = Mono_Posix_SysConf__SC_NGROUPS_MAX; return 0;}
+#endif /* ndef _SC_NGROUPS_MAX */
+#ifdef _SC_OPEN_MAX
+       if (x == _SC_OPEN_MAX)
+               {*r = Mono_Posix_SysConf__SC_OPEN_MAX; return 0;}
+#endif /* ndef _SC_OPEN_MAX */
+#ifdef _SC_STREAM_MAX
+       if (x == _SC_STREAM_MAX)
+               {*r = Mono_Posix_SysConf__SC_STREAM_MAX; return 0;}
+#endif /* ndef _SC_STREAM_MAX */
+#ifdef _SC_TZNAME_MAX
+       if (x == _SC_TZNAME_MAX)
+               {*r = Mono_Posix_SysConf__SC_TZNAME_MAX; return 0;}
+#endif /* ndef _SC_TZNAME_MAX */
+#ifdef _SC_JOB_CONTROL
+       if (x == _SC_JOB_CONTROL)
+               {*r = Mono_Posix_SysConf__SC_JOB_CONTROL; return 0;}
+#endif /* ndef _SC_JOB_CONTROL */
+#ifdef _SC_SAVED_IDS
+       if (x == _SC_SAVED_IDS)
+               {*r = Mono_Posix_SysConf__SC_SAVED_IDS; return 0;}
+#endif /* ndef _SC_SAVED_IDS */
+#ifdef _SC_REALTIME_SIGNALS
+       if (x == _SC_REALTIME_SIGNALS)
+               {*r = Mono_Posix_SysConf__SC_REALTIME_SIGNALS; return 0;}
+#endif /* ndef _SC_REALTIME_SIGNALS */
+#ifdef _SC_PRIORITY_SCHEDULING
+       if (x == _SC_PRIORITY_SCHEDULING)
+               {*r = Mono_Posix_SysConf__SC_PRIORITY_SCHEDULING; return 0;}
+#endif /* ndef _SC_PRIORITY_SCHEDULING */
+#ifdef _SC_TIMERS
+       if (x == _SC_TIMERS)
+               {*r = Mono_Posix_SysConf__SC_TIMERS; return 0;}
+#endif /* ndef _SC_TIMERS */
+#ifdef _SC_ASYNCHRONOUS_IO
+       if (x == _SC_ASYNCHRONOUS_IO)
+               {*r = Mono_Posix_SysConf__SC_ASYNCHRONOUS_IO; return 0;}
+#endif /* ndef _SC_ASYNCHRONOUS_IO */
+#ifdef _SC_PRIORITIZED_IO
+       if (x == _SC_PRIORITIZED_IO)
+               {*r = Mono_Posix_SysConf__SC_PRIORITIZED_IO; return 0;}
+#endif /* ndef _SC_PRIORITIZED_IO */
+#ifdef _SC_SYNCHRONIZED_IO
+       if (x == _SC_SYNCHRONIZED_IO)
+               {*r = Mono_Posix_SysConf__SC_SYNCHRONIZED_IO; return 0;}
+#endif /* ndef _SC_SYNCHRONIZED_IO */
+#ifdef _SC_FSYNC
+       if (x == _SC_FSYNC)
+               {*r = Mono_Posix_SysConf__SC_FSYNC; return 0;}
+#endif /* ndef _SC_FSYNC */
+#ifdef _SC_MAPPED_FILES
+       if (x == _SC_MAPPED_FILES)
+               {*r = Mono_Posix_SysConf__SC_MAPPED_FILES; return 0;}
+#endif /* ndef _SC_MAPPED_FILES */
+#ifdef _SC_MEMLOCK
+       if (x == _SC_MEMLOCK)
+               {*r = Mono_Posix_SysConf__SC_MEMLOCK; return 0;}
+#endif /* ndef _SC_MEMLOCK */
+#ifdef _SC_MEMLOCK_RANGE
+       if (x == _SC_MEMLOCK_RANGE)
+               {*r = Mono_Posix_SysConf__SC_MEMLOCK_RANGE; return 0;}
+#endif /* ndef _SC_MEMLOCK_RANGE */
+#ifdef _SC_MEMORY_PROTECTION
+       if (x == _SC_MEMORY_PROTECTION)
+               {*r = Mono_Posix_SysConf__SC_MEMORY_PROTECTION; return 0;}
+#endif /* ndef _SC_MEMORY_PROTECTION */
+#ifdef _SC_MESSAGE_PASSING
+       if (x == _SC_MESSAGE_PASSING)
+               {*r = Mono_Posix_SysConf__SC_MESSAGE_PASSING; return 0;}
+#endif /* ndef _SC_MESSAGE_PASSING */
+#ifdef _SC_SEMAPHORES
+       if (x == _SC_SEMAPHORES)
+               {*r = Mono_Posix_SysConf__SC_SEMAPHORES; return 0;}
+#endif /* ndef _SC_SEMAPHORES */
+#ifdef _SC_SHARED_MEMORY_OBJECTS
+       if (x == _SC_SHARED_MEMORY_OBJECTS)
+               {*r = Mono_Posix_SysConf__SC_SHARED_MEMORY_OBJECTS; return 0;}
+#endif /* ndef _SC_SHARED_MEMORY_OBJECTS */
+#ifdef _SC_AIO_LISTIO_MAX
+       if (x == _SC_AIO_LISTIO_MAX)
+               {*r = Mono_Posix_SysConf__SC_AIO_LISTIO_MAX; return 0;}
+#endif /* ndef _SC_AIO_LISTIO_MAX */
+#ifdef _SC_AIO_MAX
+       if (x == _SC_AIO_MAX)
+               {*r = Mono_Posix_SysConf__SC_AIO_MAX; return 0;}
+#endif /* ndef _SC_AIO_MAX */
+#ifdef _SC_AIO_PRIO_DELTA_MAX
+       if (x == _SC_AIO_PRIO_DELTA_MAX)
+               {*r = Mono_Posix_SysConf__SC_AIO_PRIO_DELTA_MAX; return 0;}
+#endif /* ndef _SC_AIO_PRIO_DELTA_MAX */
+#ifdef _SC_DELAYTIMER_MAX
+       if (x == _SC_DELAYTIMER_MAX)
+               {*r = Mono_Posix_SysConf__SC_DELAYTIMER_MAX; return 0;}
+#endif /* ndef _SC_DELAYTIMER_MAX */
+#ifdef _SC_MQ_OPEN_MAX
+       if (x == _SC_MQ_OPEN_MAX)
+               {*r = Mono_Posix_SysConf__SC_MQ_OPEN_MAX; return 0;}
+#endif /* ndef _SC_MQ_OPEN_MAX */
+#ifdef _SC_MQ_PRIO_MAX
+       if (x == _SC_MQ_PRIO_MAX)
+               {*r = Mono_Posix_SysConf__SC_MQ_PRIO_MAX; return 0;}
+#endif /* ndef _SC_MQ_PRIO_MAX */
+#ifdef _SC_VERSION
+       if (x == _SC_VERSION)
+               {*r = Mono_Posix_SysConf__SC_VERSION; return 0;}
+#endif /* ndef _SC_VERSION */
+#ifdef _SC_PAGESIZE
+       if (x == _SC_PAGESIZE)
+               {*r = Mono_Posix_SysConf__SC_PAGESIZE; return 0;}
+#endif /* ndef _SC_PAGESIZE */
+#ifdef _SC_RTSIG_MAX
+       if (x == _SC_RTSIG_MAX)
+               {*r = Mono_Posix_SysConf__SC_RTSIG_MAX; return 0;}
+#endif /* ndef _SC_RTSIG_MAX */
+#ifdef _SC_SEM_NSEMS_MAX
+       if (x == _SC_SEM_NSEMS_MAX)
+               {*r = Mono_Posix_SysConf__SC_SEM_NSEMS_MAX; return 0;}
+#endif /* ndef _SC_SEM_NSEMS_MAX */
+#ifdef _SC_SEM_VALUE_MAX
+       if (x == _SC_SEM_VALUE_MAX)
+               {*r = Mono_Posix_SysConf__SC_SEM_VALUE_MAX; return 0;}
+#endif /* ndef _SC_SEM_VALUE_MAX */
+#ifdef _SC_SIGQUEUE_MAX
+       if (x == _SC_SIGQUEUE_MAX)
+               {*r = Mono_Posix_SysConf__SC_SIGQUEUE_MAX; return 0;}
+#endif /* ndef _SC_SIGQUEUE_MAX */
+#ifdef _SC_TIMER_MAX
+       if (x == _SC_TIMER_MAX)
+               {*r = Mono_Posix_SysConf__SC_TIMER_MAX; return 0;}
+#endif /* ndef _SC_TIMER_MAX */
+#ifdef _SC_BC_BASE_MAX
+       if (x == _SC_BC_BASE_MAX)
+               {*r = Mono_Posix_SysConf__SC_BC_BASE_MAX; return 0;}
+#endif /* ndef _SC_BC_BASE_MAX */
+#ifdef _SC_BC_DIM_MAX
+       if (x == _SC_BC_DIM_MAX)
+               {*r = Mono_Posix_SysConf__SC_BC_DIM_MAX; return 0;}
+#endif /* ndef _SC_BC_DIM_MAX */
+#ifdef _SC_BC_SCALE_MAX
+       if (x == _SC_BC_SCALE_MAX)
+               {*r = Mono_Posix_SysConf__SC_BC_SCALE_MAX; return 0;}
+#endif /* ndef _SC_BC_SCALE_MAX */
+#ifdef _SC_BC_STRING_MAX
+       if (x == _SC_BC_STRING_MAX)
+               {*r = Mono_Posix_SysConf__SC_BC_STRING_MAX; return 0;}
+#endif /* ndef _SC_BC_STRING_MAX */
+#ifdef _SC_COLL_WEIGHTS_MAX
+       if (x == _SC_COLL_WEIGHTS_MAX)
+               {*r = Mono_Posix_SysConf__SC_COLL_WEIGHTS_MAX; return 0;}
+#endif /* ndef _SC_COLL_WEIGHTS_MAX */
+#ifdef _SC_EQUIV_CLASS_MAX
+       if (x == _SC_EQUIV_CLASS_MAX)
+               {*r = Mono_Posix_SysConf__SC_EQUIV_CLASS_MAX; return 0;}
+#endif /* ndef _SC_EQUIV_CLASS_MAX */
+#ifdef _SC_EXPR_NEST_MAX
+       if (x == _SC_EXPR_NEST_MAX)
+               {*r = Mono_Posix_SysConf__SC_EXPR_NEST_MAX; return 0;}
+#endif /* ndef _SC_EXPR_NEST_MAX */
+#ifdef _SC_LINE_MAX
+       if (x == _SC_LINE_MAX)
+               {*r = Mono_Posix_SysConf__SC_LINE_MAX; return 0;}
+#endif /* ndef _SC_LINE_MAX */
+#ifdef _SC_RE_DUP_MAX
+       if (x == _SC_RE_DUP_MAX)
+               {*r = Mono_Posix_SysConf__SC_RE_DUP_MAX; return 0;}
+#endif /* ndef _SC_RE_DUP_MAX */
+#ifdef _SC_CHARCLASS_NAME_MAX
+       if (x == _SC_CHARCLASS_NAME_MAX)
+               {*r = Mono_Posix_SysConf__SC_CHARCLASS_NAME_MAX; return 0;}
+#endif /* ndef _SC_CHARCLASS_NAME_MAX */
+#ifdef _SC_2_VERSION
+       if (x == _SC_2_VERSION)
+               {*r = Mono_Posix_SysConf__SC_2_VERSION; return 0;}
+#endif /* ndef _SC_2_VERSION */
+#ifdef _SC_2_C_BIND
+       if (x == _SC_2_C_BIND)
+               {*r = Mono_Posix_SysConf__SC_2_C_BIND; return 0;}
+#endif /* ndef _SC_2_C_BIND */
+#ifdef _SC_2_C_DEV
+       if (x == _SC_2_C_DEV)
+               {*r = Mono_Posix_SysConf__SC_2_C_DEV; return 0;}
+#endif /* ndef _SC_2_C_DEV */
+#ifdef _SC_2_FORT_DEV
+       if (x == _SC_2_FORT_DEV)
+               {*r = Mono_Posix_SysConf__SC_2_FORT_DEV; return 0;}
+#endif /* ndef _SC_2_FORT_DEV */
+#ifdef _SC_2_FORT_RUN
+       if (x == _SC_2_FORT_RUN)
+               {*r = Mono_Posix_SysConf__SC_2_FORT_RUN; return 0;}
+#endif /* ndef _SC_2_FORT_RUN */
+#ifdef _SC_2_SW_DEV
+       if (x == _SC_2_SW_DEV)
+               {*r = Mono_Posix_SysConf__SC_2_SW_DEV; return 0;}
+#endif /* ndef _SC_2_SW_DEV */
+#ifdef _SC_2_LOCALEDEF
+       if (x == _SC_2_LOCALEDEF)
+               {*r = Mono_Posix_SysConf__SC_2_LOCALEDEF; return 0;}
+#endif /* ndef _SC_2_LOCALEDEF */
+#ifdef _SC_PII
+       if (x == _SC_PII)
+               {*r = Mono_Posix_SysConf__SC_PII; return 0;}
+#endif /* ndef _SC_PII */
+#ifdef _SC_PII_XTI
+       if (x == _SC_PII_XTI)
+               {*r = Mono_Posix_SysConf__SC_PII_XTI; return 0;}
+#endif /* ndef _SC_PII_XTI */
+#ifdef _SC_PII_SOCKET
+       if (x == _SC_PII_SOCKET)
+               {*r = Mono_Posix_SysConf__SC_PII_SOCKET; return 0;}
+#endif /* ndef _SC_PII_SOCKET */
+#ifdef _SC_PII_INTERNET
+       if (x == _SC_PII_INTERNET)
+               {*r = Mono_Posix_SysConf__SC_PII_INTERNET; return 0;}
+#endif /* ndef _SC_PII_INTERNET */
+#ifdef _SC_PII_OSI
+       if (x == _SC_PII_OSI)
+               {*r = Mono_Posix_SysConf__SC_PII_OSI; return 0;}
+#endif /* ndef _SC_PII_OSI */
+#ifdef _SC_POLL
+       if (x == _SC_POLL)
+               {*r = Mono_Posix_SysConf__SC_POLL; return 0;}
+#endif /* ndef _SC_POLL */
+#ifdef _SC_SELECT
+       if (x == _SC_SELECT)
+               {*r = Mono_Posix_SysConf__SC_SELECT; return 0;}
+#endif /* ndef _SC_SELECT */
+#ifdef _SC_UIO_MAXIOV
+       if (x == _SC_UIO_MAXIOV)
+               {*r = Mono_Posix_SysConf__SC_UIO_MAXIOV; return 0;}
+#endif /* ndef _SC_UIO_MAXIOV */
+#ifdef _SC_IOV_MAX
+       if (x == _SC_IOV_MAX)
+               {*r = Mono_Posix_SysConf__SC_IOV_MAX; return 0;}
+#endif /* ndef _SC_IOV_MAX */
+#ifdef _SC_PII_INTERNET_STREAM
+       if (x == _SC_PII_INTERNET_STREAM)
+               {*r = Mono_Posix_SysConf__SC_PII_INTERNET_STREAM; return 0;}
+#endif /* ndef _SC_PII_INTERNET_STREAM */
+#ifdef _SC_PII_INTERNET_DGRAM
+       if (x == _SC_PII_INTERNET_DGRAM)
+               {*r = Mono_Posix_SysConf__SC_PII_INTERNET_DGRAM; return 0;}
+#endif /* ndef _SC_PII_INTERNET_DGRAM */
+#ifdef _SC_PII_OSI_COTS
+       if (x == _SC_PII_OSI_COTS)
+               {*r = Mono_Posix_SysConf__SC_PII_OSI_COTS; return 0;}
+#endif /* ndef _SC_PII_OSI_COTS */
+#ifdef _SC_PII_OSI_CLTS
+       if (x == _SC_PII_OSI_CLTS)
+               {*r = Mono_Posix_SysConf__SC_PII_OSI_CLTS; return 0;}
+#endif /* ndef _SC_PII_OSI_CLTS */
+#ifdef _SC_PII_OSI_M
+       if (x == _SC_PII_OSI_M)
+               {*r = Mono_Posix_SysConf__SC_PII_OSI_M; return 0;}
+#endif /* ndef _SC_PII_OSI_M */
+#ifdef _SC_T_IOV_MAX
+       if (x == _SC_T_IOV_MAX)
+               {*r = Mono_Posix_SysConf__SC_T_IOV_MAX; return 0;}
+#endif /* ndef _SC_T_IOV_MAX */
+#ifdef _SC_THREADS
+       if (x == _SC_THREADS)
+               {*r = Mono_Posix_SysConf__SC_THREADS; return 0;}
+#endif /* ndef _SC_THREADS */
+#ifdef _SC_THREAD_SAFE_FUNCTIONS
+       if (x == _SC_THREAD_SAFE_FUNCTIONS)
+               {*r = Mono_Posix_SysConf__SC_THREAD_SAFE_FUNCTIONS; return 0;}
+#endif /* ndef _SC_THREAD_SAFE_FUNCTIONS */
+#ifdef _SC_GETGR_R_SIZE_MAX
+       if (x == _SC_GETGR_R_SIZE_MAX)
+               {*r = Mono_Posix_SysConf__SC_GETGR_R_SIZE_MAX; return 0;}
+#endif /* ndef _SC_GETGR_R_SIZE_MAX */
+#ifdef _SC_GETPW_R_SIZE_MAX
+       if (x == _SC_GETPW_R_SIZE_MAX)
+               {*r = Mono_Posix_SysConf__SC_GETPW_R_SIZE_MAX; return 0;}
+#endif /* ndef _SC_GETPW_R_SIZE_MAX */
+#ifdef _SC_LOGIN_NAME_MAX
+       if (x == _SC_LOGIN_NAME_MAX)
+               {*r = Mono_Posix_SysConf__SC_LOGIN_NAME_MAX; return 0;}
+#endif /* ndef _SC_LOGIN_NAME_MAX */
+#ifdef _SC_TTY_NAME_MAX
+       if (x == _SC_TTY_NAME_MAX)
+               {*r = Mono_Posix_SysConf__SC_TTY_NAME_MAX; return 0;}
+#endif /* ndef _SC_TTY_NAME_MAX */
+#ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
+       if (x == _SC_THREAD_DESTRUCTOR_ITERATIONS)
+               {*r = Mono_Posix_SysConf__SC_THREAD_DESTRUCTOR_ITERATIONS; return 0;}
+#endif /* ndef _SC_THREAD_DESTRUCTOR_ITERATIONS */
+#ifdef _SC_THREAD_KEYS_MAX
+       if (x == _SC_THREAD_KEYS_MAX)
+               {*r = Mono_Posix_SysConf__SC_THREAD_KEYS_MAX; return 0;}
+#endif /* ndef _SC_THREAD_KEYS_MAX */
+#ifdef _SC_THREAD_STACK_MIN
+       if (x == _SC_THREAD_STACK_MIN)
+               {*r = Mono_Posix_SysConf__SC_THREAD_STACK_MIN; return 0;}
+#endif /* ndef _SC_THREAD_STACK_MIN */
+#ifdef _SC_THREAD_THREADS_MAX
+       if (x == _SC_THREAD_THREADS_MAX)
+               {*r = Mono_Posix_SysConf__SC_THREAD_THREADS_MAX; return 0;}
+#endif /* ndef _SC_THREAD_THREADS_MAX */
+#ifdef _SC_THREAD_ATTR_STACKADDR
+       if (x == _SC_THREAD_ATTR_STACKADDR)
+               {*r = Mono_Posix_SysConf__SC_THREAD_ATTR_STACKADDR; return 0;}
+#endif /* ndef _SC_THREAD_ATTR_STACKADDR */
+#ifdef _SC_THREAD_ATTR_STACKSIZE
+       if (x == _SC_THREAD_ATTR_STACKSIZE)
+               {*r = Mono_Posix_SysConf__SC_THREAD_ATTR_STACKSIZE; return 0;}
+#endif /* ndef _SC_THREAD_ATTR_STACKSIZE */
+#ifdef _SC_THREAD_PRIORITY_SCHEDULING
+       if (x == _SC_THREAD_PRIORITY_SCHEDULING)
+               {*r = Mono_Posix_SysConf__SC_THREAD_PRIORITY_SCHEDULING; return 0;}
+#endif /* ndef _SC_THREAD_PRIORITY_SCHEDULING */
+#ifdef _SC_THREAD_PRIO_INHERIT
+       if (x == _SC_THREAD_PRIO_INHERIT)
+               {*r = Mono_Posix_SysConf__SC_THREAD_PRIO_INHERIT; return 0;}
+#endif /* ndef _SC_THREAD_PRIO_INHERIT */
+#ifdef _SC_THREAD_PRIO_PROTECT
+       if (x == _SC_THREAD_PRIO_PROTECT)
+               {*r = Mono_Posix_SysConf__SC_THREAD_PRIO_PROTECT; return 0;}
+#endif /* ndef _SC_THREAD_PRIO_PROTECT */
+#ifdef _SC_THREAD_PROCESS_SHARED
+       if (x == _SC_THREAD_PROCESS_SHARED)
+               {*r = Mono_Posix_SysConf__SC_THREAD_PROCESS_SHARED; return 0;}
+#endif /* ndef _SC_THREAD_PROCESS_SHARED */
+#ifdef _SC_NPROCESSORS_CONF
+       if (x == _SC_NPROCESSORS_CONF)
+               {*r = Mono_Posix_SysConf__SC_NPROCESSORS_CONF; return 0;}
+#endif /* ndef _SC_NPROCESSORS_CONF */
+#ifdef _SC_NPROCESSORS_ONLN
+       if (x == _SC_NPROCESSORS_ONLN)
+               {*r = Mono_Posix_SysConf__SC_NPROCESSORS_ONLN; return 0;}
+#endif /* ndef _SC_NPROCESSORS_ONLN */
+#ifdef _SC_PHYS_PAGES
+       if (x == _SC_PHYS_PAGES)
+               {*r = Mono_Posix_SysConf__SC_PHYS_PAGES; return 0;}
+#endif /* ndef _SC_PHYS_PAGES */
+#ifdef _SC_AVPHYS_PAGES
+       if (x == _SC_AVPHYS_PAGES)
+               {*r = Mono_Posix_SysConf__SC_AVPHYS_PAGES; return 0;}
+#endif /* ndef _SC_AVPHYS_PAGES */
+#ifdef _SC_ATEXIT_MAX
+       if (x == _SC_ATEXIT_MAX)
+               {*r = Mono_Posix_SysConf__SC_ATEXIT_MAX; return 0;}
+#endif /* ndef _SC_ATEXIT_MAX */
+#ifdef _SC_PASS_MAX
+       if (x == _SC_PASS_MAX)
+               {*r = Mono_Posix_SysConf__SC_PASS_MAX; return 0;}
+#endif /* ndef _SC_PASS_MAX */
+#ifdef _SC_XOPEN_VERSION
+       if (x == _SC_XOPEN_VERSION)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_VERSION; return 0;}
+#endif /* ndef _SC_XOPEN_VERSION */
+#ifdef _SC_XOPEN_XCU_VERSION
+       if (x == _SC_XOPEN_XCU_VERSION)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_XCU_VERSION; return 0;}
+#endif /* ndef _SC_XOPEN_XCU_VERSION */
+#ifdef _SC_XOPEN_UNIX
+       if (x == _SC_XOPEN_UNIX)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_UNIX; return 0;}
+#endif /* ndef _SC_XOPEN_UNIX */
+#ifdef _SC_XOPEN_CRYPT
+       if (x == _SC_XOPEN_CRYPT)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_CRYPT; return 0;}
+#endif /* ndef _SC_XOPEN_CRYPT */
+#ifdef _SC_XOPEN_ENH_I18N
+       if (x == _SC_XOPEN_ENH_I18N)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_ENH_I18N; return 0;}
+#endif /* ndef _SC_XOPEN_ENH_I18N */
+#ifdef _SC_XOPEN_SHM
+       if (x == _SC_XOPEN_SHM)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_SHM; return 0;}
+#endif /* ndef _SC_XOPEN_SHM */
+#ifdef _SC_2_CHAR_TERM
+       if (x == _SC_2_CHAR_TERM)
+               {*r = Mono_Posix_SysConf__SC_2_CHAR_TERM; return 0;}
+#endif /* ndef _SC_2_CHAR_TERM */
+#ifdef _SC_2_C_VERSION
+       if (x == _SC_2_C_VERSION)
+               {*r = Mono_Posix_SysConf__SC_2_C_VERSION; return 0;}
+#endif /* ndef _SC_2_C_VERSION */
+#ifdef _SC_2_UPE
+       if (x == _SC_2_UPE)
+               {*r = Mono_Posix_SysConf__SC_2_UPE; return 0;}
+#endif /* ndef _SC_2_UPE */
+#ifdef _SC_XOPEN_XPG2
+       if (x == _SC_XOPEN_XPG2)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_XPG2; return 0;}
+#endif /* ndef _SC_XOPEN_XPG2 */
+#ifdef _SC_XOPEN_XPG3
+       if (x == _SC_XOPEN_XPG3)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_XPG3; return 0;}
+#endif /* ndef _SC_XOPEN_XPG3 */
+#ifdef _SC_XOPEN_XPG4
+       if (x == _SC_XOPEN_XPG4)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_XPG4; return 0;}
+#endif /* ndef _SC_XOPEN_XPG4 */
+#ifdef _SC_CHAR_BIT
+       if (x == _SC_CHAR_BIT)
+               {*r = Mono_Posix_SysConf__SC_CHAR_BIT; return 0;}
+#endif /* ndef _SC_CHAR_BIT */
+#ifdef _SC_CHAR_MAX
+       if (x == _SC_CHAR_MAX)
+               {*r = Mono_Posix_SysConf__SC_CHAR_MAX; return 0;}
+#endif /* ndef _SC_CHAR_MAX */
+#ifdef _SC_CHAR_MIN
+       if (x == _SC_CHAR_MIN)
+               {*r = Mono_Posix_SysConf__SC_CHAR_MIN; return 0;}
+#endif /* ndef _SC_CHAR_MIN */
+#ifdef _SC_INT_MAX
+       if (x == _SC_INT_MAX)
+               {*r = Mono_Posix_SysConf__SC_INT_MAX; return 0;}
+#endif /* ndef _SC_INT_MAX */
+#ifdef _SC_INT_MIN
+       if (x == _SC_INT_MIN)
+               {*r = Mono_Posix_SysConf__SC_INT_MIN; return 0;}
+#endif /* ndef _SC_INT_MIN */
+#ifdef _SC_LONG_BIT
+       if (x == _SC_LONG_BIT)
+               {*r = Mono_Posix_SysConf__SC_LONG_BIT; return 0;}
+#endif /* ndef _SC_LONG_BIT */
+#ifdef _SC_WORD_BIT
+       if (x == _SC_WORD_BIT)
+               {*r = Mono_Posix_SysConf__SC_WORD_BIT; return 0;}
+#endif /* ndef _SC_WORD_BIT */
+#ifdef _SC_MB_LEN_MAX
+       if (x == _SC_MB_LEN_MAX)
+               {*r = Mono_Posix_SysConf__SC_MB_LEN_MAX; return 0;}
+#endif /* ndef _SC_MB_LEN_MAX */
+#ifdef _SC_NZERO
+       if (x == _SC_NZERO)
+               {*r = Mono_Posix_SysConf__SC_NZERO; return 0;}
+#endif /* ndef _SC_NZERO */
+#ifdef _SC_SSIZE_MAX
+       if (x == _SC_SSIZE_MAX)
+               {*r = Mono_Posix_SysConf__SC_SSIZE_MAX; return 0;}
+#endif /* ndef _SC_SSIZE_MAX */
+#ifdef _SC_SCHAR_MAX
+       if (x == _SC_SCHAR_MAX)
+               {*r = Mono_Posix_SysConf__SC_SCHAR_MAX; return 0;}
+#endif /* ndef _SC_SCHAR_MAX */
+#ifdef _SC_SCHAR_MIN
+       if (x == _SC_SCHAR_MIN)
+               {*r = Mono_Posix_SysConf__SC_SCHAR_MIN; return 0;}
+#endif /* ndef _SC_SCHAR_MIN */
+#ifdef _SC_SHRT_MAX
+       if (x == _SC_SHRT_MAX)
+               {*r = Mono_Posix_SysConf__SC_SHRT_MAX; return 0;}
+#endif /* ndef _SC_SHRT_MAX */
+#ifdef _SC_SHRT_MIN
+       if (x == _SC_SHRT_MIN)
+               {*r = Mono_Posix_SysConf__SC_SHRT_MIN; return 0;}
+#endif /* ndef _SC_SHRT_MIN */
+#ifdef _SC_UCHAR_MAX
+       if (x == _SC_UCHAR_MAX)
+               {*r = Mono_Posix_SysConf__SC_UCHAR_MAX; return 0;}
+#endif /* ndef _SC_UCHAR_MAX */
+#ifdef _SC_UINT_MAX
+       if (x == _SC_UINT_MAX)
+               {*r = Mono_Posix_SysConf__SC_UINT_MAX; return 0;}
+#endif /* ndef _SC_UINT_MAX */
+#ifdef _SC_ULONG_MAX
+       if (x == _SC_ULONG_MAX)
+               {*r = Mono_Posix_SysConf__SC_ULONG_MAX; return 0;}
+#endif /* ndef _SC_ULONG_MAX */
+#ifdef _SC_USHRT_MAX
+       if (x == _SC_USHRT_MAX)
+               {*r = Mono_Posix_SysConf__SC_USHRT_MAX; return 0;}
+#endif /* ndef _SC_USHRT_MAX */
+#ifdef _SC_NL_ARGMAX
+       if (x == _SC_NL_ARGMAX)
+               {*r = Mono_Posix_SysConf__SC_NL_ARGMAX; return 0;}
+#endif /* ndef _SC_NL_ARGMAX */
+#ifdef _SC_NL_LANGMAX
+       if (x == _SC_NL_LANGMAX)
+               {*r = Mono_Posix_SysConf__SC_NL_LANGMAX; return 0;}
+#endif /* ndef _SC_NL_LANGMAX */
+#ifdef _SC_NL_MSGMAX
+       if (x == _SC_NL_MSGMAX)
+               {*r = Mono_Posix_SysConf__SC_NL_MSGMAX; return 0;}
+#endif /* ndef _SC_NL_MSGMAX */
+#ifdef _SC_NL_NMAX
+       if (x == _SC_NL_NMAX)
+               {*r = Mono_Posix_SysConf__SC_NL_NMAX; return 0;}
+#endif /* ndef _SC_NL_NMAX */
+#ifdef _SC_NL_SETMAX
+       if (x == _SC_NL_SETMAX)
+               {*r = Mono_Posix_SysConf__SC_NL_SETMAX; return 0;}
+#endif /* ndef _SC_NL_SETMAX */
+#ifdef _SC_NL_TEXTMAX
+       if (x == _SC_NL_TEXTMAX)
+               {*r = Mono_Posix_SysConf__SC_NL_TEXTMAX; return 0;}
+#endif /* ndef _SC_NL_TEXTMAX */
+#ifdef _SC_XBS5_ILP32_OFF32
+       if (x == _SC_XBS5_ILP32_OFF32)
+               {*r = Mono_Posix_SysConf__SC_XBS5_ILP32_OFF32; return 0;}
+#endif /* ndef _SC_XBS5_ILP32_OFF32 */
+#ifdef _SC_XBS5_ILP32_OFFBIG
+       if (x == _SC_XBS5_ILP32_OFFBIG)
+               {*r = Mono_Posix_SysConf__SC_XBS5_ILP32_OFFBIG; return 0;}
+#endif /* ndef _SC_XBS5_ILP32_OFFBIG */
+#ifdef _SC_XBS5_LP64_OFF64
+       if (x == _SC_XBS5_LP64_OFF64)
+               {*r = Mono_Posix_SysConf__SC_XBS5_LP64_OFF64; return 0;}
+#endif /* ndef _SC_XBS5_LP64_OFF64 */
+#ifdef _SC_XBS5_LPBIG_OFFBIG
+       if (x == _SC_XBS5_LPBIG_OFFBIG)
+               {*r = Mono_Posix_SysConf__SC_XBS5_LPBIG_OFFBIG; return 0;}
+#endif /* ndef _SC_XBS5_LPBIG_OFFBIG */
+#ifdef _SC_XOPEN_LEGACY
+       if (x == _SC_XOPEN_LEGACY)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_LEGACY; return 0;}
+#endif /* ndef _SC_XOPEN_LEGACY */
+#ifdef _SC_XOPEN_REALTIME
+       if (x == _SC_XOPEN_REALTIME)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_REALTIME; return 0;}
+#endif /* ndef _SC_XOPEN_REALTIME */
+#ifdef _SC_XOPEN_REALTIME_THREADS
+       if (x == _SC_XOPEN_REALTIME_THREADS)
+               {*r = Mono_Posix_SysConf__SC_XOPEN_REALTIME_THREADS; return 0;}
+#endif /* ndef _SC_XOPEN_REALTIME_THREADS */
+#ifdef _SC_ADVISORY_INFO
+       if (x == _SC_ADVISORY_INFO)
+               {*r = Mono_Posix_SysConf__SC_ADVISORY_INFO; return 0;}
+#endif /* ndef _SC_ADVISORY_INFO */
+#ifdef _SC_BARRIERS
+       if (x == _SC_BARRIERS)
+               {*r = Mono_Posix_SysConf__SC_BARRIERS; return 0;}
+#endif /* ndef _SC_BARRIERS */
+#ifdef _SC_BASE
+       if (x == _SC_BASE)
+               {*r = Mono_Posix_SysConf__SC_BASE; return 0;}
+#endif /* ndef _SC_BASE */
+#ifdef _SC_C_LANG_SUPPORT
+       if (x == _SC_C_LANG_SUPPORT)
+               {*r = Mono_Posix_SysConf__SC_C_LANG_SUPPORT; return 0;}
+#endif /* ndef _SC_C_LANG_SUPPORT */
+#ifdef _SC_C_LANG_SUPPORT_R
+       if (x == _SC_C_LANG_SUPPORT_R)
+               {*r = Mono_Posix_SysConf__SC_C_LANG_SUPPORT_R; return 0;}
+#endif /* ndef _SC_C_LANG_SUPPORT_R */
+#ifdef _SC_CLOCK_SELECTION
+       if (x == _SC_CLOCK_SELECTION)
+               {*r = Mono_Posix_SysConf__SC_CLOCK_SELECTION; return 0;}
+#endif /* ndef _SC_CLOCK_SELECTION */
+#ifdef _SC_CPUTIME
+       if (x == _SC_CPUTIME)
+               {*r = Mono_Posix_SysConf__SC_CPUTIME; return 0;}
+#endif /* ndef _SC_CPUTIME */
+#ifdef _SC_THREAD_CPUTIME
+       if (x == _SC_THREAD_CPUTIME)
+               {*r = Mono_Posix_SysConf__SC_THREAD_CPUTIME; return 0;}
+#endif /* ndef _SC_THREAD_CPUTIME */
+#ifdef _SC_DEVICE_IO
+       if (x == _SC_DEVICE_IO)
+               {*r = Mono_Posix_SysConf__SC_DEVICE_IO; return 0;}
+#endif /* ndef _SC_DEVICE_IO */
+#ifdef _SC_DEVICE_SPECIFIC
+       if (x == _SC_DEVICE_SPECIFIC)
+               {*r = Mono_Posix_SysConf__SC_DEVICE_SPECIFIC; return 0;}
+#endif /* ndef _SC_DEVICE_SPECIFIC */
+#ifdef _SC_DEVICE_SPECIFIC_R
+       if (x == _SC_DEVICE_SPECIFIC_R)
+               {*r = Mono_Posix_SysConf__SC_DEVICE_SPECIFIC_R; return 0;}
+#endif /* ndef _SC_DEVICE_SPECIFIC_R */
+#ifdef _SC_FD_MGMT
+       if (x == _SC_FD_MGMT)
+               {*r = Mono_Posix_SysConf__SC_FD_MGMT; return 0;}
+#endif /* ndef _SC_FD_MGMT */
+#ifdef _SC_FIFO
+       if (x == _SC_FIFO)
+               {*r = Mono_Posix_SysConf__SC_FIFO; return 0;}
+#endif /* ndef _SC_FIFO */
+#ifdef _SC_PIPE
+       if (x == _SC_PIPE)
+               {*r = Mono_Posix_SysConf__SC_PIPE; return 0;}
+#endif /* ndef _SC_PIPE */
+#ifdef _SC_FILE_ATTRIBUTES
+       if (x == _SC_FILE_ATTRIBUTES)
+               {*r = Mono_Posix_SysConf__SC_FILE_ATTRIBUTES; return 0;}
+#endif /* ndef _SC_FILE_ATTRIBUTES */
+#ifdef _SC_FILE_LOCKING
+       if (x == _SC_FILE_LOCKING)
+               {*r = Mono_Posix_SysConf__SC_FILE_LOCKING; return 0;}
+#endif /* ndef _SC_FILE_LOCKING */
+#ifdef _SC_FILE_SYSTEM
+       if (x == _SC_FILE_SYSTEM)
+               {*r = Mono_Posix_SysConf__SC_FILE_SYSTEM; return 0;}
+#endif /* ndef _SC_FILE_SYSTEM */
+#ifdef _SC_MONOTONIC_CLOCK
+       if (x == _SC_MONOTONIC_CLOCK)
+               {*r = Mono_Posix_SysConf__SC_MONOTONIC_CLOCK; return 0;}
+#endif /* ndef _SC_MONOTONIC_CLOCK */
+#ifdef _SC_MULTI_PROCESS
+       if (x == _SC_MULTI_PROCESS)
+               {*r = Mono_Posix_SysConf__SC_MULTI_PROCESS; return 0;}
+#endif /* ndef _SC_MULTI_PROCESS */
+#ifdef _SC_SINGLE_PROCESS
+       if (x == _SC_SINGLE_PROCESS)
+               {*r = Mono_Posix_SysConf__SC_SINGLE_PROCESS; return 0;}
+#endif /* ndef _SC_SINGLE_PROCESS */
+#ifdef _SC_NETWORKING
+       if (x == _SC_NETWORKING)
+               {*r = Mono_Posix_SysConf__SC_NETWORKING; return 0;}
+#endif /* ndef _SC_NETWORKING */
+#ifdef _SC_READER_WRITER_LOCKS
+       if (x == _SC_READER_WRITER_LOCKS)
+               {*r = Mono_Posix_SysConf__SC_READER_WRITER_LOCKS; return 0;}
+#endif /* ndef _SC_READER_WRITER_LOCKS */
+#ifdef _SC_SPIN_LOCKS
+       if (x == _SC_SPIN_LOCKS)
+               {*r = Mono_Posix_SysConf__SC_SPIN_LOCKS; return 0;}
+#endif /* ndef _SC_SPIN_LOCKS */
+#ifdef _SC_REGEXP
+       if (x == _SC_REGEXP)
+               {*r = Mono_Posix_SysConf__SC_REGEXP; return 0;}
+#endif /* ndef _SC_REGEXP */
+#ifdef _SC_REGEX_VERSION
+       if (x == _SC_REGEX_VERSION)
+               {*r = Mono_Posix_SysConf__SC_REGEX_VERSION; return 0;}
+#endif /* ndef _SC_REGEX_VERSION */
+#ifdef _SC_SHELL
+       if (x == _SC_SHELL)
+               {*r = Mono_Posix_SysConf__SC_SHELL; return 0;}
+#endif /* ndef _SC_SHELL */
+#ifdef _SC_SIGNALS
+       if (x == _SC_SIGNALS)
+               {*r = Mono_Posix_SysConf__SC_SIGNALS; return 0;}
+#endif /* ndef _SC_SIGNALS */
+#ifdef _SC_SPAWN
+       if (x == _SC_SPAWN)
+               {*r = Mono_Posix_SysConf__SC_SPAWN; return 0;}
+#endif /* ndef _SC_SPAWN */
+#ifdef _SC_SPORADIC_SERVER
+       if (x == _SC_SPORADIC_SERVER)
+               {*r = Mono_Posix_SysConf__SC_SPORADIC_SERVER; return 0;}
+#endif /* ndef _SC_SPORADIC_SERVER */
+#ifdef _SC_THREAD_SPORADIC_SERVER
+       if (x == _SC_THREAD_SPORADIC_SERVER)
+               {*r = Mono_Posix_SysConf__SC_THREAD_SPORADIC_SERVER; return 0;}
+#endif /* ndef _SC_THREAD_SPORADIC_SERVER */
+#ifdef _SC_SYSTEM_DATABASE
+       if (x == _SC_SYSTEM_DATABASE)
+               {*r = Mono_Posix_SysConf__SC_SYSTEM_DATABASE; return 0;}
+#endif /* ndef _SC_SYSTEM_DATABASE */
+#ifdef _SC_SYSTEM_DATABASE_R
+       if (x == _SC_SYSTEM_DATABASE_R)
+               {*r = Mono_Posix_SysConf__SC_SYSTEM_DATABASE_R; return 0;}
+#endif /* ndef _SC_SYSTEM_DATABASE_R */
+#ifdef _SC_TIMEOUTS
+       if (x == _SC_TIMEOUTS)
+               {*r = Mono_Posix_SysConf__SC_TIMEOUTS; return 0;}
+#endif /* ndef _SC_TIMEOUTS */
+#ifdef _SC_TYPED_MEMORY_OBJECTS
+       if (x == _SC_TYPED_MEMORY_OBJECTS)
+               {*r = Mono_Posix_SysConf__SC_TYPED_MEMORY_OBJECTS; return 0;}
+#endif /* ndef _SC_TYPED_MEMORY_OBJECTS */
+#ifdef _SC_USER_GROUPS
+       if (x == _SC_USER_GROUPS)
+               {*r = Mono_Posix_SysConf__SC_USER_GROUPS; return 0;}
+#endif /* ndef _SC_USER_GROUPS */
+#ifdef _SC_USER_GROUPS_R
+       if (x == _SC_USER_GROUPS_R)
+               {*r = Mono_Posix_SysConf__SC_USER_GROUPS_R; return 0;}
+#endif /* ndef _SC_USER_GROUPS_R */
+#ifdef _SC_2_PBS
+       if (x == _SC_2_PBS)
+               {*r = Mono_Posix_SysConf__SC_2_PBS; return 0;}
+#endif /* ndef _SC_2_PBS */
+#ifdef _SC_2_PBS_ACCOUNTING
+       if (x == _SC_2_PBS_ACCOUNTING)
+               {*r = Mono_Posix_SysConf__SC_2_PBS_ACCOUNTING; return 0;}
+#endif /* ndef _SC_2_PBS_ACCOUNTING */
+#ifdef _SC_2_PBS_LOCATE
+       if (x == _SC_2_PBS_LOCATE)
+               {*r = Mono_Posix_SysConf__SC_2_PBS_LOCATE; return 0;}
+#endif /* ndef _SC_2_PBS_LOCATE */
+#ifdef _SC_2_PBS_MESSAGE
+       if (x == _SC_2_PBS_MESSAGE)
+               {*r = Mono_Posix_SysConf__SC_2_PBS_MESSAGE; return 0;}
+#endif /* ndef _SC_2_PBS_MESSAGE */
+#ifdef _SC_2_PBS_TRACK
+       if (x == _SC_2_PBS_TRACK)
+               {*r = Mono_Posix_SysConf__SC_2_PBS_TRACK; return 0;}
+#endif /* ndef _SC_2_PBS_TRACK */
+#ifdef _SC_SYMLOOP_MAX
+       if (x == _SC_SYMLOOP_MAX)
+               {*r = Mono_Posix_SysConf__SC_SYMLOOP_MAX; return 0;}
+#endif /* ndef _SC_SYMLOOP_MAX */
+#ifdef _SC_STREAMS
+       if (x == _SC_STREAMS)
+               {*r = Mono_Posix_SysConf__SC_STREAMS; return 0;}
+#endif /* ndef _SC_STREAMS */
+#ifdef _SC_2_PBS_CHECKPOINT
+       if (x == _SC_2_PBS_CHECKPOINT)
+               {*r = Mono_Posix_SysConf__SC_2_PBS_CHECKPOINT; return 0;}
+#endif /* ndef _SC_2_PBS_CHECKPOINT */
+#ifdef _SC_V6_ILP32_OFF32
+       if (x == _SC_V6_ILP32_OFF32)
+               {*r = Mono_Posix_SysConf__SC_V6_ILP32_OFF32; return 0;}
+#endif /* ndef _SC_V6_ILP32_OFF32 */
+#ifdef _SC_V6_ILP32_OFFBIG
+       if (x == _SC_V6_ILP32_OFFBIG)
+               {*r = Mono_Posix_SysConf__SC_V6_ILP32_OFFBIG; return 0;}
+#endif /* ndef _SC_V6_ILP32_OFFBIG */
+#ifdef _SC_V6_LP64_OFF64
+       if (x == _SC_V6_LP64_OFF64)
+               {*r = Mono_Posix_SysConf__SC_V6_LP64_OFF64; return 0;}
+#endif /* ndef _SC_V6_LP64_OFF64 */
+#ifdef _SC_V6_LPBIG_OFFBIG
+       if (x == _SC_V6_LPBIG_OFFBIG)
+               {*r = Mono_Posix_SysConf__SC_V6_LPBIG_OFFBIG; return 0;}
+#endif /* ndef _SC_V6_LPBIG_OFFBIG */
+#ifdef _SC_HOST_NAME_MAX
+       if (x == _SC_HOST_NAME_MAX)
+               {*r = Mono_Posix_SysConf__SC_HOST_NAME_MAX; return 0;}
+#endif /* ndef _SC_HOST_NAME_MAX */
+#ifdef _SC_TRACE
+       if (x == _SC_TRACE)
+               {*r = Mono_Posix_SysConf__SC_TRACE; return 0;}
+#endif /* ndef _SC_TRACE */
+#ifdef _SC_TRACE_EVENT_FILTER
+       if (x == _SC_TRACE_EVENT_FILTER)
+               {*r = Mono_Posix_SysConf__SC_TRACE_EVENT_FILTER; return 0;}
+#endif /* ndef _SC_TRACE_EVENT_FILTER */
+#ifdef _SC_TRACE_INHERIT
+       if (x == _SC_TRACE_INHERIT)
+               {*r = Mono_Posix_SysConf__SC_TRACE_INHERIT; return 0;}
+#endif /* ndef _SC_TRACE_INHERIT */
+#ifdef _SC_TRACE_LOG
+       if (x == _SC_TRACE_LOG)
+               {*r = Mono_Posix_SysConf__SC_TRACE_LOG; return 0;}
+#endif /* ndef _SC_TRACE_LOG */
+#ifdef _SC_LEVEL1_ICACHE_SIZE
+       if (x == _SC_LEVEL1_ICACHE_SIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL1_ICACHE_SIZE; return 0;}
+#endif /* ndef _SC_LEVEL1_ICACHE_SIZE */
+#ifdef _SC_LEVEL1_ICACHE_ASSOC
+       if (x == _SC_LEVEL1_ICACHE_ASSOC)
+               {*r = Mono_Posix_SysConf__SC_LEVEL1_ICACHE_ASSOC; return 0;}
+#endif /* ndef _SC_LEVEL1_ICACHE_ASSOC */
+#ifdef _SC_LEVEL1_ICACHE_LINESIZE
+       if (x == _SC_LEVEL1_ICACHE_LINESIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL1_ICACHE_LINESIZE; return 0;}
+#endif /* ndef _SC_LEVEL1_ICACHE_LINESIZE */
+#ifdef _SC_LEVEL1_DCACHE_SIZE
+       if (x == _SC_LEVEL1_DCACHE_SIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL1_DCACHE_SIZE; return 0;}
+#endif /* ndef _SC_LEVEL1_DCACHE_SIZE */
+#ifdef _SC_LEVEL1_DCACHE_ASSOC
+       if (x == _SC_LEVEL1_DCACHE_ASSOC)
+               {*r = Mono_Posix_SysConf__SC_LEVEL1_DCACHE_ASSOC; return 0;}
+#endif /* ndef _SC_LEVEL1_DCACHE_ASSOC */
+#ifdef _SC_LEVEL1_DCACHE_LINESIZE
+       if (x == _SC_LEVEL1_DCACHE_LINESIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL1_DCACHE_LINESIZE; return 0;}
+#endif /* ndef _SC_LEVEL1_DCACHE_LINESIZE */
+#ifdef _SC_LEVEL2_CACHE_SIZE
+       if (x == _SC_LEVEL2_CACHE_SIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL2_CACHE_SIZE; return 0;}
+#endif /* ndef _SC_LEVEL2_CACHE_SIZE */
+#ifdef _SC_LEVEL2_CACHE_ASSOC
+       if (x == _SC_LEVEL2_CACHE_ASSOC)
+               {*r = Mono_Posix_SysConf__SC_LEVEL2_CACHE_ASSOC; return 0;}
+#endif /* ndef _SC_LEVEL2_CACHE_ASSOC */
+#ifdef _SC_LEVEL2_CACHE_LINESIZE
+       if (x == _SC_LEVEL2_CACHE_LINESIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL2_CACHE_LINESIZE; return 0;}
+#endif /* ndef _SC_LEVEL2_CACHE_LINESIZE */
+#ifdef _SC_LEVEL3_CACHE_SIZE
+       if (x == _SC_LEVEL3_CACHE_SIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL3_CACHE_SIZE; return 0;}
+#endif /* ndef _SC_LEVEL3_CACHE_SIZE */
+#ifdef _SC_LEVEL3_CACHE_ASSOC
+       if (x == _SC_LEVEL3_CACHE_ASSOC)
+               {*r = Mono_Posix_SysConf__SC_LEVEL3_CACHE_ASSOC; return 0;}
+#endif /* ndef _SC_LEVEL3_CACHE_ASSOC */
+#ifdef _SC_LEVEL3_CACHE_LINESIZE
+       if (x == _SC_LEVEL3_CACHE_LINESIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL3_CACHE_LINESIZE; return 0;}
+#endif /* ndef _SC_LEVEL3_CACHE_LINESIZE */
+#ifdef _SC_LEVEL4_CACHE_SIZE
+       if (x == _SC_LEVEL4_CACHE_SIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL4_CACHE_SIZE; return 0;}
+#endif /* ndef _SC_LEVEL4_CACHE_SIZE */
+#ifdef _SC_LEVEL4_CACHE_ASSOC
+       if (x == _SC_LEVEL4_CACHE_ASSOC)
+               {*r = Mono_Posix_SysConf__SC_LEVEL4_CACHE_ASSOC; return 0;}
+#endif /* ndef _SC_LEVEL4_CACHE_ASSOC */
+#ifdef _SC_LEVEL4_CACHE_LINESIZE
+       if (x == _SC_LEVEL4_CACHE_LINESIZE)
+               {*r = Mono_Posix_SysConf__SC_LEVEL4_CACHE_LINESIZE; return 0;}
+#endif /* ndef _SC_LEVEL4_CACHE_LINESIZE */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromConfStr (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_ConfStr__CS_PATH)
+#ifdef _CS_PATH
+               {*r = _CS_PATH; return 0;}
+#else /* def _CS_PATH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_PATH */
+       if (x == Mono_Posix_ConfStr__CS_V6_WIDTH_RESTRICTED_ENVS)
+#ifdef _CS_V6_WIDTH_RESTRICTED_ENVS
+               {*r = _CS_V6_WIDTH_RESTRICTED_ENVS; return 0;}
+#else /* def _CS_V6_WIDTH_RESTRICTED_ENVS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_V6_WIDTH_RESTRICTED_ENVS */
+       if (x == Mono_Posix_ConfStr__CS_GNU_LIBC_VERSION)
+#ifdef _CS_GNU_LIBC_VERSION
+               {*r = _CS_GNU_LIBC_VERSION; return 0;}
+#else /* def _CS_GNU_LIBC_VERSION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_GNU_LIBC_VERSION */
+       if (x == Mono_Posix_ConfStr__CS_GNU_LIBPTHREAD_VERSION)
+#ifdef _CS_GNU_LIBPTHREAD_VERSION
+               {*r = _CS_GNU_LIBPTHREAD_VERSION; return 0;}
+#else /* def _CS_GNU_LIBPTHREAD_VERSION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_GNU_LIBPTHREAD_VERSION */
+       if (x == Mono_Posix_ConfStr__CS_LFS_CFLAGS)
+#ifdef _CS_LFS_CFLAGS
+               {*r = _CS_LFS_CFLAGS; return 0;}
+#else /* def _CS_LFS_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_LFS_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_LFS_LDFLAGS)
+#ifdef _CS_LFS_LDFLAGS
+               {*r = _CS_LFS_LDFLAGS; return 0;}
+#else /* def _CS_LFS_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_LFS_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_LFS_LIBS)
+#ifdef _CS_LFS_LIBS
+               {*r = _CS_LFS_LIBS; return 0;}
+#else /* def _CS_LFS_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_LFS_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_LFS_LINTFLAGS)
+#ifdef _CS_LFS_LINTFLAGS
+               {*r = _CS_LFS_LINTFLAGS; return 0;}
+#else /* def _CS_LFS_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_LFS_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_LFS64_CFLAGS)
+#ifdef _CS_LFS64_CFLAGS
+               {*r = _CS_LFS64_CFLAGS; return 0;}
+#else /* def _CS_LFS64_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_LFS64_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_LFS64_LDFLAGS)
+#ifdef _CS_LFS64_LDFLAGS
+               {*r = _CS_LFS64_LDFLAGS; return 0;}
+#else /* def _CS_LFS64_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_LFS64_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_LFS64_LIBS)
+#ifdef _CS_LFS64_LIBS
+               {*r = _CS_LFS64_LIBS; return 0;}
+#else /* def _CS_LFS64_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_LFS64_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_LFS64_LINTFLAGS)
+#ifdef _CS_LFS64_LINTFLAGS
+               {*r = _CS_LFS64_LINTFLAGS; return 0;}
+#else /* def _CS_LFS64_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_LFS64_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_CFLAGS)
+#ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
+               {*r = _CS_XBS5_ILP32_OFF32_CFLAGS; return 0;}
+#else /* def _CS_XBS5_ILP32_OFF32_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_ILP32_OFF32_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LDFLAGS)
+#ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
+               {*r = _CS_XBS5_ILP32_OFF32_LDFLAGS; return 0;}
+#else /* def _CS_XBS5_ILP32_OFF32_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_ILP32_OFF32_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LIBS)
+#ifdef _CS_XBS5_ILP32_OFF32_LIBS
+               {*r = _CS_XBS5_ILP32_OFF32_LIBS; return 0;}
+#else /* def _CS_XBS5_ILP32_OFF32_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_ILP32_OFF32_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LINTFLAGS)
+#ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
+               {*r = _CS_XBS5_ILP32_OFF32_LINTFLAGS; return 0;}
+#else /* def _CS_XBS5_ILP32_OFF32_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_ILP32_OFF32_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_CFLAGS)
+#ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
+               {*r = _CS_XBS5_ILP32_OFFBIG_CFLAGS; return 0;}
+#else /* def _CS_XBS5_ILP32_OFFBIG_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_ILP32_OFFBIG_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LDFLAGS)
+#ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
+               {*r = _CS_XBS5_ILP32_OFFBIG_LDFLAGS; return 0;}
+#else /* def _CS_XBS5_ILP32_OFFBIG_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_ILP32_OFFBIG_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LIBS)
+#ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
+               {*r = _CS_XBS5_ILP32_OFFBIG_LIBS; return 0;}
+#else /* def _CS_XBS5_ILP32_OFFBIG_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_ILP32_OFFBIG_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LINTFLAGS)
+#ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
+               {*r = _CS_XBS5_ILP32_OFFBIG_LINTFLAGS; return 0;}
+#else /* def _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_CFLAGS)
+#ifdef _CS_XBS5_LP64_OFF64_CFLAGS
+               {*r = _CS_XBS5_LP64_OFF64_CFLAGS; return 0;}
+#else /* def _CS_XBS5_LP64_OFF64_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_LP64_OFF64_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LDFLAGS)
+#ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
+               {*r = _CS_XBS5_LP64_OFF64_LDFLAGS; return 0;}
+#else /* def _CS_XBS5_LP64_OFF64_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_LP64_OFF64_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LIBS)
+#ifdef _CS_XBS5_LP64_OFF64_LIBS
+               {*r = _CS_XBS5_LP64_OFF64_LIBS; return 0;}
+#else /* def _CS_XBS5_LP64_OFF64_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_LP64_OFF64_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LINTFLAGS)
+#ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
+               {*r = _CS_XBS5_LP64_OFF64_LINTFLAGS; return 0;}
+#else /* def _CS_XBS5_LP64_OFF64_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_LP64_OFF64_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_CFLAGS)
+#ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
+               {*r = _CS_XBS5_LPBIG_OFFBIG_CFLAGS; return 0;}
+#else /* def _CS_XBS5_LPBIG_OFFBIG_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_LPBIG_OFFBIG_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LDFLAGS)
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
+               {*r = _CS_XBS5_LPBIG_OFFBIG_LDFLAGS; return 0;}
+#else /* def _CS_XBS5_LPBIG_OFFBIG_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LIBS)
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
+               {*r = _CS_XBS5_LPBIG_OFFBIG_LIBS; return 0;}
+#else /* def _CS_XBS5_LPBIG_OFFBIG_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LINTFLAGS)
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
+               {*r = _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS; return 0;}
+#else /* def _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_CFLAGS)
+#ifdef _CS_POSIX_V6_ILP32_OFF32_CFLAGS
+               {*r = _CS_POSIX_V6_ILP32_OFF32_CFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_ILP32_OFF32_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFF32_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LDFLAGS)
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
+               {*r = _CS_POSIX_V6_ILP32_OFF32_LDFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LIBS)
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LIBS
+               {*r = _CS_POSIX_V6_ILP32_OFF32_LIBS; return 0;}
+#else /* def _CS_POSIX_V6_ILP32_OFF32_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LINTFLAGS)
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
+               {*r = _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_CFLAGS)
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
+               {*r = _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS)
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
+               {*r = _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LIBS)
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LIBS
+               {*r = _CS_POSIX_V6_ILP32_OFFBIG_LIBS; return 0;}
+#else /* def _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS)
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
+               {*r = _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_CFLAGS)
+#ifdef _CS_POSIX_V6_LP64_OFF64_CFLAGS
+               {*r = _CS_POSIX_V6_LP64_OFF64_CFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_LP64_OFF64_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_LP64_OFF64_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LDFLAGS)
+#ifdef _CS_POSIX_V6_LP64_OFF64_LDFLAGS
+               {*r = _CS_POSIX_V6_LP64_OFF64_LDFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_LP64_OFF64_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_LP64_OFF64_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LIBS)
+#ifdef _CS_POSIX_V6_LP64_OFF64_LIBS
+               {*r = _CS_POSIX_V6_LP64_OFF64_LIBS; return 0;}
+#else /* def _CS_POSIX_V6_LP64_OFF64_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_LP64_OFF64_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LINTFLAGS)
+#ifdef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
+               {*r = _CS_POSIX_V6_LP64_OFF64_LINTFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_LP64_OFF64_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS)
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
+               {*r = _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS)
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+               {*r = _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LIBS)
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
+               {*r = _CS_POSIX_V6_LPBIG_OFFBIG_LIBS; return 0;}
+#else /* def _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
+       if (x == Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS)
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
+               {*r = _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS; return 0;}
+#else /* def _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToConfStr (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef _CS_PATH
+       if (x == _CS_PATH)
+               {*r = Mono_Posix_ConfStr__CS_PATH; return 0;}
+#endif /* ndef _CS_PATH */
+#ifdef _CS_V6_WIDTH_RESTRICTED_ENVS
+       if (x == _CS_V6_WIDTH_RESTRICTED_ENVS)
+               {*r = Mono_Posix_ConfStr__CS_V6_WIDTH_RESTRICTED_ENVS; return 0;}
+#endif /* ndef _CS_V6_WIDTH_RESTRICTED_ENVS */
+#ifdef _CS_GNU_LIBC_VERSION
+       if (x == _CS_GNU_LIBC_VERSION)
+               {*r = Mono_Posix_ConfStr__CS_GNU_LIBC_VERSION; return 0;}
+#endif /* ndef _CS_GNU_LIBC_VERSION */
+#ifdef _CS_GNU_LIBPTHREAD_VERSION
+       if (x == _CS_GNU_LIBPTHREAD_VERSION)
+               {*r = Mono_Posix_ConfStr__CS_GNU_LIBPTHREAD_VERSION; return 0;}
+#endif /* ndef _CS_GNU_LIBPTHREAD_VERSION */
+#ifdef _CS_LFS_CFLAGS
+       if (x == _CS_LFS_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_LFS_CFLAGS; return 0;}
+#endif /* ndef _CS_LFS_CFLAGS */
+#ifdef _CS_LFS_LDFLAGS
+       if (x == _CS_LFS_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_LFS_LDFLAGS; return 0;}
+#endif /* ndef _CS_LFS_LDFLAGS */
+#ifdef _CS_LFS_LIBS
+       if (x == _CS_LFS_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_LFS_LIBS; return 0;}
+#endif /* ndef _CS_LFS_LIBS */
+#ifdef _CS_LFS_LINTFLAGS
+       if (x == _CS_LFS_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_LFS_LINTFLAGS; return 0;}
+#endif /* ndef _CS_LFS_LINTFLAGS */
+#ifdef _CS_LFS64_CFLAGS
+       if (x == _CS_LFS64_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_LFS64_CFLAGS; return 0;}
+#endif /* ndef _CS_LFS64_CFLAGS */
+#ifdef _CS_LFS64_LDFLAGS
+       if (x == _CS_LFS64_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_LFS64_LDFLAGS; return 0;}
+#endif /* ndef _CS_LFS64_LDFLAGS */
+#ifdef _CS_LFS64_LIBS
+       if (x == _CS_LFS64_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_LFS64_LIBS; return 0;}
+#endif /* ndef _CS_LFS64_LIBS */
+#ifdef _CS_LFS64_LINTFLAGS
+       if (x == _CS_LFS64_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_LFS64_LINTFLAGS; return 0;}
+#endif /* ndef _CS_LFS64_LINTFLAGS */
+#ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
+       if (x == _CS_XBS5_ILP32_OFF32_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_CFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_ILP32_OFF32_CFLAGS */
+#ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
+       if (x == _CS_XBS5_ILP32_OFF32_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LDFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_ILP32_OFF32_LDFLAGS */
+#ifdef _CS_XBS5_ILP32_OFF32_LIBS
+       if (x == _CS_XBS5_ILP32_OFF32_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LIBS; return 0;}
+#endif /* ndef _CS_XBS5_ILP32_OFF32_LIBS */
+#ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
+       if (x == _CS_XBS5_ILP32_OFF32_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LINTFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_ILP32_OFF32_LINTFLAGS */
+#ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
+       if (x == _CS_XBS5_ILP32_OFFBIG_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_CFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_ILP32_OFFBIG_CFLAGS */
+#ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
+       if (x == _CS_XBS5_ILP32_OFFBIG_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LDFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_ILP32_OFFBIG_LDFLAGS */
+#ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
+       if (x == _CS_XBS5_ILP32_OFFBIG_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LIBS; return 0;}
+#endif /* ndef _CS_XBS5_ILP32_OFFBIG_LIBS */
+#ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
+       if (x == _CS_XBS5_ILP32_OFFBIG_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LINTFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */
+#ifdef _CS_XBS5_LP64_OFF64_CFLAGS
+       if (x == _CS_XBS5_LP64_OFF64_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_CFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_LP64_OFF64_CFLAGS */
+#ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
+       if (x == _CS_XBS5_LP64_OFF64_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LDFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_LP64_OFF64_LDFLAGS */
+#ifdef _CS_XBS5_LP64_OFF64_LIBS
+       if (x == _CS_XBS5_LP64_OFF64_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LIBS; return 0;}
+#endif /* ndef _CS_XBS5_LP64_OFF64_LIBS */
+#ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
+       if (x == _CS_XBS5_LP64_OFF64_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LINTFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_LP64_OFF64_LINTFLAGS */
+#ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
+       if (x == _CS_XBS5_LPBIG_OFFBIG_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_CFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_LPBIG_OFFBIG_CFLAGS */
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
+       if (x == _CS_XBS5_LPBIG_OFFBIG_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LDFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS */
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
+       if (x == _CS_XBS5_LPBIG_OFFBIG_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LIBS; return 0;}
+#endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LIBS */
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
+       if (x == _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LINTFLAGS; return 0;}
+#endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
+#ifdef _CS_POSIX_V6_ILP32_OFF32_CFLAGS
+       if (x == _CS_POSIX_V6_ILP32_OFF32_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_CFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFF32_CFLAGS */
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
+       if (x == _CS_POSIX_V6_ILP32_OFF32_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LDFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LIBS
+       if (x == _CS_POSIX_V6_ILP32_OFF32_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LIBS; return 0;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LIBS */
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
+       if (x == _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LINTFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS */
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
+       if (x == _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_CFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
+       if (x == _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LIBS
+       if (x == _CS_POSIX_V6_ILP32_OFFBIG_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LIBS; return 0;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
+       if (x == _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS */
+#ifdef _CS_POSIX_V6_LP64_OFF64_CFLAGS
+       if (x == _CS_POSIX_V6_LP64_OFF64_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_CFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_LP64_OFF64_CFLAGS */
+#ifdef _CS_POSIX_V6_LP64_OFF64_LDFLAGS
+       if (x == _CS_POSIX_V6_LP64_OFF64_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LDFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_LP64_OFF64_LDFLAGS */
+#ifdef _CS_POSIX_V6_LP64_OFF64_LIBS
+       if (x == _CS_POSIX_V6_LP64_OFF64_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LIBS; return 0;}
+#endif /* ndef _CS_POSIX_V6_LP64_OFF64_LIBS */
+#ifdef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
+       if (x == _CS_POSIX_V6_LP64_OFF64_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LINTFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS */
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
+       if (x == _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+       if (x == _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
+       if (x == _CS_POSIX_V6_LPBIG_OFFBIG_LIBS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LIBS; return 0;}
+#endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
+       if (x == _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS)
+               {*r = Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS; return 0;}
+#endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromLockFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if (x == Mono_Posix_LockFlags_F_ULOCK)
+#ifdef F_ULOCK
+               {*r = F_ULOCK; return 0;}
+#else /* def F_ULOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_ULOCK */
+       if (x == Mono_Posix_LockFlags_F_LOCK)
+#ifdef F_LOCK
+               {*r = F_LOCK; return 0;}
+#else /* def F_LOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_LOCK */
+       if (x == Mono_Posix_LockFlags_F_TLOCK)
+#ifdef F_TLOCK
+               {*r = F_TLOCK; return 0;}
+#else /* def F_TLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_TLOCK */
+       if (x == Mono_Posix_LockFlags_F_TEST)
+#ifdef F_TEST
+               {*r = F_TEST; return 0;}
+#else /* def F_TEST */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_TEST */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToLockFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef F_ULOCK
+       if (x == F_ULOCK)
+               {*r = Mono_Posix_LockFlags_F_ULOCK; return 0;}
+#endif /* ndef F_ULOCK */
+#ifdef F_LOCK
+       if (x == F_LOCK)
+               {*r = Mono_Posix_LockFlags_F_LOCK; return 0;}
+#endif /* ndef F_LOCK */
+#ifdef F_TLOCK
+       if (x == F_TLOCK)
+               {*r = Mono_Posix_LockFlags_F_TLOCK; return 0;}
+#endif /* ndef F_TLOCK */
+#ifdef F_TEST
+       if (x == F_TEST)
+               {*r = Mono_Posix_LockFlags_F_TEST; return 0;}
+#endif /* ndef F_TEST */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromPollEvents (short x, short *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+       if ((x & Mono_Posix_PollEvents_POLLIN) == Mono_Posix_PollEvents_POLLIN)
+#ifdef POLLIN
+               *r |= POLLIN;
+#else /* def POLLIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLIN */
+       if ((x & Mono_Posix_PollEvents_POLLPRI) == Mono_Posix_PollEvents_POLLPRI)
+#ifdef POLLPRI
+               *r |= POLLPRI;
+#else /* def POLLPRI */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLPRI */
+       if ((x & Mono_Posix_PollEvents_POLLOUT) == Mono_Posix_PollEvents_POLLOUT)
+#ifdef POLLOUT
+               *r |= POLLOUT;
+#else /* def POLLOUT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLOUT */
+       if ((x & Mono_Posix_PollEvents_POLLERR) == Mono_Posix_PollEvents_POLLERR)
+#ifdef POLLERR
+               *r |= POLLERR;
+#else /* def POLLERR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLERR */
+       if ((x & Mono_Posix_PollEvents_POLLHUP) == Mono_Posix_PollEvents_POLLHUP)
+#ifdef POLLHUP
+               *r |= POLLHUP;
+#else /* def POLLHUP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLHUP */
+       if ((x & Mono_Posix_PollEvents_POLLNVAL) == Mono_Posix_PollEvents_POLLNVAL)
+#ifdef POLLNVAL
+               *r |= POLLNVAL;
+#else /* def POLLNVAL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLNVAL */
+       if ((x & Mono_Posix_PollEvents_POLLRDNORM) == Mono_Posix_PollEvents_POLLRDNORM)
+#ifdef POLLRDNORM
+               *r |= POLLRDNORM;
+#else /* def POLLRDNORM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLRDNORM */
+       if ((x & Mono_Posix_PollEvents_POLLRDBAND) == Mono_Posix_PollEvents_POLLRDBAND)
+#ifdef POLLRDBAND
+               *r |= POLLRDBAND;
+#else /* def POLLRDBAND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLRDBAND */
+       if ((x & Mono_Posix_PollEvents_POLLWRNORM) == Mono_Posix_PollEvents_POLLWRNORM)
+#ifdef POLLWRNORM
+               *r |= POLLWRNORM;
+#else /* def POLLWRNORM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLWRNORM */
+       if ((x & Mono_Posix_PollEvents_POLLWRBAND) == Mono_Posix_PollEvents_POLLWRBAND)
+#ifdef POLLWRBAND
+               *r |= POLLWRBAND;
+#else /* def POLLWRBAND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef POLLWRBAND */
+       return 0;
+}
+
+int Mono_Posix_ToPollEvents (short x, short *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef POLLIN
+       if ((x & POLLIN) == POLLIN)
+               *r |= Mono_Posix_PollEvents_POLLIN;
+#endif /* ndef POLLIN */
+#ifdef POLLPRI
+       if ((x & POLLPRI) == POLLPRI)
+               *r |= Mono_Posix_PollEvents_POLLPRI;
+#endif /* ndef POLLPRI */
+#ifdef POLLOUT
+       if ((x & POLLOUT) == POLLOUT)
+               *r |= Mono_Posix_PollEvents_POLLOUT;
+#endif /* ndef POLLOUT */
+#ifdef POLLERR
+       if ((x & POLLERR) == POLLERR)
+               *r |= Mono_Posix_PollEvents_POLLERR;
+#endif /* ndef POLLERR */
+#ifdef POLLHUP
+       if ((x & POLLHUP) == POLLHUP)
+               *r |= Mono_Posix_PollEvents_POLLHUP;
+#endif /* ndef POLLHUP */
+#ifdef POLLNVAL
+       if ((x & POLLNVAL) == POLLNVAL)
+               *r |= Mono_Posix_PollEvents_POLLNVAL;
+#endif /* ndef POLLNVAL */
+#ifdef POLLRDNORM
+       if ((x & POLLRDNORM) == POLLRDNORM)
+               *r |= Mono_Posix_PollEvents_POLLRDNORM;
+#endif /* ndef POLLRDNORM */
+#ifdef POLLRDBAND
+       if ((x & POLLRDBAND) == POLLRDBAND)
+               *r |= Mono_Posix_PollEvents_POLLRDBAND;
+#endif /* ndef POLLRDBAND */
+#ifdef POLLWRNORM
+       if ((x & POLLWRNORM) == POLLWRNORM)
+               *r |= Mono_Posix_PollEvents_POLLWRNORM;
+#endif /* ndef POLLWRNORM */
+#ifdef POLLWRBAND
+       if ((x & POLLWRBAND) == POLLWRBAND)
+               *r |= Mono_Posix_PollEvents_POLLWRBAND;
+#endif /* ndef POLLWRBAND */
+       return 0;
 }
 
index 369c17780183676cd35bb8d840254310e7e14c4a..e5cbd419095a70505587b94aeebf4ac42d0cbad5 100644 (file)
@@ -1,4 +1,142 @@
-/* This file was automatically generated by make-map from Mono.Posix.dll */
+/*
+ * This file was automatically generated by make-map from Mono.Posix.dll.
+ *
+ * DO NOT MODIFY.
+ */
+
+#ifndef INC_Mono_Posix_map_H
+#define INC_Mono_Posix_map_H
+
+#include <glib/gtypes.h>
+
+G_BEGIN_DECLS
+
+#define Mono_Posix_Error_EPERM 0x00000001
+#define Mono_Posix_Error_ENOENT 0x00000002
+#define Mono_Posix_Error_ESRCH 0x00000003
+#define Mono_Posix_Error_EINTR 0x00000004
+#define Mono_Posix_Error_EIO 0x00000005
+#define Mono_Posix_Error_ENXIO 0x00000006
+#define Mono_Posix_Error_E2BIG 0x00000007
+#define Mono_Posix_Error_ENOEXEC 0x00000008
+#define Mono_Posix_Error_EBADF 0x00000009
+#define Mono_Posix_Error_ECHILD 0x0000000a
+#define Mono_Posix_Error_EAGAIN 0x0000000b
+#define Mono_Posix_Error_ENOMEM 0x0000000c
+#define Mono_Posix_Error_EACCES 0x0000000d
+#define Mono_Posix_Error_EFAULT 0x0000000e
+#define Mono_Posix_Error_ENOTBLK 0x0000000f
+#define Mono_Posix_Error_EBUSY 0x00000010
+#define Mono_Posix_Error_EEXIST 0x00000011
+#define Mono_Posix_Error_EXDEV 0x00000012
+#define Mono_Posix_Error_ENODEV 0x00000013
+#define Mono_Posix_Error_ENOTDIR 0x00000014
+#define Mono_Posix_Error_EISDIR 0x00000015
+#define Mono_Posix_Error_EINVAL 0x00000016
+#define Mono_Posix_Error_ENFILE 0x00000017
+#define Mono_Posix_Error_EMFILE 0x00000018
+#define Mono_Posix_Error_ENOTTY 0x00000019
+#define Mono_Posix_Error_ETXTBSY 0x0000001a
+#define Mono_Posix_Error_EFBIG 0x0000001b
+#define Mono_Posix_Error_ENOSPC 0x0000001c
+#define Mono_Posix_Error_ESPIPE 0x0000001d
+#define Mono_Posix_Error_EROFS 0x0000001e
+#define Mono_Posix_Error_EMLINK 0x0000001f
+#define Mono_Posix_Error_EPIPE 0x00000020
+#define Mono_Posix_Error_EDOM 0x00000021
+#define Mono_Posix_Error_ERANGE 0x00000022
+#define Mono_Posix_Error_EDEADLK 0x00000023
+#define Mono_Posix_Error_ENAMETOOLONG 0x00000024
+#define Mono_Posix_Error_ENOLCK 0x00000025
+#define Mono_Posix_Error_ENOSYS 0x00000026
+#define Mono_Posix_Error_ENOTEMPTY 0x00000027
+#define Mono_Posix_Error_ELOOP 0x00000028
+#define Mono_Posix_Error_EWOULDBLOCK 0x0000000b
+#define Mono_Posix_Error_ENOMSG 0x0000002a
+#define Mono_Posix_Error_EIDRM 0x0000002b
+#define Mono_Posix_Error_ECHRNG 0x0000002c
+#define Mono_Posix_Error_EL2NSYNC 0x0000002d
+#define Mono_Posix_Error_EL3HLT 0x0000002e
+#define Mono_Posix_Error_EL3RST 0x0000002f
+#define Mono_Posix_Error_ELNRNG 0x00000030
+#define Mono_Posix_Error_EUNATCH 0x00000031
+#define Mono_Posix_Error_ENOCSI 0x00000032
+#define Mono_Posix_Error_EL2HLT 0x00000033
+#define Mono_Posix_Error_EBADE 0x00000034
+#define Mono_Posix_Error_EBADR 0x00000035
+#define Mono_Posix_Error_EXFULL 0x00000036
+#define Mono_Posix_Error_ENOANO 0x00000037
+#define Mono_Posix_Error_EBADRQC 0x00000038
+#define Mono_Posix_Error_EBADSLT 0x00000039
+#define Mono_Posix_Error_EDEADLOCK 0x00000023
+#define Mono_Posix_Error_EBFONT 0x0000003b
+#define Mono_Posix_Error_ENOSTR 0x0000003c
+#define Mono_Posix_Error_ENODATA 0x0000003d
+#define Mono_Posix_Error_ETIME 0x0000003e
+#define Mono_Posix_Error_ENOSR 0x0000003f
+#define Mono_Posix_Error_ENONET 0x00000040
+#define Mono_Posix_Error_ENOPKG 0x00000041
+#define Mono_Posix_Error_EREMOTE 0x00000042
+#define Mono_Posix_Error_ENOLINK 0x00000043
+#define Mono_Posix_Error_EADV 0x00000044
+#define Mono_Posix_Error_ESRMNT 0x00000045
+#define Mono_Posix_Error_ECOMM 0x00000046
+#define Mono_Posix_Error_EPROTO 0x00000047
+#define Mono_Posix_Error_EMULTIHOP 0x00000048
+#define Mono_Posix_Error_EDOTDOT 0x00000049
+#define Mono_Posix_Error_EBADMSG 0x0000004a
+#define Mono_Posix_Error_EOVERFLOW 0x0000004b
+#define Mono_Posix_Error_ENOTUNIQ 0x0000004c
+#define Mono_Posix_Error_EBADFD 0x0000004d
+#define Mono_Posix_Error_EREMCHG 0x0000004e
+#define Mono_Posix_Error_ELIBACC 0x0000004f
+#define Mono_Posix_Error_ELIBBAD 0x00000050
+#define Mono_Posix_Error_ELIBSCN 0x00000051
+#define Mono_Posix_Error_ELIBMAX 0x00000052
+#define Mono_Posix_Error_ELIBEXEC 0x00000053
+#define Mono_Posix_Error_EILSEQ 0x00000054
+#define Mono_Posix_Error_ERESTART 0x00000055
+#define Mono_Posix_Error_ESTRPIPE 0x00000056
+#define Mono_Posix_Error_EUSERS 0x00000057
+#define Mono_Posix_Error_ENOTSOCK 0x00000058
+#define Mono_Posix_Error_EDESTADDRREQ 0x00000059
+#define Mono_Posix_Error_EMSGSIZE 0x0000005a
+#define Mono_Posix_Error_EPROTOTYPE 0x0000005b
+#define Mono_Posix_Error_ENOPROTOOPT 0x0000005c
+#define Mono_Posix_Error_EPROTONOSUPPORT 0x0000005d
+#define Mono_Posix_Error_ESOCKTNOSUPPORT 0x0000005e
+#define Mono_Posix_Error_EOPNOTSUPP 0x0000005f
+#define Mono_Posix_Error_EPFNOSUPPORT 0x00000060
+#define Mono_Posix_Error_EAFNOSUPPORT 0x00000061
+#define Mono_Posix_Error_EADDRINUSE 0x00000062
+#define Mono_Posix_Error_EADDRNOTAVAIL 0x00000063
+#define Mono_Posix_Error_ENETDOWN 0x00000064
+#define Mono_Posix_Error_ENETUNREACH 0x00000065
+#define Mono_Posix_Error_ENETRESET 0x00000066
+#define Mono_Posix_Error_ECONNABORTED 0x00000067
+#define Mono_Posix_Error_ECONNRESET 0x00000068
+#define Mono_Posix_Error_ENOBUFS 0x00000069
+#define Mono_Posix_Error_EISCONN 0x0000006a
+#define Mono_Posix_Error_ENOTCONN 0x0000006b
+#define Mono_Posix_Error_ESHUTDOWN 0x0000006c
+#define Mono_Posix_Error_ETOOMANYREFS 0x0000006d
+#define Mono_Posix_Error_ETIMEDOUT 0x0000006e
+#define Mono_Posix_Error_ECONNREFUSED 0x0000006f
+#define Mono_Posix_Error_EHOSTDOWN 0x00000070
+#define Mono_Posix_Error_EHOSTUNREACH 0x00000071
+#define Mono_Posix_Error_EALREADY 0x00000072
+#define Mono_Posix_Error_EINPROGRESS 0x00000073
+#define Mono_Posix_Error_ESTALE 0x00000074
+#define Mono_Posix_Error_EUCLEAN 0x00000075
+#define Mono_Posix_Error_ENOTNAM 0x00000076
+#define Mono_Posix_Error_ENAVAIL 0x00000077
+#define Mono_Posix_Error_EISNAM 0x00000078
+#define Mono_Posix_Error_EREMOTEIO 0x00000079
+#define Mono_Posix_Error_EDQUOT 0x0000007a
+#define Mono_Posix_Error_ENOMEDIUM 0x0000007b
+#define Mono_Posix_Error_EMEDIUMTYPE 0x0000007c
+int Mono_Posix_FromError (int x, int *r);
+int Mono_Posix_ToError (int x, int *r);
 
 #define Mono_Posix_OpenFlags_O_RDONLY 0x00000000
 #define Mono_Posix_OpenFlags_O_WRONLY 0x00000001
 #define Mono_Posix_OpenFlags_O_APPEND 0x00000040
 #define Mono_Posix_OpenFlags_O_NONBLOCK 0x00000080
 #define Mono_Posix_OpenFlags_O_SYNC 0x00000100
+#define Mono_Posix_OpenFlags_O_NOFOLLOW 0x00000200
+#define Mono_Posix_OpenFlags_O_DIRECTORY 0x00000400
+#define Mono_Posix_OpenFlags_O_DIRECT 0x00000800
+#define Mono_Posix_OpenFlags_O_ASYNC 0x00001000
+#define Mono_Posix_OpenFlags_O_LARGEFILE 0x00002000
+int Mono_Posix_FromOpenFlags (int x, int *r);
+int Mono_Posix_ToOpenFlags (int x, int *r);
+
+#define Mono_Posix_FilePermissions_S_ISUID 0x00000800
+#define Mono_Posix_FilePermissions_S_ISGID 0x00000400
+#define Mono_Posix_FilePermissions_S_ISVTX 0x00000200
+#define Mono_Posix_FilePermissions_S_IRUSR 0x00000100
+#define Mono_Posix_FilePermissions_S_IWUSR 0x00000080
+#define Mono_Posix_FilePermissions_S_IXUSR 0x00000040
+#define Mono_Posix_FilePermissions_S_IRGRP 0x00000020
+#define Mono_Posix_FilePermissions_S_IWGRP 0x00000010
+#define Mono_Posix_FilePermissions_S_IXGRP 0x00000008
+#define Mono_Posix_FilePermissions_S_IROTH 0x00000004
+#define Mono_Posix_FilePermissions_S_IWOTH 0x00000002
+#define Mono_Posix_FilePermissions_S_IXOTH 0x00000001
+#define Mono_Posix_FilePermissions_S_IRWXG 0x00000038
+#define Mono_Posix_FilePermissions_S_IRWXU 0x000001c0
+#define Mono_Posix_FilePermissions_S_IRWXO 0x00000007
+#define Mono_Posix_FilePermissions_ACCESSPERMS 0x000001ff
+#define Mono_Posix_FilePermissions_ALLPERMS 0x00000fff
+#define Mono_Posix_FilePermissions_DEFFILEMODE 0x000001b6
+#define Mono_Posix_FilePermissions_S_IFMT 0x0000f000
+#define Mono_Posix_FilePermissions_S_IFDIR 0x00004000
+#define Mono_Posix_FilePermissions_S_IFCHR 0x00002000
+#define Mono_Posix_FilePermissions_S_IFBLK 0x00006000
+#define Mono_Posix_FilePermissions_S_IFREG 0x00008000
+#define Mono_Posix_FilePermissions_S_IFIFO 0x00001000
+#define Mono_Posix_FilePermissions_S_IFLNK 0x0000a000
+#define Mono_Posix_FilePermissions_S_IFSOCK 0x0000c000
+int Mono_Posix_FromFilePermissions (unsigned int x, unsigned int *r);
+int Mono_Posix_ToFilePermissions (unsigned int x, unsigned int *r);
+
+#define Mono_Posix_FcntlCommand_F_DUPFD 0x00000000
+#define Mono_Posix_FcntlCommand_F_GETFD 0x00000001
+#define Mono_Posix_FcntlCommand_F_SETFD 0x00000002
+#define Mono_Posix_FcntlCommand_F_GETFL 0x00000003
+#define Mono_Posix_FcntlCommand_F_SETFL 0x00000004
+#define Mono_Posix_FcntlCommand_F_GETLK 0x0000000c
+#define Mono_Posix_FcntlCommand_F_SETLK 0x0000000d
+#define Mono_Posix_FcntlCommand_F_SETLKW 0x0000000e
+#define Mono_Posix_FcntlCommand_F_SETOWN 0x00000008
+#define Mono_Posix_FcntlCommand_F_GETOWN 0x00000009
+#define Mono_Posix_FcntlCommand_F_SETSIG 0x0000000a
+#define Mono_Posix_FcntlCommand_F_GETSIG 0x0000000b
+#define Mono_Posix_FcntlCommand_F_SETLEASE 0x00000400
+#define Mono_Posix_FcntlCommand_F_GETLEASE 0x00000401
+#define Mono_Posix_FcntlCommand_F_NOTIFY 0x00000402
+int Mono_Posix_FromFcntlCommand (int x, int *r);
+int Mono_Posix_ToFcntlCommand (int x, int *r);
+
+#define Mono_Posix_LockType_F_RDLCK 0x00000000
+#define Mono_Posix_LockType_F_WRLCK 0x00000001
+#define Mono_Posix_LockType_F_UNLCK 0x00000002
+int Mono_Posix_FromLockType (short x, short *r);
+int Mono_Posix_ToLockType (short x, short *r);
+
+#define Mono_Posix_SeekFlags_SEEK_SET 0x00000000
+#define Mono_Posix_SeekFlags_SEEK_CUR 0x00000001
+#define Mono_Posix_SeekFlags_SEEK_END 0x00000002
+#define Mono_Posix_SeekFlags_L_SET 0x00000000
+#define Mono_Posix_SeekFlags_L_INCR 0x00000001
+#define Mono_Posix_SeekFlags_L_XTND 0x00000002
+int Mono_Posix_FromSeekFlags (short x, short *r);
+int Mono_Posix_ToSeekFlags (short x, short *r);
+
+#define Mono_Posix_DirectoryNotifyFlags_DN_ACCESS 0x00000001
+#define Mono_Posix_DirectoryNotifyFlags_DN_MODIFY 0x00000002
+#define Mono_Posix_DirectoryNotifyFlags_DN_CREATE 0x00000004
+#define Mono_Posix_DirectoryNotifyFlags_DN_DELETE 0x00000008
+#define Mono_Posix_DirectoryNotifyFlags_DN_RENAME 0x00000010
+#define Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB 0x00000020
+#define Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT 0x80000000
+int Mono_Posix_FromDirectoryNotifyFlags (int x, int *r);
+int Mono_Posix_ToDirectoryNotifyFlags (int x, int *r);
+
+#define Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NORMAL 0x00000000
+#define Mono_Posix_PosixFadviseAdvice_POSIX_FADV_RANDOM 0x00000001
+#define Mono_Posix_PosixFadviseAdvice_POSIX_FADV_SEQUENTIAL 0x00000002
+#define Mono_Posix_PosixFadviseAdvice_POSIX_FADV_WILLNEED 0x00000003
+#define Mono_Posix_PosixFadviseAdvice_POSIX_FADV_DONTNEED 0x00000004
+#define Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NOREUSE 0x00000005
+int Mono_Posix_FromPosixFadviseAdvice (int x, int *r);
+int Mono_Posix_ToPosixFadviseAdvice (int x, int *r);
 
-#define Mono_Posix_FileMode_S_ISUID 0x00000800
-#define Mono_Posix_FileMode_S_ISGID 0x00000400
-#define Mono_Posix_FileMode_S_ISVTX 0x00000200
-#define Mono_Posix_FileMode_S_IRUSR 0x00000100
-#define Mono_Posix_FileMode_S_IWUSR 0x00000080
-#define Mono_Posix_FileMode_S_IXUSR 0x00000040
-#define Mono_Posix_FileMode_S_IRGRP 0x00000020
-#define Mono_Posix_FileMode_S_IWGRP 0x00000010
-#define Mono_Posix_FileMode_S_IXGRP 0x00000008
-#define Mono_Posix_FileMode_S_IROTH 0x00000004
-#define Mono_Posix_FileMode_S_IWOTH 0x00000002
-#define Mono_Posix_FileMode_S_IXOTH 0x00000001
-
-#define Mono_Posix_WaitOptions_WNOHANG 0x00000000
-#define Mono_Posix_WaitOptions_WUNTRACED 0x00000001
+#define Mono_Posix_PosixMadviseAdvice_POSIX_MADV_NORMAL 0x00000000
+#define Mono_Posix_PosixMadviseAdvice_POSIX_MADV_RANDOM 0x00000001
+#define Mono_Posix_PosixMadviseAdvice_POSIX_MADV_SEQUENTIAL 0x00000002
+#define Mono_Posix_PosixMadviseAdvice_POSIX_MADV_WILLNEED 0x00000003
+#define Mono_Posix_PosixMadviseAdvice_POSIX_MADV_DONTNEED 0x00000004
+int Mono_Posix_FromPosixMadviseAdvice (int x, int *r);
+int Mono_Posix_ToPosixMadviseAdvice (int x, int *r);
+
+#define Mono_Posix_Signum_SIGHUP 0x00000001
+#define Mono_Posix_Signum_SIGINT 0x00000002
+#define Mono_Posix_Signum_SIGQUIT 0x00000003
+#define Mono_Posix_Signum_SIGILL 0x00000004
+#define Mono_Posix_Signum_SIGTRAP 0x00000005
+#define Mono_Posix_Signum_SIGABRT 0x00000006
+#define Mono_Posix_Signum_SIGIOT 0x00000006
+#define Mono_Posix_Signum_SIGBUS 0x00000007
+#define Mono_Posix_Signum_SIGFPE 0x00000008
+#define Mono_Posix_Signum_SIGKILL 0x00000009
+#define Mono_Posix_Signum_SIGUSR1 0x0000000a
+#define Mono_Posix_Signum_SIGSEGV 0x0000000b
+#define Mono_Posix_Signum_SIGUSR2 0x0000000c
+#define Mono_Posix_Signum_SIGPIPE 0x0000000d
+#define Mono_Posix_Signum_SIGALRM 0x0000000e
+#define Mono_Posix_Signum_SIGTERM 0x0000000f
+#define Mono_Posix_Signum_SIGSTKFLT 0x00000010
+#define Mono_Posix_Signum_SIGCHLD 0x00000011
+#define Mono_Posix_Signum_SIGCLD 0x00000011
+#define Mono_Posix_Signum_SIGCONT 0x00000012
+#define Mono_Posix_Signum_SIGSTOP 0x00000013
+#define Mono_Posix_Signum_SIGTSTP 0x00000014
+#define Mono_Posix_Signum_SIGTTIN 0x00000015
+#define Mono_Posix_Signum_SIGTTOU 0x00000016
+#define Mono_Posix_Signum_SIGURG 0x00000017
+#define Mono_Posix_Signum_SIGXCPU 0x00000018
+#define Mono_Posix_Signum_SIGXFSZ 0x00000019
+#define Mono_Posix_Signum_SIGVTALRM 0x0000001a
+#define Mono_Posix_Signum_SIGPROF 0x0000001b
+#define Mono_Posix_Signum_SIGWINCH 0x0000001c
+#define Mono_Posix_Signum_SIGIO 0x0000001d
+#define Mono_Posix_Signum_SIGPOLL 0x0000001d
+#define Mono_Posix_Signum_SIGPWR 0x0000001e
+#define Mono_Posix_Signum_SIGSYS 0x0000001f
+#define Mono_Posix_Signum_SIGUNUSED 0x0000001f
+int Mono_Posix_FromSignum (int x, int *r);
+int Mono_Posix_ToSignum (int x, int *r);
+
+#define Mono_Posix_MountFlags_MS_RDONLY 0x00000001
+#define Mono_Posix_MountFlags_MS_NOSUID 0x00000002
+#define Mono_Posix_MountFlags_MS_NODEV 0x00000004
+#define Mono_Posix_MountFlags_MS_NOEXEC 0x00000008
+#define Mono_Posix_MountFlags_MS_SYNCHRONOUS 0x00000010
+#define Mono_Posix_MountFlags_MS_REMOUNT 0x00000020
+#define Mono_Posix_MountFlags_MS_MANDLOCK 0x00000040
+#define Mono_Posix_MountFlags_S_WRITE 0x00000080
+#define Mono_Posix_MountFlags_S_APPEND 0x00000100
+#define Mono_Posix_MountFlags_S_IMMUTABLE 0x00000200
+#define Mono_Posix_MountFlags_MS_NOATIME 0x00000400
+#define Mono_Posix_MountFlags_MS_NODIRATIME 0x00000800
+#define Mono_Posix_MountFlags_MS_BIND 0x00001000
+#define Mono_Posix_MountFlags_MS_RMT_MASK 0x00000041
+#define Mono_Posix_MountFlags_MS_MGC_VAL 0xc0ed0000
+#define Mono_Posix_MountFlags_MS_MGC_MSK 0xffff0000
+int Mono_Posix_FromMountFlags (guint64 x, guint64 *r);
+int Mono_Posix_ToMountFlags (guint64 x, guint64 *r);
+
+#define Mono_Posix_UmountFlags_MNT_FORCE 0x00000001
+#define Mono_Posix_UmountFlags_MNT_DETACH 0x00000002
+int Mono_Posix_FromUmountFlags (int x, int *r);
+int Mono_Posix_ToUmountFlags (int x, int *r);
+
+#define Mono_Posix_WaitOptions_WNOHANG 0x00000001
+#define Mono_Posix_WaitOptions_WUNTRACED 0x00000002
+int Mono_Posix_FromWaitOptions (int x, int *r);
+int Mono_Posix_ToWaitOptions (int x, int *r);
 
 #define Mono_Posix_AccessMode_R_OK 0x00000001
 #define Mono_Posix_AccessMode_W_OK 0x00000002
 #define Mono_Posix_AccessMode_X_OK 0x00000004
 #define Mono_Posix_AccessMode_F_OK 0x00000008
+int Mono_Posix_FromAccessMode (int x, int *r);
+int Mono_Posix_ToAccessMode (int x, int *r);
+
+#define Mono_Posix_PathConf__PC_LINK_MAX 0x00000000
+#define Mono_Posix_PathConf__PC_MAX_CANON 0x00000001
+#define Mono_Posix_PathConf__PC_MAX_INPUT 0x00000002
+#define Mono_Posix_PathConf__PC_NAME_MAX 0x00000003
+#define Mono_Posix_PathConf__PC_PATH_MAX 0x00000004
+#define Mono_Posix_PathConf__PC_PIPE_BUF 0x00000005
+#define Mono_Posix_PathConf__PC_CHOWN_RESTRICTED 0x00000006
+#define Mono_Posix_PathConf__PC_NO_TRUNC 0x00000007
+#define Mono_Posix_PathConf__PC_VDISABLE 0x00000008
+#define Mono_Posix_PathConf__PC_SYNC_IO 0x00000009
+#define Mono_Posix_PathConf__PC_ASYNC_IO 0x0000000a
+#define Mono_Posix_PathConf__PC_PRIO_IO 0x0000000b
+#define Mono_Posix_PathConf__PC_SOCK_MAXBUF 0x0000000c
+#define Mono_Posix_PathConf__PC_FILESIZEBITS 0x0000000d
+#define Mono_Posix_PathConf__PC_REC_INCR_XFER_SIZE 0x0000000e
+#define Mono_Posix_PathConf__PC_REC_MAX_XFER_SIZE 0x0000000f
+#define Mono_Posix_PathConf__PC_REC_MIN_XFER_SIZE 0x00000010
+#define Mono_Posix_PathConf__PC_REC_XFER_ALIGN 0x00000011
+#define Mono_Posix_PathConf__PC_ALLOC_SIZE_MIN 0x00000012
+#define Mono_Posix_PathConf__PC_SYMLINK_MAX 0x00000013
+#define Mono_Posix_PathConf__PC_2_SYMLINKS 0x00000014
+int Mono_Posix_FromPathConf (int x, int *r);
+int Mono_Posix_ToPathConf (int x, int *r);
 
-#define Mono_Posix_Signals_SIGHUP 0x00000000
-#define Mono_Posix_Signals_SIGINT 0x00000001
-#define Mono_Posix_Signals_SIGQUIT 0x00000002
-#define Mono_Posix_Signals_SIGILL 0x00000003
-#define Mono_Posix_Signals_SIGTRAP 0x00000004
-#define Mono_Posix_Signals_SIGABRT 0x00000005
-#define Mono_Posix_Signals_SIGBUS 0x00000006
-#define Mono_Posix_Signals_SIGFPE 0x00000007
-#define Mono_Posix_Signals_SIGKILL 0x00000008
-#define Mono_Posix_Signals_SIGUSR1 0x00000009
-#define Mono_Posix_Signals_SIGSEGV 0x0000000a
-#define Mono_Posix_Signals_SIGUSR2 0x0000000b
-#define Mono_Posix_Signals_SIGPIPE 0x0000000c
-#define Mono_Posix_Signals_SIGALRM 0x0000000d
-#define Mono_Posix_Signals_SIGTERM 0x0000000e
-#define Mono_Posix_Signals_SIGCHLD 0x0000000f
-#define Mono_Posix_Signals_SIGCONT 0x00000010
-#define Mono_Posix_Signals_SIGSTOP 0x00000011
-#define Mono_Posix_Signals_SIGTSTP 0x00000012
-#define Mono_Posix_Signals_SIGTTIN 0x00000013
-#define Mono_Posix_Signals_SIGTTOU 0x00000014
-#define Mono_Posix_Signals_SIGURG 0x00000015
-#define Mono_Posix_Signals_SIGXCPU 0x00000016
-#define Mono_Posix_Signals_SIGXFSZ 0x00000017
-#define Mono_Posix_Signals_SIGVTALRM 0x00000018
-#define Mono_Posix_Signals_SIGPROF 0x00000019
-#define Mono_Posix_Signals_SIGWINCH 0x0000001a
-#define Mono_Posix_Signals_SIGIO 0x0000001b
-#define Mono_Posix_Signals_SIGSYS 0x0000001c
-
-#define Mono_Posix_PollEvents_POLLIN 0x00000002
-#define Mono_Posix_PollEvents_POLLPRI 0x00000003
+#define Mono_Posix_SysConf__SC_ARG_MAX 0x00000000
+#define Mono_Posix_SysConf__SC_CHILD_MAX 0x00000001
+#define Mono_Posix_SysConf__SC_CLK_TCK 0x00000002
+#define Mono_Posix_SysConf__SC_NGROUPS_MAX 0x00000003
+#define Mono_Posix_SysConf__SC_OPEN_MAX 0x00000004
+#define Mono_Posix_SysConf__SC_STREAM_MAX 0x00000005
+#define Mono_Posix_SysConf__SC_TZNAME_MAX 0x00000006
+#define Mono_Posix_SysConf__SC_JOB_CONTROL 0x00000007
+#define Mono_Posix_SysConf__SC_SAVED_IDS 0x00000008
+#define Mono_Posix_SysConf__SC_REALTIME_SIGNALS 0x00000009
+#define Mono_Posix_SysConf__SC_PRIORITY_SCHEDULING 0x0000000a
+#define Mono_Posix_SysConf__SC_TIMERS 0x0000000b
+#define Mono_Posix_SysConf__SC_ASYNCHRONOUS_IO 0x0000000c
+#define Mono_Posix_SysConf__SC_PRIORITIZED_IO 0x0000000d
+#define Mono_Posix_SysConf__SC_SYNCHRONIZED_IO 0x0000000e
+#define Mono_Posix_SysConf__SC_FSYNC 0x0000000f
+#define Mono_Posix_SysConf__SC_MAPPED_FILES 0x00000010
+#define Mono_Posix_SysConf__SC_MEMLOCK 0x00000011
+#define Mono_Posix_SysConf__SC_MEMLOCK_RANGE 0x00000012
+#define Mono_Posix_SysConf__SC_MEMORY_PROTECTION 0x00000013
+#define Mono_Posix_SysConf__SC_MESSAGE_PASSING 0x00000014
+#define Mono_Posix_SysConf__SC_SEMAPHORES 0x00000015
+#define Mono_Posix_SysConf__SC_SHARED_MEMORY_OBJECTS 0x00000016
+#define Mono_Posix_SysConf__SC_AIO_LISTIO_MAX 0x00000017
+#define Mono_Posix_SysConf__SC_AIO_MAX 0x00000018
+#define Mono_Posix_SysConf__SC_AIO_PRIO_DELTA_MAX 0x00000019
+#define Mono_Posix_SysConf__SC_DELAYTIMER_MAX 0x0000001a
+#define Mono_Posix_SysConf__SC_MQ_OPEN_MAX 0x0000001b
+#define Mono_Posix_SysConf__SC_MQ_PRIO_MAX 0x0000001c
+#define Mono_Posix_SysConf__SC_VERSION 0x0000001d
+#define Mono_Posix_SysConf__SC_PAGESIZE 0x0000001e
+#define Mono_Posix_SysConf__SC_RTSIG_MAX 0x0000001f
+#define Mono_Posix_SysConf__SC_SEM_NSEMS_MAX 0x00000020
+#define Mono_Posix_SysConf__SC_SEM_VALUE_MAX 0x00000021
+#define Mono_Posix_SysConf__SC_SIGQUEUE_MAX 0x00000022
+#define Mono_Posix_SysConf__SC_TIMER_MAX 0x00000023
+#define Mono_Posix_SysConf__SC_BC_BASE_MAX 0x00000024
+#define Mono_Posix_SysConf__SC_BC_DIM_MAX 0x00000025
+#define Mono_Posix_SysConf__SC_BC_SCALE_MAX 0x00000026
+#define Mono_Posix_SysConf__SC_BC_STRING_MAX 0x00000027
+#define Mono_Posix_SysConf__SC_COLL_WEIGHTS_MAX 0x00000028
+#define Mono_Posix_SysConf__SC_EQUIV_CLASS_MAX 0x00000029
+#define Mono_Posix_SysConf__SC_EXPR_NEST_MAX 0x0000002a
+#define Mono_Posix_SysConf__SC_LINE_MAX 0x0000002b
+#define Mono_Posix_SysConf__SC_RE_DUP_MAX 0x0000002c
+#define Mono_Posix_SysConf__SC_CHARCLASS_NAME_MAX 0x0000002d
+#define Mono_Posix_SysConf__SC_2_VERSION 0x0000002e
+#define Mono_Posix_SysConf__SC_2_C_BIND 0x0000002f
+#define Mono_Posix_SysConf__SC_2_C_DEV 0x00000030
+#define Mono_Posix_SysConf__SC_2_FORT_DEV 0x00000031
+#define Mono_Posix_SysConf__SC_2_FORT_RUN 0x00000032
+#define Mono_Posix_SysConf__SC_2_SW_DEV 0x00000033
+#define Mono_Posix_SysConf__SC_2_LOCALEDEF 0x00000034
+#define Mono_Posix_SysConf__SC_PII 0x00000035
+#define Mono_Posix_SysConf__SC_PII_XTI 0x00000036
+#define Mono_Posix_SysConf__SC_PII_SOCKET 0x00000037
+#define Mono_Posix_SysConf__SC_PII_INTERNET 0x00000038
+#define Mono_Posix_SysConf__SC_PII_OSI 0x00000039
+#define Mono_Posix_SysConf__SC_POLL 0x0000003a
+#define Mono_Posix_SysConf__SC_SELECT 0x0000003b
+#define Mono_Posix_SysConf__SC_UIO_MAXIOV 0x0000003c
+#define Mono_Posix_SysConf__SC_IOV_MAX 0x0000003c
+#define Mono_Posix_SysConf__SC_PII_INTERNET_STREAM 0x0000003d
+#define Mono_Posix_SysConf__SC_PII_INTERNET_DGRAM 0x0000003e
+#define Mono_Posix_SysConf__SC_PII_OSI_COTS 0x0000003f
+#define Mono_Posix_SysConf__SC_PII_OSI_CLTS 0x00000040
+#define Mono_Posix_SysConf__SC_PII_OSI_M 0x00000041
+#define Mono_Posix_SysConf__SC_T_IOV_MAX 0x00000042
+#define Mono_Posix_SysConf__SC_THREADS 0x00000043
+#define Mono_Posix_SysConf__SC_THREAD_SAFE_FUNCTIONS 0x00000044
+#define Mono_Posix_SysConf__SC_GETGR_R_SIZE_MAX 0x00000045
+#define Mono_Posix_SysConf__SC_GETPW_R_SIZE_MAX 0x00000046
+#define Mono_Posix_SysConf__SC_LOGIN_NAME_MAX 0x00000047
+#define Mono_Posix_SysConf__SC_TTY_NAME_MAX 0x00000048
+#define Mono_Posix_SysConf__SC_THREAD_DESTRUCTOR_ITERATIONS 0x00000049
+#define Mono_Posix_SysConf__SC_THREAD_KEYS_MAX 0x0000004a
+#define Mono_Posix_SysConf__SC_THREAD_STACK_MIN 0x0000004b
+#define Mono_Posix_SysConf__SC_THREAD_THREADS_MAX 0x0000004c
+#define Mono_Posix_SysConf__SC_THREAD_ATTR_STACKADDR 0x0000004d
+#define Mono_Posix_SysConf__SC_THREAD_ATTR_STACKSIZE 0x0000004e
+#define Mono_Posix_SysConf__SC_THREAD_PRIORITY_SCHEDULING 0x0000004f
+#define Mono_Posix_SysConf__SC_THREAD_PRIO_INHERIT 0x00000050
+#define Mono_Posix_SysConf__SC_THREAD_PRIO_PROTECT 0x00000051
+#define Mono_Posix_SysConf__SC_THREAD_PROCESS_SHARED 0x00000052
+#define Mono_Posix_SysConf__SC_NPROCESSORS_CONF 0x00000053
+#define Mono_Posix_SysConf__SC_NPROCESSORS_ONLN 0x00000054
+#define Mono_Posix_SysConf__SC_PHYS_PAGES 0x00000055
+#define Mono_Posix_SysConf__SC_AVPHYS_PAGES 0x00000056
+#define Mono_Posix_SysConf__SC_ATEXIT_MAX 0x00000057
+#define Mono_Posix_SysConf__SC_PASS_MAX 0x00000058
+#define Mono_Posix_SysConf__SC_XOPEN_VERSION 0x00000059
+#define Mono_Posix_SysConf__SC_XOPEN_XCU_VERSION 0x0000005a
+#define Mono_Posix_SysConf__SC_XOPEN_UNIX 0x0000005b
+#define Mono_Posix_SysConf__SC_XOPEN_CRYPT 0x0000005c
+#define Mono_Posix_SysConf__SC_XOPEN_ENH_I18N 0x0000005d
+#define Mono_Posix_SysConf__SC_XOPEN_SHM 0x0000005e
+#define Mono_Posix_SysConf__SC_2_CHAR_TERM 0x0000005f
+#define Mono_Posix_SysConf__SC_2_C_VERSION 0x00000060
+#define Mono_Posix_SysConf__SC_2_UPE 0x00000061
+#define Mono_Posix_SysConf__SC_XOPEN_XPG2 0x00000062
+#define Mono_Posix_SysConf__SC_XOPEN_XPG3 0x00000063
+#define Mono_Posix_SysConf__SC_XOPEN_XPG4 0x00000064
+#define Mono_Posix_SysConf__SC_CHAR_BIT 0x00000065
+#define Mono_Posix_SysConf__SC_CHAR_MAX 0x00000066
+#define Mono_Posix_SysConf__SC_CHAR_MIN 0x00000067
+#define Mono_Posix_SysConf__SC_INT_MAX 0x00000068
+#define Mono_Posix_SysConf__SC_INT_MIN 0x00000069
+#define Mono_Posix_SysConf__SC_LONG_BIT 0x0000006a
+#define Mono_Posix_SysConf__SC_WORD_BIT 0x0000006b
+#define Mono_Posix_SysConf__SC_MB_LEN_MAX 0x0000006c
+#define Mono_Posix_SysConf__SC_NZERO 0x0000006d
+#define Mono_Posix_SysConf__SC_SSIZE_MAX 0x0000006e
+#define Mono_Posix_SysConf__SC_SCHAR_MAX 0x0000006f
+#define Mono_Posix_SysConf__SC_SCHAR_MIN 0x00000070
+#define Mono_Posix_SysConf__SC_SHRT_MAX 0x00000071
+#define Mono_Posix_SysConf__SC_SHRT_MIN 0x00000072
+#define Mono_Posix_SysConf__SC_UCHAR_MAX 0x00000073
+#define Mono_Posix_SysConf__SC_UINT_MAX 0x00000074
+#define Mono_Posix_SysConf__SC_ULONG_MAX 0x00000075
+#define Mono_Posix_SysConf__SC_USHRT_MAX 0x00000076
+#define Mono_Posix_SysConf__SC_NL_ARGMAX 0x00000077
+#define Mono_Posix_SysConf__SC_NL_LANGMAX 0x00000078
+#define Mono_Posix_SysConf__SC_NL_MSGMAX 0x00000079
+#define Mono_Posix_SysConf__SC_NL_NMAX 0x0000007a
+#define Mono_Posix_SysConf__SC_NL_SETMAX 0x0000007b
+#define Mono_Posix_SysConf__SC_NL_TEXTMAX 0x0000007c
+#define Mono_Posix_SysConf__SC_XBS5_ILP32_OFF32 0x0000007d
+#define Mono_Posix_SysConf__SC_XBS5_ILP32_OFFBIG 0x0000007e
+#define Mono_Posix_SysConf__SC_XBS5_LP64_OFF64 0x0000007f
+#define Mono_Posix_SysConf__SC_XBS5_LPBIG_OFFBIG 0x00000080
+#define Mono_Posix_SysConf__SC_XOPEN_LEGACY 0x00000081
+#define Mono_Posix_SysConf__SC_XOPEN_REALTIME 0x00000082
+#define Mono_Posix_SysConf__SC_XOPEN_REALTIME_THREADS 0x00000083
+#define Mono_Posix_SysConf__SC_ADVISORY_INFO 0x00000084
+#define Mono_Posix_SysConf__SC_BARRIERS 0x00000085
+#define Mono_Posix_SysConf__SC_BASE 0x00000086
+#define Mono_Posix_SysConf__SC_C_LANG_SUPPORT 0x00000087
+#define Mono_Posix_SysConf__SC_C_LANG_SUPPORT_R 0x00000088
+#define Mono_Posix_SysConf__SC_CLOCK_SELECTION 0x00000089
+#define Mono_Posix_SysConf__SC_CPUTIME 0x0000008a
+#define Mono_Posix_SysConf__SC_THREAD_CPUTIME 0x0000008b
+#define Mono_Posix_SysConf__SC_DEVICE_IO 0x0000008c
+#define Mono_Posix_SysConf__SC_DEVICE_SPECIFIC 0x0000008d
+#define Mono_Posix_SysConf__SC_DEVICE_SPECIFIC_R 0x0000008e
+#define Mono_Posix_SysConf__SC_FD_MGMT 0x0000008f
+#define Mono_Posix_SysConf__SC_FIFO 0x00000090
+#define Mono_Posix_SysConf__SC_PIPE 0x00000091
+#define Mono_Posix_SysConf__SC_FILE_ATTRIBUTES 0x00000092
+#define Mono_Posix_SysConf__SC_FILE_LOCKING 0x00000093
+#define Mono_Posix_SysConf__SC_FILE_SYSTEM 0x00000094
+#define Mono_Posix_SysConf__SC_MONOTONIC_CLOCK 0x00000095
+#define Mono_Posix_SysConf__SC_MULTI_PROCESS 0x00000096
+#define Mono_Posix_SysConf__SC_SINGLE_PROCESS 0x00000097
+#define Mono_Posix_SysConf__SC_NETWORKING 0x00000098
+#define Mono_Posix_SysConf__SC_READER_WRITER_LOCKS 0x00000099
+#define Mono_Posix_SysConf__SC_SPIN_LOCKS 0x0000009a
+#define Mono_Posix_SysConf__SC_REGEXP 0x0000009b
+#define Mono_Posix_SysConf__SC_REGEX_VERSION 0x0000009c
+#define Mono_Posix_SysConf__SC_SHELL 0x0000009d
+#define Mono_Posix_SysConf__SC_SIGNALS 0x0000009e
+#define Mono_Posix_SysConf__SC_SPAWN 0x0000009f
+#define Mono_Posix_SysConf__SC_SPORADIC_SERVER 0x000000a0
+#define Mono_Posix_SysConf__SC_THREAD_SPORADIC_SERVER 0x000000a1
+#define Mono_Posix_SysConf__SC_SYSTEM_DATABASE 0x000000a2
+#define Mono_Posix_SysConf__SC_SYSTEM_DATABASE_R 0x000000a3
+#define Mono_Posix_SysConf__SC_TIMEOUTS 0x000000a4
+#define Mono_Posix_SysConf__SC_TYPED_MEMORY_OBJECTS 0x000000a5
+#define Mono_Posix_SysConf__SC_USER_GROUPS 0x000000a6
+#define Mono_Posix_SysConf__SC_USER_GROUPS_R 0x000000a7
+#define Mono_Posix_SysConf__SC_2_PBS 0x000000a8
+#define Mono_Posix_SysConf__SC_2_PBS_ACCOUNTING 0x000000a9
+#define Mono_Posix_SysConf__SC_2_PBS_LOCATE 0x000000aa
+#define Mono_Posix_SysConf__SC_2_PBS_MESSAGE 0x000000ab
+#define Mono_Posix_SysConf__SC_2_PBS_TRACK 0x000000ac
+#define Mono_Posix_SysConf__SC_SYMLOOP_MAX 0x000000ad
+#define Mono_Posix_SysConf__SC_STREAMS 0x000000ae
+#define Mono_Posix_SysConf__SC_2_PBS_CHECKPOINT 0x000000af
+#define Mono_Posix_SysConf__SC_V6_ILP32_OFF32 0x000000b0
+#define Mono_Posix_SysConf__SC_V6_ILP32_OFFBIG 0x000000b1
+#define Mono_Posix_SysConf__SC_V6_LP64_OFF64 0x000000b2
+#define Mono_Posix_SysConf__SC_V6_LPBIG_OFFBIG 0x000000b3
+#define Mono_Posix_SysConf__SC_HOST_NAME_MAX 0x000000b4
+#define Mono_Posix_SysConf__SC_TRACE 0x000000b5
+#define Mono_Posix_SysConf__SC_TRACE_EVENT_FILTER 0x000000b6
+#define Mono_Posix_SysConf__SC_TRACE_INHERIT 0x000000b7
+#define Mono_Posix_SysConf__SC_TRACE_LOG 0x000000b8
+#define Mono_Posix_SysConf__SC_LEVEL1_ICACHE_SIZE 0x000000b9
+#define Mono_Posix_SysConf__SC_LEVEL1_ICACHE_ASSOC 0x000000ba
+#define Mono_Posix_SysConf__SC_LEVEL1_ICACHE_LINESIZE 0x000000bb
+#define Mono_Posix_SysConf__SC_LEVEL1_DCACHE_SIZE 0x000000bc
+#define Mono_Posix_SysConf__SC_LEVEL1_DCACHE_ASSOC 0x000000bd
+#define Mono_Posix_SysConf__SC_LEVEL1_DCACHE_LINESIZE 0x000000be
+#define Mono_Posix_SysConf__SC_LEVEL2_CACHE_SIZE 0x000000bf
+#define Mono_Posix_SysConf__SC_LEVEL2_CACHE_ASSOC 0x000000c0
+#define Mono_Posix_SysConf__SC_LEVEL2_CACHE_LINESIZE 0x000000c1
+#define Mono_Posix_SysConf__SC_LEVEL3_CACHE_SIZE 0x000000c2
+#define Mono_Posix_SysConf__SC_LEVEL3_CACHE_ASSOC 0x000000c3
+#define Mono_Posix_SysConf__SC_LEVEL3_CACHE_LINESIZE 0x000000c4
+#define Mono_Posix_SysConf__SC_LEVEL4_CACHE_SIZE 0x000000c5
+#define Mono_Posix_SysConf__SC_LEVEL4_CACHE_ASSOC 0x000000c6
+#define Mono_Posix_SysConf__SC_LEVEL4_CACHE_LINESIZE 0x000000c7
+int Mono_Posix_FromSysConf (int x, int *r);
+int Mono_Posix_ToSysConf (int x, int *r);
+
+#define Mono_Posix_ConfStr__CS_PATH 0x00000000
+#define Mono_Posix_ConfStr__CS_V6_WIDTH_RESTRICTED_ENVS 0x00000001
+#define Mono_Posix_ConfStr__CS_GNU_LIBC_VERSION 0x00000002
+#define Mono_Posix_ConfStr__CS_GNU_LIBPTHREAD_VERSION 0x00000003
+#define Mono_Posix_ConfStr__CS_LFS_CFLAGS 0x000003e8
+#define Mono_Posix_ConfStr__CS_LFS_LDFLAGS 0x000003e9
+#define Mono_Posix_ConfStr__CS_LFS_LIBS 0x000003ea
+#define Mono_Posix_ConfStr__CS_LFS_LINTFLAGS 0x000003eb
+#define Mono_Posix_ConfStr__CS_LFS64_CFLAGS 0x000003ec
+#define Mono_Posix_ConfStr__CS_LFS64_LDFLAGS 0x000003ed
+#define Mono_Posix_ConfStr__CS_LFS64_LIBS 0x000003ee
+#define Mono_Posix_ConfStr__CS_LFS64_LINTFLAGS 0x000003ef
+#define Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_CFLAGS 0x0000044c
+#define Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LDFLAGS 0x0000044d
+#define Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LIBS 0x0000044e
+#define Mono_Posix_ConfStr__CS_XBS5_ILP32_OFF32_LINTFLAGS 0x0000044f
+#define Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_CFLAGS 0x00000450
+#define Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LDFLAGS 0x00000451
+#define Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LIBS 0x00000452
+#define Mono_Posix_ConfStr__CS_XBS5_ILP32_OFFBIG_LINTFLAGS 0x00000453
+#define Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_CFLAGS 0x00000454
+#define Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LDFLAGS 0x00000455
+#define Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LIBS 0x00000456
+#define Mono_Posix_ConfStr__CS_XBS5_LP64_OFF64_LINTFLAGS 0x00000457
+#define Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_CFLAGS 0x00000458
+#define Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LDFLAGS 0x00000459
+#define Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LIBS 0x0000045a
+#define Mono_Posix_ConfStr__CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 0x0000045b
+#define Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_CFLAGS 0x0000045c
+#define Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LDFLAGS 0x0000045d
+#define Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LIBS 0x0000045e
+#define Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 0x0000045f
+#define Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 0x00000460
+#define Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 0x00000461
+#define Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LIBS 0x00000462
+#define Mono_Posix_ConfStr__CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 0x00000463
+#define Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_CFLAGS 0x00000464
+#define Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LDFLAGS 0x00000465
+#define Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LIBS 0x00000466
+#define Mono_Posix_ConfStr__CS_POSIX_V6_LP64_OFF64_LINTFLAGS 0x00000467
+#define Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 0x00000468
+#define Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 0x00000469
+#define Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LIBS 0x0000046a
+#define Mono_Posix_ConfStr__CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 0x0000046b
+int Mono_Posix_FromConfStr (int x, int *r);
+int Mono_Posix_ToConfStr (int x, int *r);
+
+#define Mono_Posix_LockFlags_F_ULOCK 0x00000000
+#define Mono_Posix_LockFlags_F_LOCK 0x00000001
+#define Mono_Posix_LockFlags_F_TLOCK 0x00000002
+#define Mono_Posix_LockFlags_F_TEST 0x00000003
+int Mono_Posix_FromLockFlags (int x, int *r);
+int Mono_Posix_ToLockFlags (int x, int *r);
+
+#define Mono_Posix_PollEvents_POLLIN 0x00000001
+#define Mono_Posix_PollEvents_POLLPRI 0x00000002
 #define Mono_Posix_PollEvents_POLLOUT 0x00000004
-#define Mono_Posix_PollEvents_POLLERR 0x00000005
-#define Mono_Posix_PollEvents_POLLHUP 0x00000006
-#define Mono_Posix_PollEvents_POLLNVAL 0x00000007
+#define Mono_Posix_PollEvents_POLLERR 0x00000008
+#define Mono_Posix_PollEvents_POLLHUP 0x00000010
+#define Mono_Posix_PollEvents_POLLNVAL 0x00000020
+#define Mono_Posix_PollEvents_POLLRDNORM 0x00000040
+#define Mono_Posix_PollEvents_POLLRDBAND 0x00000080
+#define Mono_Posix_PollEvents_POLLWRNORM 0x00000100
+#define Mono_Posix_PollEvents_POLLWRBAND 0x00000200
+int Mono_Posix_FromPollEvents (short x, short *r);
+int Mono_Posix_ToPollEvents (short x, short *r);
+
+G_END_DECLS
+
+#endif /* ndef INC_Mono_Posix_map_H */
 
diff --git a/support/mph.h b/support/mph.h
new file mode 100644 (file)
index 0000000..b7a9b4c
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Common/shared macros and routines.
+ *
+ * This file contains macros of the form
+ *
+ *   mph_return_if_TYPE_overflow(val);
+ *
+ * Which tests `val' for a TYPE underflow/overflow (that is, is `val' within
+ * the range for TYPE?).  If `val' can't fit in TYPE, errno is set to
+ * EOVERFLOW, and `return -1' is executed (which is why it's a macro).
+ *
+ * Assumptions:
+ *
+ * I'm working from GLibc, so that's the basis for my assumptions.  They may
+ * not be completely portable, in which case I'll need to fix my assumptions.
+ * :-(
+ *
+ * See the typedefs for type size assumptions.  These typedefs *must* be kept
+ * in sync with the types used in Mono.Posix.dll.
+ */
+
+#ifndef INC_mph_H
+#define INC_mph_H
+
+#include <stdint.h>  /* for SIZE_MAX */
+#include <limits.h>
+#include <glib/gtypes.h>
+
+#ifdef _LARGEFILE64_SOURCE
+#define MPH_USE_64_API
+#endif
+
+typedef    gint64 mph_blkcnt_t;
+typedef    gint64 mph_blksize_t;
+typedef   guint64 mph_dev_t;
+typedef   guint64 mph_ino_t;
+typedef   guint64 mph_nlink_t;
+typedef    gint64 mph_off_t;
+typedef   guint64 mph_size_t;
+typedef    gint64 mph_ssize_t;
+typedef    gint32 mph_pid_t;
+typedef   guint32 mph_gid_t;
+typedef   guint32 mph_uid_t;
+typedef    gint64 mph_time_t;
+typedef    gint64 mph_clock_t;
+
+#define mph_have_long_overflow(var) ((var) > LONG_MAX || (var) < LONG_MIN)
+
+#define mph_return_val_if_long_overflow(var, ret) G_STMT_START{ \
+       if (mph_have_long_overflow(var)) { \
+               errno = EOVERFLOW; \
+               return ret; \
+       }}G_STMT_END
+
+#define mph_return_if_long_overflow(var) mph_return_val_if_long_overflow(var, -1)
+
+#define mph_have_ulong_overflow(var) ((var) > ULONG_MAX)
+#define mph_return_val_if_ulong_overflow(var, ret) G_STMT_START{ \
+       if (mph_have_ulong_overflow(var)) { \
+               errno = EOVERFLOW; \
+               return ret; \
+       }}G_STMT_END
+
+#define mph_return_if_ulong_overflow(var) mph_return_val_if_ulong_overflow(var, -1)
+
+#ifdef SIZE_MAX
+#define mph_have_size_t_overflow(var) ((var) > SIZE_MAX)
+#define mph_return_val_if_size_t_overflow(var, ret) G_STMT_START{ \
+       if (mph_have_size_t_overflow(var)) { \
+               errno = EOVERFLOW; \
+               return ret; \
+       }}G_STMT_END
+#define mph_return_if_size_t_overflow(var) mph_return_val_if_size_t_overflow(var, -1)
+#else
+#define mph_have_size_t_overflow(var) mph_have_ulong_overflow(var)
+#define mph_return_if_size_t_overflow(var) mph_return_if_ulong_overflow(var)
+#define mph_return_val_if_size_t_overflow(var, ret) mph_return_if_ulong_overflow(var, ret)
+#endif
+
+#define mph_return_if_off_t_overflow(var) mph_return_if_long_overflow(var)
+#define mph_return_if_ssize_t_overflow(var) mph_return_if_long_overflow(var)
+#define mph_return_if_time_t_overflow(var) mph_return_if_long_overflow(var)
+
+#endif /* ndef INC_mph_H */
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/old-map.c b/support/old-map.c
new file mode 100644 (file)
index 0000000..e313921
--- /dev/null
@@ -0,0 +1,174 @@
+/* This file was automatically generated by make-map from 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 <signal.h>
+#include <poll.h>
+#include "old-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;
+#ifdef O_SYNC
+       if ((x & Mono_Posix_OpenFlags_O_SYNC) != 0)
+               r |= O_SYNC;
+#endif
+       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_SIGSYS)
+                return SIGSYS;
+       return -1;
+}
+
+int map_Mono_Posix_PollEvents (int x)
+{
+       int r = 0;
+       if ((x & Mono_Posix_PollEvents_POLLIN) != 0)
+               r |= POLLIN;
+       if ((x & Mono_Posix_PollEvents_POLLPRI) != 0)
+               r |= POLLPRI;
+       if ((x & Mono_Posix_PollEvents_POLLOUT) != 0)
+               r |= POLLOUT;
+       if ((x & Mono_Posix_PollEvents_POLLERR) != 0)
+               r |= POLLERR;
+       if ((x & Mono_Posix_PollEvents_POLLHUP) != 0)
+               r |= POLLHUP;
+       if ((x & Mono_Posix_PollEvents_POLLNVAL) != 0)
+               r |= POLLNVAL;
+       return r;
+}
+
diff --git a/support/old-map.h b/support/old-map.h
new file mode 100644 (file)
index 0000000..369c177
--- /dev/null
@@ -0,0 +1,71 @@
+/* This file was automatically generated by make-map from Mono.Posix.dll */
+
+#define Mono_Posix_OpenFlags_O_RDONLY 0x00000000
+#define Mono_Posix_OpenFlags_O_WRONLY 0x00000001
+#define Mono_Posix_OpenFlags_O_RDWR 0x00000002
+#define Mono_Posix_OpenFlags_O_CREAT 0x00000004
+#define Mono_Posix_OpenFlags_O_EXCL 0x00000008
+#define Mono_Posix_OpenFlags_O_NOCTTY 0x00000010
+#define Mono_Posix_OpenFlags_O_TRUNC 0x00000020
+#define Mono_Posix_OpenFlags_O_APPEND 0x00000040
+#define Mono_Posix_OpenFlags_O_NONBLOCK 0x00000080
+#define Mono_Posix_OpenFlags_O_SYNC 0x00000100
+
+#define Mono_Posix_FileMode_S_ISUID 0x00000800
+#define Mono_Posix_FileMode_S_ISGID 0x00000400
+#define Mono_Posix_FileMode_S_ISVTX 0x00000200
+#define Mono_Posix_FileMode_S_IRUSR 0x00000100
+#define Mono_Posix_FileMode_S_IWUSR 0x00000080
+#define Mono_Posix_FileMode_S_IXUSR 0x00000040
+#define Mono_Posix_FileMode_S_IRGRP 0x00000020
+#define Mono_Posix_FileMode_S_IWGRP 0x00000010
+#define Mono_Posix_FileMode_S_IXGRP 0x00000008
+#define Mono_Posix_FileMode_S_IROTH 0x00000004
+#define Mono_Posix_FileMode_S_IWOTH 0x00000002
+#define Mono_Posix_FileMode_S_IXOTH 0x00000001
+
+#define Mono_Posix_WaitOptions_WNOHANG 0x00000000
+#define Mono_Posix_WaitOptions_WUNTRACED 0x00000001
+
+#define Mono_Posix_AccessMode_R_OK 0x00000001
+#define Mono_Posix_AccessMode_W_OK 0x00000002
+#define Mono_Posix_AccessMode_X_OK 0x00000004
+#define Mono_Posix_AccessMode_F_OK 0x00000008
+
+#define Mono_Posix_Signals_SIGHUP 0x00000000
+#define Mono_Posix_Signals_SIGINT 0x00000001
+#define Mono_Posix_Signals_SIGQUIT 0x00000002
+#define Mono_Posix_Signals_SIGILL 0x00000003
+#define Mono_Posix_Signals_SIGTRAP 0x00000004
+#define Mono_Posix_Signals_SIGABRT 0x00000005
+#define Mono_Posix_Signals_SIGBUS 0x00000006
+#define Mono_Posix_Signals_SIGFPE 0x00000007
+#define Mono_Posix_Signals_SIGKILL 0x00000008
+#define Mono_Posix_Signals_SIGUSR1 0x00000009
+#define Mono_Posix_Signals_SIGSEGV 0x0000000a
+#define Mono_Posix_Signals_SIGUSR2 0x0000000b
+#define Mono_Posix_Signals_SIGPIPE 0x0000000c
+#define Mono_Posix_Signals_SIGALRM 0x0000000d
+#define Mono_Posix_Signals_SIGTERM 0x0000000e
+#define Mono_Posix_Signals_SIGCHLD 0x0000000f
+#define Mono_Posix_Signals_SIGCONT 0x00000010
+#define Mono_Posix_Signals_SIGSTOP 0x00000011
+#define Mono_Posix_Signals_SIGTSTP 0x00000012
+#define Mono_Posix_Signals_SIGTTIN 0x00000013
+#define Mono_Posix_Signals_SIGTTOU 0x00000014
+#define Mono_Posix_Signals_SIGURG 0x00000015
+#define Mono_Posix_Signals_SIGXCPU 0x00000016
+#define Mono_Posix_Signals_SIGXFSZ 0x00000017
+#define Mono_Posix_Signals_SIGVTALRM 0x00000018
+#define Mono_Posix_Signals_SIGPROF 0x00000019
+#define Mono_Posix_Signals_SIGWINCH 0x0000001a
+#define Mono_Posix_Signals_SIGIO 0x0000001b
+#define Mono_Posix_Signals_SIGSYS 0x0000001c
+
+#define Mono_Posix_PollEvents_POLLIN 0x00000002
+#define Mono_Posix_PollEvents_POLLPRI 0x00000003
+#define Mono_Posix_PollEvents_POLLOUT 0x00000004
+#define Mono_Posix_PollEvents_POLLERR 0x00000005
+#define Mono_Posix_PollEvents_POLLHUP 0x00000006
+#define Mono_Posix_PollEvents_POLLNVAL 0x00000007
+
diff --git a/support/pwd.c b/support/pwd.c
new file mode 100644 (file)
index 0000000..99aabcb
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * <pwd.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <pwd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+struct Mono_Posix_Syscall__Passwd {
+       /* string */ char      *pw_name;
+       /* string */ char      *pw_passwd;
+       /* uid_t  */ mph_uid_t  pw_uid;
+       /* gid_t  */ mph_gid_t  pw_gid;
+       /* string */ char      *pw_gecos;
+       /* string */ char      *pw_dir;
+       /* string */ char      *pw_shell;
+       /* string */ char      *_pw_buf_;
+};
+
+/*
+ * Copy the native `passwd' structure to it's managed representation.
+ *
+ * To minimize separate mallocs, all the strings are allocated within the same
+ * memory block (stored in _pw_buf_).
+ */
+static int
+copy_passwd (struct Mono_Posix_Syscall__Passwd *to, struct passwd *from)
+{
+       enum {PW_NAME = 0, PW_PASSWD, PW_GECOS, PW_DIR, PW_SHELL, PW_LAST};
+       size_t buflen, len[PW_LAST];
+       /* bool */ unsigned char copy[PW_LAST] = {0};
+       const char *source[PW_LAST];
+       char **dest[PW_LAST];
+       int i;
+       char *cur;
+
+       to->pw_uid    = from->pw_uid;
+       to->pw_gid    = from->pw_gid;
+
+       to->pw_name   = NULL;
+       to->pw_passwd = NULL;
+       to->pw_gecos  = NULL;
+       to->pw_dir    = NULL;
+       to->pw_shell  = NULL;
+       to->_pw_buf_  = NULL;
+
+       source[PW_NAME]   = from->pw_name;
+       source[PW_PASSWD] = from->pw_passwd;
+       source[PW_GECOS]  = from->pw_gecos;
+       source[PW_DIR]    = from->pw_dir;
+       source[PW_SHELL]  = from->pw_shell;
+
+       dest[PW_NAME]   = &to->pw_name;
+       dest[PW_PASSWD] = &to->pw_passwd;
+       dest[PW_GECOS]  = &to->pw_gecos;
+       dest[PW_DIR]    = &to->pw_dir;
+       dest[PW_SHELL]  = &to->pw_shell;
+
+       buflen = PW_LAST;
+
+       /* over-rigorous checking for integer overflow */
+       for (i = 0; i != PW_LAST; ++i) {
+               len[i] = strlen (source[i]);
+               if (len[i] < INT_MAX - buflen) {
+                       buflen += len[i];
+                       copy[i] = 1;
+               }
+       }
+
+       cur = to->_pw_buf_ = (char*) malloc (buflen);
+       if (cur == NULL) {
+               return -1;
+       }
+
+       for (i = 0; i != PW_LAST; ++i) {
+               if (copy[i]) {
+                       *dest[i] = strcpy (cur, source[i]);
+                       cur += (len[i] + 1);
+               }
+       }
+
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_getpwnam (const char *name, struct Mono_Posix_Syscall__Passwd *pwbuf)
+{
+       struct passwd *pw;
+
+       if (pwbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       pw = getpwnam (name);
+       if (pw == NULL)
+               return -1;
+
+       if (copy_passwd (pwbuf, pw) == -1) {
+               errno = ENOMEM;
+               return -1;
+       }
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_getpwuid (mph_uid_t uid, struct Mono_Posix_Syscall__Passwd *pwbuf)
+{
+       struct passwd *pw;
+
+       if (pwbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       errno = 0;
+       pw = getpwuid (uid);
+       if (pw == NULL) {
+               return -1;
+       }
+
+       if (copy_passwd (pwbuf, pw) == -1) {
+               errno = ENOMEM;
+               return -1;
+       }
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_getpwnam_r (const char *name, 
+       struct Mono_Posix_Syscall__Passwd *pwbuf,
+       struct passwd **pwbufp)
+{
+       char *buf, *buf2;
+       size_t buflen;
+       int r;
+       struct passwd _pwbuf;
+
+       if (pwbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       buf = buf2 = NULL;
+       buflen = 2;
+
+       do {
+               buf2 = realloc (buf, buflen *= 2);
+               if (buf2 == NULL) {
+                       free (buf);
+                       errno = ENOMEM;
+                       return -1;
+               }
+               buf = buf2;
+       } while ((r = getpwnam_r (name, &_pwbuf, buf, buflen, pwbufp)) && r == ERANGE);
+
+       if (r == 0 && copy_passwd (pwbuf, &_pwbuf) == -1)
+               r = errno = ENOMEM;
+       free (buf);
+
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_getpwuid_r (mph_uid_t uid,
+       struct Mono_Posix_Syscall__Passwd *pwbuf,
+       struct passwd **pwbufp)
+{
+       char *buf, *buf2;
+       size_t buflen;
+       int r;
+       struct passwd _pwbuf;
+
+       if (pwbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       buf = buf2 = NULL;
+       buflen = 2;
+
+       do {
+               buf2 = realloc (buf, buflen *= 2);
+               if (buf2 == NULL) {
+                       free (buf);
+                       errno = ENOMEM;
+                       return -1;
+               }
+               buf = buf2;
+       } while ((r = getpwuid_r (uid, &_pwbuf, buf, buflen, pwbufp)) && r == ERANGE);
+
+       if (r == 0 && copy_passwd (pwbuf, &_pwbuf) == -1)
+               r = errno = ENOMEM;
+       free (buf);
+
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_getpwent (struct Mono_Posix_Syscall__Passwd *pwbuf)
+{
+       struct passwd *pw;
+
+       if (pwbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       pw = getpwent ();
+       if (pw == NULL)
+               return -1;
+
+       if (copy_passwd (pwbuf, pw) == -1) {
+               errno = ENOMEM;
+               return -1;
+       }
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_fgetpwent (FILE *stream, struct Mono_Posix_Syscall__Passwd *pwbuf)
+{
+       struct passwd *pw;
+
+       if (pwbuf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       pw = fgetpwent (stream);
+       if (pw == NULL)
+               return -1;
+
+       if (copy_passwd (pwbuf, pw) == -1) {
+               errno = ENOMEM;
+               return -1;
+       }
+       return 0;
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/stdio.c b/support/stdio.c
new file mode 100644 (file)
index 0000000..d423125
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * <stdio.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <stdio.h>
+
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+gint32
+Mono_Posix_Syscall_L_ctermid (void)
+{
+       return L_ctermid;
+}
+
+gint32
+Mono_Posix_Syscall_L_cuserid (void)
+{
+       return L_cuserid;
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/stdlib.c b/support/stdlib.c
new file mode 100644 (file)
index 0000000..d29c57b
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * <stdlib.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <stdlib.h>
+
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+void*
+Mono_Posix_Stdlib_calloc (mph_size_t nmemb, mph_size_t size)
+{
+       if (mph_have_size_t_overflow(nmemb) || mph_have_size_t_overflow(size))
+               return NULL;
+
+       return calloc ((size_t) nmemb, (size_t) size);
+}
+
+void*
+Mono_Posix_Stdlib_malloc (mph_size_t size)
+{
+       if (mph_have_size_t_overflow(size))
+               return NULL;
+
+       return malloc ((size_t) size);
+}
+
+void*
+Mono_Posix_Stdlib_realloc (void* ptr, mph_size_t size)
+{
+       if (mph_have_size_t_overflow(size))
+               return NULL;
+
+       return realloc (ptr, (size_t) size);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/sys-mman.c b/support/sys-mman.c
new file mode 100644 (file)
index 0000000..a91f4f8
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * <sys/mman.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#define _XOPEN_SOURCE 600
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+#include "map.h"
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+gint32
+Mono_Posix_Syscall_posix_madvise (void *addr, mph_size_t len, gint32 advice)
+{
+       mph_return_if_size_t_overflow (len);
+
+       if (Mono_Posix_FromPosixMadviseAdvice (advice, &advice) == -1)
+               return -1;
+
+       return posix_madvise (addr, (size_t) len, advice);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/sys-mount.c b/support/sys-mount.c
new file mode 100644 (file)
index 0000000..9e5cd27
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * <sys/mount.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <sys/mount.h>
+#include <glib/gtypes.h>
+
+#include "map.h"
+
+G_BEGIN_DECLS
+
+gint32
+Mono_Posix_Syscall_mount (const char *source, const char *target, 
+               const char *filesystemtype, guint64 mountflags, const void *data)
+{
+       if (Mono_Posix_FromMountFlags (mountflags, &mountflags) == -1)
+               return -1;
+
+       return mount (source, target, filesystemtype, (unsigned long) mountflags, data);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/sys-sendfile.c b/support/sys-sendfile.c
new file mode 100644 (file)
index 0000000..1e8092d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * <sys/sendfile.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <sys/sendfile.h>
+#include <errno.h>
+
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+mph_ssize_t
+Mono_Posix_Syscall_sendfile (int out_fd, int in_fd, mph_off_t *offset, mph_size_t count)
+{
+       off_t _offset;
+       ssize_t r;
+       mph_return_if_off_t_overflow (*offset);
+
+       _offset = *offset;
+
+       r = sendfile (out_fd, in_fd, &_offset, (size_t) count);
+
+       *offset = _offset;
+
+       return r;
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/sys-stat.c b/support/sys-stat.c
new file mode 100644 (file)
index 0000000..3ff4888
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * <sys/stat.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif /* ndef _GNU_SOURCE */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "map.h"
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+struct Mono_Posix_Syscall_Stat {
+       /* dev_t */     mph_dev_t     st_dev;     /* device */
+       /* ino_t */     mph_ino_t     st_ino;     /* inode */
+       /* mode_t */    guint32       st_mode;    /* protection */
+                       guint32       _padding_;  /* structure padding */
+       /* nlink_t */   mph_nlink_t   st_nlink;   /* number of hard links */
+       /* uid_t */     mph_uid_t     st_uid;     /* user ID of owner */
+       /* gid_t */     mph_gid_t     st_gid;     /* group ID of owner */
+       /* dev_t */     mph_dev_t     st_rdev;    /* device type (if inode device) */
+       /* off_t */     mph_off_t     st_size;    /* total size, in bytes */
+       /* blksize_t */ mph_blksize_t st_blksize; /* blocksize for filesystem I/O */
+       /* blkcnt_t */  mph_blkcnt_t  st_blocks;  /* number of blocks allocated */
+
+       /* st_atime, st_mtime, and st_ctime are macros (!), so use a slightly
+        * different name to appease CPP */
+
+       /* time_t */    mph_time_t    st_atime_;  /* time of last access */
+       /* time_t */    mph_time_t    st_mtime_;  /* time of last modification */
+       /* time_t */    mph_time_t    st_ctime_;  /* time of last status change */
+};
+
+static int
+copy_stat (struct Mono_Posix_Syscall_Stat *to, struct stat *from)
+{
+       if (Mono_Posix_ToFilePermissions (from->st_mode, &to->st_mode) == -1)
+               return -1;
+       to->st_dev      = from->st_dev;
+       to->st_ino      = from->st_ino;
+       to->st_nlink    = from->st_nlink;
+       to->st_uid      = from->st_uid;
+       to->st_gid      = from->st_gid;
+       to->st_rdev     = from->st_rdev;
+       to->st_size     = from->st_size;
+       to->st_blksize  = from->st_blksize;
+       to->st_blocks   = from->st_blocks;
+       to->st_atime_   = from->st_atime;
+       to->st_mtime_   = from->st_mtime;
+       to->st_ctime_   = from->st_ctime;
+       return 0;
+}
+
+gint32
+Mono_Posix_Syscall_stat (const char *file_name, struct Mono_Posix_Syscall_Stat *buf)
+{
+       int r;
+       struct stat _buf;
+
+       if (buf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+       r = stat (file_name, &_buf);
+       if (r != -1 && copy_stat (buf, &_buf) == -1)
+               r = -1;
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_fstat (int filedes, struct Mono_Posix_Syscall_Stat *buf)
+{
+       int r;
+       struct stat _buf;
+
+       if (buf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+       r = fstat (filedes, &_buf);
+       if (r != -1 && copy_stat (buf, &_buf) == -1)
+               r = -1;
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Syscall_Stat *buf)
+{
+       int r;
+       struct stat _buf;
+
+       if (buf == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+       r = lstat (file_name, &_buf);
+       if (r != -1 && copy_stat (buf, &_buf) == -1)
+               r = -1;
+       return r;
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/sys-wait.c b/support/sys-wait.c
new file mode 100644 (file)
index 0000000..12a4b17
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * <sys/wait.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <glib/gtypes.h>
+
+#include "map.h"
+
+G_BEGIN_DECLS
+
+gint32
+Mono_Posix_Syscall_WIFEXITED (gint32 status)
+{
+       return WIFEXITED (status);
+}
+
+gint32
+Mono_Posix_Syscall_WEXITSTATUS (gint32 status)
+{
+       return WEXITSTATUS (status);
+}
+
+gint32
+Mono_Posix_Syscall_WIFSIGNALED (gint32 status)
+{
+       return WIFSIGNALED (status);
+}
+
+gint32
+Mono_Posix_Syscall_WTERMSIG (gint32 status)
+{
+       return WTERMSIG (status);
+}
+
+gint32
+Mono_Posix_Syscall_WIFSTOPPED (gint32 status)
+{
+       return WIFSTOPPED (status);
+}
+
+gint32
+Mono_Posix_Syscall_WSTOPSIG (gint32 status)
+{
+       return WSTOPSIG (status);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/time.c b/support/time.c
new file mode 100644 (file)
index 0000000..5919339
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * <time.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#define _SVID_SOURCE
+#include <time.h>
+#include <errno.h>
+
+#include "mph.h"
+#include <glib/gtypes.h>
+
+G_BEGIN_DECLS
+
+gint32
+Mono_Posix_Syscall_stime (mph_time_t *t)
+{
+       time_t _t;
+       if (t == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+       mph_return_if_time_t_overflow (*t);
+       _t = (time_t) *t;
+       return stime (&_t);
+}
+
+mph_time_t
+Mono_Posix_Syscall_time (mph_time_t *t)
+{
+       time_t _t, r;
+       if (t == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       mph_return_if_time_t_overflow (*t);
+
+       _t = (time_t) *t;
+       r = time (&_t);
+       *t = _t;
+
+       return r;
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/unistd.c b/support/unistd.c
new file mode 100644 (file)
index 0000000..51bc760
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * <unistd.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif /* ndef _GNU_SOURCE */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <glib/gtypes.h>
+
+#include "map.h"
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+mph_off_t
+Mono_Posix_Syscall_lseek (gint32 fd, mph_off_t offset, gint32 whence)
+{
+       short _whence;
+       mph_return_if_off_t_overflow (offset);
+       if (Mono_Posix_FromSeekFlags (whence, &_whence) == -1)
+               return -1;
+       whence = _whence;
+#ifdef MPH_USE_64_API
+       return lseek64 (fd, offset, whence);
+#else
+       return lseek (fd, offset, whence);
+#endif
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_read (gint32 fd, void *buf, mph_size_t count)
+{
+       mph_return_if_size_t_overflow (count);
+       return read (fd, buf, (size_t) count);
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_write (gint32 fd, const void *buf, mph_size_t count)
+{
+       mph_return_if_size_t_overflow (count);
+       return write (fd, buf, (size_t) count);
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_pread (gint32 fd, void *buf, mph_size_t count, mph_off_t offset)
+{
+       mph_return_if_size_t_overflow (count);
+       mph_return_if_off_t_overflow (offset);
+#ifdef MPH_USE_64_API
+       return pread64 (fd, buf, (size_t) count, offset);
+#else
+       return pread (fd, buf, (size_t) count, (off_t) offset);
+#endif
+}
+
+mph_ssize_t
+Mono_Posix_Syscall_pwrite (gint32 fd, const void *buf, mph_size_t count, mph_off_t offset)
+{
+       mph_return_if_size_t_overflow (count);
+       mph_return_if_off_t_overflow (offset);
+#ifdef MPH_USE_64_API
+       return pwrite64 (fd, buf, (size_t) count, offset);
+#else
+       return pwrite (fd, buf, (size_t) count, (off_t) offset);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_pipe (gint32 *reading, gint32 *writing)
+{
+       int filedes[2] = {-1, -1};
+       int r;
+
+       if (reading == NULL || writing == NULL) {
+               errno = EFAULT;
+               return -1;
+       }
+
+       r = pipe (filedes);
+
+       *reading = filedes[0];
+       *writing = filedes[1];
+       return r;
+}
+
+char*
+Mono_Posix_Syscall_getcwd (char *buf, mph_size_t size)
+{
+       mph_return_val_if_size_t_overflow (size, NULL);
+       return getcwd (buf, (size_t) size);
+}
+
+gint64
+Mono_Posix_Syscall_fpathconf (int filedes, int name)
+{
+       if (Mono_Posix_FromPathConf (name, &name) == -1)
+               return -1;
+       return fpathconf (filedes, name);
+}
+
+gint64
+Mono_Posix_Syscall_pathconf (char *path, int name)
+{
+       if (Mono_Posix_FromPathConf (name, &name) == -1)
+               return -1;
+       return pathconf (path, name);
+}
+
+gint64
+Mono_Posix_Syscall_sysconf (int name)
+{
+       if (Mono_Posix_FromSysConf (name, &name) == -1)
+               return -1;
+       return sysconf (name);
+}
+
+gint64
+Mono_Posix_Syscall_confstr (int name, char *buf, mph_size_t len)
+{
+       mph_return_if_size_t_overflow (len);
+       if (Mono_Posix_FromConfStr (name, &name) == -1)
+               return -1;
+       return confstr (name, buf, (size_t) len);
+}
+
+gint32
+Mono_Posix_Syscall_ttyname_r (int fd, char *buf, mph_size_t len)
+{
+       mph_return_if_size_t_overflow (len);
+       return ttyname_r (fd, buf, (size_t) len);
+}
+
+gint32
+Mono_Posix_Syscall_readlink (const char *path, char *buf, mph_size_t len)
+{
+       mph_return_if_size_t_overflow (len);
+       return readlink (path, buf, (size_t) len);
+}
+
+gint32
+Mono_Posix_Syscall_getlogin_r (char *buf, mph_size_t len)
+{
+       mph_return_if_size_t_overflow (len);
+       return getlogin_r (buf, (size_t) len);
+}
+
+gint32
+Mono_Posix_Syscall_gethostname (char *buf, mph_size_t len)
+{
+       mph_return_if_size_t_overflow (len);
+       return gethostname (buf, (size_t) len);
+}
+
+gint32
+Mono_Posix_Syscall_sethostname (const char *name, mph_size_t len)
+{
+       mph_return_if_size_t_overflow (len);
+       return sethostname (name, (size_t) len);
+}
+
+gint64
+Mono_Posix_Syscall_gethostid (void)
+{
+       return gethostid ();
+}
+
+gint32
+Mono_Posix_Syscall_sethostid (gint64 hostid)
+{
+       mph_return_if_long_overflow (hostid);
+       return sethostid ((long) hostid);
+}
+
+gint32
+Mono_Posix_Syscall_getdomainname (char *name, mph_size_t len)
+{
+       mph_return_if_size_t_overflow (len);
+       return getdomainname (name, (size_t) len);
+}
+
+gint32
+Mono_Posix_Syscall_setdomainname (const char *name, mph_size_t len)
+{
+       mph_return_if_size_t_overflow (len);
+       return setdomainname (name, (size_t) len);
+}
+
+gint32
+Mono_Posix_Syscall_truncate (const char *path, mph_off_t length)
+{
+       mph_return_if_off_t_overflow (length);
+#ifdef MPH_USE_64_API
+       return truncate64 (path, length);
+#else
+       return truncate (path, (off_t) length);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_ftruncate (int fd, mph_off_t length)
+{
+       mph_return_if_off_t_overflow (length);
+#ifdef MPH_USE_64_API
+       return ftruncate64 (fd, length);
+#else
+       return ftruncate (fd, (off_t) length);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_lockf (int fd, int cmd, mph_off_t len)
+{
+       mph_return_if_off_t_overflow (len);
+       if (Mono_Posix_FromLockFlags (cmd, &cmd) == -1)
+               return -1;
+#ifdef MPH_USE_64_API
+       return lockf64 (fd, cmd, len);
+#else
+       return lockf (fd, cmd, (off_t) len);
+#endif
+}
+
+void
+Mono_Posix_Syscall_swab (void *from, void *to, mph_ssize_t n)
+{
+       if (n > LONG_MAX || n < LONG_MAX)
+               return;
+       swab (from, to, (ssize_t) n);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */