private PagerState CreatePagerState() { var startingBaseAddressPtr = Syscall.mmap(IntPtr.Zero, (UIntPtr)_totalAllocationSize, MmapProts.PROT_READ | MmapProts.PROT_WRITE, MmapFlags.MAP_SHARED, _fd, IntPtr.Zero); if (startingBaseAddressPtr.ToInt64() == -1) //system didn't succeed in mapping the address where we wanted { var err = Marshal.GetLastWin32Error(); PosixHelper.ThrowLastError(err, "mmap on " + FileName); } NativeMemory.RegisterFileMapping(FileName, startingBaseAddressPtr, _totalAllocationSize); var allocationInfo = new PagerState.AllocationInfo { BaseAddress = (byte *)startingBaseAddressPtr.ToPointer(), Size = _totalAllocationSize, MappedFile = null }; var newPager = new PagerState(this) { Files = null, // unused MapBase = allocationInfo.BaseAddress, AllocationInfos = new[] { allocationInfo } }; return(newPager); }
private PagerState CreatePagerState() { var fileSize = GetFileSize(); var startingBaseAddressPtr = Syscall.mmap(IntPtr.Zero, (ulong)fileSize, MmapProts.PROT_READ | MmapProts.PROT_WRITE, MmapFlags.MAP_SHARED, _fd, 0); if (startingBaseAddressPtr.ToInt64() == -1) //system didn't succeed in mapping the address where we wanted { PosixHelper.ThrowLastError(Marshal.GetLastWin32Error()); } var allocationInfo = new PagerState.AllocationInfo { BaseAddress = (byte *)startingBaseAddressPtr.ToPointer(), Size = fileSize, MappedFile = null }; var newPager = new PagerState(this) { Files = null, // unused MapBase = allocationInfo.BaseAddress, AllocationInfos = new[] { allocationInfo } }; newPager.AddRef(); // one for the pager return(newPager); }
private PagerState.AllocationInfo RemapViewOfFileAtAddress(long allocationSize, long offsetInFile, byte *baseAddress) { var intPtr = Syscall.mmap(new IntPtr(baseAddress), (ulong)allocationSize, MmapProts.PROT_READ | MmapProts.PROT_WRITE, MmapFlags.MAP_FIXED | MmapFlags.MAP_SHARED, _fd, offsetInFile); if (intPtr.ToInt64() == -1) { return(null); // couldn't map to the right place } return(new PagerState.AllocationInfo { BaseAddress = baseAddress, Size = allocationSize, }); }