| ... | @@ -1004,6 +1004,10 @@ pub fn unlockMemoryAll() UnlockMemoryError!void { | ... | @@ -1004,6 +1004,10 @@ pub fn unlockMemoryAll() UnlockMemoryError!void { |
| 1004 | | 1004 | |
| 1005 | pub const ProtectMemoryError = error{ | 1005 | pub const ProtectMemoryError = error{ |
| 1006 | UnsupportedOperation, | 1006 | UnsupportedOperation, |
| | 1007 | /// OpenBSD will refuse to change memory protection if the specified region |
| | 1008 | /// contains any pages that have previously been marked immutable using the |
| | 1009 | /// `mimmutable` function. |
| | 1010 | PermissionDenied, |
| 1007 | /// The memory cannot be given the specified access. This can happen, for | 1011 | /// The memory cannot be given the specified access. This can happen, for |
| 1008 | /// example, if you memory map a file to which you have read-only access, | 1012 | /// example, if you memory map a file to which you have read-only access, |
| 1009 | /// then use `protectMemory` to mark it writable. | 1013 | /// then use `protectMemory` to mark it writable. |
| ... | @@ -1052,6 +1056,7 @@ pub fn protectMemory( | ... | @@ -1052,6 +1056,7 @@ pub fn protectMemory( |
| 1052 | }; | 1056 | }; |
| 1053 | switch (posix.errno(posix.system.mprotect(memory.ptr, memory.len, flags))) { | 1057 | switch (posix.errno(posix.system.mprotect(memory.ptr, memory.len, flags))) { |
| 1054 | .SUCCESS => return, | 1058 | .SUCCESS => return, |
| | 1059 | .PERM => return error.PermissionDenied, |
| 1055 | .INVAL => |err| return std.Io.Threaded.errnoBug(err), | 1060 | .INVAL => |err| return std.Io.Threaded.errnoBug(err), |
| 1056 | .ACCES => return error.AccessDenied, | 1061 | .ACCES => return error.AccessDenied, |
| 1057 | .NOMEM => return error.OutOfMemory, | 1062 | .NOMEM => return error.OutOfMemory, |