Skip to content

Add VTL on windows#16

Open
joschaschmiedt wants to merge 2 commits into
mainfrom
feature/vtl-on-windows
Open

Add VTL on windows#16
joschaschmiedt wants to merge 2 commits into
mainfrom
feature/vtl-on-windows

Conversation

@joschaschmiedt

Copy link
Copy Markdown
Contributor

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 VtlOwner and VtlClient in vtl/src/owner.rs and vtl/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 in Drop implementations. [1] [2] [3] [4] [5] [6] [7]

  • Updated the conditional compilation in server/src/main.rs to 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.toml to add windows-sys as a dependency for the Windows target, enabling use of Windows API bindings.

Other improvements and refactoring:

  • Added utility for converting POSIX-style shared memory names to Windows object names (windows_wide_name).
  • Clarified documentation and comments to reflect cross-platform support and behavior. [1] [2] [3]

joschaschmiedt and others added 2 commits June 10, 2026 16:58
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 windows and unix targets.
  • 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 thread vtl/src/owner.rs
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 thread vtl/src/owner.rs
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 thread vtl/src/owner.rs
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 thread vtl/src/client.rs
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 thread vtl/src/client.rs
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})"),
));
}
Comment thread server/src/main.rs
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 thread vtl/Cargo.toml
Comment on lines +11 to +15
windows-sys = { version = "0.61", features = [
"Win32_Foundation",
"Win32_Security",
"Win32_System_Memory",
] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants