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;
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;
}
int Mono_Posix_FromSeekFlags (short x, short *r)
{
*r = 0;
- if (x == Mono_Posix_SeekFlags_L_INCR)
#ifdef L_INCR
+ if (x == Mono_Posix_SeekFlags_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_SET)
+#endif /* def L_INCR */
#ifdef L_SET
+ if (x == Mono_Posix_SeekFlags_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_XTND)
+#endif /* def L_SET */
#ifdef L_XTND
+ if (x == Mono_Posix_SeekFlags_L_XTND)
{*r = L_XTND; return 0;}
-#else /* def L_XTND */
- {errno = EINVAL; return -1;}
-#endif /* ndef L_XTND */
- if (x == Mono_Posix_SeekFlags_SEEK_CUR)
+#endif /* def L_XTND */
#ifdef SEEK_CUR
+ if (x == Mono_Posix_SeekFlags_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)
+#endif /* def SEEK_CUR */
#ifdef SEEK_END
+ if (x == Mono_Posix_SeekFlags_SEEK_END)
{*r = SEEK_END; return 0;}
-#else /* def SEEK_END */
- {errno = EINVAL; return -1;}
-#endif /* ndef SEEK_END */
- if (x == Mono_Posix_SeekFlags_SEEK_SET)
+#endif /* def SEEK_END */
#ifdef SEEK_SET
+ if (x == Mono_Posix_SeekFlags_SEEK_SET)
{*r = SEEK_SET; return 0;}
-#else /* def SEEK_SET */
- {errno = EINVAL; return -1;}
-#endif /* ndef SEEK_SET */
- if (x == 0)
- return 0;
+#endif /* def SEEK_SET */
errno = EINVAL; return -1;
}
int Mono_Posix_ToSeekFlags (short x, short *r)
{
*r = 0;
- if (x == 0)
- return 0;
#ifdef L_INCR
if (x == L_INCR)
{*r = Mono_Posix_SeekFlags_L_INCR; return 0;}
#endif /* ndef XATTR_REPLACE */
return 0;
}
-