Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / support / map.c
index a8563a7f7a98a91193474ae3528420b9db6b8111..a0580964684a6c532f2f9378dd11e31005a21ee7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file was automatically generated by create-native-map from ../../mcs/class/lib/net_2_0/Mono.Posix.dll.
+ * This file was automatically generated by create-native-map from ../mcs/class/lib/net_4_x/Mono.Posix.dll.
  *
  * DO NOT MODIFY.
  */
  */
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif /* ndef HAVE_NETINET_IN_H */
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
+#endif /* ndef HAVE_SYS_TIME_H */
 #ifdef HAVE_SYS_POLL_H
 #include <sys/poll.h>
 #endif /* ndef HAVE_SYS_POLL_H */
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif /* ndef HAVE_SYS_MMAN_H */
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif /* ndef HAVE_SYS_SOCKET_H */
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif /* ndef HAVE_SYS_UIO_H */
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif /* ndef HAVE_UNISTD_H */
 #include <fcntl.h>
 #include <signal.h>
 #ifdef HAVE_POLL_H
 #ifdef HAVE_SYSLOG_H
 #include <syslog.h>
 #endif /* ndef HAVE_SYSLOG_H */
+#ifdef HAVE_DIRENT_H
 #include <dirent.h>
+#endif /* ndef HAVE_DIRENT_H */
+#ifdef HAVE_UTIME_H
 #include <utime.h>
+#endif /* ndef HAVE_UTIME_H */
+#include <time.h>
 #include "mph.h"
 
 #include "map.h"
 #include <errno.h>    /* errno, EOVERFLOW */
 #include <glib.h>     /* g* types, g_assert_not_reached() */
 
+#if defined (G_MININT8)
+#define CNM_MININT8 G_MININT8
+#else
+#define CNM_MININT8 (-128)
+#endif
+
+#if defined (G_MAXINT8)
+#define CNM_MAXINT8 G_MAXINT8
+#else
+#define CNM_MAXINT8 (127)
+#endif
+
+#if defined (G_MAXUINT8)
+#define CNM_MAXUINT8 G_MAXUINT8
+#else
+#define CNM_MAXUINT8 (255)
+#endif
+
+#if defined (G_MININT16)
+#define CNM_MININT16 G_MININT16
+#else
+#define CNM_MININT16 (-32768)
+#endif
+
+#if defined (G_MAXINT16)
+#define CNM_MAXINT16 G_MAXINT16
+#else
+#define CNM_MAXINT16 (32767)
+#endif
+
+#if defined (G_MAXUINT16)
+#define CNM_MAXUINT16 G_MAXUINT16
+#else
+#define CNM_MAXUINT16 (65535)
+#endif
+
+#if defined (G_MININT32)
+#define CNM_MININT32 G_MININT32
+#else
+#define CNM_MININT32 (-2147483648)
+#endif
+
+#if defined (G_MAXINT32)
+#define CNM_MAXINT32 G_MAXINT32
+#else
+#define CNM_MAXINT32 (2147483647)
+#endif
+
+#if defined (G_MAXUINT32)
+#define CNM_MAXUINT32 G_MAXUINT32
+#else
+#define CNM_MAXUINT32 (4294967295U)
+#endif
+
+#if defined (G_MININT64)
+#define CNM_MININT64 G_MININT64
+#else
+#define CNM_MININT64 (-9223372036854775808LL)
+#endif
+
+#if defined (G_MAXINT64)
+#define CNM_MAXINT64 G_MAXINT64
+#else
+#define CNM_MAXINT64 (9223372036854775807LL)
+#endif
+
+#if defined (G_MAXUINT64)
+#define CNM_MAXUINT64 G_MAXUINT64
+#else
+#define CNM_MAXUINT64 (18446744073709551615ULL)
+#endif
+
+
 /* returns TRUE if @type is an unsigned type */
 #define _cnm_integral_type_is_unsigned(type) \
     (sizeof(type) == sizeof(gint8)           \
-      ? (((type)-1) > G_MAXINT8)             \
+      ? (((type)-1) > CNM_MAXINT8)             \
       : sizeof(type) == sizeof(gint16)       \
-        ? (((type)-1) > G_MAXINT16)          \
+        ? (((type)-1) > CNM_MAXINT16)          \
         : sizeof(type) == sizeof(gint32)     \
-          ? (((type)-1) > G_MAXINT32)        \
+          ? (((type)-1) > CNM_MAXINT32)        \
           : sizeof(type) == sizeof(gint64)   \
-            ? (((type)-1) > G_MAXINT64)      \
+            ? (((type)-1) > CNM_MAXINT64)      \
             : (g_assert_not_reached (), 0))
 
 /* returns the minimum value of @type as a gint64 */
     (_cnm_integral_type_is_unsigned (type)    \
       ? 0                                     \
       : sizeof(type) == sizeof(gint8)         \
-        ? G_MININT8                           \
+        ? CNM_MININT8                           \
         : sizeof(type) == sizeof(gint16)      \
-          ? G_MININT16                        \
+          ? CNM_MININT16                        \
           : sizeof(type) == sizeof(gint32)    \
-            ? G_MININT32                      \
+            ? CNM_MININT32                      \
             : sizeof(type) == sizeof(gint64)  \
-              ? G_MININT64                    \
+              ? CNM_MININT64                    \
               : (g_assert_not_reached (), 0))
 
 /* returns the maximum value of @type as a guint64 */
 #define _cnm_integral_type_max(type)            \
     (_cnm_integral_type_is_unsigned (type)      \
       ? sizeof(type) == sizeof(gint8)           \
-        ? G_MAXUINT8                            \
+        ? CNM_MAXUINT8                            \
         : sizeof(type) == sizeof(gint16)        \
-          ? G_MAXUINT16                         \
+          ? CNM_MAXUINT16                         \
           : sizeof(type) == sizeof(gint32)      \
-            ? G_MAXUINT32                       \
+            ? CNM_MAXUINT32                       \
             : sizeof(type) == sizeof(gint64)    \
-              ? G_MAXUINT64                     \
+              ? CNM_MAXUINT64                     \
               : (g_assert_not_reached (), 0)    \
       : sizeof(type) == sizeof(gint8)           \
-          ? G_MAXINT8                           \
+          ? CNM_MAXINT8                           \
           : sizeof(type) == sizeof(gint16)      \
-            ? G_MAXINT16                        \
+            ? CNM_MAXINT16                        \
             : sizeof(type) == sizeof(gint32)    \
-              ? G_MAXINT32                      \
+              ? CNM_MAXINT32                      \
               : sizeof(type) == sizeof(gint64)  \
-                ? G_MAXINT64                    \
+                ? CNM_MAXINT64                    \
                 : (g_assert_not_reached (), 0))
 
-#ifdef DEBUG
-#define _cnm_dump_(to_t,from)                                            \
-  printf ("# %s -> %s: min=%llx; max=%llx; value=%llx; lt=%i; l0=%i; gt=%i; e=%i\n", \
+#ifdef _CNM_DUMP
+#define _cnm_dump(to_t,from)                                             \
+  printf ("# %s -> %s: uns=%i; min=%llx; max=%llx; value=%llx; lt=%i; l0=%i; gt=%i; e=%i\n", \
     #from, #to_t,                                                        \
-    (gint64) (_cnm_integral_type_min(to_t)),                             \
+    (int) _cnm_integral_type_is_unsigned (to_t),                         \
+    (gint64) (_cnm_integral_type_min (to_t)),                            \
     (gint64) (_cnm_integral_type_max (to_t)),                            \
     (gint64) (from),                                                     \
-    (_cnm_integral_type_min (to_t) <= from),                             \
+    (((gint64) _cnm_integral_type_min (to_t)) <= (gint64) from),         \
     (from < 0),                                                          \
-    /* (_cnm_integral_type_max (to_t) >= from) */                        \
-    (from <= _cnm_integral_type_max (to_t)),                             \
-    ((_cnm_integral_type_min(to_t) >= from) &&                           \
-          ((from < 0) ? 1 : (from <= _cnm_integral_type_max(to_t))))     \
+    (((guint64) from) <= (guint64) _cnm_integral_type_max (to_t)),       \
+    !((int) _cnm_integral_type_is_unsigned (to_t)                        \
+      ? ((0 <= from) &&                                                  \
+         ((guint64) from <= (guint64) _cnm_integral_type_max (to_t)))    \
+      : ((gint64) _cnm_integral_type_min(to_t) <= (gint64) from &&       \
+         (guint64) from <= (guint64) _cnm_integral_type_max (to_t)))     \
   )
-#else
-#define _cnm_dump_(to_t, from) do {} while (0)
-#endif
+#else /* ndef _CNM_DUMP */
+#define _cnm_dump(to_t, from) do {} while (0)
+#endif /* def _CNM_DUMP */
 
+#ifdef DEBUG
 #define _cnm_return_val_if_overflow(to_t,from,val)  G_STMT_START {   \
-    if (!(_cnm_integral_type_min(to_t) <= from &&                    \
-          ((from < 0) || (from <= _cnm_integral_type_max(to_t))))) { \
-      _cnm_dump_(to_t, from);                                        \
+    int     uns = _cnm_integral_type_is_unsigned (to_t);             \
+    gint64  min = (gint64)  _cnm_integral_type_min (to_t);           \
+    guint64 max = (guint64) _cnm_integral_type_max (to_t);           \
+    gint64  sf  = (gint64)  from;                                    \
+    guint64 uf  = (guint64) from;                                    \
+    if (!(uns ? ((0 <= from) && (uf <= max))                         \
+              : (min <= sf && (from < 0 || uf <= max)))) {           \
+      _cnm_dump(to_t, from);                                         \
       errno = EOVERFLOW;                                             \
       return (val);                                                  \
     }                                                                \
   } G_STMT_END
+#else /* !def DEBUG */
+/* don't do any overflow checking */
+#define _cnm_return_val_if_overflow(to_t,from,val)  G_STMT_START {   \
+  } G_STMT_END
+#endif /* def DEBUG */
 
 int Mono_Posix_FromAccessModes (int x, int *r)
 {
@@ -196,6 +301,114 @@ int Mono_Posix_ToAccessModes (int x, int *r)
        return 0;
 }
 
