@cli.System.Security.SecuritySafeCriticalAttribute.Annotation
private static long mapViewOfFilePosix(FileStream fs, int prot, long position, long length) throws IOException
{
byte writeable = prot != MAP_RO ? (byte)1 : (byte)0;
byte copy_on_write = prot == MAP_PV ? (byte)1 : (byte)0;
IntPtr p = ikvm_mmap(fs.get_SafeFileHandle(), writeable, copy_on_write, position, (int)length);
cli.System.GC.KeepAlive(fs);
// HACK ikvm_mmap should really be changed to return a null pointer on failure,
// instead of whatever MAP_FAILED is defined to on the particular system we're running on,
// common values for MAP_FAILED are 0 and -1, so we test for these.
if (p.Equals(IntPtr.Zero) || p.Equals(new IntPtr(-1)))
{
throw new IOException("file mapping failed");
}
cli.System.GC.AddMemoryPressure(length);
return p.ToInt64();
}