Add ability to change memory protection on std::os::MemoryMap.

Instead of duplicating the logic above, could it be refactored into a helper function? (same for unix)