+int Mono_Posix_FromAtFlags (int x, int *r)
+{
+       *r = 0;
+       if ((x & Mono_Posix_AtFlags_AT_EMPTY_PATH) == Mono_Posix_AtFlags_AT_EMPTY_PATH)
+#ifdef AT_EMPTY_PATH
+               *r |= AT_EMPTY_PATH;
+#else /* def AT_EMPTY_PATH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AT_EMPTY_PATH */
+       if ((x & Mono_Posix_AtFlags_AT_NO_AUTOMOUNT) == Mono_Posix_AtFlags_AT_NO_AUTOMOUNT)
+#ifdef AT_NO_AUTOMOUNT
+               *r |= AT_NO_AUTOMOUNT;
+#else /* def AT_NO_AUTOMOUNT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AT_NO_AUTOMOUNT */
+       if ((x & Mono_Posix_AtFlags_AT_REMOVEDIR) == Mono_Posix_AtFlags_AT_REMOVEDIR)
+#ifdef AT_REMOVEDIR
+               *r |= AT_REMOVEDIR;
+#else /* def AT_REMOVEDIR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AT_REMOVEDIR */
+       if ((x & Mono_Posix_AtFlags_AT_SYMLINK_FOLLOW) == Mono_Posix_AtFlags_AT_SYMLINK_FOLLOW)
+#ifdef AT_SYMLINK_FOLLOW
+               *r |= AT_SYMLINK_FOLLOW;
+#else /* def AT_SYMLINK_FOLLOW */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AT_SYMLINK_FOLLOW */
+       if ((x & Mono_Posix_AtFlags_AT_SYMLINK_NOFOLLOW) == Mono_Posix_AtFlags_AT_SYMLINK_NOFOLLOW)
+#ifdef AT_SYMLINK_NOFOLLOW
+               *r |= AT_SYMLINK_NOFOLLOW;
+#else /* def AT_SYMLINK_NOFOLLOW */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AT_SYMLINK_NOFOLLOW */
+       if (x == 0)
+               return 0;
+       return 0;
+}
+
+int Mono_Posix_ToAtFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef AT_EMPTY_PATH
+       if ((x & AT_EMPTY_PATH) == AT_EMPTY_PATH)
+               *r |= Mono_Posix_AtFlags_AT_EMPTY_PATH;
+#endif /* ndef AT_EMPTY_PATH */
+#ifdef AT_NO_AUTOMOUNT
+       if ((x & AT_NO_AUTOMOUNT) == AT_NO_AUTOMOUNT)
+               *r |= Mono_Posix_AtFlags_AT_NO_AUTOMOUNT;
+#endif /* ndef AT_NO_AUTOMOUNT */
+#ifdef AT_REMOVEDIR
+       if ((x & AT_REMOVEDIR) == AT_REMOVEDIR)
+               *r |= Mono_Posix_AtFlags_AT_REMOVEDIR;
+#endif /* ndef AT_REMOVEDIR */
+#ifdef AT_SYMLINK_FOLLOW
+       if ((x & AT_SYMLINK_FOLLOW) == AT_SYMLINK_FOLLOW)
+               *r |= Mono_Posix_AtFlags_AT_SYMLINK_FOLLOW;
+#endif /* ndef AT_SYMLINK_FOLLOW */
+#ifdef AT_SYMLINK_NOFOLLOW
+       if ((x & AT_SYMLINK_NOFOLLOW) == AT_SYMLINK_NOFOLLOW)
+               *r |= Mono_Posix_AtFlags_AT_SYMLINK_NOFOLLOW;
+#endif /* ndef AT_SYMLINK_NOFOLLOW */
+       return 0;
+}
+
+#ifdef HAVE_STRUCT_CMSGHDR
+int
+Mono_Posix_FromCmsghdr (struct Mono_Posix_Cmsghdr *from, struct cmsghdr *to)
+{
+       _cnm_return_val_if_overflow (gint64, from->cmsg_len, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->cmsg_len   = from->cmsg_len;
+       if (Mono_Posix_FromUnixSocketProtocol (from->cmsg_level, &to->cmsg_level) != 0) {
+               return -1;
+       }
+       if (Mono_Posix_FromUnixSocketControlMessage (from->cmsg_type, &to->cmsg_type) != 0) {
+               return -1;
+       }
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_CMSGHDR */
+
+
+#ifdef HAVE_STRUCT_CMSGHDR
+int
+Mono_Posix_ToCmsghdr (struct cmsghdr *from, struct Mono_Posix_Cmsghdr *to)
+{
+       _cnm_return_val_if_overflow (gint64, from->cmsg_len, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->cmsg_len   = from->cmsg_len;
+       if (Mono_Posix_ToUnixSocketProtocol (from->cmsg_level, &to->cmsg_level) != 0) {
+               return -1;
+       }
+       if (Mono_Posix_ToUnixSocketControlMessage (from->cmsg_type, &to->cmsg_type) != 0) {
+               return -1;
+       }
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_CMSGHDR */
+
+
 int Mono_Posix_FromConfstrName (int x, int *r)
 {
        *r = 0;
@@ -738,6 +951,188 @@ int Mono_Posix_ToDirectoryNotifyFlags (int x, int *r)
        return 0;
 }
 
+int Mono_Posix_FromEpollEvents (unsigned int x, unsigned int *r)
+{
+       *r = 0;
+       if ((x & Mono_Posix_EpollEvents_EPOLLERR) == Mono_Posix_EpollEvents_EPOLLERR)
+#ifdef EPOLLERR
+               *r |= EPOLLERR;
+#else /* def EPOLLERR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLERR */
+       if ((x & Mono_Posix_EpollEvents_EPOLLET) == Mono_Posix_EpollEvents_EPOLLET)
+#ifdef EPOLLET
+               *r |= EPOLLET;
+#else /* def EPOLLET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLET */
+       if ((x & Mono_Posix_EpollEvents_EPOLLHUP) == Mono_Posix_EpollEvents_EPOLLHUP)
+#ifdef EPOLLHUP
+               *r |= EPOLLHUP;
+#else /* def EPOLLHUP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLHUP */
+       if ((x & Mono_Posix_EpollEvents_EPOLLIN) == Mono_Posix_EpollEvents_EPOLLIN)
+#ifdef EPOLLIN
+               *r |= EPOLLIN;
+#else /* def EPOLLIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLIN */
+       if ((x & Mono_Posix_EpollEvents_EPOLLMSG) == Mono_Posix_EpollEvents_EPOLLMSG)
+#ifdef EPOLLMSG
+               *r |= EPOLLMSG;
+#else /* def EPOLLMSG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLMSG */
+       if ((x & Mono_Posix_EpollEvents_EPOLLONESHOT) == Mono_Posix_EpollEvents_EPOLLONESHOT)
+#ifdef EPOLLONESHOT
+               *r |= EPOLLONESHOT;
+#else /* def EPOLLONESHOT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLONESHOT */
+       if ((x & Mono_Posix_EpollEvents_EPOLLOUT) == Mono_Posix_EpollEvents_EPOLLOUT)
+#ifdef EPOLLOUT
+               *r |= EPOLLOUT;
+#else /* def EPOLLOUT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLOUT */
+       if ((x & Mono_Posix_EpollEvents_EPOLLPRI) == Mono_Posix_EpollEvents_EPOLLPRI)
+#ifdef EPOLLPRI
+               *r |= EPOLLPRI;
+#else /* def EPOLLPRI */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLPRI */
+       if ((x & Mono_Posix_EpollEvents_EPOLLRDBAND) == Mono_Posix_EpollEvents_EPOLLRDBAND)
+#ifdef EPOLLRDBAND
+               *r |= EPOLLRDBAND;
+#else /* def EPOLLRDBAND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLRDBAND */
+       if ((x & Mono_Posix_EpollEvents_EPOLLRDHUP) == Mono_Posix_EpollEvents_EPOLLRDHUP)
+#ifdef EPOLLRDHUP
+               *r |= EPOLLRDHUP;
+#else /* def EPOLLRDHUP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLRDHUP */
+       if ((x & Mono_Posix_EpollEvents_EPOLLRDNORM) == Mono_Posix_EpollEvents_EPOLLRDNORM)
+#ifdef EPOLLRDNORM
+               *r |= EPOLLRDNORM;
+#else /* def EPOLLRDNORM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLRDNORM */
+       if ((x & Mono_Posix_EpollEvents_EPOLLWRBAND) == Mono_Posix_EpollEvents_EPOLLWRBAND)
+#ifdef EPOLLWRBAND
+               *r |= EPOLLWRBAND;
+#else /* def EPOLLWRBAND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLWRBAND */
+       if ((x & Mono_Posix_EpollEvents_EPOLLWRNORM) == Mono_Posix_EpollEvents_EPOLLWRNORM)
+#ifdef EPOLLWRNORM
+               *r |= EPOLLWRNORM;
+#else /* def EPOLLWRNORM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLWRNORM */
+       if (x == 0)
+               return 0;
+       return 0;
+}
+
+int Mono_Posix_ToEpollEvents (unsigned int x, unsigned int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef EPOLLERR
+       if ((x & EPOLLERR) == EPOLLERR)
+               *r |= Mono_Posix_EpollEvents_EPOLLERR;
+#endif /* ndef EPOLLERR */
+#ifdef EPOLLET
+       if ((x & EPOLLET) == EPOLLET)
+               *r |= Mono_Posix_EpollEvents_EPOLLET;
+#endif /* ndef EPOLLET */
+#ifdef EPOLLHUP
+       if ((x & EPOLLHUP) == EPOLLHUP)
+               *r |= Mono_Posix_EpollEvents_EPOLLHUP;
+#endif /* ndef EPOLLHUP */
+#ifdef EPOLLIN
+       if ((x & EPOLLIN) == EPOLLIN)
+               *r |= Mono_Posix_EpollEvents_EPOLLIN;
+#endif /* ndef EPOLLIN */
+#ifdef EPOLLMSG
+       if ((x & EPOLLMSG) == EPOLLMSG)
+               *r |= Mono_Posix_EpollEvents_EPOLLMSG;
+#endif /* ndef EPOLLMSG */
+#ifdef EPOLLONESHOT
+       if ((x & EPOLLONESHOT) == EPOLLONESHOT)
+               *r |= Mono_Posix_EpollEvents_EPOLLONESHOT;
+#endif /* ndef EPOLLONESHOT */
+#ifdef EPOLLOUT
+       if ((x & EPOLLOUT) == EPOLLOUT)
+               *r |= Mono_Posix_EpollEvents_EPOLLOUT;
+#endif /* ndef EPOLLOUT */
+#ifdef EPOLLPRI
+       if ((x & EPOLLPRI) == EPOLLPRI)
+               *r |= Mono_Posix_EpollEvents_EPOLLPRI;
+#endif /* ndef EPOLLPRI */
+#ifdef EPOLLRDBAND
+       if ((x & EPOLLRDBAND) == EPOLLRDBAND)
+               *r |= Mono_Posix_EpollEvents_EPOLLRDBAND;
+#endif /* ndef EPOLLRDBAND */
+#ifdef EPOLLRDHUP
+       if ((x & EPOLLRDHUP) == EPOLLRDHUP)
+               *r |= Mono_Posix_EpollEvents_EPOLLRDHUP;
+#endif /* ndef EPOLLRDHUP */
+#ifdef EPOLLRDNORM
+       if ((x & EPOLLRDNORM) == EPOLLRDNORM)
+               *r |= Mono_Posix_EpollEvents_EPOLLRDNORM;
+#endif /* ndef EPOLLRDNORM */
+#ifdef EPOLLWRBAND
+       if ((x & EPOLLWRBAND) == EPOLLWRBAND)
+               *r |= Mono_Posix_EpollEvents_EPOLLWRBAND;
+#endif /* ndef EPOLLWRBAND */
+#ifdef EPOLLWRNORM
+       if ((x & EPOLLWRNORM) == EPOLLWRNORM)
+               *r |= Mono_Posix_EpollEvents_EPOLLWRNORM;
+#endif /* ndef EPOLLWRNORM */
+       return 0;
+}
+
+int Mono_Posix_FromEpollFlags (int x, int *r)
+{
+       *r = 0;
+       if ((x & Mono_Posix_EpollFlags_EPOLL_CLOEXEC) == Mono_Posix_EpollFlags_EPOLL_CLOEXEC)
+#ifdef EPOLL_CLOEXEC
+               *r |= EPOLL_CLOEXEC;
+#else /* def EPOLL_CLOEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLL_CLOEXEC */
+       if ((x & Mono_Posix_EpollFlags_EPOLL_NONBLOCK) == Mono_Posix_EpollFlags_EPOLL_NONBLOCK)
+#ifdef EPOLL_NONBLOCK
+               *r |= EPOLL_NONBLOCK;
+#else /* def EPOLL_NONBLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPOLL_NONBLOCK */
+       if (x == 0)
+               return 0;
+       return 0;
+}
+
+int Mono_Posix_ToEpollFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef EPOLL_CLOEXEC
+       if ((x & EPOLL_CLOEXEC) == EPOLL_CLOEXEC)
+               *r |= Mono_Posix_EpollFlags_EPOLL_CLOEXEC;
+#endif /* ndef EPOLL_CLOEXEC */
+#ifdef EPOLL_NONBLOCK
+       if ((x & EPOLL_NONBLOCK) == EPOLL_NONBLOCK)
+               *r |= Mono_Posix_EpollFlags_EPOLL_NONBLOCK;
+#endif /* ndef EPOLL_NONBLOCK */
+       return 0;
+}
+
 int Mono_Posix_FromErrno (int x, int *r)
 {
        *r = 0;
@@ -789,12 +1184,30 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EALREADY */
                {errno = EINVAL; return -1;}
 #endif /* ndef EALREADY */
+       if (x == Mono_Posix_Errno_EAUTH)
+#ifdef EAUTH
+               {*r = EAUTH; return 0;}
+#else /* def EAUTH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EAUTH */
+       if (x == Mono_Posix_Errno_EBADARCH)
+#ifdef EBADARCH
+               {*r = EBADARCH; return 0;}
+#else /* def EBADARCH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADARCH */
        if (x == Mono_Posix_Errno_EBADE)
 #ifdef EBADE
                {*r = EBADE; return 0;}
 #else /* def EBADE */
                {errno = EINVAL; return -1;}
 #endif /* ndef EBADE */
+       if (x == Mono_Posix_Errno_EBADEXEC)
+#ifdef EBADEXEC
+               {*r = EBADEXEC; return 0;}
+#else /* def EBADEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADEXEC */
        if (x == Mono_Posix_Errno_EBADF)
 #ifdef EBADF
                {*r = EBADF; return 0;}
@@ -807,6 +1220,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EBADFD */
                {errno = EINVAL; return -1;}
 #endif /* ndef EBADFD */
+       if (x == Mono_Posix_Errno_EBADMACHO)
+#ifdef EBADMACHO
+               {*r = EBADMACHO; return 0;}
+#else /* def EBADMACHO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADMACHO */
        if (x == Mono_Posix_Errno_EBADMSG)
 #ifdef EBADMSG
                {*r = EBADMSG; return 0;}
@@ -819,6 +1238,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EBADR */
                {errno = EINVAL; return -1;}
 #endif /* ndef EBADR */
+       if (x == Mono_Posix_Errno_EBADRPC)
+#ifdef EBADRPC
+               {*r = EBADRPC; return 0;}
+#else /* def EBADRPC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EBADRPC */
        if (x == Mono_Posix_Errno_EBADRQC)
 #ifdef EBADRQC
                {*r = EBADRQC; return 0;}
@@ -843,6 +1268,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EBUSY */
                {errno = EINVAL; return -1;}
 #endif /* ndef EBUSY */
+       if (x == Mono_Posix_Errno_ECANCELED)
+#ifdef ECANCELED
+               {*r = ECANCELED; return 0;}
+#else /* def ECANCELED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ECANCELED */
        if (x == Mono_Posix_Errno_ECHILD)
 #ifdef ECHILD
                {*r = ECHILD; return 0;}
@@ -897,6 +1328,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EDESTADDRREQ */
                {errno = EINVAL; return -1;}
 #endif /* ndef EDESTADDRREQ */
+       if (x == Mono_Posix_Errno_EDEVERR)
+#ifdef EDEVERR
+               {*r = EDEVERR; return 0;}
+#else /* def EDEVERR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EDEVERR */
        if (x == Mono_Posix_Errno_EDOM)
 #ifdef EDOM
                {*r = EDOM; return 0;}
@@ -933,6 +1370,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EFBIG */
                {errno = EINVAL; return -1;}
 #endif /* ndef EFBIG */
+       if (x == Mono_Posix_Errno_EFTYPE)
+#ifdef EFTYPE
+               {*r = EFTYPE; return 0;}
+#else /* def EFTYPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EFTYPE */
        if (x == Mono_Posix_Errno_EHOSTDOWN)
 #ifdef EHOSTDOWN
                {*r = EHOSTDOWN; return 0;}
@@ -999,6 +1442,24 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EISNAM */
                {errno = EINVAL; return -1;}
 #endif /* ndef EISNAM */
+       if (x == Mono_Posix_Errno_EKEYEXPIRED)
+#ifdef EKEYEXPIRED
+               {*r = EKEYEXPIRED; return 0;}
+#else /* def EKEYEXPIRED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EKEYEXPIRED */
+       if (x == Mono_Posix_Errno_EKEYREJECTED)
+#ifdef EKEYREJECTED
+               {*r = EKEYREJECTED; return 0;}
+#else /* def EKEYREJECTED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EKEYREJECTED */
+       if (x == Mono_Posix_Errno_EKEYREVOKED)
+#ifdef EKEYREVOKED
+               {*r = EKEYREVOKED; return 0;}
+#else /* def EKEYREVOKED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EKEYREVOKED */
        if (x == Mono_Posix_Errno_EL2HLT)
 #ifdef EL2HLT
                {*r = EL2HLT; return 0;}
@@ -1107,6 +1568,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def ENAVAIL */
                {errno = EINVAL; return -1;}
 #endif /* ndef ENAVAIL */
+       if (x == Mono_Posix_Errno_ENEEDAUTH)
+#ifdef ENEEDAUTH
+               {*r = ENEEDAUTH; return 0;}
+#else /* def ENEEDAUTH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENEEDAUTH */
        if (x == Mono_Posix_Errno_ENETDOWN)
 #ifdef ENETDOWN
                {*r = ENETDOWN; return 0;}
@@ -1137,6 +1604,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def ENOANO */
                {errno = EINVAL; return -1;}
 #endif /* ndef ENOANO */
+       if (x == Mono_Posix_Errno_ENOATTR)
+#ifdef ENOATTR
+               {*r = ENOATTR; return 0;}
+#else /* def ENOATTR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOATTR */
        if (x == Mono_Posix_Errno_ENOBUFS)
 #ifdef ENOBUFS
                {*r = ENOBUFS; return 0;}
@@ -1173,6 +1646,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def ENOEXEC */
                {errno = EINVAL; return -1;}
 #endif /* ndef ENOEXEC */
+       if (x == Mono_Posix_Errno_ENOKEY)
+#ifdef ENOKEY
+               {*r = ENOKEY; return 0;}
+#else /* def ENOKEY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOKEY */
        if (x == Mono_Posix_Errno_ENOLCK)
 #ifdef ENOLCK
                {*r = ENOLCK; return 0;}
@@ -1215,6 +1694,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def ENOPKG */
                {errno = EINVAL; return -1;}
 #endif /* ndef ENOPKG */
+       if (x == Mono_Posix_Errno_ENOPOLICY)
+#ifdef ENOPOLICY
+               {*r = ENOPOLICY; return 0;}
+#else /* def ENOPOLICY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOPOLICY */
        if (x == Mono_Posix_Errno_ENOPROTOOPT)
 #ifdef ENOPROTOOPT
                {*r = ENOPROTOOPT; return 0;}
@@ -1275,6 +1760,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def ENOTNAM */
                {errno = EINVAL; return -1;}
 #endif /* ndef ENOTNAM */
+       if (x == Mono_Posix_Errno_ENOTRECOVERABLE)
+#ifdef ENOTRECOVERABLE
+               {*r = ENOTRECOVERABLE; return 0;}
+#else /* def ENOTRECOVERABLE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ENOTRECOVERABLE */
        if (x == Mono_Posix_Errno_ENOTSOCK)
 #ifdef ENOTSOCK
                {*r = ENOTSOCK; return 0;}
@@ -1311,6 +1802,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EOVERFLOW */
                {errno = EINVAL; return -1;}
 #endif /* ndef EOVERFLOW */
+       if (x == Mono_Posix_Errno_EOWNERDEAD)
+#ifdef EOWNERDEAD
+               {*r = EOWNERDEAD; return 0;}
+#else /* def EOWNERDEAD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EOWNERDEAD */
        if (x == Mono_Posix_Errno_EPERM)
 #ifdef EPERM
                {*r = EPERM; return 0;}
@@ -1329,6 +1826,30 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EPIPE */
                {errno = EINVAL; return -1;}
 #endif /* ndef EPIPE */
+       if (x == Mono_Posix_Errno_EPROCLIM)
+#ifdef EPROCLIM
+               {*r = EPROCLIM; return 0;}
+#else /* def EPROCLIM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPROCLIM */
+       if (x == Mono_Posix_Errno_EPROCUNAVAIL)
+#ifdef EPROCUNAVAIL
+               {*r = EPROCUNAVAIL; return 0;}
+#else /* def EPROCUNAVAIL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPROCUNAVAIL */
+       if (x == Mono_Posix_Errno_EPROGMISMATCH)
+#ifdef EPROGMISMATCH
+               {*r = EPROGMISMATCH; return 0;}
+#else /* def EPROGMISMATCH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPROGMISMATCH */
+       if (x == Mono_Posix_Errno_EPROGUNAVAIL)
+#ifdef EPROGUNAVAIL
+               {*r = EPROGUNAVAIL; return 0;}
+#else /* def EPROGUNAVAIL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPROGUNAVAIL */
        if (x == Mono_Posix_Errno_EPROTO)
 #ifdef EPROTO
                {*r = EPROTO; return 0;}
@@ -1347,6 +1868,12 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EPROTOTYPE */
                {errno = EINVAL; return -1;}
 #endif /* ndef EPROTOTYPE */
+       if (x == Mono_Posix_Errno_EPWROFF)
+#ifdef EPWROFF
+               {*r = EPWROFF; return 0;}
+#else /* def EPWROFF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef EPWROFF */
        if (x == Mono_Posix_Errno_ERANGE)
 #ifdef ERANGE
                {*r = ERANGE; return 0;}
@@ -1383,6 +1910,18 @@ int Mono_Posix_FromErrno (int x, int *r)
 #else /* def EROFS */
                {errno = EINVAL; return -1;}
 #endif /* ndef EROFS */
+       if (x == Mono_Posix_Errno_ERPCMISMATCH)
+#ifdef ERPCMISMATCH
+               {*r = ERPCMISMATCH; return 0;}
+#else /* def ERPCMISMATCH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ERPCMISMATCH */
+       if (x == Mono_Posix_Errno_ESHLIBVERS)
+#ifdef ESHLIBVERS
+               {*r = ESHLIBVERS; return 0;}
+#else /* def ESHLIBVERS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ESHLIBVERS */
        if (x == Mono_Posix_Errno_ESHUTDOWN)
 #ifdef ESHUTDOWN
                {*r = ESHUTDOWN; return 0;}
@@ -1527,10 +2066,22 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EALREADY)
                {*r = Mono_Posix_Errno_EALREADY; return 0;}
 #endif /* ndef EALREADY */
+#ifdef EAUTH
+       if (x == EAUTH)
+               {*r = Mono_Posix_Errno_EAUTH; return 0;}
+#endif /* ndef EAUTH */
+#ifdef EBADARCH
+       if (x == EBADARCH)
+               {*r = Mono_Posix_Errno_EBADARCH; return 0;}
+#endif /* ndef EBADARCH */
 #ifdef EBADE
        if (x == EBADE)
                {*r = Mono_Posix_Errno_EBADE; return 0;}
 #endif /* ndef EBADE */
+#ifdef EBADEXEC
+       if (x == EBADEXEC)
+               {*r = Mono_Posix_Errno_EBADEXEC; return 0;}
+#endif /* ndef EBADEXEC */
 #ifdef EBADF
        if (x == EBADF)
                {*r = Mono_Posix_Errno_EBADF; return 0;}
@@ -1539,6 +2090,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EBADFD)
                {*r = Mono_Posix_Errno_EBADFD; return 0;}
 #endif /* ndef EBADFD */
+#ifdef EBADMACHO
+       if (x == EBADMACHO)
+               {*r = Mono_Posix_Errno_EBADMACHO; return 0;}
+#endif /* ndef EBADMACHO */
 #ifdef EBADMSG
        if (x == EBADMSG)
                {*r = Mono_Posix_Errno_EBADMSG; return 0;}
@@ -1547,6 +2102,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EBADR)
                {*r = Mono_Posix_Errno_EBADR; return 0;}
 #endif /* ndef EBADR */
+#ifdef EBADRPC
+       if (x == EBADRPC)
+               {*r = Mono_Posix_Errno_EBADRPC; return 0;}
+#endif /* ndef EBADRPC */
 #ifdef EBADRQC
        if (x == EBADRQC)
                {*r = Mono_Posix_Errno_EBADRQC; return 0;}
@@ -1563,6 +2122,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EBUSY)
                {*r = Mono_Posix_Errno_EBUSY; return 0;}
 #endif /* ndef EBUSY */
