more windows bits

This commit is contained in:
Andrea Fioraldi 2021-02-16 10:57:47 +01:00
parent 97ad4e92f9
commit 00e2e2cefb
4 changed files with 33 additions and 2 deletions

View File

@ -2,9 +2,10 @@ fn main() {
#[cfg(target_os = "windows")]
windows::build!(
windows::win32::system_services::HANDLE,
windows::win32::windows_programming::CloseHandle,
// API needed for the shared memory
windows::win32::system_services::{CreateFileMappingA, MapViewOfFile, UnmapViewOfFile},
windows::win32::windows_programming::CloseHandle
windows::win32::system_services::{CreateFileMappingA, OpenFileMappingA, MapViewOfFile, UnmapViewOfFile},
);
}

View File

@ -0,0 +1,2 @@
#[cfg(windows)]
::windows::include_bindings!();

View File

@ -5,3 +5,4 @@ pub mod ownedref;
pub mod serdeany;
pub mod shmem;
pub mod tuples;
pub mod bindings;

View File

@ -5,6 +5,10 @@
#[cfg(unix)]
pub use shmem::UnixShMem;
#[cfg(feature = "std")]
#[cfg(windows)]
pub use shmem::Win32ShMem;
use alloc::string::{String, ToString};
use core::fmt::Debug;
use serde::{Deserialize, Serialize};
@ -319,6 +323,29 @@ pub mod shmem {
}
}
#[cfg(windows)]
#[cfg(feature = "std")]
pub mod shmem {
use core::{mem::size_of, slice};
use std::ffi::CStr;
use crate::Error;
use super::ShMem;
/// The default Sharedmap impl for windows using shmctl & shmget
#[derive(Clone, Debug)]
pub struct Win32ShMem {
pub filename: [u8; 64],
pub handle: windows::win32::system_services::HANDLE,
pub map: *mut u8,
pub map_size: usize,
}
// TODO complete
}
#[cfg(test)]
mod tests {