Add VTL on windows#16
Open
joschaschmiedt wants to merge 2 commits into
Open
Conversation
POSIX shm_open/mmap is replaced on Windows with CreateFileMappingW/MapViewOfFile (pagefile-backed, Local\ namespace). VtlOwner and VtlClient now compile and work on Windows; the server enables VTL on any(unix, windows) instead of linux-only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-Authored-By: Claude <noreply@anthropic.com>
Separate optional workflow on windows-latest: - cargo build --release, cargo test, cargo clippy - python-null-e2e using make.ps1 test-e2e-null with the built vstimd.exe artifact Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds Windows support for the VTL shared-memory interface by introducing Windows-specific shared-memory creation/mapping code paths, updating the server to enable VTL on Windows/Unix, and adding a Windows CI workflow to build/test the workspace and run Python e2e tests.
Changes:
- Implement Windows-backed VTL segments using named file mappings (
CreateFileMappingW/OpenFileMappingW) with appropriate mapping/unmapping cleanup. - Enable VTL initialization in the server on
windowsandunixtargets. - Add a dedicated GitHub Actions workflow to run Rust + Python tests on Windows.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
vtl/src/segment.rs |
Adds Windows-friendly struct annotation for size field usage across platforms. |
vtl/src/owner.rs |
Adds Windows implementation for creating and owning a VTL shared mapping, plus Windows name conversion helper. |
vtl/src/client.rs |
Adds Windows implementation for opening and mapping an existing VTL shared mapping. |
vtl/Cargo.toml |
Adds windows-sys dependency for Windows builds. |
server/src/main.rs |
Enables VTL shared memory initialization on Unix + Windows. |
Cargo.lock |
Locks new Windows dependency (windows-sys). |
.github/workflows/ci-windows.yml |
Adds Windows CI to build/test Rust and run Python null e2e tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
30
to
35
| if num_input_banks as usize > MAX_BANKS || num_output_banks as usize > MAX_BANKS { | ||
| return Err(io::Error::new( | ||
| io::ErrorKind::InvalidInput, | ||
| format!("bank counts must be <= {MAX_BANKS}"), | ||
| )); | ||
| } |
Comment on lines
+91
to
+109
| use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE}; | ||
| use windows_sys::Win32::System::Memory::{ | ||
| CreateFileMappingW, MapViewOfFile, FILE_MAP_ALL_ACCESS, PAGE_READWRITE, | ||
| }; | ||
|
|
||
| let name_wide = windows_wide_name(shm_name); | ||
| let mapping_handle = unsafe { | ||
| CreateFileMappingW( | ||
| INVALID_HANDLE_VALUE, // pagefile-backed | ||
| std::ptr::null(), // default security attributes | ||
| PAGE_READWRITE, | ||
| (SHM_SIZE >> 32) as u32, | ||
| (SHM_SIZE & 0xFFFF_FFFF) as u32, | ||
| name_wide.as_ptr(), | ||
| ) | ||
| }; | ||
| if mapping_handle.is_null() { | ||
| return Err(io::Error::last_os_error()); | ||
| } |
Comment on lines
+183
to
+185
| let stripped = shm_name.strip_prefix('/').unwrap_or(shm_name); | ||
| let win_name = format!("Local\\{stripped}"); | ||
| OsStr::new(&win_name).encode_wide().chain(std::iter::once(0)).collect() |
Comment on lines
+53
to
+59
| if seg.num_input_banks() as usize > MAX_BANKS || seg.num_output_banks() as usize > MAX_BANKS { | ||
| unsafe { libc::munmap(ptr, SHM_SIZE) }; | ||
| return Err(io::Error::new( | ||
| io::ErrorKind::InvalidData, | ||
| format!("invalid VTL bank counts (max {MAX_BANKS})"), | ||
| )); | ||
| } |
Comment on lines
+99
to
+108
| if seg.num_input_banks() as usize > MAX_BANKS || seg.num_output_banks() as usize > MAX_BANKS { | ||
| unsafe { | ||
| UnmapViewOfFile(MEMORY_MAPPED_VIEW_ADDRESS { Value: mapped.Value }); | ||
| CloseHandle(mapping_handle); | ||
| } | ||
| return Err(io::Error::new( | ||
| io::ErrorKind::InvalidData, | ||
| format!("invalid VTL bank counts (max {MAX_BANKS})"), | ||
| )); | ||
| } |
| let scene = Arc::new(RwLock::new(SceneState::new())); | ||
|
|
||
| // Create VTL shared memory on Linux. The Arc<Mutex<>> lets both the ZMQ | ||
| // Create VTL shared memory on Linux/Windows. The Arc<Mutex<>> lets both the ZMQ |
Comment on lines
+11
to
+15
| windows-sys = { version = "0.61", features = [ | ||
| "Win32_Foundation", | ||
| "Win32_Security", | ||
| "Win32_System_Memory", | ||
| ] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds full Windows support to the VTL shared memory interface, allowing both the server and clients to create and access VTL segments on Windows in addition to Unix platforms. It introduces Windows-specific code paths for shared memory creation, mapping, and cleanup, and updates the continuous integration workflow to test on Windows.
Windows platform support for VTL shared memory:
Added Windows-specific implementations for
VtlOwnerandVtlClientinvtl/src/owner.rsandvtl/src/client.rs, using Windows API functions (CreateFileMappingW,OpenFileMappingW,MapViewOfFile,UnmapViewOfFile, etc.) to create, map, and clean up shared memory segments. This includes safe handling of Windows kernel object handles and proper cleanup inDropimplementations. [1] [2] [3] [4] [5] [6] [7]Updated the conditional compilation in
server/src/main.rsto enable VTL shared memory support on both Unix and Windows platforms, instead of Unix only.Build and CI improvements:
Added a new GitHub Actions workflow (
.github/workflows/ci-windows.yml) to build, test, and run end-to-end tests for both Rust and Python components on Windows.Updated
vtl/Cargo.tomlto addwindows-sysas a dependency for the Windows target, enabling use of Windows API bindings.Other improvements and refactoring:
windows_wide_name).