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();