+#ifdef ECANCELED
+       if (x == ECANCELED)
+               {*r = Mono_Posix_Errno_ECANCELED; return 0;}
+#endif /* ndef ECANCELED */
 #ifdef ECHILD
        if (x == ECHILD)
                {*r = Mono_Posix_Errno_ECHILD; return 0;}
@@ -1599,6 +2162,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EDESTADDRREQ)
                {*r = Mono_Posix_Errno_EDESTADDRREQ; return 0;}
 #endif /* ndef EDESTADDRREQ */
+#ifdef EDEVERR
+       if (x == EDEVERR)
+               {*r = Mono_Posix_Errno_EDEVERR; return 0;}
+#endif /* ndef EDEVERR */
 #ifdef EDOM
        if (x == EDOM)
                {*r = Mono_Posix_Errno_EDOM; return 0;}
@@ -1623,6 +2190,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EFBIG)
                {*r = Mono_Posix_Errno_EFBIG; return 0;}
 #endif /* ndef EFBIG */
+#ifdef EFTYPE
+       if (x == EFTYPE)
+               {*r = Mono_Posix_Errno_EFTYPE; return 0;}
+#endif /* ndef EFTYPE */
 #ifdef EHOSTDOWN
        if (x == EHOSTDOWN)
                {*r = Mono_Posix_Errno_EHOSTDOWN; return 0;}
@@ -1667,6 +2238,18 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EISNAM)
                {*r = Mono_Posix_Errno_EISNAM; return 0;}
 #endif /* ndef EISNAM */
+#ifdef EKEYEXPIRED
+       if (x == EKEYEXPIRED)
+               {*r = Mono_Posix_Errno_EKEYEXPIRED; return 0;}
+#endif /* ndef EKEYEXPIRED */
+#ifdef EKEYREJECTED
+       if (x == EKEYREJECTED)
+               {*r = Mono_Posix_Errno_EKEYREJECTED; return 0;}
+#endif /* ndef EKEYREJECTED */
+#ifdef EKEYREVOKED
+       if (x == EKEYREVOKED)
+               {*r = Mono_Posix_Errno_EKEYREVOKED; return 0;}
+#endif /* ndef EKEYREVOKED */
 #ifdef EL2HLT
        if (x == EL2HLT)
                {*r = Mono_Posix_Errno_EL2HLT; return 0;}
@@ -1739,6 +2322,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == ENAVAIL)
                {*r = Mono_Posix_Errno_ENAVAIL; return 0;}
 #endif /* ndef ENAVAIL */
+#ifdef ENEEDAUTH
+       if (x == ENEEDAUTH)
+               {*r = Mono_Posix_Errno_ENEEDAUTH; return 0;}
+#endif /* ndef ENEEDAUTH */
 #ifdef ENETDOWN
        if (x == ENETDOWN)
                {*r = Mono_Posix_Errno_ENETDOWN; return 0;}
@@ -1759,6 +2346,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == ENOANO)
                {*r = Mono_Posix_Errno_ENOANO; return 0;}
 #endif /* ndef ENOANO */
+#ifdef ENOATTR
+       if (x == ENOATTR)
+               {*r = Mono_Posix_Errno_ENOATTR; return 0;}
+#endif /* ndef ENOATTR */
 #ifdef ENOBUFS
        if (x == ENOBUFS)
                {*r = Mono_Posix_Errno_ENOBUFS; return 0;}
@@ -1783,6 +2374,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == ENOEXEC)
                {*r = Mono_Posix_Errno_ENOEXEC; return 0;}
 #endif /* ndef ENOEXEC */
+#ifdef ENOKEY
+       if (x == ENOKEY)
+               {*r = Mono_Posix_Errno_ENOKEY; return 0;}
+#endif /* ndef ENOKEY */
 #ifdef ENOLCK
        if (x == ENOLCK)
                {*r = Mono_Posix_Errno_ENOLCK; return 0;}
@@ -1811,6 +2406,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == ENOPKG)
                {*r = Mono_Posix_Errno_ENOPKG; return 0;}
 #endif /* ndef ENOPKG */
+#ifdef ENOPOLICY
+       if (x == ENOPOLICY)
+               {*r = Mono_Posix_Errno_ENOPOLICY; return 0;}
+#endif /* ndef ENOPOLICY */
 #ifdef ENOPROTOOPT
        if (x == ENOPROTOOPT)
                {*r = Mono_Posix_Errno_ENOPROTOOPT; return 0;}
@@ -1851,6 +2450,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == ENOTNAM)
                {*r = Mono_Posix_Errno_ENOTNAM; return 0;}
 #endif /* ndef ENOTNAM */
+#ifdef ENOTRECOVERABLE
+       if (x == ENOTRECOVERABLE)
+               {*r = Mono_Posix_Errno_ENOTRECOVERABLE; return 0;}
+#endif /* ndef ENOTRECOVERABLE */
 #ifdef ENOTSOCK
        if (x == ENOTSOCK)
                {*r = Mono_Posix_Errno_ENOTSOCK; return 0;}
@@ -1875,6 +2478,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EOVERFLOW)
                {*r = Mono_Posix_Errno_EOVERFLOW; return 0;}
 #endif /* ndef EOVERFLOW */
+#ifdef EOWNERDEAD
+       if (x == EOWNERDEAD)
+               {*r = Mono_Posix_Errno_EOWNERDEAD; return 0;}
+#endif /* ndef EOWNERDEAD */
 #ifdef EPERM
        if (x == EPERM)
                {*r = Mono_Posix_Errno_EPERM; return 0;}
@@ -1887,6 +2494,22 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EPIPE)
                {*r = Mono_Posix_Errno_EPIPE; return 0;}
 #endif /* ndef EPIPE */
+#ifdef EPROCLIM
+       if (x == EPROCLIM)
+               {*r = Mono_Posix_Errno_EPROCLIM; return 0;}
+#endif /* ndef EPROCLIM */
+#ifdef EPROCUNAVAIL
+       if (x == EPROCUNAVAIL)
+               {*r = Mono_Posix_Errno_EPROCUNAVAIL; return 0;}
+#endif /* ndef EPROCUNAVAIL */
+#ifdef EPROGMISMATCH
+       if (x == EPROGMISMATCH)
+               {*r = Mono_Posix_Errno_EPROGMISMATCH; return 0;}
+#endif /* ndef EPROGMISMATCH */
+#ifdef EPROGUNAVAIL
+       if (x == EPROGUNAVAIL)
+               {*r = Mono_Posix_Errno_EPROGUNAVAIL; return 0;}
+#endif /* ndef EPROGUNAVAIL */
 #ifdef EPROTO
        if (x == EPROTO)
                {*r = Mono_Posix_Errno_EPROTO; return 0;}
@@ -1899,6 +2522,10 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EPROTOTYPE)
                {*r = Mono_Posix_Errno_EPROTOTYPE; return 0;}
 #endif /* ndef EPROTOTYPE */
+#ifdef EPWROFF
+       if (x == EPWROFF)
+               {*r = Mono_Posix_Errno_EPWROFF; return 0;}
+#endif /* ndef EPWROFF */
 #ifdef ERANGE
        if (x == ERANGE)
                {*r = Mono_Posix_Errno_ERANGE; return 0;}
@@ -1923,6 +2550,14 @@ int Mono_Posix_ToErrno (int x, int *r)
        if (x == EROFS)
                {*r = Mono_Posix_Errno_EROFS; return 0;}
 #endif /* ndef EROFS */
+#ifdef ERPCMISMATCH
+       if (x == ERPCMISMATCH)
+               {*r = Mono_Posix_Errno_ERPCMISMATCH; return 0;}
+#endif /* ndef ERPCMISMATCH */
+#ifdef ESHLIBVERS
+       if (x == ESHLIBVERS)
+               {*r = Mono_Posix_Errno_ESHLIBVERS; return 0;}
+#endif /* ndef ESHLIBVERS */
 #ifdef ESHUTDOWN
        if (x == ESHUTDOWN)
                {*r = Mono_Posix_Errno_ESHUTDOWN; return 0;}
@@ -2039,6 +2674,12 @@ int Mono_Posix_FromFcntlCommand (int x, int *r)
 #else /* def F_GETSIG */
                {errno = EINVAL; return -1;}
 #endif /* ndef F_GETSIG */
+       if (x == Mono_Posix_FcntlCommand_F_NOCACHE)
+#ifdef F_NOCACHE
+               {*r = F_NOCACHE; return 0;}
+#else /* def F_NOCACHE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef F_NOCACHE */
        if (x == Mono_Posix_FcntlCommand_F_NOTIFY)
 #ifdef F_NOTIFY
                {*r = F_NOTIFY; return 0;}
@@ -2125,6 +2766,10 @@ int Mono_Posix_ToFcntlCommand (int x, int *r)
        if (x == F_GETSIG)
                {*r = Mono_Posix_FcntlCommand_F_GETSIG; return 0;}
 #endif /* ndef F_GETSIG */
+#ifdef F_NOCACHE
+       if (x == F_NOCACHE)
+               {*r = Mono_Posix_FcntlCommand_F_NOCACHE; return 0;}
+#endif /* ndef F_NOCACHE */
 #ifdef F_NOTIFY
        if (x == F_NOTIFY)
                {*r = Mono_Posix_FcntlCommand_F_NOTIFY; return 0;}
@@ -2167,45 +2812,45 @@ int Mono_Posix_FromFilePermissions (unsigned int x, unsigned int *r)
 #ifdef ACCESSPERMS
                *r |= ACCESSPERMS;
 #else /* def ACCESSPERMS */
-               {errno = EINVAL; return -1;}
+               {/* Ignoring Mono_Posix_FilePermissions_ACCESSPERMS, as it is constructed from other values */}
 #endif /* ndef ACCESSPERMS */
        if ((x & Mono_Posix_FilePermissions_ALLPERMS) == Mono_Posix_FilePermissions_ALLPERMS)
 #ifdef ALLPERMS
                *r |= ALLPERMS;
 #else /* def ALLPERMS */
-               {errno = EINVAL; return -1;}
+               {/* Ignoring Mono_Posix_FilePermissions_ALLPERMS, as it is constructed from other values */}
 #endif /* ndef ALLPERMS */
        if ((x & Mono_Posix_FilePermissions_DEFFILEMODE) == Mono_Posix_FilePermissions_DEFFILEMODE)
 #ifdef DEFFILEMODE
                *r |= DEFFILEMODE;
 #else /* def DEFFILEMODE */
-               {errno = EINVAL; return -1;}
+               {/* Ignoring Mono_Posix_FilePermissions_DEFFILEMODE, as it is constructed from other values */}
 #endif /* ndef DEFFILEMODE */
-       if ((x & Mono_Posix_FilePermissions_S_IFBLK) == Mono_Posix_FilePermissions_S_IFBLK)
+       if ((x & Mono_Posix_FilePermissions_S_IFMT) == 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_IFCHR) == Mono_Posix_FilePermissions_S_IFCHR)
+       if ((x & Mono_Posix_FilePermissions_S_IFMT) == 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_IFDIR) == Mono_Posix_FilePermissions_S_IFDIR)
+       if ((x & Mono_Posix_FilePermissions_S_IFMT) == 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_IFIFO) == Mono_Posix_FilePermissions_S_IFIFO)
+       if ((x & Mono_Posix_FilePermissions_S_IFMT) == 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)
+       if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFLNK)
 #ifdef S_IFLNK
                *r |= S_IFLNK;
 #else /* def S_IFLNK */
@@ -2215,15 +2860,15 @@ int Mono_Posix_FromFilePermissions (unsigned int x, unsigned int *r)
 #ifdef S_IFMT
                *r |= S_IFMT;
 #else /* def S_IFMT */
-               {errno = EINVAL; return -1;}
+               {/* Ignoring Mono_Posix_FilePermissions_S_IFMT, as it is constructed from other values */}
 #endif /* ndef S_IFMT */
-       if ((x & Mono_Posix_FilePermissions_S_IFREG) == Mono_Posix_FilePermissions_S_IFREG)
+       if ((x & Mono_Posix_FilePermissions_S_IFMT) == 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_IFSOCK) == Mono_Posix_FilePermissions_S_IFSOCK)
+       if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFSOCK)
 #ifdef S_IFSOCK
                *r |= S_IFSOCK;
 #else /* def S_IFSOCK */
@@ -2251,19 +2896,19 @@ int Mono_Posix_FromFilePermissions (unsigned int x, unsigned int *r)
 #ifdef S_IRWXG
                *r |= S_IRWXG;
 #else /* def S_IRWXG */
-               {errno = EINVAL; return -1;}
+               {/* Ignoring Mono_Posix_FilePermissions_S_IRWXG, as it is constructed from other values */}
 #endif /* ndef S_IRWXG */
        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;}
+               {/* Ignoring Mono_Posix_FilePermissions_S_IRWXO, as it is constructed from other values */}
 #endif /* ndef S_IRWXO */
        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;}
+               {/* Ignoring Mono_Posix_FilePermissions_S_IRWXU, as it is constructed from other values */}
 #endif /* ndef S_IRWXU */
        if ((x & Mono_Posix_FilePermissions_S_ISGID) == Mono_Posix_FilePermissions_S_ISGID)
 #ifdef S_ISGID
@@ -2342,23 +2987,23 @@ int Mono_Posix_ToFilePermissions (unsigned int x, unsigned int *r)
                *r |= Mono_Posix_FilePermissions_DEFFILEMODE;
 #endif /* ndef DEFFILEMODE */
 #ifdef S_IFBLK
-       if ((x & S_IFBLK) == S_IFBLK)
+       if ((x & S_IFMT) == S_IFBLK)
                *r |= Mono_Posix_FilePermissions_S_IFBLK;
 #endif /* ndef S_IFBLK */
 #ifdef S_IFCHR
-       if ((x & S_IFCHR) == S_IFCHR)
+       if ((x & S_IFMT) == S_IFCHR)
                *r |= Mono_Posix_FilePermissions_S_IFCHR;
 #endif /* ndef S_IFCHR */
 #ifdef S_IFDIR
-       if ((x & S_IFDIR) == S_IFDIR)
+       if ((x & S_IFMT) == S_IFDIR)
                *r |= Mono_Posix_FilePermissions_S_IFDIR;
 #endif /* ndef S_IFDIR */
 #ifdef S_IFIFO
-       if ((x & S_IFIFO) == S_IFIFO)
+       if ((x & S_IFMT) == S_IFIFO)
                *r |= Mono_Posix_FilePermissions_S_IFIFO;
 #endif /* ndef S_IFIFO */
 #ifdef S_IFLNK
-       if ((x & S_IFLNK) == S_IFLNK)
+       if ((x & S_IFMT) == S_IFLNK)
                *r |= Mono_Posix_FilePermissions_S_IFLNK;
 #endif /* ndef S_IFLNK */
 #ifdef S_IFMT
@@ -2366,11 +3011,11 @@ int Mono_Posix_ToFilePermissions (unsigned int x, unsigned int *r)
                *r |= Mono_Posix_FilePermissions_S_IFMT;
 #endif /* ndef S_IFMT */
 #ifdef S_IFREG
-       if ((x & S_IFREG) == S_IFREG)
+       if ((x & S_IFMT) == S_IFREG)
                *r |= Mono_Posix_FilePermissions_S_IFREG;
 #endif /* ndef S_IFREG */
 #ifdef S_IFSOCK
-       if ((x & S_IFSOCK) == S_IFSOCK)
+       if ((x & S_IFMT) == S_IFSOCK)
                *r |= Mono_Posix_FilePermissions_S_IFSOCK;
 #endif /* ndef S_IFSOCK */
 #ifdef S_IRGRP
@@ -2436,6 +3081,122 @@ int Mono_Posix_ToFilePermissions (unsigned int x, unsigned int *r)
        return 0;
 }
 
