| ... | @@ -16279,6 +16279,8 @@ fn createFileMap( | ... | @@ -16279,6 +16279,8 @@ fn createFileMap( |
| 16279 | .SUCCESS => {}, | 16279 | .SUCCESS => {}, |
| 16280 | .CONFLICTING_ADDRESSES => return error.MappingAlreadyExists, | 16280 | .CONFLICTING_ADDRESSES => return error.MappingAlreadyExists, |
| 16281 | .SECTION_PROTECTION => return error.PermissionDenied, | 16281 | .SECTION_PROTECTION => return error.PermissionDenied, |
| | 16282 | .ACCESS_DENIED => return error.AccessDenied, |
| | 16283 | .INVALID_VIEW_SIZE => |status| return windows.statusBug(status), |
| 16282 | else => |status| return windows.unexpectedStatus(status), | 16284 | else => |status| return windows.unexpectedStatus(status), |
| 16283 | } | 16285 | } |
| 16284 | if (builtin.mode == .Debug) { | 16286 | if (builtin.mode == .Debug) { |
| ... | @@ -16392,32 +16394,47 @@ fn fileMemoryMapSetLength( | ... | @@ -16392,32 +16394,47 @@ fn fileMemoryMapSetLength( |
| 16392 | const new_len = options.len; | 16394 | const new_len = options.len; |
| 16393 | | 16395 | |
| 16394 | if (mm.section) |section| { | 16396 | if (mm.section) |section| { |
| 16395 | if (alignment.forward(new_len) == alignment.forward(old_memory.len)) { | 16397 | const aligned_old_len = alignment.forward(old_memory.len); |
| | 16398 | const aligned_new_len = alignment.forward(new_len); |
| | 16399 | if (aligned_new_len == aligned_old_len) { |
| 16396 | mm.memory.len = new_len; | 16400 | mm.memory.len = new_len; |
| 16397 | return; | 16401 | return; |
| 16398 | } | 16402 | } |
| 16399 | switch (native_os) { | 16403 | switch (native_os) { |
| 16400 | .windows => { | 16404 | .windows => { |
| 16401 | var contents_ptr: ?[*]align(page_align) u8 = null; | 16405 | if (aligned_new_len > aligned_old_len) { |
| 16402 | var contents_len = new_len; | 16406 | var new_section_size: windows.LARGE_INTEGER = @intCast(aligned_new_len); |
| 16403 | switch (windows.ntdll.NtMapViewOfSection( | 16407 | switch (windows.ntdll.NtExtendSection(section, &new_section_size)) { |
| 16404 | section, | 16408 | .SUCCESS => {}, |
| 16405 | windows.current_process, | 16409 | else => |status| return windows.unexpectedStatus(status), |
| 16406 | @ptrCast(&contents_ptr), | 16410 | } |
| 16407 | null, | 16411 | assert(new_section_size == aligned_new_len); |
| 16408 | 0, | 16412 | mm.memory.len = new_len; |
| 16409 | null, | 16413 | } else { |
| 16410 | &contents_len, | 16414 | _ = windows.ntdll.NtUnmapViewOfSection(windows.current_process, old_memory.ptr); |
| 16411 | .Unmap, | 16415 | windows.CloseHandle(section); |
| 16412 | .{}, | 16416 | var contents_len = aligned_new_len; |
| 16413 | .{ .READWRITE = true }, | 16417 | var contents_ptr: ?[*]align(std.heap.page_size_min) u8 = null; |
| 16414 | )) { | 16418 | switch (windows.ntdll.NtMapViewOfSection( |
| 16415 | .SUCCESS => {}, | 16419 | section, |
| 16416 | .SECTION_PROTECTION => return error.PermissionDenied, | 16420 | windows.current_process, |
| 16417 | else => |status| return windows.unexpectedStatus(status), | 16421 | @ptrCast(&contents_ptr), |
| | 16422 | null, |
| | 16423 | 0, |
| | 16424 | null, |
| | 16425 | &contents_len, |
| | 16426 | .Unmap, |
| | 16427 | .{}, |
| | 16428 | .{ .READWRITE = true }, |
| | 16429 | )) { |
| | 16430 | .SUCCESS => {}, |
| | 16431 | .SECTION_PROTECTION => return error.PermissionDenied, |
| | 16432 | .INVALID_VIEW_SIZE => |status| return windows.statusBug(status), |
| | 16433 | else => |status| return windows.unexpectedStatus(status), |
| | 16434 | } |
| | 16435 | assert(contents_len == aligned_new_len); |
| | 16436 | mm.memory = contents_ptr.?[0..new_len]; |
| 16418 | } | 16437 | } |
| 16419 | assert(contents_len == alignment.forward(new_len)); | | |
| 16420 | mm.memory = contents_ptr.?[0..new_len]; | | |
| 16421 | }, | 16438 | }, |
| 16422 | .wasi => unreachable, | 16439 | .wasi => unreachable, |
| 16423 | .linux => { | 16440 | .linux => { |