extern "C" void* SystemNative_MMap(void* address, uint64_t length, int32_t protection, // bitwise OR of PAL_PROT_* int32_t flags, // bitwise OR of PAL_MAP_*, but PRIVATE and SHARED are mutually exclusive. intptr_t fd, int64_t offset) { if (length > SIZE_MAX) { errno = ERANGE; return nullptr; } protection = ConvertMMapProtection(protection); flags = ConvertMMapFlags(flags); if (flags == -1 || protection == -1) { errno = EINVAL; return nullptr; } // Use ToFileDescriptorUnchecked to allow -1 to be passed for the file descriptor, since managed code explicitly uses -1 void* ret = mmap(address, static_cast<size_t>(length), protection, flags, ToFileDescriptorUnchecked(fd), offset); if (ret == MAP_FAILED) { return nullptr; } assert(ret != nullptr); return ret; }
void* SystemNative_MMap(void* address, uint64_t length, int32_t protection, // bitwise OR of PAL_PROT_* int32_t flags, // bitwise OR of PAL_MAP_*, but PRIVATE and SHARED are mutually exclusive. intptr_t fd, int64_t offset) { if (length > SIZE_MAX) { errno = ERANGE; return NULL; } protection = ConvertMMapProtection(protection); flags = ConvertMMapFlags(flags); if (flags == -1 || protection == -1) { errno = EINVAL; return NULL; } // Use ToFileDescriptorUnchecked to allow -1 to be passed for the file descriptor, since managed code explicitly uses -1 void* ret = #if HAVE_MMAP64 mmap64( #else mmap( #endif address, (size_t)length, protection, flags, ToFileDescriptorUnchecked(fd), (off_t)offset); if (ret == MAP_FAILED) { return NULL; } assert(ret != NULL); return ret; }