+#ifdef HAVE_STRUCT_FLOCK
+int
+Mono_Posix_FromFlock (struct Mono_Posix_Flock *from, struct flock *to)
+{
+       _cnm_return_val_if_overflow (off_t, from->l_start, -1);
+       _cnm_return_val_if_overflow (off_t, from->l_len, -1);
+       _cnm_return_val_if_overflow (pid_t, from->l_pid, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       if (Mono_Posix_FromLockType (from->l_type, &to->l_type) != 0) {
+               return -1;
+       }
+       if (Mono_Posix_FromSeekFlags (from->l_whence, &to->l_whence) != 0) {
+               return -1;
+       }
+       to->l_start  = from->l_start;
+       to->l_len    = from->l_len;
+       to->l_pid    = from->l_pid;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_FLOCK */
+
+
+#ifdef HAVE_STRUCT_FLOCK
+int
+Mono_Posix_ToFlock (struct flock *from, struct Mono_Posix_Flock *to)
+{
+       _cnm_return_val_if_overflow (gint64, from->l_start, -1);
+       _cnm_return_val_if_overflow (gint64, from->l_len, -1);
+       _cnm_return_val_if_overflow (int, from->l_pid, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       if (Mono_Posix_ToLockType (from->l_type, &to->l_type) != 0) {
+               return -1;
+       }
+       if (Mono_Posix_ToSeekFlags (from->l_whence, &to->l_whence) != 0) {
+               return -1;
+       }
+       to->l_start  = from->l_start;
+       to->l_len    = from->l_len;
+       to->l_pid    = from->l_pid;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_FLOCK */
+
+
+#ifdef HAVE_STRUCT_IOVEC
+int
+Mono_Posix_FromIovec (struct Mono_Posix_Iovec *from, struct iovec *to)
+{
+       _cnm_return_val_if_overflow (guint64, from->iov_len, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->iov_base = from->iov_base;
+       to->iov_len  = from->iov_len;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_IOVEC */
+
+
+#ifdef HAVE_STRUCT_IOVEC
+int
+Mono_Posix_ToIovec (struct iovec *from, struct Mono_Posix_Iovec *to)
+{
+       _cnm_return_val_if_overflow (guint64, from->iov_len, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->iov_base = from->iov_base;
+       to->iov_len  = from->iov_len;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_IOVEC */
+
+
+#ifdef HAVE_STRUCT_LINGER
+int
+Mono_Posix_FromLinger (struct Mono_Posix_Linger *from, struct linger *to)
+{
+       _cnm_return_val_if_overflow (int, from->l_onoff, -1);
+       _cnm_return_val_if_overflow (int, from->l_linger, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->l_onoff  = from->l_onoff;
+       to->l_linger = from->l_linger;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_LINGER */
+
+
+#ifdef HAVE_STRUCT_LINGER
+int
+Mono_Posix_ToLinger (struct linger *from, struct Mono_Posix_Linger *to)
+{
+       _cnm_return_val_if_overflow (int, from->l_onoff, -1);
+       _cnm_return_val_if_overflow (int, from->l_linger, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->l_onoff  = from->l_onoff;
+       to->l_linger = from->l_linger;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_LINGER */
+
+
 int Mono_Posix_FromLockType (short x, short *r)
 {
        *r = 0;
@@ -2538,6 +3299,212 @@ int Mono_Posix_ToLockfCommand (int x, int *r)
        errno = EINVAL; return -1;
 }
 
+int Mono_Posix_FromMessageFlags (int x, int *r)
+{
+       *r = 0;
+       if ((x & Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC) == Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC)
+#ifdef MSG_CMSG_CLOEXEC
+               *r |= MSG_CMSG_CLOEXEC;
+#else /* def MSG_CMSG_CLOEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_CMSG_CLOEXEC */
+       if ((x & Mono_Posix_MessageFlags_MSG_CONFIRM) == Mono_Posix_MessageFlags_MSG_CONFIRM)
+#ifdef MSG_CONFIRM
+               *r |= MSG_CONFIRM;
+#else /* def MSG_CONFIRM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_CONFIRM */
+       if ((x & Mono_Posix_MessageFlags_MSG_CTRUNC) == Mono_Posix_MessageFlags_MSG_CTRUNC)
+#ifdef MSG_CTRUNC
+               *r |= MSG_CTRUNC;
+#else /* def MSG_CTRUNC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_CTRUNC */
+       if ((x & Mono_Posix_MessageFlags_MSG_DONTROUTE) == Mono_Posix_MessageFlags_MSG_DONTROUTE)
+#ifdef MSG_DONTROUTE
+               *r |= MSG_DONTROUTE;
+#else /* def MSG_DONTROUTE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_DONTROUTE */
+       if ((x & Mono_Posix_MessageFlags_MSG_DONTWAIT) == Mono_Posix_MessageFlags_MSG_DONTWAIT)
+#ifdef MSG_DONTWAIT
+               *r |= MSG_DONTWAIT;
+#else /* def MSG_DONTWAIT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_DONTWAIT */
+       if ((x & Mono_Posix_MessageFlags_MSG_EOR) == Mono_Posix_MessageFlags_MSG_EOR)
+#ifdef MSG_EOR
+               *r |= MSG_EOR;
+#else /* def MSG_EOR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_EOR */
+       if ((x & Mono_Posix_MessageFlags_MSG_ERRQUEUE) == Mono_Posix_MessageFlags_MSG_ERRQUEUE)
+#ifdef MSG_ERRQUEUE
+               *r |= MSG_ERRQUEUE;
+#else /* def MSG_ERRQUEUE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_ERRQUEUE */
+       if ((x & Mono_Posix_MessageFlags_MSG_FASTOPEN) == Mono_Posix_MessageFlags_MSG_FASTOPEN)
+#ifdef MSG_FASTOPEN
+               *r |= MSG_FASTOPEN;
+#else /* def MSG_FASTOPEN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_FASTOPEN */
+       if ((x & Mono_Posix_MessageFlags_MSG_FIN) == Mono_Posix_MessageFlags_MSG_FIN)
+#ifdef MSG_FIN
+               *r |= MSG_FIN;
+#else /* def MSG_FIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_FIN */
+       if ((x & Mono_Posix_MessageFlags_MSG_MORE) == Mono_Posix_MessageFlags_MSG_MORE)
+#ifdef MSG_MORE
+               *r |= MSG_MORE;
+#else /* def MSG_MORE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_MORE */
+       if ((x & Mono_Posix_MessageFlags_MSG_NOSIGNAL) == Mono_Posix_MessageFlags_MSG_NOSIGNAL)
+#ifdef MSG_NOSIGNAL
+               *r |= MSG_NOSIGNAL;
+#else /* def MSG_NOSIGNAL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_NOSIGNAL */
+       if ((x & Mono_Posix_MessageFlags_MSG_OOB) == Mono_Posix_MessageFlags_MSG_OOB)
+#ifdef MSG_OOB
+               *r |= MSG_OOB;
+#else /* def MSG_OOB */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_OOB */
+       if ((x & Mono_Posix_MessageFlags_MSG_PEEK) == Mono_Posix_MessageFlags_MSG_PEEK)
+#ifdef MSG_PEEK
+               *r |= MSG_PEEK;
+#else /* def MSG_PEEK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_PEEK */
+       if ((x & Mono_Posix_MessageFlags_MSG_PROXY) == Mono_Posix_MessageFlags_MSG_PROXY)
+#ifdef MSG_PROXY
+               *r |= MSG_PROXY;
+#else /* def MSG_PROXY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_PROXY */
+       if ((x & Mono_Posix_MessageFlags_MSG_RST) == Mono_Posix_MessageFlags_MSG_RST)
+#ifdef MSG_RST
+               *r |= MSG_RST;
+#else /* def MSG_RST */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_RST */
+       if ((x & Mono_Posix_MessageFlags_MSG_SYN) == Mono_Posix_MessageFlags_MSG_SYN)
+#ifdef MSG_SYN
+               *r |= MSG_SYN;
+#else /* def MSG_SYN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_SYN */
+       if ((x & Mono_Posix_MessageFlags_MSG_TRUNC) == Mono_Posix_MessageFlags_MSG_TRUNC)
+#ifdef MSG_TRUNC
+               *r |= MSG_TRUNC;
+#else /* def MSG_TRUNC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_TRUNC */
+       if ((x & Mono_Posix_MessageFlags_MSG_WAITALL) == Mono_Posix_MessageFlags_MSG_WAITALL)
+#ifdef MSG_WAITALL
+               *r |= MSG_WAITALL;
+#else /* def MSG_WAITALL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_WAITALL */
+       if ((x & Mono_Posix_MessageFlags_MSG_WAITFORONE) == Mono_Posix_MessageFlags_MSG_WAITFORONE)
+#ifdef MSG_WAITFORONE
+               *r |= MSG_WAITFORONE;
+#else /* def MSG_WAITFORONE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MSG_WAITFORONE */
+       if (x == 0)
+               return 0;
+       return 0;
+}
+
+int Mono_Posix_ToMessageFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef MSG_CMSG_CLOEXEC
+       if ((x & MSG_CMSG_CLOEXEC) == MSG_CMSG_CLOEXEC)
+               *r |= Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC;
+#endif /* ndef MSG_CMSG_CLOEXEC */
+#ifdef MSG_CONFIRM
+       if ((x & MSG_CONFIRM) == MSG_CONFIRM)
+               *r |= Mono_Posix_MessageFlags_MSG_CONFIRM;
+#endif /* ndef MSG_CONFIRM */
+#ifdef MSG_CTRUNC
+       if ((x & MSG_CTRUNC) == MSG_CTRUNC)
+               *r |= Mono_Posix_MessageFlags_MSG_CTRUNC;
+#endif /* ndef MSG_CTRUNC */
+#ifdef MSG_DONTROUTE
+       if ((x & MSG_DONTROUTE) == MSG_DONTROUTE)
+               *r |= Mono_Posix_MessageFlags_MSG_DONTROUTE;
+#endif /* ndef MSG_DONTROUTE */
+#ifdef MSG_DONTWAIT
+       if ((x & MSG_DONTWAIT) == MSG_DONTWAIT)
+               *r |= Mono_Posix_MessageFlags_MSG_DONTWAIT;
+#endif /* ndef MSG_DONTWAIT */
+#ifdef MSG_EOR
+       if ((x & MSG_EOR) == MSG_EOR)
+               *r |= Mono_Posix_MessageFlags_MSG_EOR;
+#endif /* ndef MSG_EOR */
+#ifdef MSG_ERRQUEUE
+       if ((x & MSG_ERRQUEUE) == MSG_ERRQUEUE)
+               *r |= Mono_Posix_MessageFlags_MSG_ERRQUEUE;
+#endif /* ndef MSG_ERRQUEUE */
+#ifdef MSG_FASTOPEN
+       if ((x & MSG_FASTOPEN) == MSG_FASTOPEN)
+               *r |= Mono_Posix_MessageFlags_MSG_FASTOPEN;
+#endif /* ndef MSG_FASTOPEN */
+#ifdef MSG_FIN
+       if ((x & MSG_FIN) == MSG_FIN)
+               *r |= Mono_Posix_MessageFlags_MSG_FIN;
+#endif /* ndef MSG_FIN */
+#ifdef MSG_MORE
+       if ((x & MSG_MORE) == MSG_MORE)
+               *r |= Mono_Posix_MessageFlags_MSG_MORE;
+#endif /* ndef MSG_MORE */
+#ifdef MSG_NOSIGNAL
+       if ((x & MSG_NOSIGNAL) == MSG_NOSIGNAL)
+               *r |= Mono_Posix_MessageFlags_MSG_NOSIGNAL;
+#endif /* ndef MSG_NOSIGNAL */
+#ifdef MSG_OOB
+       if ((x & MSG_OOB) == MSG_OOB)
+               *r |= Mono_Posix_MessageFlags_MSG_OOB;
+#endif /* ndef MSG_OOB */
+#ifdef MSG_PEEK
+       if ((x & MSG_PEEK) == MSG_PEEK)
+               *r |= Mono_Posix_MessageFlags_MSG_PEEK;
+#endif /* ndef MSG_PEEK */
+#ifdef MSG_PROXY
+       if ((x & MSG_PROXY) == MSG_PROXY)
+               *r |= Mono_Posix_MessageFlags_MSG_PROXY;
+#endif /* ndef MSG_PROXY */
+#ifdef MSG_RST
+       if ((x & MSG_RST) == MSG_RST)
+               *r |= Mono_Posix_MessageFlags_MSG_RST;
+#endif /* ndef MSG_RST */
+#ifdef MSG_SYN
+       if ((x & MSG_SYN) == MSG_SYN)
+               *r |= Mono_Posix_MessageFlags_MSG_SYN;
+#endif /* ndef MSG_SYN */
+#ifdef MSG_TRUNC
+       if ((x & MSG_TRUNC) == MSG_TRUNC)
+               *r |= Mono_Posix_MessageFlags_MSG_TRUNC;
+#endif /* ndef MSG_TRUNC */
+#ifdef MSG_WAITALL
+       if ((x & MSG_WAITALL) == MSG_WAITALL)
+               *r |= Mono_Posix_MessageFlags_MSG_WAITALL;
+#endif /* ndef MSG_WAITALL */
+#ifdef MSG_WAITFORONE
+       if ((x & MSG_WAITFORONE) == MSG_WAITFORONE)
+               *r |= Mono_Posix_MessageFlags_MSG_WAITFORONE;
+#endif /* ndef MSG_WAITFORONE */
+       return 0;
+}
+
 int Mono_Posix_FromMlockallFlags (int x, int *r)
 {
        *r = 0;
@@ -2815,6 +3782,12 @@ int Mono_Posix_FromMountFlags (guint64 x, guint64 *r)
 #else /* def ST_APPEND */
                {errno = EINVAL; return -1;}
 #endif /* ndef ST_APPEND */
+       if ((x & Mono_Posix_MountFlags_ST_BIND) == Mono_Posix_MountFlags_ST_BIND)
+#ifdef ST_BIND
+               *r |= ST_BIND;
+#else /* def ST_BIND */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_BIND */
        if ((x & Mono_Posix_MountFlags_ST_IMMUTABLE) == Mono_Posix_MountFlags_ST_IMMUTABLE)
 #ifdef ST_IMMUTABLE
                *r |= ST_IMMUTABLE;
@@ -2845,6 +3818,12 @@ int Mono_Posix_FromMountFlags (guint64 x, guint64 *r)
 #else /* def ST_NODIRATIME */
                {errno = EINVAL; return -1;}
 #endif /* ndef ST_NODIRATIME */
+       if ((x & Mono_Posix_MountFlags_ST_NOEXEC) == Mono_Posix_MountFlags_ST_NOEXEC)
+#ifdef ST_NOEXEC
+               *r |= ST_NOEXEC;
+#else /* def ST_NOEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_NOEXEC */
        if ((x & Mono_Posix_MountFlags_ST_NOSUID) == Mono_Posix_MountFlags_ST_NOSUID)
 #ifdef ST_NOSUID
                *r |= ST_NOSUID;
@@ -2857,6 +3836,12 @@ int Mono_Posix_FromMountFlags (guint64 x, guint64 *r)
 #else /* def ST_RDONLY */
                {errno = EINVAL; return -1;}
 #endif /* ndef ST_RDONLY */
+       if ((x & Mono_Posix_MountFlags_ST_REMOUNT) == Mono_Posix_MountFlags_ST_REMOUNT)
+#ifdef ST_REMOUNT
+               *r |= ST_REMOUNT;
+#else /* def ST_REMOUNT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef ST_REMOUNT */
        if ((x & Mono_Posix_MountFlags_ST_SYNCHRONOUS) == Mono_Posix_MountFlags_ST_SYNCHRONOUS)
 #ifdef ST_SYNCHRONOUS
                *r |= ST_SYNCHRONOUS;
@@ -2883,6 +3868,10 @@ int Mono_Posix_ToMountFlags (guint64 x, guint64 *r)
        if ((x & ST_APPEND) == ST_APPEND)
                *r |= Mono_Posix_MountFlags_ST_APPEND;
 #endif /* ndef ST_APPEND */
+#ifdef ST_BIND
+       if ((x & ST_BIND) == ST_BIND)
+               *r |= Mono_Posix_MountFlags_ST_BIND;
+#endif /* ndef ST_BIND */
 #ifdef ST_IMMUTABLE
        if ((x & ST_IMMUTABLE) == ST_IMMUTABLE)
                *r |= Mono_Posix_MountFlags_ST_IMMUTABLE;
@@ -2903,6 +3892,10 @@ int Mono_Posix_ToMountFlags (guint64 x, guint64 *r)
        if ((x & ST_NODIRATIME) == ST_NODIRATIME)
                *r |= Mono_Posix_MountFlags_ST_NODIRATIME;
 #endif /* ndef ST_NODIRATIME */
+#ifdef ST_NOEXEC
+       if ((x & ST_NOEXEC) == ST_NOEXEC)
+               *r |= Mono_Posix_MountFlags_ST_NOEXEC;
+#endif /* ndef ST_NOEXEC */
 #ifdef ST_NOSUID
        if ((x & ST_NOSUID) == ST_NOSUID)
                *r |= Mono_Posix_MountFlags_ST_NOSUID;
@@ -2911,6 +3904,10 @@ int Mono_Posix_ToMountFlags (guint64 x, guint64 *r)
        if ((x & ST_RDONLY) == ST_RDONLY)
                *r |= Mono_Posix_MountFlags_ST_RDONLY;
 #endif /* ndef ST_RDONLY */
+#ifdef ST_REMOUNT
+       if ((x & ST_REMOUNT) == ST_REMOUNT)
+               *r |= Mono_Posix_MountFlags_ST_REMOUNT;
+#endif /* ndef ST_REMOUNT */
 #ifdef ST_SYNCHRONOUS
        if ((x & ST_SYNCHRONOUS) == ST_SYNCHRONOUS)
                *r |= Mono_Posix_MountFlags_ST_SYNCHRONOUS;
@@ -2925,12 +3922,17 @@ int Mono_Posix_ToMountFlags (guint64 x, guint64 *r)
 int Mono_Posix_FromMremapFlags (guint64 x, guint64 *r)
 {
        *r = 0;
+#ifndef __NetBSD__
        if ((x & Mono_Posix_MremapFlags_MREMAP_MAYMOVE) == Mono_Posix_MremapFlags_MREMAP_MAYMOVE)
 #ifdef MREMAP_MAYMOVE
                *r |= MREMAP_MAYMOVE;
 #else /* def MREMAP_MAYMOVE */
                {errno = EINVAL; return -1;}
 #endif /* ndef MREMAP_MAYMOVE */
+#else /* def __NetBSD__ */
+       if ((x & Mono_Posix_MremapFlags_MREMAP_MAYMOVE) != Mono_Posix_MremapFlags_MREMAP_MAYMOVE)
+               *r = MAP_FIXED;
+#endif /* def __NetBSD__ */
        if (x == 0)
                return 0;
        return 0;
@@ -2939,12 +3941,17 @@ int Mono_Posix_FromMremapFlags (guint64 x, guint64 *r)
 int Mono_Posix_ToMremapFlags (guint64 x, guint64 *r)
 {
        *r = 0;
+#ifndef __NetBSD__
        if (x == 0)
                return 0;
 #ifdef MREMAP_MAYMOVE
        if ((x & MREMAP_MAYMOVE) == MREMAP_MAYMOVE)
                *r |= Mono_Posix_MremapFlags_MREMAP_MAYMOVE;
 #endif /* ndef MREMAP_MAYMOVE */
+#else /* def __NetBSD__ */
+       if ((x & MAP_FIXED) != MAP_FIXED)
+               *r |= Mono_Posix_MremapFlags_MREMAP_MAYMOVE;
+#endif
        return 0;
 }
 
@@ -3009,6 +4016,12 @@ int Mono_Posix_FromOpenFlags (int x, int *r)
 #else /* def O_ASYNC */
                {errno = EINVAL; return -1;}
 #endif /* ndef O_ASYNC */
+       if ((x & Mono_Posix_OpenFlags_O_CLOEXEC) == Mono_Posix_OpenFlags_O_CLOEXEC)
+#ifdef O_CLOEXEC
+               *r |= O_CLOEXEC;
+#else /* def O_CLOEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_CLOEXEC */
        if ((x & Mono_Posix_OpenFlags_O_CREAT) == Mono_Posix_OpenFlags_O_CREAT)
 #ifdef O_CREAT
                *r |= O_CREAT;
@@ -3057,6 +4070,12 @@ int Mono_Posix_FromOpenFlags (int x, int *r)
 #else /* def O_NONBLOCK */
                {errno = EINVAL; return -1;}
 #endif /* ndef O_NONBLOCK */
+       if ((x & Mono_Posix_OpenFlags_O_PATH) == Mono_Posix_OpenFlags_O_PATH)
+#ifdef O_PATH
+               *r |= O_PATH;
+#else /* def O_PATH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef O_PATH */
        if ((x & Mono_Posix_OpenFlags_O_RDONLY) == Mono_Posix_OpenFlags_O_RDONLY)
 #ifdef O_RDONLY
                *r |= O_RDONLY;
@@ -3105,6 +4124,10 @@ int Mono_Posix_ToOpenFlags (int x, int *r)
        if ((x & O_ASYNC) == O_ASYNC)
                *r |= Mono_Posix_OpenFlags_O_ASYNC;
 #endif /* ndef O_ASYNC */
+#ifdef O_CLOEXEC
+       if ((x & O_CLOEXEC) == O_CLOEXEC)
+               *r |= Mono_Posix_OpenFlags_O_CLOEXEC;
+#endif /* ndef O_CLOEXEC */
 #ifdef O_CREAT
        if ((x & O_CREAT) == O_CREAT)
                *r |= Mono_Posix_OpenFlags_O_CREAT;
@@ -3137,6 +4160,10 @@ int Mono_Posix_ToOpenFlags (int x, int *r)
        if ((x & O_NONBLOCK) == O_NONBLOCK)
                *r |= Mono_Posix_OpenFlags_O_NONBLOCK;
 #endif /* ndef O_NONBLOCK */
+#ifdef O_PATH
+       if ((x & O_PATH) == O_PATH)
+               *r |= Mono_Posix_OpenFlags_O_PATH;
+#endif /* ndef O_PATH */
 #ifdef O_RDONLY
        if ((x & O_RDONLY) == O_RDONLY)
                *r |= Mono_Posix_OpenFlags_O_RDONLY;
@@ -3502,6 +4529,7 @@ int Mono_Posix_ToPollEvents (short x, short *r)
        return 0;
 }
 
+#ifdef HAVE_STRUCT_POLLFD
 int
 Mono_Posix_FromPollfd (struct Mono_Posix_Pollfd *from, struct pollfd *to)
 {
@@ -3519,8 +4547,10 @@ Mono_Posix_FromPollfd (struct Mono_Posix_Pollfd *from, struct pollfd *to)
 
        return 0;
 }
+#endif /* ndef HAVE_STRUCT_POLLFD */
 
 
+#ifdef HAVE_STRUCT_POLLFD
 int
 Mono_Posix_ToPollfd (struct pollfd *from, struct Mono_Posix_Pollfd *to)
 {
@@ -3538,6 +4568,7 @@ Mono_Posix_ToPollfd (struct pollfd *from, struct Mono_Posix_Pollfd *to)
 
        return 0;
 }
+#endif /* ndef HAVE_STRUCT_POLLFD */
 
 
 int Mono_Posix_FromPosixFadviseAdvice (int x, int *r)
@@ -3758,6 +4789,52 @@ int Mono_Posix_ToSeekFlags (short x, short *r)
        errno = EINVAL; return -1;
 }
 
+int Mono_Posix_FromShutdownOption (int x, int *r)
+{
+       *r = 0;
+       if (x == Mono_Posix_ShutdownOption_SHUT_RD)
+#ifdef SHUT_RD
+               {*r = SHUT_RD; return 0;}
+#else /* def SHUT_RD */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SHUT_RD */
+       if (x == Mono_Posix_ShutdownOption_SHUT_RDWR)
+#ifdef SHUT_RDWR
+               {*r = SHUT_RDWR; return 0;}
+#else /* def SHUT_RDWR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SHUT_RDWR */
+       if (x == Mono_Posix_ShutdownOption_SHUT_WR)
+#ifdef SHUT_WR
+               {*r = SHUT_WR; return 0;}
+#else /* def SHUT_WR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SHUT_WR */
+       if (x == 0)
+               return 0;
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToShutdownOption (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef SHUT_RD
+       if (x == SHUT_RD)
+               {*r = Mono_Posix_ShutdownOption_SHUT_RD; return 0;}
+#endif /* ndef SHUT_RD */
+#ifdef SHUT_RDWR
+       if (x == SHUT_RDWR)
+               {*r = Mono_Posix_ShutdownOption_SHUT_RDWR; return 0;}
+#endif /* ndef SHUT_RDWR */
+#ifdef SHUT_WR
+       if (x == SHUT_WR)
+               {*r = Mono_Posix_ShutdownOption_SHUT_WR; return 0;}
+#endif /* ndef SHUT_WR */
+       errno = EINVAL; return -1;
+}
+
 int Mono_Posix_FromSignum (int x, int *r)
 {
        *r = 0;
@@ -4124,81 +5201,171 @@ int Mono_Posix_ToSignum (int x, int *r)
        errno = EINVAL; return -1;
 }
 
+#ifdef HAVE_STRUCT_SOCKADDR_IN
 int
-Mono_Posix_FromStat (struct Mono_Posix_Stat *from, struct stat *to)
+Mono_Posix_FromSockaddrIn (struct Mono_Posix_SockaddrIn *from, struct sockaddr_in *to)
 {
-       _cnm_return_val_if_overflow (dev_t, from->st_dev, -1);
-       _cnm_return_val_if_overflow (ino_t, from->st_ino, -1);
-       _cnm_return_val_if_overflow (nlink_t, from->st_nlink, -1);
-       _cnm_return_val_if_overflow (uid_t, from->st_uid, -1);
-       _cnm_return_val_if_overflow (gid_t, from->st_gid, -1);
-       _cnm_return_val_if_overflow (dev_t, from->st_rdev, -1);
-       _cnm_return_val_if_overflow (off_t, from->st_size, -1);
-       _cnm_return_val_if_overflow (blksize_t, from->st_blksize, -1);
-       _cnm_return_val_if_overflow (blkcnt_t, from->st_blocks, -1);
-       _cnm_return_val_if_overflow (time_t, from->st_atime_, -1);
-       _cnm_return_val_if_overflow (time_t, from->st_mtime_, -1);
-       _cnm_return_val_if_overflow (time_t, from->st_ctime_, -1);
+       _cnm_return_val_if_overflow (unsigned short, from->sin_port, -1);
 
        memset (to, 0, sizeof(*to));
 
-       to->st_dev     = from->st_dev;
-       to->st_ino     = from->st_ino;
-       if (Mono_Posix_FromFilePermissions (from->st_mode, &to->st_mode) != 0) {
+       to->sin_port = from->sin_port;
+       if (Mono_Posix_FromInAddr (&from->sin_addr, &to->sin_addr) != 0) {
                return -1;
        }
-       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;
 }
+#endif /* ndef HAVE_STRUCT_SOCKADDR_IN */
 
 
+#ifdef HAVE_STRUCT_SOCKADDR_IN
 int
-Mono_Posix_ToStat (struct stat *from, struct Mono_Posix_Stat *to)
+Mono_Posix_ToSockaddrIn (struct sockaddr_in *from, struct Mono_Posix_SockaddrIn *to)
 {
-       _cnm_return_val_if_overflow (guint64, from->st_dev, -1);
-       _cnm_return_val_if_overflow (guint64, from->st_ino, -1);
-       _cnm_return_val_if_overflow (guint64, from->st_nlink, -1);
-       _cnm_return_val_if_overflow (unsigned int, from->st_uid, -1);
-       _cnm_return_val_if_overflow (unsigned int, from->st_gid, -1);
-       _cnm_return_val_if_overflow (guint64, from->st_rdev, -1);
-       _cnm_return_val_if_overflow (gint64, from->st_size, -1);
-       _cnm_return_val_if_overflow (gint64, from->st_blksize, -1);
-       _cnm_return_val_if_overflow (gint64, from->st_blocks, -1);
-       _cnm_return_val_if_overflow (gint64, from->st_atime, -1);
-       _cnm_return_val_if_overflow (gint64, from->st_mtime, -1);
-       _cnm_return_val_if_overflow (gint64, from->st_ctime, -1);
+       _cnm_return_val_if_overflow (unsigned short, from->sin_port, -1);
 
        memset (to, 0, sizeof(*to));
 
-       to->st_dev     = from->st_dev;
-       to->st_ino     = from->st_ino;
-       if (Mono_Posix_ToFilePermissions (from->st_mode, &to->st_mode) != 0) {
+       to->sin_port = from->sin_port;
+       if (Mono_Posix_ToInAddr (&from->sin_addr, &to->sin_addr) != 0) {
                return -1;
        }
-       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;
 }
+#endif /* ndef HAVE_STRUCT_SOCKADDR_IN */
+
 
+#if defined(HAVE_STRUCT_SOCKADDR_IN6) && !defined(HOST_WIN32)
+int
+Mono_Posix_FromSockaddrIn6 (struct Mono_Posix_SockaddrIn6 *from, struct sockaddr_in6 *to)
+{
+       _cnm_return_val_if_overflow (unsigned short, from->sin6_port, -1);
+       _cnm_return_val_if_overflow (unsigned int, from->sin6_flowinfo, -1);
+       _cnm_return_val_if_overflow (unsigned int, from->sin6_scope_id, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->sin6_port     = from->sin6_port;
+       to->sin6_flowinfo = from->sin6_flowinfo;
+       if (Mono_Posix_FromIn6Addr (&from->sin6_addr, &to->sin6_addr) != 0) {
+               return -1;
+       }
+       to->sin6_scope_id = from->sin6_scope_id;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_SOCKADDR_IN6 */
+
+
+#if defined(HAVE_STRUCT_SOCKADDR_IN6) && !defined(HOST_WIN32)
+int
+Mono_Posix_ToSockaddrIn6 (struct sockaddr_in6 *from, struct Mono_Posix_SockaddrIn6 *to)
+{
+       _cnm_return_val_if_overflow (unsigned short, from->sin6_port, -1);
+       _cnm_return_val_if_overflow (unsigned int, from->sin6_flowinfo, -1);
+       _cnm_return_val_if_overflow (unsigned int, from->sin6_scope_id, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->sin6_port     = from->sin6_port;
+       to->sin6_flowinfo = from->sin6_flowinfo;
+       if (Mono_Posix_ToIn6Addr (&from->sin6_addr, &to->sin6_addr) != 0) {
+               return -1;
+       }
+       to->sin6_scope_id = from->sin6_scope_id;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_SOCKADDR_IN6 */
+
+
+int Mono_Posix_FromSockaddrType (int x, int *r)
+{
+       *r = 0;
+       if (x == Mono_Posix_SockaddrType_Invalid)
+#ifdef Invalid
+               {*r = Invalid; return 0;}
+#else /* def Invalid */
+               {errno = EINVAL; return -1;}
+#endif /* ndef Invalid */
+       if (x == Mono_Posix_SockaddrType_MustBeWrapped)
+#ifdef MustBeWrapped
+               {*r = MustBeWrapped; return 0;}
+#else /* def MustBeWrapped */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MustBeWrapped */
+       if (x == Mono_Posix_SockaddrType_Sockaddr)
+#ifdef Sockaddr
+               {*r = Sockaddr; return 0;}
+#else /* def Sockaddr */
+               {errno = EINVAL; return -1;}
+#endif /* ndef Sockaddr */
+       if (x == Mono_Posix_SockaddrType_SockaddrIn)
+#ifdef SockaddrIn
+               {*r = SockaddrIn; return 0;}
+#else /* def SockaddrIn */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SockaddrIn */
+       if (x == Mono_Posix_SockaddrType_SockaddrIn6)
+#ifdef SockaddrIn6
+               {*r = SockaddrIn6; return 0;}
+#else /* def SockaddrIn6 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SockaddrIn6 */
+       if (x == Mono_Posix_SockaddrType_SockaddrStorage)
+#ifdef SockaddrStorage
+               {*r = SockaddrStorage; return 0;}
+#else /* def SockaddrStorage */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SockaddrStorage */
+       if (x == Mono_Posix_SockaddrType_SockaddrUn)
+#ifdef SockaddrUn
+               {*r = SockaddrUn; return 0;}
+#else /* def SockaddrUn */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SockaddrUn */
+       if (x == 0)
+               return 0;
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToSockaddrType (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef Invalid
+       if (x == Invalid)
+               {*r = Mono_Posix_SockaddrType_Invalid; return 0;}
+#endif /* ndef Invalid */
+#ifdef MustBeWrapped
+       if (x == MustBeWrapped)
+               {*r = Mono_Posix_SockaddrType_MustBeWrapped; return 0;}
+#endif /* ndef MustBeWrapped */
+#ifdef Sockaddr
+       if (x == Sockaddr)
+               {*r = Mono_Posix_SockaddrType_Sockaddr; return 0;}
+#endif /* ndef Sockaddr */
+#ifdef SockaddrIn
+       if (x == SockaddrIn)
+               {*r = Mono_Posix_SockaddrType_SockaddrIn; return 0;}
+#endif /* ndef SockaddrIn */
+#ifdef SockaddrIn6
+       if (x == SockaddrIn6)
+               {*r = Mono_Posix_SockaddrType_SockaddrIn6; return 0;}
+#endif /* ndef SockaddrIn6 */
+#ifdef SockaddrStorage
+       if (x == SockaddrStorage)
+               {*r = Mono_Posix_SockaddrType_SockaddrStorage; return 0;}
+#endif /* ndef SockaddrStorage */
+#ifdef SockaddrUn
+       if (x == SockaddrUn)
+               {*r = Mono_Posix_SockaddrType_SockaddrUn; return 0;}
+#endif /* ndef SockaddrUn */
+       errno = EINVAL; return -1;
+}
 
 int Mono_Posix_FromSysconfName (int x, int *r)
 {
@@ -6614,6 +7781,41 @@ int Mono_Posix_ToSyslogOptions (int x, int *r)
        return 0;
 }
 
+#ifdef HAVE_STRUCT_TIMESPEC
+int
+Mono_Posix_FromTimespec (struct Mono_Posix_Timespec *from, struct timespec *to)
+{
+       _cnm_return_val_if_overflow (time_t, from->tv_sec, -1);
+       _cnm_return_val_if_overflow (gint64, from->tv_nsec, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->tv_sec  = from->tv_sec;
+       to->tv_nsec = from->tv_nsec;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_TIMESPEC */
+
+
+#ifdef HAVE_STRUCT_TIMESPEC
+int
+Mono_Posix_ToTimespec (struct timespec *from, struct Mono_Posix_Timespec *to)
+{
+       _cnm_return_val_if_overflow (gint64, from->tv_sec, -1);
+       _cnm_return_val_if_overflow (gint64, from->tv_nsec, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->tv_sec  = from->tv_sec;
+       to->tv_nsec = from->tv_nsec;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_TIMESPEC */
+
+
+#ifdef HAVE_STRUCT_TIMEVAL
 int
 Mono_Posix_FromTimeval (struct Mono_Posix_Timeval *from, struct timeval *to)
 {
@@ -6627,8 +7829,10 @@ Mono_Posix_FromTimeval (struct Mono_Posix_Timeval *from, struct timeval *to)
 
        return 0;
 }
+#endif /* ndef HAVE_STRUCT_TIMEVAL */
 
 
+#ifdef HAVE_STRUCT_TIMEVAL
 int
 Mono_Posix_ToTimeval (struct timeval *from, struct Mono_Posix_Timeval *to)
 {
@@ -6642,8 +7846,10 @@ Mono_Posix_ToTimeval (struct timeval *from, struct Mono_Posix_Timeval *to)
 
        return 0;
 }
+#endif /* ndef HAVE_STRUCT_TIMEVAL */
 
 
+#ifdef HAVE_STRUCT_TIMEZONE
 int
 Mono_Posix_FromTimezone (struct Mono_Posix_Timezone *from, struct timezone *to)
 {
@@ -6657,8 +7863,10 @@ Mono_Posix_FromTimezone (struct Mono_Posix_Timezone *from, struct timezone *to)
 
        return 0;
 }
+#endif /* ndef HAVE_STRUCT_TIMEZONE */
 
 
+#ifdef HAVE_STRUCT_TIMEZONE
 int
 Mono_Posix_ToTimezone (struct timezone *from, struct Mono_Posix_Timezone *to)
 {
@@ -6672,6 +7880,1367 @@ Mono_Posix_ToTimezone (struct timezone *from, struct Mono_Posix_Timezone *to)
 
        return 0;
 }
+#endif /* ndef HAVE_STRUCT_TIMEZONE */
+
+
+int Mono_Posix_FromUnixAddressFamily (int x, int *r)
+{
+       *r = 0;
+       if (x == Mono_Posix_UnixAddressFamily_AF_ALG)
+#ifdef AF_ALG
+               {*r = AF_ALG; return 0;}
+#else /* def AF_ALG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_ALG */
+       if (x == Mono_Posix_UnixAddressFamily_AF_APPLETALK)
+#ifdef AF_APPLETALK
+               {*r = AF_APPLETALK; return 0;}
+#else /* def AF_APPLETALK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_APPLETALK */
+       if (x == Mono_Posix_UnixAddressFamily_AF_ASH)
+#ifdef AF_ASH
+               {*r = AF_ASH; return 0;}
+#else /* def AF_ASH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_ASH */
+       if (x == Mono_Posix_UnixAddressFamily_AF_ATMPVC)
+#ifdef AF_ATMPVC
+               {*r = AF_ATMPVC; return 0;}
+#else /* def AF_ATMPVC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_ATMPVC */
+       if (x == Mono_Posix_UnixAddressFamily_AF_ATMSVC)
+#ifdef AF_ATMSVC
+               {*r = AF_ATMSVC; return 0;}
+#else /* def AF_ATMSVC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_ATMSVC */
+       if (x == Mono_Posix_UnixAddressFamily_AF_AX25)
+#ifdef AF_AX25
+               {*r = AF_AX25; return 0;}
+#else /* def AF_AX25 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_AX25 */
+       if (x == Mono_Posix_UnixAddressFamily_AF_BLUETOOTH)
+#ifdef AF_BLUETOOTH
+               {*r = AF_BLUETOOTH; return 0;}
+#else /* def AF_BLUETOOTH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_BLUETOOTH */
+       if (x == Mono_Posix_UnixAddressFamily_AF_BRIDGE)
+#ifdef AF_BRIDGE
+               {*r = AF_BRIDGE; return 0;}
+#else /* def AF_BRIDGE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_BRIDGE */
+       if (x == Mono_Posix_UnixAddressFamily_AF_CAIF)
+#ifdef AF_CAIF
+               {*r = AF_CAIF; return 0;}
+#else /* def AF_CAIF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_CAIF */
+       if (x == Mono_Posix_UnixAddressFamily_AF_CAN)
+#ifdef AF_CAN
+               {*r = AF_CAN; return 0;}
+#else /* def AF_CAN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_CAN */
+       if (x == Mono_Posix_UnixAddressFamily_AF_DECnet)
+#ifdef AF_DECnet
+               {*r = AF_DECnet; return 0;}
+#else /* def AF_DECnet */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_DECnet */
+       if (x == Mono_Posix_UnixAddressFamily_AF_ECONET)
+#ifdef AF_ECONET
+               {*r = AF_ECONET; return 0;}
+#else /* def AF_ECONET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_ECONET */
+       if (x == Mono_Posix_UnixAddressFamily_AF_IEEE802154)
+#ifdef AF_IEEE802154
+               {*r = AF_IEEE802154; return 0;}
+#else /* def AF_IEEE802154 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_IEEE802154 */
+       if (x == Mono_Posix_UnixAddressFamily_AF_INET)
+#ifdef AF_INET
+               {*r = AF_INET; return 0;}
+#else /* def AF_INET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_INET */
+       if (x == Mono_Posix_UnixAddressFamily_AF_INET6)
+#ifdef AF_INET6
+               {*r = AF_INET6; return 0;}
+#else /* def AF_INET6 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_INET6 */
+       if (x == Mono_Posix_UnixAddressFamily_AF_IPX)
+#ifdef AF_IPX
+               {*r = AF_IPX; return 0;}
+#else /* def AF_IPX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_IPX */
+       if (x == Mono_Posix_UnixAddressFamily_AF_IRDA)
+#ifdef AF_IRDA
+               {*r = AF_IRDA; return 0;}
+#else /* def AF_IRDA */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_IRDA */
+       if (x == Mono_Posix_UnixAddressFamily_AF_ISDN)
+#ifdef AF_ISDN
+               {*r = AF_ISDN; return 0;}
+#else /* def AF_ISDN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_ISDN */
+       if (x == Mono_Posix_UnixAddressFamily_AF_IUCV)
+#ifdef AF_IUCV
+               {*r = AF_IUCV; return 0;}
+#else /* def AF_IUCV */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_IUCV */
+       if (x == Mono_Posix_UnixAddressFamily_AF_KEY)
+#ifdef AF_KEY
+               {*r = AF_KEY; return 0;}
+#else /* def AF_KEY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_KEY */
+       if (x == Mono_Posix_UnixAddressFamily_AF_LLC)
+#ifdef AF_LLC
+               {*r = AF_LLC; return 0;}
+#else /* def AF_LLC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_LLC */
+       if (x == Mono_Posix_UnixAddressFamily_AF_NETBEUI)
+#ifdef AF_NETBEUI
+               {*r = AF_NETBEUI; return 0;}
+#else /* def AF_NETBEUI */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_NETBEUI */
+       if (x == Mono_Posix_UnixAddressFamily_AF_NETLINK)
+#ifdef AF_NETLINK
+               {*r = AF_NETLINK; return 0;}
+#else /* def AF_NETLINK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_NETLINK */
+       if (x == Mono_Posix_UnixAddressFamily_AF_NETROM)
+#ifdef AF_NETROM
+               {*r = AF_NETROM; return 0;}
+#else /* def AF_NETROM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_NETROM */
+       if (x == Mono_Posix_UnixAddressFamily_AF_NFC)
+#ifdef AF_NFC
+               {*r = AF_NFC; return 0;}
+#else /* def AF_NFC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_NFC */
+       if (x == Mono_Posix_UnixAddressFamily_AF_PACKET)
+#ifdef AF_PACKET
+               {*r = AF_PACKET; return 0;}
+#else /* def AF_PACKET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_PACKET */
+       if (x == Mono_Posix_UnixAddressFamily_AF_PHONET)
+#ifdef AF_PHONET
+               {*r = AF_PHONET; return 0;}
+#else /* def AF_PHONET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_PHONET */
+       if (x == Mono_Posix_UnixAddressFamily_AF_PPPOX)
+#ifdef AF_PPPOX
+               {*r = AF_PPPOX; return 0;}
+#else /* def AF_PPPOX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_PPPOX */
+       if (x == Mono_Posix_UnixAddressFamily_AF_RDS)
+#ifdef AF_RDS
+               {*r = AF_RDS; return 0;}
+#else /* def AF_RDS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_RDS */
+       if (x == Mono_Posix_UnixAddressFamily_AF_ROSE)
+#ifdef AF_ROSE
+               {*r = AF_ROSE; return 0;}
+#else /* def AF_ROSE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_ROSE */
+       if (x == Mono_Posix_UnixAddressFamily_AF_RXRPC)
+#ifdef AF_RXRPC
+               {*r = AF_RXRPC; return 0;}
+#else /* def AF_RXRPC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_RXRPC */
+       if (x == Mono_Posix_UnixAddressFamily_AF_SECURITY)
+#ifdef AF_SECURITY
+               {*r = AF_SECURITY; return 0;}
+#else /* def AF_SECURITY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_SECURITY */
+       if (x == Mono_Posix_UnixAddressFamily_AF_SNA)
+#ifdef AF_SNA
+               {*r = AF_SNA; return 0;}
+#else /* def AF_SNA */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_SNA */
+       if (x == Mono_Posix_UnixAddressFamily_AF_TIPC)
+#ifdef AF_TIPC
+               {*r = AF_TIPC; return 0;}
+#else /* def AF_TIPC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_TIPC */
+       if (x == Mono_Posix_UnixAddressFamily_AF_UNIX)
+#ifdef AF_UNIX
+               {*r = AF_UNIX; return 0;}
+#else /* def AF_UNIX */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_UNIX */
+       if (x == Mono_Posix_UnixAddressFamily_AF_UNSPEC)
+#ifdef AF_UNSPEC
+               {*r = AF_UNSPEC; return 0;}
+#else /* def AF_UNSPEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_UNSPEC */
+       if (x == Mono_Posix_UnixAddressFamily_AF_VSOCK)
+#ifdef AF_VSOCK
+               {*r = AF_VSOCK; return 0;}
+#else /* def AF_VSOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_VSOCK */
+       if (x == Mono_Posix_UnixAddressFamily_AF_WANPIPE)
+#ifdef AF_WANPIPE
+               {*r = AF_WANPIPE; return 0;}
+#else /* def AF_WANPIPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_WANPIPE */
+       if (x == Mono_Posix_UnixAddressFamily_AF_X25)
+#ifdef AF_X25
+               {*r = AF_X25; return 0;}
+#else /* def AF_X25 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef AF_X25 */
+       if (x == Mono_Posix_UnixAddressFamily_Unknown)
+#ifdef Unknown
+               {*r = Unknown; return 0;}
+#else /* def Unknown */
+               {errno = EINVAL; return -1;}
+#endif /* ndef Unknown */
+       if (x == 0)
+               return 0;
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixAddressFamily (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef AF_ALG
+       if (x == AF_ALG)
+               {*r = Mono_Posix_UnixAddressFamily_AF_ALG; return 0;}
+#endif /* ndef AF_ALG */
+#ifdef AF_APPLETALK
+       if (x == AF_APPLETALK)
+               {*r = Mono_Posix_UnixAddressFamily_AF_APPLETALK; return 0;}
+#endif /* ndef AF_APPLETALK */
+#ifdef AF_ASH
+       if (x == AF_ASH)
+               {*r = Mono_Posix_UnixAddressFamily_AF_ASH; return 0;}
+#endif /* ndef AF_ASH */
+#ifdef AF_ATMPVC
+       if (x == AF_ATMPVC)
+               {*r = Mono_Posix_UnixAddressFamily_AF_ATMPVC; return 0;}
+#endif /* ndef AF_ATMPVC */
+#ifdef AF_ATMSVC
+       if (x == AF_ATMSVC)
+               {*r = Mono_Posix_UnixAddressFamily_AF_ATMSVC; return 0;}
+#endif /* ndef AF_ATMSVC */
+#ifdef AF_AX25
+       if (x == AF_AX25)
+               {*r = Mono_Posix_UnixAddressFamily_AF_AX25; return 0;}
+#endif /* ndef AF_AX25 */
+#ifdef AF_BLUETOOTH
+       if (x == AF_BLUETOOTH)
+               {*r = Mono_Posix_UnixAddressFamily_AF_BLUETOOTH; return 0;}
+#endif /* ndef AF_BLUETOOTH */
+#ifdef AF_BRIDGE
+       if (x == AF_BRIDGE)
+               {*r = Mono_Posix_UnixAddressFamily_AF_BRIDGE; return 0;}
+#endif /* ndef AF_BRIDGE */
+#ifdef AF_CAIF
+       if (x == AF_CAIF)
+               {*r = Mono_Posix_UnixAddressFamily_AF_CAIF; return 0;}
+#endif /* ndef AF_CAIF */
+#ifdef AF_CAN
+       if (x == AF_CAN)
+               {*r = Mono_Posix_UnixAddressFamily_AF_CAN; return 0;}
+#endif /* ndef AF_CAN */
+#ifdef AF_DECnet
+       if (x == AF_DECnet)
+               {*r = Mono_Posix_UnixAddressFamily_AF_DECnet; return 0;}
+#endif /* ndef AF_DECnet */
+#ifdef AF_ECONET
+       if (x == AF_ECONET)
+               {*r = Mono_Posix_UnixAddressFamily_AF_ECONET; return 0;}
+#endif /* ndef AF_ECONET */
+#ifdef AF_IEEE802154
+       if (x == AF_IEEE802154)
+               {*r = Mono_Posix_UnixAddressFamily_AF_IEEE802154; return 0;}
+#endif /* ndef AF_IEEE802154 */
+#ifdef AF_INET
+       if (x == AF_INET)
+               {*r = Mono_Posix_UnixAddressFamily_AF_INET; return 0;}
+#endif /* ndef AF_INET */
+#ifdef AF_INET6
+       if (x == AF_INET6)
+               {*r = Mono_Posix_UnixAddressFamily_AF_INET6; return 0;}
+#endif /* ndef AF_INET6 */
+#ifdef AF_IPX
+       if (x == AF_IPX)
+               {*r = Mono_Posix_UnixAddressFamily_AF_IPX; return 0;}
+#endif /* ndef AF_IPX */
+#ifdef AF_IRDA
+       if (x == AF_IRDA)
+               {*r = Mono_Posix_UnixAddressFamily_AF_IRDA; return 0;}
+#endif /* ndef AF_IRDA */
+#ifdef AF_ISDN
+       if (x == AF_ISDN)
+               {*r = Mono_Posix_UnixAddressFamily_AF_ISDN; return 0;}
+#endif /* ndef AF_ISDN */
+#ifdef AF_IUCV
+       if (x == AF_IUCV)
+               {*r = Mono_Posix_UnixAddressFamily_AF_IUCV; return 0;}
+#endif /* ndef AF_IUCV */
+#ifdef AF_KEY
+       if (x == AF_KEY)
+               {*r = Mono_Posix_UnixAddressFamily_AF_KEY; return 0;}
+#endif /* ndef AF_KEY */
+#ifdef AF_LLC
+       if (x == AF_LLC)
+               {*r = Mono_Posix_UnixAddressFamily_AF_LLC; return 0;}
+#endif /* ndef AF_LLC */
+#ifdef AF_NETBEUI
+       if (x == AF_NETBEUI)
+               {*r = Mono_Posix_UnixAddressFamily_AF_NETBEUI; return 0;}
+#endif /* ndef AF_NETBEUI */
+#ifdef AF_NETLINK
+       if (x == AF_NETLINK)
+               {*r = Mono_Posix_UnixAddressFamily_AF_NETLINK; return 0;}
+#endif /* ndef AF_NETLINK */
+#ifdef AF_NETROM
+       if (x == AF_NETROM)
+               {*r = Mono_Posix_UnixAddressFamily_AF_NETROM; return 0;}
+#endif /* ndef AF_NETROM */
+#ifdef AF_NFC
+       if (x == AF_NFC)
+               {*r = Mono_Posix_UnixAddressFamily_AF_NFC; return 0;}
+#endif /* ndef AF_NFC */
+#ifdef AF_PACKET
+       if (x == AF_PACKET)
+               {*r = Mono_Posix_UnixAddressFamily_AF_PACKET; return 0;}
+#endif /* ndef AF_PACKET */
+#ifdef AF_PHONET
+       if (x == AF_PHONET)
+               {*r = Mono_Posix_UnixAddressFamily_AF_PHONET; return 0;}
+#endif /* ndef AF_PHONET */
+#ifdef AF_PPPOX
+       if (x == AF_PPPOX)
+               {*r = Mono_Posix_UnixAddressFamily_AF_PPPOX; return 0;}
+#endif /* ndef AF_PPPOX */
+#ifdef AF_RDS
+       if (x == AF_RDS)
+               {*r = Mono_Posix_UnixAddressFamily_AF_RDS; return 0;}
+#endif /* ndef AF_RDS */
+#ifdef AF_ROSE
+       if (x == AF_ROSE)
+               {*r = Mono_Posix_UnixAddressFamily_AF_ROSE; return 0;}
+#endif /* ndef AF_ROSE */
+#ifdef AF_RXRPC
+       if (x == AF_RXRPC)
+               {*r = Mono_Posix_UnixAddressFamily_AF_RXRPC; return 0;}
+#endif /* ndef AF_RXRPC */
+#ifdef AF_SECURITY
+       if (x == AF_SECURITY)
+               {*r = Mono_Posix_UnixAddressFamily_AF_SECURITY; return 0;}
+#endif /* ndef AF_SECURITY */
+#ifdef AF_SNA
+       if (x == AF_SNA)
+               {*r = Mono_Posix_UnixAddressFamily_AF_SNA; return 0;}
+#endif /* ndef AF_SNA */
+#ifdef AF_TIPC
+       if (x == AF_TIPC)
+               {*r = Mono_Posix_UnixAddressFamily_AF_TIPC; return 0;}
+#endif /* ndef AF_TIPC */
+#ifdef AF_UNIX
+       if (x == AF_UNIX)
+               {*r = Mono_Posix_UnixAddressFamily_AF_UNIX; return 0;}
+#endif /* ndef AF_UNIX */
+#ifdef AF_UNSPEC
+       if (x == AF_UNSPEC)
+               {*r = Mono_Posix_UnixAddressFamily_AF_UNSPEC; return 0;}
+#endif /* ndef AF_UNSPEC */
+#ifdef AF_VSOCK
+       if (x == AF_VSOCK)
+               {*r = Mono_Posix_UnixAddressFamily_AF_VSOCK; return 0;}
+#endif /* ndef AF_VSOCK */
+#ifdef AF_WANPIPE
+       if (x == AF_WANPIPE)
+               {*r = Mono_Posix_UnixAddressFamily_AF_WANPIPE; return 0;}
+#endif /* ndef AF_WANPIPE */
+#ifdef AF_X25
+       if (x == AF_X25)
+               {*r = Mono_Posix_UnixAddressFamily_AF_X25; return 0;}
+#endif /* ndef AF_X25 */
+#ifdef Unknown
+       if (x == Unknown)
+               {*r = Mono_Posix_UnixAddressFamily_Unknown; return 0;}
+#endif /* ndef Unknown */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromUnixSocketControlMessage (int x, int *r)
+{
+       *r = 0;
+       if (x == Mono_Posix_UnixSocketControlMessage_SCM_CREDENTIALS)
+#ifdef SCM_CREDENTIALS
+               {*r = SCM_CREDENTIALS; return 0;}
+#else /* def SCM_CREDENTIALS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SCM_CREDENTIALS */
+       if (x == Mono_Posix_UnixSocketControlMessage_SCM_RIGHTS)
+#ifdef SCM_RIGHTS
+               {*r = SCM_RIGHTS; return 0;}
+#else /* def SCM_RIGHTS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SCM_RIGHTS */
+       if (x == 0)
+               return 0;
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixSocketControlMessage (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef SCM_CREDENTIALS
+       if (x == SCM_CREDENTIALS)
+               {*r = Mono_Posix_UnixSocketControlMessage_SCM_CREDENTIALS; return 0;}
+#endif /* ndef SCM_CREDENTIALS */
+#ifdef SCM_RIGHTS
+       if (x == SCM_RIGHTS)
+               {*r = Mono_Posix_UnixSocketControlMessage_SCM_RIGHTS; return 0;}
+#endif /* ndef SCM_RIGHTS */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromUnixSocketFlags (int x, int *r)
+{
+       *r = 0;
+       if ((x & Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC) == Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC)
+#ifdef SOCK_CLOEXEC
+               *r |= SOCK_CLOEXEC;
+#else /* def SOCK_CLOEXEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_CLOEXEC */
+       if ((x & Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK) == Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK)
+#ifdef SOCK_NONBLOCK
+               *r |= SOCK_NONBLOCK;
+#else /* def SOCK_NONBLOCK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_NONBLOCK */
+       if (x == 0)
+               return 0;
+       return 0;
+}
+
+int Mono_Posix_ToUnixSocketFlags (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef SOCK_CLOEXEC
+       if ((x & SOCK_CLOEXEC) == SOCK_CLOEXEC)
+               *r |= Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC;
+#endif /* ndef SOCK_CLOEXEC */
+#ifdef SOCK_NONBLOCK
+       if ((x & SOCK_NONBLOCK) == SOCK_NONBLOCK)
+               *r |= Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK;
+#endif /* ndef SOCK_NONBLOCK */
+       return 0;
+}
+
+int Mono_Posix_FromUnixSocketOptionName (int x, int *r)
+{
+       *r = 0;
+       if (x == Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN)
+#ifdef SO_ACCEPTCONN
+               {*r = SO_ACCEPTCONN; return 0;}
+#else /* def SO_ACCEPTCONN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_ACCEPTCONN */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER)
+#ifdef SO_ATTACH_FILTER
+               {*r = SO_ATTACH_FILTER; return 0;}
+#else /* def SO_ATTACH_FILTER */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_ATTACH_FILTER */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE)
+#ifdef SO_BINDTODEVICE
+               {*r = SO_BINDTODEVICE; return 0;}
+#else /* def SO_BINDTODEVICE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_BINDTODEVICE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_BROADCAST)
+#ifdef SO_BROADCAST
+               {*r = SO_BROADCAST; return 0;}
+#else /* def SO_BROADCAST */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_BROADCAST */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT)
+#ifdef SO_BSDCOMPAT
+               {*r = SO_BSDCOMPAT; return 0;}
+#else /* def SO_BSDCOMPAT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_BSDCOMPAT */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL)
+#ifdef SO_BUSY_POLL
+               {*r = SO_BUSY_POLL; return 0;}
+#else /* def SO_BUSY_POLL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_BUSY_POLL */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_DEBUG)
+#ifdef SO_DEBUG
+               {*r = SO_DEBUG; return 0;}
+#else /* def SO_DEBUG */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_DEBUG */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER)
+#ifdef SO_DETACH_FILTER
+               {*r = SO_DETACH_FILTER; return 0;}
+#else /* def SO_DETACH_FILTER */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_DETACH_FILTER */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_DOMAIN)
+#ifdef SO_DOMAIN
+               {*r = SO_DOMAIN; return 0;}
+#else /* def SO_DOMAIN */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_DOMAIN */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_DONTROUTE)
+#ifdef SO_DONTROUTE
+               {*r = SO_DONTROUTE; return 0;}
+#else /* def SO_DONTROUTE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_DONTROUTE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_ERROR)
+#ifdef SO_ERROR
+               {*r = SO_ERROR; return 0;}
+#else /* def SO_ERROR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_ERROR */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE)
+#ifdef SO_KEEPALIVE
+               {*r = SO_KEEPALIVE; return 0;}
+#else /* def SO_KEEPALIVE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_KEEPALIVE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_LINGER)
+#ifdef SO_LINGER
+               {*r = SO_LINGER; return 0;}
+#else /* def SO_LINGER */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_LINGER */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER)
+#ifdef SO_LOCK_FILTER
+               {*r = SO_LOCK_FILTER; return 0;}
+#else /* def SO_LOCK_FILTER */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_LOCK_FILTER */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_MARK)
+#ifdef SO_MARK
+               {*r = SO_MARK; return 0;}
+#else /* def SO_MARK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_MARK */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE)
+#ifdef SO_MAX_PACING_RATE
+               {*r = SO_MAX_PACING_RATE; return 0;}
+#else /* def SO_MAX_PACING_RATE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_MAX_PACING_RATE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_NOFCS)
+#ifdef SO_NOFCS
+               {*r = SO_NOFCS; return 0;}
+#else /* def SO_NOFCS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_NOFCS */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_NO_CHECK)
+#ifdef SO_NO_CHECK
+               {*r = SO_NO_CHECK; return 0;}
+#else /* def SO_NO_CHECK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_NO_CHECK */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_OOBINLINE)
+#ifdef SO_OOBINLINE
+               {*r = SO_OOBINLINE; return 0;}
+#else /* def SO_OOBINLINE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_OOBINLINE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_PASSCRED)
+#ifdef SO_PASSCRED
+               {*r = SO_PASSCRED; return 0;}
+#else /* def SO_PASSCRED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_PASSCRED */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_PASSSEC)
+#ifdef SO_PASSSEC
+               {*r = SO_PASSSEC; return 0;}
+#else /* def SO_PASSSEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_PASSSEC */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF)
+#ifdef SO_PEEK_OFF
+               {*r = SO_PEEK_OFF; return 0;}
+#else /* def SO_PEEK_OFF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_PEEK_OFF */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_PEERCRED)
+#ifdef SO_PEERCRED
+               {*r = SO_PEERCRED; return 0;}
+#else /* def SO_PEERCRED */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_PEERCRED */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_PEERNAME)
+#ifdef SO_PEERNAME
+               {*r = SO_PEERNAME; return 0;}
+#else /* def SO_PEERNAME */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_PEERNAME */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_PEERSEC)
+#ifdef SO_PEERSEC
+               {*r = SO_PEERSEC; return 0;}
+#else /* def SO_PEERSEC */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_PEERSEC */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_PRIORITY)
+#ifdef SO_PRIORITY
+               {*r = SO_PRIORITY; return 0;}
+#else /* def SO_PRIORITY */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_PRIORITY */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_PROTOCOL)
+#ifdef SO_PROTOCOL
+               {*r = SO_PROTOCOL; return 0;}
+#else /* def SO_PROTOCOL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_PROTOCOL */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_RCVBUF)
+#ifdef SO_RCVBUF
+               {*r = SO_RCVBUF; return 0;}
+#else /* def SO_RCVBUF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_RCVBUF */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE)
+#ifdef SO_RCVBUFFORCE
+               {*r = SO_RCVBUFFORCE; return 0;}
+#else /* def SO_RCVBUFFORCE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_RCVBUFFORCE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT)
+#ifdef SO_RCVLOWAT
+               {*r = SO_RCVLOWAT; return 0;}
+#else /* def SO_RCVLOWAT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_RCVLOWAT */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO)
+#ifdef SO_RCVTIMEO
+               {*r = SO_RCVTIMEO; return 0;}
+#else /* def SO_RCVTIMEO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_RCVTIMEO */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_REUSEADDR)
+#ifdef SO_REUSEADDR
+               {*r = SO_REUSEADDR; return 0;}
+#else /* def SO_REUSEADDR */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_REUSEADDR */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_REUSEPORT)
+#ifdef SO_REUSEPORT
+               {*r = SO_REUSEPORT; return 0;}
+#else /* def SO_REUSEPORT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_REUSEPORT */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL)
+#ifdef SO_RXQ_OVFL
+               {*r = SO_RXQ_OVFL; return 0;}
+#else /* def SO_RXQ_OVFL */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_RXQ_OVFL */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION)
+#ifdef SO_SECURITY_AUTHENTICATION
+               {*r = SO_SECURITY_AUTHENTICATION; return 0;}
+#else /* def SO_SECURITY_AUTHENTICATION */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_SECURITY_AUTHENTICATION */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK)
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+               {*r = SO_SECURITY_ENCRYPTION_NETWORK; return 0;}
+#else /* def SO_SECURITY_ENCRYPTION_NETWORK */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_SECURITY_ENCRYPTION_NETWORK */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT)
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+               {*r = SO_SECURITY_ENCRYPTION_TRANSPORT; return 0;}
+#else /* def SO_SECURITY_ENCRYPTION_TRANSPORT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_SECURITY_ENCRYPTION_TRANSPORT */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE)
+#ifdef SO_SELECT_ERR_QUEUE
+               {*r = SO_SELECT_ERR_QUEUE; return 0;}
+#else /* def SO_SELECT_ERR_QUEUE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_SELECT_ERR_QUEUE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_SNDBUF)
+#ifdef SO_SNDBUF
+               {*r = SO_SNDBUF; return 0;}
+#else /* def SO_SNDBUF */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_SNDBUF */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE)
+#ifdef SO_SNDBUFFORCE
+               {*r = SO_SNDBUFFORCE; return 0;}
+#else /* def SO_SNDBUFFORCE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_SNDBUFFORCE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT)
+#ifdef SO_SNDLOWAT
+               {*r = SO_SNDLOWAT; return 0;}
+#else /* def SO_SNDLOWAT */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_SNDLOWAT */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO)
+#ifdef SO_SNDTIMEO
+               {*r = SO_SNDTIMEO; return 0;}
+#else /* def SO_SNDTIMEO */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_SNDTIMEO */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP)
+#ifdef SO_TIMESTAMP
+               {*r = SO_TIMESTAMP; return 0;}
+#else /* def SO_TIMESTAMP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_TIMESTAMP */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING)
+#ifdef SO_TIMESTAMPING
+               {*r = SO_TIMESTAMPING; return 0;}
+#else /* def SO_TIMESTAMPING */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_TIMESTAMPING */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS)
+#ifdef SO_TIMESTAMPNS
+               {*r = SO_TIMESTAMPNS; return 0;}
+#else /* def SO_TIMESTAMPNS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_TIMESTAMPNS */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_TYPE)
+#ifdef SO_TYPE
+               {*r = SO_TYPE; return 0;}
+#else /* def SO_TYPE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_TYPE */
+       if (x == Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS)
+#ifdef SO_WIFI_STATUS
+               {*r = SO_WIFI_STATUS; return 0;}
+#else /* def SO_WIFI_STATUS */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SO_WIFI_STATUS */
+       if (x == 0)
+               return 0;
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixSocketOptionName (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef SO_ACCEPTCONN
+       if (x == SO_ACCEPTCONN)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN; return 0;}
+#endif /* ndef SO_ACCEPTCONN */
+#ifdef SO_ATTACH_FILTER
+       if (x == SO_ATTACH_FILTER)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER; return 0;}
+#endif /* ndef SO_ATTACH_FILTER */
+#ifdef SO_BINDTODEVICE
+       if (x == SO_BINDTODEVICE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE; return 0;}
+#endif /* ndef SO_BINDTODEVICE */
+#ifdef SO_BROADCAST
+       if (x == SO_BROADCAST)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_BROADCAST; return 0;}
+#endif /* ndef SO_BROADCAST */
+#ifdef SO_BSDCOMPAT
+       if (x == SO_BSDCOMPAT)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT; return 0;}
+#endif /* ndef SO_BSDCOMPAT */
+#ifdef SO_BUSY_POLL
+       if (x == SO_BUSY_POLL)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL; return 0;}
+#endif /* ndef SO_BUSY_POLL */
+#ifdef SO_DEBUG
+       if (x == SO_DEBUG)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_DEBUG; return 0;}
+#endif /* ndef SO_DEBUG */
+#ifdef SO_DETACH_FILTER
+       if (x == SO_DETACH_FILTER)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER; return 0;}
+#endif /* ndef SO_DETACH_FILTER */
+#ifdef SO_DOMAIN
+       if (x == SO_DOMAIN)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_DOMAIN; return 0;}
+#endif /* ndef SO_DOMAIN */
+#ifdef SO_DONTROUTE
+       if (x == SO_DONTROUTE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_DONTROUTE; return 0;}
+#endif /* ndef SO_DONTROUTE */
+#ifdef SO_ERROR
+       if (x == SO_ERROR)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_ERROR; return 0;}
+#endif /* ndef SO_ERROR */
+#ifdef SO_KEEPALIVE
+       if (x == SO_KEEPALIVE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE; return 0;}
+#endif /* ndef SO_KEEPALIVE */
+#ifdef SO_LINGER
+       if (x == SO_LINGER)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_LINGER; return 0;}
+#endif /* ndef SO_LINGER */
+#ifdef SO_LOCK_FILTER
+       if (x == SO_LOCK_FILTER)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER; return 0;}
+#endif /* ndef SO_LOCK_FILTER */
+#ifdef SO_MARK
+       if (x == SO_MARK)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_MARK; return 0;}
+#endif /* ndef SO_MARK */
+#ifdef SO_MAX_PACING_RATE
+       if (x == SO_MAX_PACING_RATE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE; return 0;}
+#endif /* ndef SO_MAX_PACING_RATE */
+#ifdef SO_NOFCS
+       if (x == SO_NOFCS)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_NOFCS; return 0;}
+#endif /* ndef SO_NOFCS */
+#ifdef SO_NO_CHECK
+       if (x == SO_NO_CHECK)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_NO_CHECK; return 0;}
+#endif /* ndef SO_NO_CHECK */
+#ifdef SO_OOBINLINE
+       if (x == SO_OOBINLINE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_OOBINLINE; return 0;}
+#endif /* ndef SO_OOBINLINE */
+#ifdef SO_PASSCRED
+       if (x == SO_PASSCRED)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_PASSCRED; return 0;}
+#endif /* ndef SO_PASSCRED */
+#ifdef SO_PASSSEC
+       if (x == SO_PASSSEC)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_PASSSEC; return 0;}
+#endif /* ndef SO_PASSSEC */
+#ifdef SO_PEEK_OFF
+       if (x == SO_PEEK_OFF)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF; return 0;}
+#endif /* ndef SO_PEEK_OFF */
+#ifdef SO_PEERCRED
+       if (x == SO_PEERCRED)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_PEERCRED; return 0;}
+#endif /* ndef SO_PEERCRED */
+#ifdef SO_PEERNAME
+       if (x == SO_PEERNAME)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_PEERNAME; return 0;}
+#endif /* ndef SO_PEERNAME */
+#ifdef SO_PEERSEC
+       if (x == SO_PEERSEC)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_PEERSEC; return 0;}
+#endif /* ndef SO_PEERSEC */
+#ifdef SO_PRIORITY
+       if (x == SO_PRIORITY)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_PRIORITY; return 0;}
+#endif /* ndef SO_PRIORITY */
+#ifdef SO_PROTOCOL
+       if (x == SO_PROTOCOL)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_PROTOCOL; return 0;}
+#endif /* ndef SO_PROTOCOL */
+#ifdef SO_RCVBUF
+       if (x == SO_RCVBUF)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_RCVBUF; return 0;}
+#endif /* ndef SO_RCVBUF */
+#ifdef SO_RCVBUFFORCE
+       if (x == SO_RCVBUFFORCE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE; return 0;}
+#endif /* ndef SO_RCVBUFFORCE */
+#ifdef SO_RCVLOWAT
+       if (x == SO_RCVLOWAT)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT; return 0;}
+#endif /* ndef SO_RCVLOWAT */
+#ifdef SO_RCVTIMEO
+       if (x == SO_RCVTIMEO)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO; return 0;}
+#endif /* ndef SO_RCVTIMEO */
+#ifdef SO_REUSEADDR
+       if (x == SO_REUSEADDR)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_REUSEADDR; return 0;}
+#endif /* ndef SO_REUSEADDR */
+#ifdef SO_REUSEPORT
+       if (x == SO_REUSEPORT)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_REUSEPORT; return 0;}
+#endif /* ndef SO_REUSEPORT */
+#ifdef SO_RXQ_OVFL
+       if (x == SO_RXQ_OVFL)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL; return 0;}
+#endif /* ndef SO_RXQ_OVFL */
+#ifdef SO_SECURITY_AUTHENTICATION
+       if (x == SO_SECURITY_AUTHENTICATION)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION; return 0;}
+#endif /* ndef SO_SECURITY_AUTHENTICATION */
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+       if (x == SO_SECURITY_ENCRYPTION_NETWORK)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK; return 0;}
+#endif /* ndef SO_SECURITY_ENCRYPTION_NETWORK */
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+       if (x == SO_SECURITY_ENCRYPTION_TRANSPORT)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT; return 0;}
+#endif /* ndef SO_SECURITY_ENCRYPTION_TRANSPORT */
+#ifdef SO_SELECT_ERR_QUEUE
+       if (x == SO_SELECT_ERR_QUEUE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE; return 0;}
+#endif /* ndef SO_SELECT_ERR_QUEUE */
+#ifdef SO_SNDBUF
+       if (x == SO_SNDBUF)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_SNDBUF; return 0;}
+#endif /* ndef SO_SNDBUF */
+#ifdef SO_SNDBUFFORCE
+       if (x == SO_SNDBUFFORCE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE; return 0;}
+#endif /* ndef SO_SNDBUFFORCE */
+#ifdef SO_SNDLOWAT
+       if (x == SO_SNDLOWAT)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT; return 0;}
+#endif /* ndef SO_SNDLOWAT */
+#ifdef SO_SNDTIMEO
+       if (x == SO_SNDTIMEO)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO; return 0;}
+#endif /* ndef SO_SNDTIMEO */
+#ifdef SO_TIMESTAMP
+       if (x == SO_TIMESTAMP)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP; return 0;}
+#endif /* ndef SO_TIMESTAMP */
+#ifdef SO_TIMESTAMPING
+       if (x == SO_TIMESTAMPING)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING; return 0;}
+#endif /* ndef SO_TIMESTAMPING */
+#ifdef SO_TIMESTAMPNS
+       if (x == SO_TIMESTAMPNS)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS; return 0;}
+#endif /* ndef SO_TIMESTAMPNS */
+#ifdef SO_TYPE
+       if (x == SO_TYPE)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_TYPE; return 0;}
+#endif /* ndef SO_TYPE */
+#ifdef SO_WIFI_STATUS
+       if (x == SO_WIFI_STATUS)
+               {*r = Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS; return 0;}
+#endif /* ndef SO_WIFI_STATUS */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromUnixSocketProtocol (int x, int *r)
+{
+       *r = 0;
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_AH)
+#ifdef IPPROTO_AH
+               {*r = IPPROTO_AH; return 0;}
+#else /* def IPPROTO_AH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_AH */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH)
+#ifdef IPPROTO_BEETPH
+               {*r = IPPROTO_BEETPH; return 0;}
+#else /* def IPPROTO_BEETPH */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_BEETPH */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_COMP)
+#ifdef IPPROTO_COMP
+               {*r = IPPROTO_COMP; return 0;}
+#else /* def IPPROTO_COMP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_COMP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP)
+#ifdef IPPROTO_DCCP
+               {*r = IPPROTO_DCCP; return 0;}
+#else /* def IPPROTO_DCCP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_DCCP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_EGP)
+#ifdef IPPROTO_EGP
+               {*r = IPPROTO_EGP; return 0;}
+#else /* def IPPROTO_EGP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_EGP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP)
+#ifdef IPPROTO_ENCAP
+               {*r = IPPROTO_ENCAP; return 0;}
+#else /* def IPPROTO_ENCAP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_ENCAP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ESP)
+#ifdef IPPROTO_ESP
+               {*r = IPPROTO_ESP; return 0;}
+#else /* def IPPROTO_ESP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_ESP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_GRE)
+#ifdef IPPROTO_GRE
+               {*r = IPPROTO_GRE; return 0;}
+#else /* def IPPROTO_GRE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_GRE */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP)
+#ifdef IPPROTO_ICMP
+               {*r = IPPROTO_ICMP; return 0;}
+#else /* def IPPROTO_ICMP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_ICMP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IDP)
+#ifdef IPPROTO_IDP
+               {*r = IPPROTO_IDP; return 0;}
+#else /* def IPPROTO_IDP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IDP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP)
+#ifdef IPPROTO_IGMP
+               {*r = IPPROTO_IGMP; return 0;}
+#else /* def IPPROTO_IGMP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IGMP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IP)
+#ifdef IPPROTO_IP
+               {*r = IPPROTO_IP; return 0;}
+#else /* def IPPROTO_IP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP)
+#ifdef IPPROTO_IPIP
+               {*r = IPPROTO_IPIP; return 0;}
+#else /* def IPPROTO_IPIP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IPIP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6)
+#ifdef IPPROTO_IPV6
+               {*r = IPPROTO_IPV6; return 0;}
+#else /* def IPPROTO_IPV6 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IPV6 */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_MTP)
+#ifdef IPPROTO_MTP
+               {*r = IPPROTO_MTP; return 0;}
+#else /* def IPPROTO_MTP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_MTP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_PIM)
+#ifdef IPPROTO_PIM
+               {*r = IPPROTO_PIM; return 0;}
+#else /* def IPPROTO_PIM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_PIM */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_PUP)
+#ifdef IPPROTO_PUP
+               {*r = IPPROTO_PUP; return 0;}
+#else /* def IPPROTO_PUP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_PUP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_RAW)
+#ifdef IPPROTO_RAW
+               {*r = IPPROTO_RAW; return 0;}
+#else /* def IPPROTO_RAW */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_RAW */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP)
+#ifdef IPPROTO_RSVP
+               {*r = IPPROTO_RSVP; return 0;}
+#else /* def IPPROTO_RSVP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_RSVP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP)
+#ifdef IPPROTO_SCTP
+               {*r = IPPROTO_SCTP; return 0;}
+#else /* def IPPROTO_SCTP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_SCTP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_TCP)
+#ifdef IPPROTO_TCP
+               {*r = IPPROTO_TCP; return 0;}
+#else /* def IPPROTO_TCP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_TCP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_TP)
+#ifdef IPPROTO_TP
+               {*r = IPPROTO_TP; return 0;}
+#else /* def IPPROTO_TP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_TP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_UDP)
+#ifdef IPPROTO_UDP
+               {*r = IPPROTO_UDP; return 0;}
+#else /* def IPPROTO_UDP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_UDP */
+       if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE)
+#ifdef IPPROTO_UDPLITE
+               {*r = IPPROTO_UDPLITE; return 0;}
+#else /* def IPPROTO_UDPLITE */
+               {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_UDPLITE */
+       if (x == Mono_Posix_UnixSocketProtocol_SOL_SOCKET)
+#ifdef SOL_SOCKET
+               {*r = SOL_SOCKET; return 0;}
+#else /* def SOL_SOCKET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOL_SOCKET */
+       if (x == 0)
+               return 0;
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixSocketProtocol (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef IPPROTO_AH
+       if (x == IPPROTO_AH)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_AH; return 0;}
+#endif /* ndef IPPROTO_AH */
+#ifdef IPPROTO_BEETPH
+       if (x == IPPROTO_BEETPH)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH; return 0;}
+#endif /* ndef IPPROTO_BEETPH */
+#ifdef IPPROTO_COMP
+       if (x == IPPROTO_COMP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_COMP; return 0;}
+#endif /* ndef IPPROTO_COMP */
+#ifdef IPPROTO_DCCP
+       if (x == IPPROTO_DCCP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP; return 0;}
+#endif /* ndef IPPROTO_DCCP */
+#ifdef IPPROTO_EGP
+       if (x == IPPROTO_EGP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_EGP; return 0;}
+#endif /* ndef IPPROTO_EGP */
+#ifdef IPPROTO_ENCAP
+       if (x == IPPROTO_ENCAP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP; return 0;}
+#endif /* ndef IPPROTO_ENCAP */
+#ifdef IPPROTO_ESP
+       if (x == IPPROTO_ESP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ESP; return 0;}
+#endif /* ndef IPPROTO_ESP */
+#ifdef IPPROTO_GRE
+       if (x == IPPROTO_GRE)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_GRE; return 0;}
+#endif /* ndef IPPROTO_GRE */
+#ifdef IPPROTO_ICMP
+       if (x == IPPROTO_ICMP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP; return 0;}
+#endif /* ndef IPPROTO_ICMP */
+#ifdef IPPROTO_IDP
+       if (x == IPPROTO_IDP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IDP; return 0;}
+#endif /* ndef IPPROTO_IDP */
+#ifdef IPPROTO_IGMP
+       if (x == IPPROTO_IGMP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP; return 0;}
+#endif /* ndef IPPROTO_IGMP */
+#ifdef IPPROTO_IP
+       if (x == IPPROTO_IP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IP; return 0;}
+#endif /* ndef IPPROTO_IP */
+#ifdef IPPROTO_IPIP
+       if (x == IPPROTO_IPIP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP; return 0;}
+#endif /* ndef IPPROTO_IPIP */
+#ifdef IPPROTO_IPV6
+       if (x == IPPROTO_IPV6)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6; return 0;}
+#endif /* ndef IPPROTO_IPV6 */
+#ifdef IPPROTO_MTP
+       if (x == IPPROTO_MTP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_MTP; return 0;}
+#endif /* ndef IPPROTO_MTP */
+#ifdef IPPROTO_PIM
+       if (x == IPPROTO_PIM)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_PIM; return 0;}
+#endif /* ndef IPPROTO_PIM */
+#ifdef IPPROTO_PUP
+       if (x == IPPROTO_PUP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_PUP; return 0;}
+#endif /* ndef IPPROTO_PUP */
+#ifdef IPPROTO_RAW
+       if (x == IPPROTO_RAW)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_RAW; return 0;}
+#endif /* ndef IPPROTO_RAW */
+#ifdef IPPROTO_RSVP
+       if (x == IPPROTO_RSVP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP; return 0;}
+#endif /* ndef IPPROTO_RSVP */
+#ifdef IPPROTO_SCTP
+       if (x == IPPROTO_SCTP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP; return 0;}
+#endif /* ndef IPPROTO_SCTP */
+#ifdef IPPROTO_TCP
+       if (x == IPPROTO_TCP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_TCP; return 0;}
+#endif /* ndef IPPROTO_TCP */
+#ifdef IPPROTO_TP
+       if (x == IPPROTO_TP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_TP; return 0;}
+#endif /* ndef IPPROTO_TP */
+#ifdef IPPROTO_UDP
+       if (x == IPPROTO_UDP)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_UDP; return 0;}
+#endif /* ndef IPPROTO_UDP */
+#ifdef IPPROTO_UDPLITE
+       if (x == IPPROTO_UDPLITE)
+               {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE; return 0;}
+#endif /* ndef IPPROTO_UDPLITE */
+#ifdef SOL_SOCKET
+       if (x == SOL_SOCKET)
+               {*r = Mono_Posix_UnixSocketProtocol_SOL_SOCKET; return 0;}
+#endif /* ndef SOL_SOCKET */
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromUnixSocketType (int x, int *r)
+{
+       *r = 0;
+       if (x == Mono_Posix_UnixSocketType_SOCK_DCCP)
+#ifdef SOCK_DCCP
+               {*r = SOCK_DCCP; return 0;}
+#else /* def SOCK_DCCP */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_DCCP */
+       if (x == Mono_Posix_UnixSocketType_SOCK_DGRAM)
+#ifdef SOCK_DGRAM
+               {*r = SOCK_DGRAM; return 0;}
+#else /* def SOCK_DGRAM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_DGRAM */
+       if (x == Mono_Posix_UnixSocketType_SOCK_PACKET)
+#ifdef SOCK_PACKET
+               {*r = SOCK_PACKET; return 0;}
+#else /* def SOCK_PACKET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_PACKET */
+       if (x == Mono_Posix_UnixSocketType_SOCK_RAW)
+#ifdef SOCK_RAW
+               {*r = SOCK_RAW; return 0;}
+#else /* def SOCK_RAW */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_RAW */
+       if (x == Mono_Posix_UnixSocketType_SOCK_RDM)
+#ifdef SOCK_RDM
+               {*r = SOCK_RDM; return 0;}
+#else /* def SOCK_RDM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_RDM */
+       if (x == Mono_Posix_UnixSocketType_SOCK_SEQPACKET)
+#ifdef SOCK_SEQPACKET
+               {*r = SOCK_SEQPACKET; return 0;}
+#else /* def SOCK_SEQPACKET */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_SEQPACKET */
+       if (x == Mono_Posix_UnixSocketType_SOCK_STREAM)
+#ifdef SOCK_STREAM
+               {*r = SOCK_STREAM; return 0;}
+#else /* def SOCK_STREAM */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_STREAM */
+       if (x == 0)
+               return 0;
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixSocketType (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef SOCK_DCCP
+       if (x == SOCK_DCCP)
+               {*r = Mono_Posix_UnixSocketType_SOCK_DCCP; return 0;}
+#endif /* ndef SOCK_DCCP */
+#ifdef SOCK_DGRAM
+       if (x == SOCK_DGRAM)
+               {*r = Mono_Posix_UnixSocketType_SOCK_DGRAM; return 0;}
+#endif /* ndef SOCK_DGRAM */
+#ifdef SOCK_PACKET
+       if (x == SOCK_PACKET)
+               {*r = Mono_Posix_UnixSocketType_SOCK_PACKET; return 0;}
+#endif /* ndef SOCK_PACKET */
+#ifdef SOCK_RAW
+       if (x == SOCK_RAW)
+               {*r = Mono_Posix_UnixSocketType_SOCK_RAW; return 0;}
+#endif /* ndef SOCK_RAW */
+#ifdef SOCK_RDM
+       if (x == SOCK_RDM)
+               {*r = Mono_Posix_UnixSocketType_SOCK_RDM; return 0;}
+#endif /* ndef SOCK_RDM */
+#ifdef SOCK_SEQPACKET
+       if (x == SOCK_SEQPACKET)
+               {*r = Mono_Posix_UnixSocketType_SOCK_SEQPACKET; return 0;}
+#endif /* ndef SOCK_SEQPACKET */
+#ifdef SOCK_STREAM
+       if (x == SOCK_STREAM)
+               {*r = Mono_Posix_UnixSocketType_SOCK_STREAM; return 0;}
+#endif /* ndef SOCK_STREAM */
+       errno = EINVAL; return -1;
+}
+
+#ifdef HAVE_STRUCT_UTIMBUF
+int
+Mono_Posix_FromUtimbuf (struct Mono_Posix_Utimbuf *from, struct utimbuf *to)
+{
+       _cnm_return_val_if_overflow (time_t, from->actime, -1);
+       _cnm_return_val_if_overflow (time_t, from->modtime, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->actime  = from->actime;
+       to->modtime = from->modtime;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_UTIMBUF */
+
+
+#ifdef HAVE_STRUCT_UTIMBUF
+int
+Mono_Posix_ToUtimbuf (struct utimbuf *from, struct Mono_Posix_Utimbuf *to)
+{
+       _cnm_return_val_if_overflow (gint64, from->actime, -1);
+       _cnm_return_val_if_overflow (gint64, from->modtime, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->actime  = from->actime;
+       to->modtime = from->modtime;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_UTIMBUF */
 
 
 int Mono_Posix_FromWaitOptions (int x, int *r)
@@ -6755,4 +9324,3 @@ int Mono_Posix_ToXattrFlags (int x, int *r)
 #endif /* ndef XATTR_REPLACE */
        return 0;
 }
-