- if ((x & Mono_Posix_FilePermissions_S_ISUID) == Mono_Posix_FilePermissions_S_ISUID)
-#ifdef S_ISUID
- *r |= S_ISUID;
-#else /* def S_ISUID */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_ISUID */
- if ((x & Mono_Posix_FilePermissions_S_ISGID) == Mono_Posix_FilePermissions_S_ISGID)
-#ifdef S_ISGID
- *r |= S_ISGID;
-#else /* def S_ISGID */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_ISGID */
- if ((x & Mono_Posix_FilePermissions_S_ISVTX) == Mono_Posix_FilePermissions_S_ISVTX)
-#ifdef S_ISVTX
- *r |= S_ISVTX;
-#else /* def S_ISVTX */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_ISVTX */
- if ((x & Mono_Posix_FilePermissions_S_IRUSR) == Mono_Posix_FilePermissions_S_IRUSR)
-#ifdef S_IRUSR
- *r |= S_IRUSR;
-#else /* def S_IRUSR */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IRUSR */
- if ((x & Mono_Posix_FilePermissions_S_IWUSR) == Mono_Posix_FilePermissions_S_IWUSR)
-#ifdef S_IWUSR
- *r |= S_IWUSR;
-#else /* def S_IWUSR */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IWUSR */
- if ((x & Mono_Posix_FilePermissions_S_IXUSR) == Mono_Posix_FilePermissions_S_IXUSR)
-#ifdef S_IXUSR
- *r |= S_IXUSR;
-#else /* def S_IXUSR */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IXUSR */
- if ((x & Mono_Posix_FilePermissions_S_IRGRP) == Mono_Posix_FilePermissions_S_IRGRP)
-#ifdef S_IRGRP
- *r |= S_IRGRP;
-#else /* def S_IRGRP */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IRGRP */
- if ((x & Mono_Posix_FilePermissions_S_IWGRP) == Mono_Posix_FilePermissions_S_IWGRP)
-#ifdef S_IWGRP
- *r |= S_IWGRP;
-#else /* def S_IWGRP */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IWGRP */
- if ((x & Mono_Posix_FilePermissions_S_IXGRP) == Mono_Posix_FilePermissions_S_IXGRP)
-#ifdef S_IXGRP
- *r |= S_IXGRP;
-#else /* def S_IXGRP */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IXGRP */
- if ((x & Mono_Posix_FilePermissions_S_IROTH) == Mono_Posix_FilePermissions_S_IROTH)
-#ifdef S_IROTH
- *r |= S_IROTH;
-#else /* def S_IROTH */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IROTH */
- if ((x & Mono_Posix_FilePermissions_S_IWOTH) == Mono_Posix_FilePermissions_S_IWOTH)
-#ifdef S_IWOTH
- *r |= S_IWOTH;
-#else /* def S_IWOTH */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IWOTH */
- if ((x & Mono_Posix_FilePermissions_S_IXOTH) == Mono_Posix_FilePermissions_S_IXOTH)
-#ifdef S_IXOTH
- *r |= S_IXOTH;
-#else /* def S_IXOTH */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IXOTH */
- if ((x & Mono_Posix_FilePermissions_S_IRWXG) == Mono_Posix_FilePermissions_S_IRWXG)
-#ifdef S_IRWXG
- *r |= S_IRWXG;
-#else /* def S_IRWXG */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IRWXG */
- if ((x & Mono_Posix_FilePermissions_S_IRWXU) == Mono_Posix_FilePermissions_S_IRWXU)
-#ifdef S_IRWXU
- *r |= S_IRWXU;
-#else /* def S_IRWXU */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IRWXU */
- if ((x & Mono_Posix_FilePermissions_S_IRWXO) == Mono_Posix_FilePermissions_S_IRWXO)
-#ifdef S_IRWXO
- *r |= S_IRWXO;
-#else /* def S_IRWXO */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IRWXO */
- if ((x & Mono_Posix_FilePermissions_ACCESSPERMS) == Mono_Posix_FilePermissions_ACCESSPERMS)
-#ifdef ACCESSPERMS
- *r |= ACCESSPERMS;
-#else /* def ACCESSPERMS */
- {errno = EINVAL; return -1;}
-#endif /* ndef ACCESSPERMS */
- if ((x & Mono_Posix_FilePermissions_ALLPERMS) == Mono_Posix_FilePermissions_ALLPERMS)
-#ifdef ALLPERMS
- *r |= ALLPERMS;
-#else /* def ALLPERMS */
- {errno = EINVAL; return -1;}
-#endif /* ndef ALLPERMS */
- if ((x & Mono_Posix_FilePermissions_DEFFILEMODE) == Mono_Posix_FilePermissions_DEFFILEMODE)
-#ifdef DEFFILEMODE
- *r |= DEFFILEMODE;
-#else /* def DEFFILEMODE */
- {errno = EINVAL; return -1;}
-#endif /* ndef DEFFILEMODE */
- if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFMT)
-#ifdef S_IFMT
- *r |= S_IFMT;
-#else /* def S_IFMT */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IFMT */
- if ((x & Mono_Posix_FilePermissions_S_IFDIR) == Mono_Posix_FilePermissions_S_IFDIR)
-#ifdef S_IFDIR
- *r |= S_IFDIR;
-#else /* def S_IFDIR */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IFDIR */
- if ((x & Mono_Posix_FilePermissions_S_IFCHR) == Mono_Posix_FilePermissions_S_IFCHR)
-#ifdef S_IFCHR
- *r |= S_IFCHR;
-#else /* def S_IFCHR */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IFCHR */
- if ((x & Mono_Posix_FilePermissions_S_IFBLK) == Mono_Posix_FilePermissions_S_IFBLK)
-#ifdef S_IFBLK
- *r |= S_IFBLK;
-#else /* def S_IFBLK */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IFBLK */
- if ((x & Mono_Posix_FilePermissions_S_IFREG) == Mono_Posix_FilePermissions_S_IFREG)
-#ifdef S_IFREG
- *r |= S_IFREG;
-#else /* def S_IFREG */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IFREG */
- if ((x & Mono_Posix_FilePermissions_S_IFIFO) == Mono_Posix_FilePermissions_S_IFIFO)
-#ifdef S_IFIFO
- *r |= S_IFIFO;
-#else /* def S_IFIFO */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IFIFO */
- if ((x & Mono_Posix_FilePermissions_S_IFLNK) == Mono_Posix_FilePermissions_S_IFLNK)
-#ifdef S_IFLNK
- *r |= S_IFLNK;
-#else /* def S_IFLNK */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IFLNK */
- if ((x & Mono_Posix_FilePermissions_S_IFSOCK) == Mono_Posix_FilePermissions_S_IFSOCK)
-#ifdef S_IFSOCK
- *r |= S_IFSOCK;
-#else /* def S_IFSOCK */
- {errno = EINVAL; return -1;}
-#endif /* ndef S_IFSOCK */
- return 0;
-}
-
-int Mono_Posix_ToFilePermissions (unsigned int x, unsigned int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef S_ISUID
- if ((x & S_ISUID) == S_ISUID)
- *r |= Mono_Posix_FilePermissions_S_ISUID;
-#endif /* ndef S_ISUID */
-#ifdef S_ISGID
- if ((x & S_ISGID) == S_ISGID)
- *r |= Mono_Posix_FilePermissions_S_ISGID;
-#endif /* ndef S_ISGID */
-#ifdef S_ISVTX
- if ((x & S_ISVTX) == S_ISVTX)
- *r |= Mono_Posix_FilePermissions_S_ISVTX;
-#endif /* ndef S_ISVTX */
-#ifdef S_IRUSR
- if ((x & S_IRUSR) == S_IRUSR)
- *r |= Mono_Posix_FilePermissions_S_IRUSR;
-#endif /* ndef S_IRUSR */
-#ifdef S_IWUSR
- if ((x & S_IWUSR) == S_IWUSR)
- *r |= Mono_Posix_FilePermissions_S_IWUSR;
-#endif /* ndef S_IWUSR */
-#ifdef S_IXUSR
- if ((x & S_IXUSR) == S_IXUSR)
- *r |= Mono_Posix_FilePermissions_S_IXUSR;
-#endif /* ndef S_IXUSR */
-#ifdef S_IRGRP
- if ((x & S_IRGRP) == S_IRGRP)
- *r |= Mono_Posix_FilePermissions_S_IRGRP;
-#endif /* ndef S_IRGRP */
-#ifdef S_IWGRP
- if ((x & S_IWGRP) == S_IWGRP)
- *r |= Mono_Posix_FilePermissions_S_IWGRP;
-#endif /* ndef S_IWGRP */
-#ifdef S_IXGRP
- if ((x & S_IXGRP) == S_IXGRP)
- *r |= Mono_Posix_FilePermissions_S_IXGRP;
-#endif /* ndef S_IXGRP */
-#ifdef S_IROTH
- if ((x & S_IROTH) == S_IROTH)
- *r |= Mono_Posix_FilePermissions_S_IROTH;
-#endif /* ndef S_IROTH */
-#ifdef S_IWOTH
- if ((x & S_IWOTH) == S_IWOTH)
- *r |= Mono_Posix_FilePermissions_S_IWOTH;
-#endif /* ndef S_IWOTH */
-#ifdef S_IXOTH
- if ((x & S_IXOTH) == S_IXOTH)
- *r |= Mono_Posix_FilePermissions_S_IXOTH;
-#endif /* ndef S_IXOTH */
-#ifdef S_IRWXG
- if ((x & S_IRWXG) == S_IRWXG)
- *r |= Mono_Posix_FilePermissions_S_IRWXG;
-#endif /* ndef S_IRWXG */
-#ifdef S_IRWXU
- if ((x & S_IRWXU) == S_IRWXU)
- *r |= Mono_Posix_FilePermissions_S_IRWXU;
-#endif /* ndef S_IRWXU */
-#ifdef S_IRWXO
- if ((x & S_IRWXO) == S_IRWXO)
- *r |= Mono_Posix_FilePermissions_S_IRWXO;
-#endif /* ndef S_IRWXO */
-#ifdef ACCESSPERMS
- if ((x & ACCESSPERMS) == ACCESSPERMS)
- *r |= Mono_Posix_FilePermissions_ACCESSPERMS;
-#endif /* ndef ACCESSPERMS */
-#ifdef ALLPERMS
- if ((x & ALLPERMS) == ALLPERMS)
- *r |= Mono_Posix_FilePermissions_ALLPERMS;
-#endif /* ndef ALLPERMS */
-#ifdef DEFFILEMODE
- if ((x & DEFFILEMODE) == DEFFILEMODE)
- *r |= Mono_Posix_FilePermissions_DEFFILEMODE;
-#endif /* ndef DEFFILEMODE */
-#ifdef S_IFMT
- if ((x & S_IFMT) == S_IFMT)
- *r |= Mono_Posix_FilePermissions_S_IFMT;
-#endif /* ndef S_IFMT */
-#ifdef S_IFDIR
- if ((x & S_IFDIR) == S_IFDIR)
- *r |= Mono_Posix_FilePermissions_S_IFDIR;
-#endif /* ndef S_IFDIR */
-#ifdef S_IFCHR
- if ((x & S_IFCHR) == S_IFCHR)
- *r |= Mono_Posix_FilePermissions_S_IFCHR;
-#endif /* ndef S_IFCHR */
-#ifdef S_IFBLK
- if ((x & S_IFBLK) == S_IFBLK)
- *r |= Mono_Posix_FilePermissions_S_IFBLK;
-#endif /* ndef S_IFBLK */
-#ifdef S_IFREG
- if ((x & S_IFREG) == S_IFREG)
- *r |= Mono_Posix_FilePermissions_S_IFREG;
-#endif /* ndef S_IFREG */
-#ifdef S_IFIFO
- if ((x & S_IFIFO) == S_IFIFO)
- *r |= Mono_Posix_FilePermissions_S_IFIFO;
-#endif /* ndef S_IFIFO */
-#ifdef S_IFLNK
- if ((x & S_IFLNK) == S_IFLNK)
- *r |= Mono_Posix_FilePermissions_S_IFLNK;
-#endif /* ndef S_IFLNK */
-#ifdef S_IFSOCK
- if ((x & S_IFSOCK) == S_IFSOCK)
- *r |= Mono_Posix_FilePermissions_S_IFSOCK;
-#endif /* ndef S_IFSOCK */
- return 0;
-}
-
-int Mono_Posix_FromFcntlCommand (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if (x == Mono_Posix_FcntlCommand_F_DUPFD)
-#ifdef F_DUPFD
- {*r = F_DUPFD; return 0;}
-#else /* def F_DUPFD */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_DUPFD */
- if (x == Mono_Posix_FcntlCommand_F_GETFD)
-#ifdef F_GETFD
- {*r = F_GETFD; return 0;}
-#else /* def F_GETFD */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_GETFD */
- if (x == Mono_Posix_FcntlCommand_F_SETFD)
-#ifdef F_SETFD
- {*r = F_SETFD; return 0;}
-#else /* def F_SETFD */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_SETFD */
- if (x == Mono_Posix_FcntlCommand_F_GETFL)
-#ifdef F_GETFL
- {*r = F_GETFL; return 0;}
-#else /* def F_GETFL */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_GETFL */
- if (x == Mono_Posix_FcntlCommand_F_SETFL)
-#ifdef F_SETFL
- {*r = F_SETFL; return 0;}
-#else /* def F_SETFL */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_SETFL */
- if (x == Mono_Posix_FcntlCommand_F_GETLK)
-#ifdef F_GETLK
- {*r = F_GETLK; return 0;}
-#else /* def F_GETLK */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_GETLK */
- if (x == Mono_Posix_FcntlCommand_F_SETLK)
-#ifdef F_SETLK
- {*r = F_SETLK; return 0;}
-#else /* def F_SETLK */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_SETLK */
- if (x == Mono_Posix_FcntlCommand_F_SETLKW)
-#ifdef F_SETLKW
- {*r = F_SETLKW; return 0;}
-#else /* def F_SETLKW */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_SETLKW */
- if (x == Mono_Posix_FcntlCommand_F_SETOWN)
-#ifdef F_SETOWN
- {*r = F_SETOWN; return 0;}
-#else /* def F_SETOWN */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_SETOWN */
- if (x == Mono_Posix_FcntlCommand_F_GETOWN)
-#ifdef F_GETOWN
- {*r = F_GETOWN; return 0;}
-#else /* def F_GETOWN */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_GETOWN */
- if (x == Mono_Posix_FcntlCommand_F_SETSIG)
-#ifdef F_SETSIG
- {*r = F_SETSIG; return 0;}
-#else /* def F_SETSIG */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_SETSIG */
- if (x == Mono_Posix_FcntlCommand_F_GETSIG)
-#ifdef F_GETSIG
- {*r = F_GETSIG; return 0;}
-#else /* def F_GETSIG */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_GETSIG */
- if (x == Mono_Posix_FcntlCommand_F_SETLEASE)
-#ifdef F_SETLEASE
- {*r = F_SETLEASE; return 0;}
-#else /* def F_SETLEASE */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_SETLEASE */
- if (x == Mono_Posix_FcntlCommand_F_GETLEASE)
-#ifdef F_GETLEASE
- {*r = F_GETLEASE; return 0;}
-#else /* def F_GETLEASE */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_GETLEASE */
- if (x == Mono_Posix_FcntlCommand_F_NOTIFY)
-#ifdef F_NOTIFY
- {*r = F_NOTIFY; return 0;}
-#else /* def F_NOTIFY */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_NOTIFY */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_ToFcntlCommand (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef F_DUPFD
- if (x == F_DUPFD)
- {*r = Mono_Posix_FcntlCommand_F_DUPFD; return 0;}
-#endif /* ndef F_DUPFD */
-#ifdef F_GETFD
- if (x == F_GETFD)
- {*r = Mono_Posix_FcntlCommand_F_GETFD; return 0;}
-#endif /* ndef F_GETFD */
-#ifdef F_SETFD
- if (x == F_SETFD)
- {*r = Mono_Posix_FcntlCommand_F_SETFD; return 0;}
-#endif /* ndef F_SETFD */
-#ifdef F_GETFL
- if (x == F_GETFL)
- {*r = Mono_Posix_FcntlCommand_F_GETFL; return 0;}
-#endif /* ndef F_GETFL */
-#ifdef F_SETFL
- if (x == F_SETFL)
- {*r = Mono_Posix_FcntlCommand_F_SETFL; return 0;}
-#endif /* ndef F_SETFL */
-#ifdef F_GETLK
- if (x == F_GETLK)
- {*r = Mono_Posix_FcntlCommand_F_GETLK; return 0;}
-#endif /* ndef F_GETLK */
-#ifdef F_SETLK
- if (x == F_SETLK)
- {*r = Mono_Posix_FcntlCommand_F_SETLK; return 0;}
-#endif /* ndef F_SETLK */
-#ifdef F_SETLKW
- if (x == F_SETLKW)
- {*r = Mono_Posix_FcntlCommand_F_SETLKW; return 0;}
-#endif /* ndef F_SETLKW */
-#ifdef F_SETOWN
- if (x == F_SETOWN)
- {*r = Mono_Posix_FcntlCommand_F_SETOWN; return 0;}
-#endif /* ndef F_SETOWN */
-#ifdef F_GETOWN
- if (x == F_GETOWN)
- {*r = Mono_Posix_FcntlCommand_F_GETOWN; return 0;}
-#endif /* ndef F_GETOWN */
-#ifdef F_SETSIG
- if (x == F_SETSIG)
- {*r = Mono_Posix_FcntlCommand_F_SETSIG; return 0;}
-#endif /* ndef F_SETSIG */
-#ifdef F_GETSIG
- if (x == F_GETSIG)
- {*r = Mono_Posix_FcntlCommand_F_GETSIG; return 0;}
-#endif /* ndef F_GETSIG */
-#ifdef F_SETLEASE
- if (x == F_SETLEASE)
- {*r = Mono_Posix_FcntlCommand_F_SETLEASE; return 0;}
-#endif /* ndef F_SETLEASE */
-#ifdef F_GETLEASE
- if (x == F_GETLEASE)
- {*r = Mono_Posix_FcntlCommand_F_GETLEASE; return 0;}
-#endif /* ndef F_GETLEASE */
-#ifdef F_NOTIFY
- if (x == F_NOTIFY)
- {*r = Mono_Posix_FcntlCommand_F_NOTIFY; return 0;}
-#endif /* ndef F_NOTIFY */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_FromLockType (short x, short *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if (x == Mono_Posix_LockType_F_RDLCK)
-#ifdef F_RDLCK
- {*r = F_RDLCK; return 0;}
-#else /* def F_RDLCK */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_RDLCK */
- if (x == Mono_Posix_LockType_F_WRLCK)
-#ifdef F_WRLCK
- {*r = F_WRLCK; return 0;}
-#else /* def F_WRLCK */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_WRLCK */
- if (x == Mono_Posix_LockType_F_UNLCK)
-#ifdef F_UNLCK
- {*r = F_UNLCK; return 0;}
-#else /* def F_UNLCK */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_UNLCK */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_ToLockType (short x, short *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef F_RDLCK
- if (x == F_RDLCK)
- {*r = Mono_Posix_LockType_F_RDLCK; return 0;}
-#endif /* ndef F_RDLCK */
-#ifdef F_WRLCK
- if (x == F_WRLCK)
- {*r = Mono_Posix_LockType_F_WRLCK; return 0;}
-#endif /* ndef F_WRLCK */
-#ifdef F_UNLCK
- if (x == F_UNLCK)
- {*r = Mono_Posix_LockType_F_UNLCK; return 0;}
-#endif /* ndef F_UNLCK */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_FromSeekFlags (short x, short *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if (x == Mono_Posix_SeekFlags_SEEK_SET)
-#ifdef SEEK_SET
- {*r = SEEK_SET; return 0;}
-#else /* def SEEK_SET */
- {errno = EINVAL; return -1;}
-#endif /* ndef SEEK_SET */
- if (x == Mono_Posix_SeekFlags_SEEK_CUR)
-#ifdef SEEK_CUR
- {*r = SEEK_CUR; return 0;}
-#else /* def SEEK_CUR */
- {errno = EINVAL; return -1;}
-#endif /* ndef SEEK_CUR */
- if (x == Mono_Posix_SeekFlags_SEEK_END)
-#ifdef SEEK_END
- {*r = SEEK_END; return 0;}
-#else /* def SEEK_END */
- {errno = EINVAL; return -1;}
-#endif /* ndef SEEK_END */
- if (x == Mono_Posix_SeekFlags_L_SET)
-#ifdef L_SET
- {*r = L_SET; return 0;}
-#else /* def L_SET */
- {errno = EINVAL; return -1;}
-#endif /* ndef L_SET */
- if (x == Mono_Posix_SeekFlags_L_INCR)
-#ifdef L_INCR
- {*r = L_INCR; return 0;}
-#else /* def L_INCR */
- {errno = EINVAL; return -1;}
-#endif /* ndef L_INCR */
- if (x == Mono_Posix_SeekFlags_L_XTND)
-#ifdef L_XTND
- {*r = L_XTND; return 0;}
-#else /* def L_XTND */
- {errno = EINVAL; return -1;}
-#endif /* ndef L_XTND */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_ToSeekFlags (short x, short *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef SEEK_SET
- if (x == SEEK_SET)
- {*r = Mono_Posix_SeekFlags_SEEK_SET; return 0;}
-#endif /* ndef SEEK_SET */
-#ifdef SEEK_CUR
- if (x == SEEK_CUR)
- {*r = Mono_Posix_SeekFlags_SEEK_CUR; return 0;}
-#endif /* ndef SEEK_CUR */
-#ifdef SEEK_END
- if (x == SEEK_END)
- {*r = Mono_Posix_SeekFlags_SEEK_END; return 0;}
-#endif /* ndef SEEK_END */
-#ifdef L_SET
- if (x == L_SET)
- {*r = Mono_Posix_SeekFlags_L_SET; return 0;}
-#endif /* ndef L_SET */
-#ifdef L_INCR
- if (x == L_INCR)
- {*r = Mono_Posix_SeekFlags_L_INCR; return 0;}
-#endif /* ndef L_INCR */
-#ifdef L_XTND
- if (x == L_XTND)
- {*r = Mono_Posix_SeekFlags_L_XTND; return 0;}
-#endif /* ndef L_XTND */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_FromDirectoryNotifyFlags (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if ((x & Mono_Posix_DirectoryNotifyFlags_DN_ACCESS) == Mono_Posix_DirectoryNotifyFlags_DN_ACCESS)
-#ifdef DN_ACCESS
- *r |= DN_ACCESS;
-#else /* def DN_ACCESS */
- {errno = EINVAL; return -1;}
-#endif /* ndef DN_ACCESS */
- if ((x & Mono_Posix_DirectoryNotifyFlags_DN_MODIFY) == Mono_Posix_DirectoryNotifyFlags_DN_MODIFY)
-#ifdef DN_MODIFY
- *r |= DN_MODIFY;
-#else /* def DN_MODIFY */
- {errno = EINVAL; return -1;}
-#endif /* ndef DN_MODIFY */
- if ((x & Mono_Posix_DirectoryNotifyFlags_DN_CREATE) == Mono_Posix_DirectoryNotifyFlags_DN_CREATE)
-#ifdef DN_CREATE
- *r |= DN_CREATE;
-#else /* def DN_CREATE */
- {errno = EINVAL; return -1;}
-#endif /* ndef DN_CREATE */
- if ((x & Mono_Posix_DirectoryNotifyFlags_DN_DELETE) == Mono_Posix_DirectoryNotifyFlags_DN_DELETE)
-#ifdef DN_DELETE
- *r |= DN_DELETE;
-#else /* def DN_DELETE */
- {errno = EINVAL; return -1;}
-#endif /* ndef DN_DELETE */
- if ((x & Mono_Posix_DirectoryNotifyFlags_DN_RENAME) == Mono_Posix_DirectoryNotifyFlags_DN_RENAME)
-#ifdef DN_RENAME
- *r |= DN_RENAME;
-#else /* def DN_RENAME */
- {errno = EINVAL; return -1;}
-#endif /* ndef DN_RENAME */
- if ((x & Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB) == Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB)
-#ifdef DN_ATTRIB
- *r |= DN_ATTRIB;
-#else /* def DN_ATTRIB */
- {errno = EINVAL; return -1;}
-#endif /* ndef DN_ATTRIB */
- if ((x & Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT) == Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT)
-#ifdef DN_MULTISHOT
- *r |= DN_MULTISHOT;
-#else /* def DN_MULTISHOT */
- {errno = EINVAL; return -1;}
-#endif /* ndef DN_MULTISHOT */
- return 0;
-}
-
-int Mono_Posix_ToDirectoryNotifyFlags (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef DN_ACCESS
- if ((x & DN_ACCESS) == DN_ACCESS)
- *r |= Mono_Posix_DirectoryNotifyFlags_DN_ACCESS;
-#endif /* ndef DN_ACCESS */
-#ifdef DN_MODIFY
- if ((x & DN_MODIFY) == DN_MODIFY)
- *r |= Mono_Posix_DirectoryNotifyFlags_DN_MODIFY;
-#endif /* ndef DN_MODIFY */
-#ifdef DN_CREATE
- if ((x & DN_CREATE) == DN_CREATE)
- *r |= Mono_Posix_DirectoryNotifyFlags_DN_CREATE;
-#endif /* ndef DN_CREATE */
-#ifdef DN_DELETE
- if ((x & DN_DELETE) == DN_DELETE)
- *r |= Mono_Posix_DirectoryNotifyFlags_DN_DELETE;
-#endif /* ndef DN_DELETE */
-#ifdef DN_RENAME
- if ((x & DN_RENAME) == DN_RENAME)
- *r |= Mono_Posix_DirectoryNotifyFlags_DN_RENAME;
-#endif /* ndef DN_RENAME */
-#ifdef DN_ATTRIB
- if ((x & DN_ATTRIB) == DN_ATTRIB)
- *r |= Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB;
-#endif /* ndef DN_ATTRIB */
-#ifdef DN_MULTISHOT
- if ((x & DN_MULTISHOT) == DN_MULTISHOT)
- *r |= Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT;
-#endif /* ndef DN_MULTISHOT */
- return 0;
-}
-
-int Mono_Posix_FromPosixFadviseAdvice (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NORMAL)
-#ifdef POSIX_FADV_NORMAL
- {*r = POSIX_FADV_NORMAL; return 0;}
-#else /* def POSIX_FADV_NORMAL */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_FADV_NORMAL */
- if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_RANDOM)
-#ifdef POSIX_FADV_RANDOM
- {*r = POSIX_FADV_RANDOM; return 0;}
-#else /* def POSIX_FADV_RANDOM */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_FADV_RANDOM */
- if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_SEQUENTIAL)
-#ifdef POSIX_FADV_SEQUENTIAL
- {*r = POSIX_FADV_SEQUENTIAL; return 0;}
-#else /* def POSIX_FADV_SEQUENTIAL */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_FADV_SEQUENTIAL */
- if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_WILLNEED)
-#ifdef POSIX_FADV_WILLNEED
- {*r = POSIX_FADV_WILLNEED; return 0;}
-#else /* def POSIX_FADV_WILLNEED */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_FADV_WILLNEED */
- if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_DONTNEED)
-#ifdef POSIX_FADV_DONTNEED
- {*r = POSIX_FADV_DONTNEED; return 0;}
-#else /* def POSIX_FADV_DONTNEED */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_FADV_DONTNEED */
- if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NOREUSE)
-#ifdef POSIX_FADV_NOREUSE
- {*r = POSIX_FADV_NOREUSE; return 0;}
-#else /* def POSIX_FADV_NOREUSE */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_FADV_NOREUSE */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_ToPosixFadviseAdvice (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef POSIX_FADV_NORMAL
- if (x == POSIX_FADV_NORMAL)
- {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NORMAL; return 0;}
-#endif /* ndef POSIX_FADV_NORMAL */
-#ifdef POSIX_FADV_RANDOM
- if (x == POSIX_FADV_RANDOM)
- {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_RANDOM; return 0;}
-#endif /* ndef POSIX_FADV_RANDOM */
-#ifdef POSIX_FADV_SEQUENTIAL
- if (x == POSIX_FADV_SEQUENTIAL)
- {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_SEQUENTIAL; return 0;}
-#endif /* ndef POSIX_FADV_SEQUENTIAL */
-#ifdef POSIX_FADV_WILLNEED
- if (x == POSIX_FADV_WILLNEED)
- {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_WILLNEED; return 0;}
-#endif /* ndef POSIX_FADV_WILLNEED */
-#ifdef POSIX_FADV_DONTNEED
- if (x == POSIX_FADV_DONTNEED)
- {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_DONTNEED; return 0;}
-#endif /* ndef POSIX_FADV_DONTNEED */
-#ifdef POSIX_FADV_NOREUSE
- if (x == POSIX_FADV_NOREUSE)
- {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NOREUSE; return 0;}
-#endif /* ndef POSIX_FADV_NOREUSE */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_FromPosixMadviseAdvice (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_NORMAL)
-#ifdef POSIX_MADV_NORMAL
- {*r = POSIX_MADV_NORMAL; return 0;}
-#else /* def POSIX_MADV_NORMAL */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_MADV_NORMAL */
- if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_RANDOM)
-#ifdef POSIX_MADV_RANDOM
- {*r = POSIX_MADV_RANDOM; return 0;}
-#else /* def POSIX_MADV_RANDOM */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_MADV_RANDOM */
- if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_SEQUENTIAL)
-#ifdef POSIX_MADV_SEQUENTIAL
- {*r = POSIX_MADV_SEQUENTIAL; return 0;}
-#else /* def POSIX_MADV_SEQUENTIAL */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_MADV_SEQUENTIAL */
- if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_WILLNEED)
-#ifdef POSIX_MADV_WILLNEED
- {*r = POSIX_MADV_WILLNEED; return 0;}
-#else /* def POSIX_MADV_WILLNEED */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_MADV_WILLNEED */
- if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_DONTNEED)
-#ifdef POSIX_MADV_DONTNEED
- {*r = POSIX_MADV_DONTNEED; return 0;}
-#else /* def POSIX_MADV_DONTNEED */
- {errno = EINVAL; return -1;}
-#endif /* ndef POSIX_MADV_DONTNEED */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_ToPosixMadviseAdvice (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef POSIX_MADV_NORMAL
- if (x == POSIX_MADV_NORMAL)
- {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_NORMAL; return 0;}
-#endif /* ndef POSIX_MADV_NORMAL */
-#ifdef POSIX_MADV_RANDOM
- if (x == POSIX_MADV_RANDOM)
- {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_RANDOM; return 0;}
-#endif /* ndef POSIX_MADV_RANDOM */
-#ifdef POSIX_MADV_SEQUENTIAL
- if (x == POSIX_MADV_SEQUENTIAL)
- {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_SEQUENTIAL; return 0;}
-#endif /* ndef POSIX_MADV_SEQUENTIAL */
-#ifdef POSIX_MADV_WILLNEED
- if (x == POSIX_MADV_WILLNEED)
- {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_WILLNEED; return 0;}
-#endif /* ndef POSIX_MADV_WILLNEED */
-#ifdef POSIX_MADV_DONTNEED
- if (x == POSIX_MADV_DONTNEED)
- {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_DONTNEED; return 0;}
-#endif /* ndef POSIX_MADV_DONTNEED */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_FromSignum (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if (x == Mono_Posix_Signum_SIGHUP)
-#ifdef SIGHUP
- {*r = SIGHUP; return 0;}
-#else /* def SIGHUP */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGHUP */
- if (x == Mono_Posix_Signum_SIGINT)
-#ifdef SIGINT
- {*r = SIGINT; return 0;}
-#else /* def SIGINT */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGINT */
- if (x == Mono_Posix_Signum_SIGQUIT)
-#ifdef SIGQUIT
- {*r = SIGQUIT; return 0;}
-#else /* def SIGQUIT */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGQUIT */
- if (x == Mono_Posix_Signum_SIGILL)
-#ifdef SIGILL
- {*r = SIGILL; return 0;}
-#else /* def SIGILL */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGILL */
- if (x == Mono_Posix_Signum_SIGTRAP)
-#ifdef SIGTRAP
- {*r = SIGTRAP; return 0;}
-#else /* def SIGTRAP */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGTRAP */
- if (x == Mono_Posix_Signum_SIGABRT)
-#ifdef SIGABRT
- {*r = SIGABRT; return 0;}
-#else /* def SIGABRT */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGABRT */
- if (x == Mono_Posix_Signum_SIGIOT)
-#ifdef SIGIOT
- {*r = SIGIOT; return 0;}
-#else /* def SIGIOT */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGIOT */
- if (x == Mono_Posix_Signum_SIGBUS)
-#ifdef SIGBUS
- {*r = SIGBUS; return 0;}
-#else /* def SIGBUS */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGBUS */
- if (x == Mono_Posix_Signum_SIGFPE)
-#ifdef SIGFPE
- {*r = SIGFPE; return 0;}
-#else /* def SIGFPE */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGFPE */
- if (x == Mono_Posix_Signum_SIGKILL)
-#ifdef SIGKILL
- {*r = SIGKILL; return 0;}
-#else /* def SIGKILL */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGKILL */
- if (x == Mono_Posix_Signum_SIGUSR1)
-#ifdef SIGUSR1
- {*r = SIGUSR1; return 0;}
-#else /* def SIGUSR1 */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGUSR1 */
- if (x == Mono_Posix_Signum_SIGSEGV)
-#ifdef SIGSEGV
- {*r = SIGSEGV; return 0;}
-#else /* def SIGSEGV */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGSEGV */
- if (x == Mono_Posix_Signum_SIGUSR2)
-#ifdef SIGUSR2
- {*r = SIGUSR2; return 0;}
-#else /* def SIGUSR2 */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGUSR2 */
- if (x == Mono_Posix_Signum_SIGPIPE)
-#ifdef SIGPIPE
- {*r = SIGPIPE; return 0;}
-#else /* def SIGPIPE */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGPIPE */
- if (x == Mono_Posix_Signum_SIGALRM)
-#ifdef SIGALRM
- {*r = SIGALRM; return 0;}
-#else /* def SIGALRM */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGALRM */
- if (x == Mono_Posix_Signum_SIGTERM)
-#ifdef SIGTERM
- {*r = SIGTERM; return 0;}
-#else /* def SIGTERM */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGTERM */
- if (x == Mono_Posix_Signum_SIGSTKFLT)
-#ifdef SIGSTKFLT
- {*r = SIGSTKFLT; return 0;}
-#else /* def SIGSTKFLT */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGSTKFLT */
- if (x == Mono_Posix_Signum_SIGCHLD)
-#ifdef SIGCHLD
- {*r = SIGCHLD; return 0;}
-#else /* def SIGCHLD */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGCHLD */
- if (x == Mono_Posix_Signum_SIGCLD)
-#ifdef SIGCLD
- {*r = SIGCLD; return 0;}
-#else /* def SIGCLD */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGCLD */
- if (x == Mono_Posix_Signum_SIGCONT)
-#ifdef SIGCONT
- {*r = SIGCONT; return 0;}
-#else /* def SIGCONT */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGCONT */
- if (x == Mono_Posix_Signum_SIGSTOP)
-#ifdef SIGSTOP
- {*r = SIGSTOP; return 0;}
-#else /* def SIGSTOP */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGSTOP */
- if (x == Mono_Posix_Signum_SIGTSTP)
-#ifdef SIGTSTP
- {*r = SIGTSTP; return 0;}
-#else /* def SIGTSTP */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGTSTP */
- if (x == Mono_Posix_Signum_SIGTTIN)
-#ifdef SIGTTIN
- {*r = SIGTTIN; return 0;}
-#else /* def SIGTTIN */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGTTIN */
- if (x == Mono_Posix_Signum_SIGTTOU)
-#ifdef SIGTTOU
- {*r = SIGTTOU; return 0;}
-#else /* def SIGTTOU */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGTTOU */
- if (x == Mono_Posix_Signum_SIGURG)
-#ifdef SIGURG
- {*r = SIGURG; return 0;}
-#else /* def SIGURG */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGURG */
- if (x == Mono_Posix_Signum_SIGXCPU)
-#ifdef SIGXCPU
- {*r = SIGXCPU; return 0;}
-#else /* def SIGXCPU */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGXCPU */
- if (x == Mono_Posix_Signum_SIGXFSZ)
-#ifdef SIGXFSZ
- {*r = SIGXFSZ; return 0;}
-#else /* def SIGXFSZ */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGXFSZ */
- if (x == Mono_Posix_Signum_SIGVTALRM)
-#ifdef SIGVTALRM
- {*r = SIGVTALRM; return 0;}
-#else /* def SIGVTALRM */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGVTALRM */
- if (x == Mono_Posix_Signum_SIGPROF)
-#ifdef SIGPROF
- {*r = SIGPROF; return 0;}
-#else /* def SIGPROF */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGPROF */
- if (x == Mono_Posix_Signum_SIGWINCH)
-#ifdef SIGWINCH
- {*r = SIGWINCH; return 0;}
-#else /* def SIGWINCH */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGWINCH */
- if (x == Mono_Posix_Signum_SIGIO)
-#ifdef SIGIO
- {*r = SIGIO; return 0;}
-#else /* def SIGIO */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGIO */
- if (x == Mono_Posix_Signum_SIGPOLL)
-#ifdef SIGPOLL
- {*r = SIGPOLL; return 0;}
-#else /* def SIGPOLL */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGPOLL */
- if (x == Mono_Posix_Signum_SIGPWR)
-#ifdef SIGPWR
- {*r = SIGPWR; return 0;}
-#else /* def SIGPWR */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGPWR */
- if (x == Mono_Posix_Signum_SIGSYS)
-#ifdef SIGSYS
- {*r = SIGSYS; return 0;}
-#else /* def SIGSYS */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGSYS */
- if (x == Mono_Posix_Signum_SIGUNUSED)
-#ifdef SIGUNUSED
- {*r = SIGUNUSED; return 0;}
-#else /* def SIGUNUSED */
- {errno = EINVAL; return -1;}
-#endif /* ndef SIGUNUSED */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_ToSignum (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef SIGHUP
- if (x == SIGHUP)
- {*r = Mono_Posix_Signum_SIGHUP; return 0;}
-#endif /* ndef SIGHUP */
-#ifdef SIGINT
- if (x == SIGINT)
- {*r = Mono_Posix_Signum_SIGINT; return 0;}
-#endif /* ndef SIGINT */
-#ifdef SIGQUIT
- if (x == SIGQUIT)
- {*r = Mono_Posix_Signum_SIGQUIT; return 0;}
-#endif /* ndef SIGQUIT */
-#ifdef SIGILL
- if (x == SIGILL)
- {*r = Mono_Posix_Signum_SIGILL; return 0;}
-#endif /* ndef SIGILL */
-#ifdef SIGTRAP
- if (x == SIGTRAP)
- {*r = Mono_Posix_Signum_SIGTRAP; return 0;}
-#endif /* ndef SIGTRAP */
-#ifdef SIGABRT
- if (x == SIGABRT)
- {*r = Mono_Posix_Signum_SIGABRT; return 0;}
-#endif /* ndef SIGABRT */
-#ifdef SIGIOT
- if (x == SIGIOT)
- {*r = Mono_Posix_Signum_SIGIOT; return 0;}
-#endif /* ndef SIGIOT */
-#ifdef SIGBUS
- if (x == SIGBUS)
- {*r = Mono_Posix_Signum_SIGBUS; return 0;}
-#endif /* ndef SIGBUS */
-#ifdef SIGFPE
- if (x == SIGFPE)
- {*r = Mono_Posix_Signum_SIGFPE; return 0;}
-#endif /* ndef SIGFPE */
-#ifdef SIGKILL
- if (x == SIGKILL)
- {*r = Mono_Posix_Signum_SIGKILL; return 0;}
-#endif /* ndef SIGKILL */
-#ifdef SIGUSR1
- if (x == SIGUSR1)
- {*r = Mono_Posix_Signum_SIGUSR1; return 0;}
-#endif /* ndef SIGUSR1 */
-#ifdef SIGSEGV
- if (x == SIGSEGV)
- {*r = Mono_Posix_Signum_SIGSEGV; return 0;}
-#endif /* ndef SIGSEGV */
-#ifdef SIGUSR2
- if (x == SIGUSR2)
- {*r = Mono_Posix_Signum_SIGUSR2; return 0;}
-#endif /* ndef SIGUSR2 */
-#ifdef SIGPIPE
- if (x == SIGPIPE)
- {*r = Mono_Posix_Signum_SIGPIPE; return 0;}
-#endif /* ndef SIGPIPE */
-#ifdef SIGALRM
- if (x == SIGALRM)
- {*r = Mono_Posix_Signum_SIGALRM; return 0;}
-#endif /* ndef SIGALRM */
-#ifdef SIGTERM
- if (x == SIGTERM)
- {*r = Mono_Posix_Signum_SIGTERM; return 0;}
-#endif /* ndef SIGTERM */
-#ifdef SIGSTKFLT
- if (x == SIGSTKFLT)
- {*r = Mono_Posix_Signum_SIGSTKFLT; return 0;}
-#endif /* ndef SIGSTKFLT */
-#ifdef SIGCHLD
- if (x == SIGCHLD)
- {*r = Mono_Posix_Signum_SIGCHLD; return 0;}
-#endif /* ndef SIGCHLD */
-#ifdef SIGCLD
- if (x == SIGCLD)
- {*r = Mono_Posix_Signum_SIGCLD; return 0;}
-#endif /* ndef SIGCLD */
-#ifdef SIGCONT
- if (x == SIGCONT)
- {*r = Mono_Posix_Signum_SIGCONT; return 0;}
-#endif /* ndef SIGCONT */
-#ifdef SIGSTOP
- if (x == SIGSTOP)
- {*r = Mono_Posix_Signum_SIGSTOP; return 0;}
-#endif /* ndef SIGSTOP */
-#ifdef SIGTSTP
- if (x == SIGTSTP)
- {*r = Mono_Posix_Signum_SIGTSTP; return 0;}
-#endif /* ndef SIGTSTP */
-#ifdef SIGTTIN
- if (x == SIGTTIN)
- {*r = Mono_Posix_Signum_SIGTTIN; return 0;}
-#endif /* ndef SIGTTIN */
-#ifdef SIGTTOU
- if (x == SIGTTOU)
- {*r = Mono_Posix_Signum_SIGTTOU; return 0;}
-#endif /* ndef SIGTTOU */
-#ifdef SIGURG
- if (x == SIGURG)
- {*r = Mono_Posix_Signum_SIGURG; return 0;}
-#endif /* ndef SIGURG */
-#ifdef SIGXCPU
- if (x == SIGXCPU)
- {*r = Mono_Posix_Signum_SIGXCPU; return 0;}
-#endif /* ndef SIGXCPU */
-#ifdef SIGXFSZ
- if (x == SIGXFSZ)
- {*r = Mono_Posix_Signum_SIGXFSZ; return 0;}
-#endif /* ndef SIGXFSZ */
-#ifdef SIGVTALRM
- if (x == SIGVTALRM)
- {*r = Mono_Posix_Signum_SIGVTALRM; return 0;}
-#endif /* ndef SIGVTALRM */
-#ifdef SIGPROF
- if (x == SIGPROF)
- {*r = Mono_Posix_Signum_SIGPROF; return 0;}
-#endif /* ndef SIGPROF */
-#ifdef SIGWINCH
- if (x == SIGWINCH)
- {*r = Mono_Posix_Signum_SIGWINCH; return 0;}
-#endif /* ndef SIGWINCH */
-#ifdef SIGIO
- if (x == SIGIO)
- {*r = Mono_Posix_Signum_SIGIO; return 0;}
-#endif /* ndef SIGIO */
-#ifdef SIGPOLL
- if (x == SIGPOLL)
- {*r = Mono_Posix_Signum_SIGPOLL; return 0;}
-#endif /* ndef SIGPOLL */
-#ifdef SIGPWR
- if (x == SIGPWR)
- {*r = Mono_Posix_Signum_SIGPWR; return 0;}
-#endif /* ndef SIGPWR */
-#ifdef SIGSYS
- if (x == SIGSYS)
- {*r = Mono_Posix_Signum_SIGSYS; return 0;}
-#endif /* ndef SIGSYS */
-#ifdef SIGUNUSED
- if (x == SIGUNUSED)
- {*r = Mono_Posix_Signum_SIGUNUSED; return 0;}
-#endif /* ndef SIGUNUSED */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_FromWaitOptions (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if ((x & Mono_Posix_WaitOptions_WNOHANG) == Mono_Posix_WaitOptions_WNOHANG)
-#ifdef WNOHANG
- *r |= WNOHANG;
-#else /* def WNOHANG */
- {errno = EINVAL; return -1;}
-#endif /* ndef WNOHANG */
- if ((x & Mono_Posix_WaitOptions_WUNTRACED) == Mono_Posix_WaitOptions_WUNTRACED)
-#ifdef WUNTRACED
- *r |= WUNTRACED;
-#else /* def WUNTRACED */
- {errno = EINVAL; return -1;}
-#endif /* ndef WUNTRACED */
- return 0;
-}
-
-int Mono_Posix_ToWaitOptions (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef WNOHANG
- if ((x & WNOHANG) == WNOHANG)
- *r |= Mono_Posix_WaitOptions_WNOHANG;
-#endif /* ndef WNOHANG */
-#ifdef WUNTRACED
- if ((x & WUNTRACED) == WUNTRACED)
- *r |= Mono_Posix_WaitOptions_WUNTRACED;
-#endif /* ndef WUNTRACED */
- return 0;
-}
-
-int Mono_Posix_FromAccessMode (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if ((x & Mono_Posix_AccessMode_R_OK) == Mono_Posix_AccessMode_R_OK)
-#ifdef R_OK
- *r |= R_OK;
-#else /* def R_OK */
- {errno = EINVAL; return -1;}
-#endif /* ndef R_OK */
- if ((x & Mono_Posix_AccessMode_W_OK) == Mono_Posix_AccessMode_W_OK)
-#ifdef W_OK
- *r |= W_OK;
-#else /* def W_OK */
- {errno = EINVAL; return -1;}
-#endif /* ndef W_OK */
- if ((x & Mono_Posix_AccessMode_X_OK) == Mono_Posix_AccessMode_X_OK)
-#ifdef X_OK
- *r |= X_OK;
-#else /* def X_OK */
- {errno = EINVAL; return -1;}
-#endif /* ndef X_OK */
- if ((x & Mono_Posix_AccessMode_F_OK) == Mono_Posix_AccessMode_F_OK)
-#ifdef F_OK
- *r |= F_OK;
-#else /* def F_OK */
- {errno = EINVAL; return -1;}
-#endif /* ndef F_OK */
- return 0;
-}
-
-int Mono_Posix_ToAccessMode (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef R_OK
- if ((x & R_OK) == R_OK)
- *r |= Mono_Posix_AccessMode_R_OK;
-#endif /* ndef R_OK */
-#ifdef W_OK
- if ((x & W_OK) == W_OK)
- *r |= Mono_Posix_AccessMode_W_OK;
-#endif /* ndef W_OK */
-#ifdef X_OK
- if ((x & X_OK) == X_OK)
- *r |= Mono_Posix_AccessMode_X_OK;
-#endif /* ndef X_OK */
-#ifdef F_OK
- if ((x & F_OK) == F_OK)
- *r |= Mono_Posix_AccessMode_F_OK;
-#endif /* ndef F_OK */
- return 0;
-}
-
-int Mono_Posix_FromPathConf (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
- if (x == Mono_Posix_PathConf__PC_LINK_MAX)
-#ifdef _PC_LINK_MAX
- {*r = _PC_LINK_MAX; return 0;}
-#else /* def _PC_LINK_MAX */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_LINK_MAX */
- if (x == Mono_Posix_PathConf__PC_MAX_CANON)
-#ifdef _PC_MAX_CANON
- {*r = _PC_MAX_CANON; return 0;}
-#else /* def _PC_MAX_CANON */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_MAX_CANON */
- if (x == Mono_Posix_PathConf__PC_MAX_INPUT)
-#ifdef _PC_MAX_INPUT
- {*r = _PC_MAX_INPUT; return 0;}
-#else /* def _PC_MAX_INPUT */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_MAX_INPUT */
- if (x == Mono_Posix_PathConf__PC_NAME_MAX)
-#ifdef _PC_NAME_MAX
- {*r = _PC_NAME_MAX; return 0;}
-#else /* def _PC_NAME_MAX */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_NAME_MAX */
- if (x == Mono_Posix_PathConf__PC_PATH_MAX)
-#ifdef _PC_PATH_MAX
- {*r = _PC_PATH_MAX; return 0;}
-#else /* def _PC_PATH_MAX */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_PATH_MAX */
- if (x == Mono_Posix_PathConf__PC_PIPE_BUF)
-#ifdef _PC_PIPE_BUF
- {*r = _PC_PIPE_BUF; return 0;}
-#else /* def _PC_PIPE_BUF */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_PIPE_BUF */
- if (x == Mono_Posix_PathConf__PC_CHOWN_RESTRICTED)
-#ifdef _PC_CHOWN_RESTRICTED
- {*r = _PC_CHOWN_RESTRICTED; return 0;}
-#else /* def _PC_CHOWN_RESTRICTED */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_CHOWN_RESTRICTED */
- if (x == Mono_Posix_PathConf__PC_NO_TRUNC)
-#ifdef _PC_NO_TRUNC
- {*r = _PC_NO_TRUNC; return 0;}
-#else /* def _PC_NO_TRUNC */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_NO_TRUNC */
- if (x == Mono_Posix_PathConf__PC_VDISABLE)
-#ifdef _PC_VDISABLE
- {*r = _PC_VDISABLE; return 0;}
-#else /* def _PC_VDISABLE */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_VDISABLE */
- if (x == Mono_Posix_PathConf__PC_SYNC_IO)
-#ifdef _PC_SYNC_IO
- {*r = _PC_SYNC_IO; return 0;}
-#else /* def _PC_SYNC_IO */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_SYNC_IO */
- if (x == Mono_Posix_PathConf__PC_ASYNC_IO)
-#ifdef _PC_ASYNC_IO
- {*r = _PC_ASYNC_IO; return 0;}
-#else /* def _PC_ASYNC_IO */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_ASYNC_IO */
- if (x == Mono_Posix_PathConf__PC_PRIO_IO)
-#ifdef _PC_PRIO_IO
- {*r = _PC_PRIO_IO; return 0;}
-#else /* def _PC_PRIO_IO */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_PRIO_IO */
- if (x == Mono_Posix_PathConf__PC_SOCK_MAXBUF)
-#ifdef _PC_SOCK_MAXBUF
- {*r = _PC_SOCK_MAXBUF; return 0;}
-#else /* def _PC_SOCK_MAXBUF */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_SOCK_MAXBUF */
- if (x == Mono_Posix_PathConf__PC_FILESIZEBITS)
-#ifdef _PC_FILESIZEBITS
- {*r = _PC_FILESIZEBITS; return 0;}
-#else /* def _PC_FILESIZEBITS */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_FILESIZEBITS */
- if (x == Mono_Posix_PathConf__PC_REC_INCR_XFER_SIZE)
-#ifdef _PC_REC_INCR_XFER_SIZE
- {*r = _PC_REC_INCR_XFER_SIZE; return 0;}
-#else /* def _PC_REC_INCR_XFER_SIZE */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_REC_INCR_XFER_SIZE */
- if (x == Mono_Posix_PathConf__PC_REC_MAX_XFER_SIZE)
-#ifdef _PC_REC_MAX_XFER_SIZE
- {*r = _PC_REC_MAX_XFER_SIZE; return 0;}
-#else /* def _PC_REC_MAX_XFER_SIZE */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_REC_MAX_XFER_SIZE */
- if (x == Mono_Posix_PathConf__PC_REC_MIN_XFER_SIZE)
-#ifdef _PC_REC_MIN_XFER_SIZE
- {*r = _PC_REC_MIN_XFER_SIZE; return 0;}
-#else /* def _PC_REC_MIN_XFER_SIZE */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_REC_MIN_XFER_SIZE */
- if (x == Mono_Posix_PathConf__PC_REC_XFER_ALIGN)
-#ifdef _PC_REC_XFER_ALIGN
- {*r = _PC_REC_XFER_ALIGN; return 0;}
-#else /* def _PC_REC_XFER_ALIGN */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_REC_XFER_ALIGN */
- if (x == Mono_Posix_PathConf__PC_ALLOC_SIZE_MIN)
-#ifdef _PC_ALLOC_SIZE_MIN
- {*r = _PC_ALLOC_SIZE_MIN; return 0;}
-#else /* def _PC_ALLOC_SIZE_MIN */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_ALLOC_SIZE_MIN */
- if (x == Mono_Posix_PathConf__PC_SYMLINK_MAX)
-#ifdef _PC_SYMLINK_MAX
- {*r = _PC_SYMLINK_MAX; return 0;}
-#else /* def _PC_SYMLINK_MAX */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_SYMLINK_MAX */
- if (x == Mono_Posix_PathConf__PC_2_SYMLINKS)
-#ifdef _PC_2_SYMLINKS
- {*r = _PC_2_SYMLINKS; return 0;}
-#else /* def _PC_2_SYMLINKS */
- {errno = EINVAL; return -1;}
-#endif /* ndef _PC_2_SYMLINKS */
- errno = EINVAL; return -1;
-}
-
-int Mono_Posix_ToPathConf (int x, int *r)
-{
- *r = 0;
- if (x == 0)
- return 0;
-#ifdef _PC_LINK_MAX
- if (x == _PC_LINK_MAX)
- {*r = Mono_Posix_PathConf__PC_LINK_MAX; return 0;}
-#endif /* ndef _PC_LINK_MAX */
-#ifdef _PC_MAX_CANON
- if (x == _PC_MAX_CANON)
- {*r = Mono_Posix_PathConf__PC_MAX_CANON; return 0;}
-#endif /* ndef _PC_MAX_CANON */
-#ifdef _PC_MAX_INPUT
- if (x == _PC_MAX_INPUT)
- {*r = Mono_Posix_PathConf__PC_MAX_INPUT; return 0;}
-#endif /* ndef _PC_MAX_INPUT */
-#ifdef _PC_NAME_MAX
- if (x == _PC_NAME_MAX)
- {*r = Mono_Posix_PathConf__PC_NAME_MAX; return 0;}
-#endif /* ndef _PC_NAME_MAX */
-#ifdef _PC_PATH_MAX
- if (x == _PC_PATH_MAX)
- {*r = Mono_Posix_PathConf__PC_PATH_MAX; return 0;}
-#endif /* ndef _PC_PATH_MAX */
-#ifdef _PC_PIPE_BUF
- if (x == _PC_PIPE_BUF)
- {*r = Mono_Posix_PathConf__PC_PIPE_BUF; return 0;}
-#endif /* ndef _PC_PIPE_BUF */
-#ifdef _PC_CHOWN_RESTRICTED
- if (x == _PC_CHOWN_RESTRICTED)
- {*r = Mono_Posix_PathConf__PC_CHOWN_RESTRICTED; return 0;}
-#endif /* ndef _PC_CHOWN_RESTRICTED */
-#ifdef _PC_NO_TRUNC
- if (x == _PC_NO_TRUNC)
- {*r = Mono_Posix_PathConf__PC_NO_TRUNC; return 0;}
-#endif /* ndef _PC_NO_TRUNC */
-#ifdef _PC_VDISABLE
- if (x == _PC_VDISABLE)
- {*r = Mono_Posix_PathConf__PC_VDISABLE; return 0;}
-#endif /* ndef _PC_VDISABLE */
-#ifdef _PC_SYNC_IO
- if (x == _PC_SYNC_IO)
- {*r = Mono_Posix_PathConf__PC_SYNC_IO; return 0;}
-#endif /* ndef _PC_SYNC_IO */
-#ifdef _PC_ASYNC_IO
- if (x == _PC_ASYNC_IO)
- {*r = Mono_Posix_PathConf__PC_ASYNC_IO; return 0;}
-#endif /* ndef _PC_ASYNC_IO */
-#ifdef _PC_PRIO_IO
- if (x == _PC_PRIO_IO)
- {*r = Mono_Posix_PathConf__PC_PRIO_IO; return 0;}
-#endif /* ndef _PC_PRIO_IO */
-#ifdef _PC_SOCK_MAXBUF
- if (x == _PC_SOCK_MAXBUF)
- {*r = Mono_Posix_PathConf__PC_SOCK_MAXBUF; return 0;}
-#endif /* ndef _PC_SOCK_MAXBUF */
-#ifdef _PC_FILESIZEBITS
- if (x == _PC_FILESIZEBITS)
- {*r = Mono_Posix_PathConf__PC_FILESIZEBITS; return 0;}
-#endif /* ndef _PC_FILESIZEBITS */
-#ifdef _PC_REC_INCR_XFER_SIZE
- if (x == _PC_REC_INCR_XFER_SIZE)
- {*r = Mono_Posix_PathConf__PC_REC_INCR_XFER_SIZE; return 0;}
-#endif /* ndef _PC_REC_INCR_XFER_SIZE */
-#ifdef _PC_REC_MAX_XFER_SIZE
- if (x == _PC_REC_MAX_XFER_SIZE)
- {*r = Mono_Posix_PathConf__PC_REC_MAX_XFER_SIZE; return 0;}
-#endif /* ndef _PC_REC_MAX_XFER_SIZE */
-#ifdef _PC_REC_MIN_XFER_SIZE
- if (x == _PC_REC_MIN_XFER_SIZE)
- {*r = Mono_Posix_PathConf__PC_REC_MIN_XFER_SIZE; return 0;}
-#endif /* ndef _PC_REC_MIN_XFER_SIZE */
-#ifdef _PC_REC_XFER_ALIGN
- if (x == _PC_REC_XFER_ALIGN)
- {*r = Mono_Posix_PathConf__PC_REC_XFER_ALIGN; return 0;}
-#endif /* ndef _PC_REC_XFER_ALIGN */
-#ifdef _PC_ALLOC_SIZE_MIN
- if (x == _PC_ALLOC_SIZE_MIN)
- {*r = Mono_Posix_PathConf__PC_ALLOC_SIZE_MIN; return 0;}
-#endif /* ndef _PC_ALLOC_SIZE_MIN */
-#ifdef _PC_SYMLINK_MAX
- if (x == _PC_SYMLINK_MAX)
- {*r = Mono_Posix_PathConf__PC_SYMLINK_MAX; return 0;}
-#endif /* ndef _PC_SYMLINK_MAX */
-#ifdef _PC_2_SYMLINKS
- if (x == _PC_2_SYMLINKS)
- {*r = Mono_Posix_PathConf__PC_2_SYMLINKS; return 0;}
-#endif /* ndef _PC_2_SYMLINKS */
+#ifdef E2BIG
+ if (x == E2BIG)
+ {*r = Mono_Posix_Errno_E2BIG; return 0;}
+#endif /* ndef E2BIG */
+#ifdef EACCES
+ if (x == EACCES)
+ {*r = Mono_Posix_Errno_EACCES; return 0;}
+#endif /* ndef EACCES */
+#ifdef EADDRINUSE
+ if (x == EADDRINUSE)
+ {*r = Mono_Posix_Errno_EADDRINUSE; return 0;}
+#endif /* ndef EADDRINUSE */
+#ifdef EADDRNOTAVAIL
+ if (x == EADDRNOTAVAIL)
+ {*r = Mono_Posix_Errno_EADDRNOTAVAIL; return 0;}
+#endif /* ndef EADDRNOTAVAIL */
+#ifdef EADV
+ if (x == EADV)
+ {*r = Mono_Posix_Errno_EADV; return 0;}
+#endif /* ndef EADV */
+#ifdef EAFNOSUPPORT
+ if (x == EAFNOSUPPORT)
+ {*r = Mono_Posix_Errno_EAFNOSUPPORT; return 0;}
+#endif /* ndef EAFNOSUPPORT */
+#ifdef EAGAIN
+ if (x == EAGAIN)
+ {*r = Mono_Posix_Errno_EAGAIN; return 0;}
+#endif /* ndef EAGAIN */
+#ifdef EALREADY
+ if (x == EALREADY)
+ {*r = Mono_Posix_Errno_EALREADY; return 0;}
+#endif /* ndef EALREADY */
+#ifdef EBADE
+ if (x == EBADE)
+ {*r = Mono_Posix_Errno_EBADE; return 0;}
+#endif /* ndef EBADE */
+#ifdef EBADF
+ if (x == EBADF)
+ {*r = Mono_Posix_Errno_EBADF; return 0;}
+#endif /* ndef EBADF */
+#ifdef EBADFD
+ if (x == EBADFD)
+ {*r = Mono_Posix_Errno_EBADFD; return 0;}
+#endif /* ndef EBADFD */
+#ifdef EBADMSG
+ if (x == EBADMSG)
+ {*r = Mono_Posix_Errno_EBADMSG; return 0;}
+#endif /* ndef EBADMSG */
+#ifdef EBADR
+ if (x == EBADR)
+ {*r = Mono_Posix_Errno_EBADR; return 0;}
+#endif /* ndef EBADR */
+#ifdef EBADRQC
+ if (x == EBADRQC)
+ {*r = Mono_Posix_Errno_EBADRQC; return 0;}
+#endif /* ndef EBADRQC */
+#ifdef EBADSLT
+ if (x == EBADSLT)
+ {*r = Mono_Posix_Errno_EBADSLT; return 0;}
+#endif /* ndef EBADSLT */
+#ifdef EBFONT
+ if (x == EBFONT)
+ {*r = Mono_Posix_Errno_EBFONT; return 0;}
+#endif /* ndef EBFONT */
+#ifdef EBUSY
+ if (x == EBUSY)
+ {*r = Mono_Posix_Errno_EBUSY; return 0;}
+#endif /* ndef EBUSY */
+#ifdef ECHILD
+ if (x == ECHILD)
+ {*r = Mono_Posix_Errno_ECHILD; return 0;}
+#endif /* ndef ECHILD */
+#ifdef ECHRNG
+ if (x == ECHRNG)
+ {*r = Mono_Posix_Errno_ECHRNG; return 0;}
+#endif /* ndef ECHRNG */
+#ifdef ECOMM
+ if (x == ECOMM)
+ {*r = Mono_Posix_Errno_ECOMM; return 0;}
+#endif /* ndef ECOMM */
+#ifdef ECONNABORTED
+ if (x == ECONNABORTED)
+ {*r = Mono_Posix_Errno_ECONNABORTED; return 0;}
+#endif /* ndef ECONNABORTED */
+#ifdef ECONNREFUSED
+ if (x == ECONNREFUSED)
+ {*r = Mono_Posix_Errno_ECONNREFUSED; return 0;}
+#endif /* ndef ECONNREFUSED */
+#ifdef ECONNRESET
+ if (x == ECONNRESET)
+ {*r = Mono_Posix_Errno_ECONNRESET; return 0;}
+#endif /* ndef ECONNRESET */
+#ifdef EDEADLK
+ if (x == EDEADLK)
+ {*r = Mono_Posix_Errno_EDEADLK; return 0;}
+#endif /* ndef EDEADLK */
+#ifdef EDEADLOCK
+ if (x == EDEADLOCK)
+ {*r = Mono_Posix_Errno_EDEADLOCK; return 0;}
+#endif /* ndef EDEADLOCK */
+#ifdef EDESTADDRREQ
+ if (x == EDESTADDRREQ)
+ {*r = Mono_Posix_Errno_EDESTADDRREQ; return 0;}
+#endif /* ndef EDESTADDRREQ */
+#ifdef EDOM
+ if (x == EDOM)
+ {*r = Mono_Posix_Errno_EDOM; return 0;}
+#endif /* ndef EDOM */
+#ifdef EDOTDOT
+ if (x == EDOTDOT)
+ {*r = Mono_Posix_Errno_EDOTDOT; return 0;}
+#endif /* ndef EDOTDOT */
+#ifdef EDQUOT
+ if (x == EDQUOT)
+ {*r = Mono_Posix_Errno_EDQUOT; return 0;}
+#endif /* ndef EDQUOT */
+#ifdef EEXIST
+ if (x == EEXIST)
+ {*r = Mono_Posix_Errno_EEXIST; return 0;}
+#endif /* ndef EEXIST */
+#ifdef EFAULT
+ if (x == EFAULT)
+ {*r = Mono_Posix_Errno_EFAULT; return 0;}
+#endif /* ndef EFAULT */
+#ifdef EFBIG
+ if (x == EFBIG)
+ {*r = Mono_Posix_Errno_EFBIG; return 0;}
+#endif /* ndef EFBIG */
+#ifdef EHOSTDOWN
+ if (x == EHOSTDOWN)
+ {*r = Mono_Posix_Errno_EHOSTDOWN; return 0;}
+#endif /* ndef EHOSTDOWN */
+#ifdef EHOSTUNREACH
+ if (x == EHOSTUNREACH)
+ {*r = Mono_Posix_Errno_EHOSTUNREACH; return 0;}
+#endif /* ndef EHOSTUNREACH */
+#ifdef EIDRM
+ if (x == EIDRM)
+ {*r = Mono_Posix_Errno_EIDRM; return 0;}
+#endif /* ndef EIDRM */
+#ifdef EILSEQ
+ if (x == EILSEQ)
+ {*r = Mono_Posix_Errno_EILSEQ; return 0;}
+#endif /* ndef EILSEQ */
+#ifdef EINPROGRESS
+ if (x == EINPROGRESS)
+ {*r = Mono_Posix_Errno_EINPROGRESS; return 0;}
+#endif /* ndef EINPROGRESS */
+#ifdef EINTR
+ if (x == EINTR)
+ {*r = Mono_Posix_Errno_EINTR; return 0;}
+#endif /* ndef EINTR */
+#ifdef EINVAL
+ if (x == EINVAL)
+ {*r = Mono_Posix_Errno_EINVAL; return 0;}
+#endif /* ndef EINVAL */
+#ifdef EIO
+ if (x == EIO)
+ {*r = Mono_Posix_Errno_EIO; return 0;}
+#endif /* ndef EIO */
+#ifdef EISCONN
+ if (x == EISCONN)
+ {*r = Mono_Posix_Errno_EISCONN; return 0;}
+#endif /* ndef EISCONN */
+#ifdef EISDIR
+ if (x == EISDIR)
+ {*r = Mono_Posix_Errno_EISDIR; return 0;}
+#endif /* ndef EISDIR */
+#ifdef EISNAM
+ if (x == EISNAM)
+ {*r = Mono_Posix_Errno_EISNAM; return 0;}
+#endif /* ndef EISNAM */
+#ifdef EL2HLT
+ if (x == EL2HLT)
+ {*r = Mono_Posix_Errno_EL2HLT; return 0;}
+#endif /* ndef EL2HLT */
+#ifdef EL2NSYNC
+ if (x == EL2NSYNC)
+ {*r = Mono_Posix_Errno_EL2NSYNC; return 0;}
+#endif /* ndef EL2NSYNC */
+#ifdef EL3HLT
+ if (x == EL3HLT)
+ {*r = Mono_Posix_Errno_EL3HLT; return 0;}
+#endif /* ndef EL3HLT */
+#ifdef EL3RST
+ if (x == EL3RST)
+ {*r = Mono_Posix_Errno_EL3RST; return 0;}
+#endif /* ndef EL3RST */
+#ifdef ELIBACC
+ if (x == ELIBACC)
+ {*r = Mono_Posix_Errno_ELIBACC; return 0;}
+#endif /* ndef ELIBACC */
+#ifdef ELIBBAD
+ if (x == ELIBBAD)
+ {*r = Mono_Posix_Errno_ELIBBAD; return 0;}
+#endif /* ndef ELIBBAD */
+#ifdef ELIBEXEC
+ if (x == ELIBEXEC)
+ {*r = Mono_Posix_Errno_ELIBEXEC; return 0;}
+#endif /* ndef ELIBEXEC */
+#ifdef ELIBMAX
+ if (x == ELIBMAX)
+ {*r = Mono_Posix_Errno_ELIBMAX; return 0;}
+#endif /* ndef ELIBMAX */
+#ifdef ELIBSCN
+ if (x == ELIBSCN)
+ {*r = Mono_Posix_Errno_ELIBSCN; return 0;}
+#endif /* ndef ELIBSCN */
+#ifdef ELNRNG
+ if (x == ELNRNG)
+ {*r = Mono_Posix_Errno_ELNRNG; return 0;}
+#endif /* ndef ELNRNG */
+#ifdef ELOOP
+ if (x == ELOOP)
+ {*r = Mono_Posix_Errno_ELOOP; return 0;}
+#endif /* ndef ELOOP */
+#ifdef EMEDIUMTYPE
+ if (x == EMEDIUMTYPE)
+ {*r = Mono_Posix_Errno_EMEDIUMTYPE; return 0;}
+#endif /* ndef EMEDIUMTYPE */
+#ifdef EMFILE
+ if (x == EMFILE)
+ {*r = Mono_Posix_Errno_EMFILE; return 0;}
+#endif /* ndef EMFILE */
+#ifdef EMLINK
+ if (x == EMLINK)
+ {*r = Mono_Posix_Errno_EMLINK; return 0;}
+#endif /* ndef EMLINK */
+#ifdef EMSGSIZE
+ if (x == EMSGSIZE)
+ {*r = Mono_Posix_Errno_EMSGSIZE; return 0;}
+#endif /* ndef EMSGSIZE */
+#ifdef EMULTIHOP
+ if (x == EMULTIHOP)
+ {*r = Mono_Posix_Errno_EMULTIHOP; return 0;}
+#endif /* ndef EMULTIHOP */
+#ifdef ENAMETOOLONG
+ if (x == ENAMETOOLONG)
+ {*r = Mono_Posix_Errno_ENAMETOOLONG; return 0;}
+#endif /* ndef ENAMETOOLONG */
+#ifdef ENAVAIL
+ if (x == ENAVAIL)
+ {*r = Mono_Posix_Errno_ENAVAIL; return 0;}
+#endif /* ndef ENAVAIL */
+#ifdef ENETDOWN
+ if (x == ENETDOWN)
+ {*r = Mono_Posix_Errno_ENETDOWN; return 0;}
+#endif /* ndef ENETDOWN */
+#ifdef ENETRESET
+ if (x == ENETRESET)
+ {*r = Mono_Posix_Errno_ENETRESET; return 0;}
+#endif /* ndef ENETRESET */
+#ifdef ENETUNREACH
+ if (x == ENETUNREACH)
+ {*r = Mono_Posix_Errno_ENETUNREACH; return 0;}
+#endif /* ndef ENETUNREACH */
+#ifdef ENFILE
+ if (x == ENFILE)
+ {*r = Mono_Posix_Errno_ENFILE; return 0;}
+#endif /* ndef ENFILE */
+#ifdef ENOANO
+ if (x == ENOANO)
+ {*r = Mono_Posix_Errno_ENOANO; return 0;}
+#endif /* ndef ENOANO */
+#ifdef ENOBUFS
+ if (x == ENOBUFS)
+ {*r = Mono_Posix_Errno_ENOBUFS; return 0;}
+#endif /* ndef ENOBUFS */
+#ifdef ENOCSI
+ if (x == ENOCSI)
+ {*r = Mono_Posix_Errno_ENOCSI; return 0;}
+#endif /* ndef ENOCSI */
+#ifdef ENODATA
+ if (x == ENODATA)
+ {*r = Mono_Posix_Errno_ENODATA; return 0;}
+#endif /* ndef ENODATA */
+#ifdef ENODEV
+ if (x == ENODEV)
+ {*r = Mono_Posix_Errno_ENODEV; return 0;}
+#endif /* ndef ENODEV */
+#ifdef ENOENT
+ if (x == ENOENT)
+ {*r = Mono_Posix_Errno_ENOENT; return 0;}
+#endif /* ndef ENOENT */
+#ifdef ENOEXEC
+ if (x == ENOEXEC)
+ {*r = Mono_Posix_Errno_ENOEXEC; return 0;}
+#endif /* ndef ENOEXEC */
+#ifdef ENOLCK
+ if (x == ENOLCK)
+ {*r = Mono_Posix_Errno_ENOLCK; return 0;}
+#endif /* ndef ENOLCK */
+#ifdef ENOLINK
+ if (x == ENOLINK)
+ {*r = Mono_Posix_Errno_ENOLINK; return 0;}
+#endif /* ndef ENOLINK */
+#ifdef ENOMEDIUM
+ if (x == ENOMEDIUM)
+ {*r = Mono_Posix_Errno_ENOMEDIUM; return 0;}
+#endif /* ndef ENOMEDIUM */
+#ifdef ENOMEM
+ if (x == ENOMEM)
+ {*r = Mono_Posix_Errno_ENOMEM; return 0;}
+#endif /* ndef ENOMEM */
+#ifdef ENOMSG
+ if (x == ENOMSG)
+ {*r = Mono_Posix_Errno_ENOMSG; return 0;}
+#endif /* ndef ENOMSG */
+#ifdef ENONET
+ if (x == ENONET)
+ {*r = Mono_Posix_Errno_ENONET; return 0;}
+#endif /* ndef ENONET */
+#ifdef ENOPKG
+ if (x == ENOPKG)
+ {*r = Mono_Posix_Errno_ENOPKG; return 0;}
+#endif /* ndef ENOPKG */
+#ifdef ENOPROTOOPT
+ if (x == ENOPROTOOPT)
+ {*r = Mono_Posix_Errno_ENOPROTOOPT; return 0;}
+#endif /* ndef ENOPROTOOPT */
+#ifdef ENOSPC
+ if (x == ENOSPC)
+ {*r = Mono_Posix_Errno_ENOSPC; return 0;}
+#endif /* ndef ENOSPC */
+#ifdef ENOSR
+ if (x == ENOSR)
+ {*r = Mono_Posix_Errno_ENOSR; return 0;}
+#endif /* ndef ENOSR */
+#ifdef ENOSTR
+ if (x == ENOSTR)
+ {*r = Mono_Posix_Errno_ENOSTR; return 0;}
+#endif /* ndef ENOSTR */
+#ifdef ENOSYS
+ if (x == ENOSYS)
+ {*r = Mono_Posix_Errno_ENOSYS; return 0;}
+#endif /* ndef ENOSYS */
+#ifdef ENOTBLK
+ if (x == ENOTBLK)
+ {*r = Mono_Posix_Errno_ENOTBLK; return 0;}
+#endif /* ndef ENOTBLK */
+#ifdef ENOTCONN
+ if (x == ENOTCONN)
+ {*r = Mono_Posix_Errno_ENOTCONN; return 0;}
+#endif /* ndef ENOTCONN */
+#ifdef ENOTDIR
+ if (x == ENOTDIR)
+ {*r = Mono_Posix_Errno_ENOTDIR; return 0;}
+#endif /* ndef ENOTDIR */
+#ifdef ENOTEMPTY
+ if (x == ENOTEMPTY)
+ {*r = Mono_Posix_Errno_ENOTEMPTY; return 0;}
+#endif /* ndef ENOTEMPTY */
+#ifdef ENOTNAM
+ if (x == ENOTNAM)
+ {*r = Mono_Posix_Errno_ENOTNAM; return 0;}
+#endif /* ndef ENOTNAM */
+#ifdef ENOTSOCK
+ if (x == ENOTSOCK)
+ {*r = Mono_Posix_Errno_ENOTSOCK; return 0;}
+#endif /* ndef ENOTSOCK */
+#ifdef ENOTTY
+ if (x == ENOTTY)
+ {*r = Mono_Posix_Errno_ENOTTY; return 0;}
+#endif /* ndef ENOTTY */
+#ifdef ENOTUNIQ
+ if (x == ENOTUNIQ)
+ {*r = Mono_Posix_Errno_ENOTUNIQ; return 0;}
+#endif /* ndef ENOTUNIQ */
+#ifdef ENXIO
+ if (x == ENXIO)
+ {*r = Mono_Posix_Errno_ENXIO; return 0;}
+#endif /* ndef ENXIO */
+#ifdef EOPNOTSUPP
+ if (x == EOPNOTSUPP)
+ {*r = Mono_Posix_Errno_EOPNOTSUPP; return 0;}
+#endif /* ndef EOPNOTSUPP */
+#ifdef EOVERFLOW
+ if (x == EOVERFLOW)
+ {*r = Mono_Posix_Errno_EOVERFLOW; return 0;}
+#endif /* ndef EOVERFLOW */
+#ifdef EPERM
+ if (x == EPERM)
+ {*r = Mono_Posix_Errno_EPERM; return 0;}
+#endif /* ndef EPERM */
+#ifdef EPFNOSUPPORT
+ if (x == EPFNOSUPPORT)
+ {*r = Mono_Posix_Errno_EPFNOSUPPORT; return 0;}
+#endif /* ndef EPFNOSUPPORT */
+#ifdef EPIPE
+ if (x == EPIPE)
+ {*r = Mono_Posix_Errno_EPIPE; return 0;}
+#endif /* ndef EPIPE */
+#ifdef EPROTO
+ if (x == EPROTO)
+ {*r = Mono_Posix_Errno_EPROTO; return 0;}
+#endif /* ndef EPROTO */
+#ifdef EPROTONOSUPPORT
+ if (x == EPROTONOSUPPORT)
+ {*r = Mono_Posix_Errno_EPROTONOSUPPORT; return 0;}
+#endif /* ndef EPROTONOSUPPORT */
+#ifdef EPROTOTYPE
+ if (x == EPROTOTYPE)
+ {*r = Mono_Posix_Errno_EPROTOTYPE; return 0;}
+#endif /* ndef EPROTOTYPE */
+#ifdef ERANGE
+ if (x == ERANGE)
+ {*r = Mono_Posix_Errno_ERANGE; return 0;}
+#endif /* ndef ERANGE */
+#ifdef EREMCHG
+ if (x == EREMCHG)
+ {*r = Mono_Posix_Errno_EREMCHG; return 0;}
+#endif /* ndef EREMCHG */
+#ifdef EREMOTE
+ if (x == EREMOTE)
+ {*r = Mono_Posix_Errno_EREMOTE; return 0;}
+#endif /* ndef EREMOTE */
+#ifdef EREMOTEIO
+ if (x == EREMOTEIO)
+ {*r = Mono_Posix_Errno_EREMOTEIO; return 0;}
+#endif /* ndef EREMOTEIO */
+#ifdef ERESTART
+ if (x == ERESTART)
+ {*r = Mono_Posix_Errno_ERESTART; return 0;}
+#endif /* ndef ERESTART */
+#ifdef EROFS
+ if (x == EROFS)
+ {*r = Mono_Posix_Errno_EROFS; return 0;}
+#endif /* ndef EROFS */
+#ifdef ESHUTDOWN
+ if (x == ESHUTDOWN)
+ {*r = Mono_Posix_Errno_ESHUTDOWN; return 0;}
+#endif /* ndef ESHUTDOWN */
+#ifdef ESOCKTNOSUPPORT
+ if (x == ESOCKTNOSUPPORT)
+ {*r = Mono_Posix_Errno_ESOCKTNOSUPPORT; return 0;}
+#endif /* ndef ESOCKTNOSUPPORT */
+#ifdef ESPIPE
+ if (x == ESPIPE)
+ {*r = Mono_Posix_Errno_ESPIPE; return 0;}
+#endif /* ndef ESPIPE */
+#ifdef ESRCH
+ if (x == ESRCH)
+ {*r = Mono_Posix_Errno_ESRCH; return 0;}
+#endif /* ndef ESRCH */
+#ifdef ESRMNT
+ if (x == ESRMNT)
+ {*r = Mono_Posix_Errno_ESRMNT; return 0;}
+#endif /* ndef ESRMNT */
+#ifdef ESTALE
+ if (x == ESTALE)
+ {*r = Mono_Posix_Errno_ESTALE; return 0;}
+#endif /* ndef ESTALE */
+#ifdef ESTRPIPE
+ if (x == ESTRPIPE)
+ {*r = Mono_Posix_Errno_ESTRPIPE; return 0;}
+#endif /* ndef ESTRPIPE */
+#ifdef ETIME
+ if (x == ETIME)
+ {*r = Mono_Posix_Errno_ETIME; return 0;}
+#endif /* ndef ETIME */
+#ifdef ETIMEDOUT
+ if (x == ETIMEDOUT)
+ {*r = Mono_Posix_Errno_ETIMEDOUT; return 0;}
+#endif /* ndef ETIMEDOUT */
+#ifdef ETOOMANYREFS
+ if (x == ETOOMANYREFS)
+ {*r = Mono_Posix_Errno_ETOOMANYREFS; return 0;}
+#endif /* ndef ETOOMANYREFS */
+#ifdef ETXTBSY
+ if (x == ETXTBSY)
+ {*r = Mono_Posix_Errno_ETXTBSY; return 0;}
+#endif /* ndef ETXTBSY */
+#ifdef EUCLEAN
+ if (x == EUCLEAN)
+ {*r = Mono_Posix_Errno_EUCLEAN; return 0;}
+#endif /* ndef EUCLEAN */
+#ifdef EUNATCH
+ if (x == EUNATCH)
+ {*r = Mono_Posix_Errno_EUNATCH; return 0;}
+#endif /* ndef EUNATCH */
+#ifdef EUSERS
+ if (x == EUSERS)
+ {*r = Mono_Posix_Errno_EUSERS; return 0;}
+#endif /* ndef EUSERS */
+#ifdef EWOULDBLOCK
+ if (x == EWOULDBLOCK)
+ {*r = Mono_Posix_Errno_EWOULDBLOCK; return 0;}
+#endif /* ndef EWOULDBLOCK */
+#ifdef EXDEV
+ if (x == EXDEV)
+ {*r = Mono_Posix_Errno_EXDEV; return 0;}
+#endif /* ndef EXDEV */
+#ifdef EXFULL
+ if (x == EXFULL)
+ {*r = Mono_Posix_Errno_EXFULL; return 0;}
+#endif /* ndef EXFULL */