X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fmap.c;h=92fca755371d09ab6336dd25c5c131d014c47d7d;hb=cb0267cf438a78f54b0d9307dec47984b38b97bb;hp=6201c260c93369f1e37c4ceb340fe7c693b9a055;hpb=fb197673ce77081b0e28cbf6056e9bee44e0430c;p=mono.git diff --git a/support/map.c b/support/map.c index 6201c260c93..92fca755371 100644 --- a/support/map.c +++ b/support/map.c @@ -367,6 +367,48 @@ int Mono_Posix_ToAtFlags (int x, int *r) 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; @@ -3880,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; @@ -3894,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; } @@ -8247,6 +8299,42 @@ int Mono_Posix_ToUnixAddressFamily (int x, int *r) 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; @@ -9236,4 +9324,3 @@ int Mono_Posix_ToXattrFlags (int x, int *r) #endif /* ndef XATTR_REPLACE */ return 0; } -