11//! Platform shared-memory implementation for fspy channels.
22
3- #[ cfg( not( target_os = "linux" ) ) ]
3+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
44use std:: io;
55
66#[ cfg( target_os = "linux" ) ]
77mod linux;
8+ #[ cfg( target_os = "windows" ) ]
9+ mod windows;
810
911#[ cfg( target_os = "linux" ) ]
1012pub use linux:: { CreatedShm , Shm , ShmBroker , ShmBrokerHandle , create, open} ;
11- #[ cfg( not( target_os = "linux" ) ) ]
13+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
1214use shared_memory:: { Shmem , ShmemConf } ;
15+ #[ cfg( target_os = "windows" ) ]
16+ pub use windows:: { CreatedShm , Shm , create, open} ;
1317
1418/// An owned shared-memory mapping.
15- #[ cfg( not( target_os = "linux" ) ) ]
19+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
1620pub struct Shm {
1721 inner : Shmem ,
1822}
1923
2024/// A newly created shared-memory mapping and its platform service.
21- #[ cfg( not( target_os = "linux" ) ) ]
25+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
2226pub struct CreatedShm {
2327 /// The owned shared-memory mapping.
2428 pub shm : Shm ,
@@ -29,11 +33,9 @@ pub struct CreatedShm {
2933/// # Errors
3034///
3135/// Returns an error if the platform cannot create or map the region.
32- #[ cfg( not( target_os = "linux" ) ) ]
36+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
3337pub fn create ( size : usize ) -> io:: Result < CreatedShm > {
3438 let conf = ShmemConf :: new ( ) . size ( size) ;
35- #[ cfg( target_os = "windows" ) ]
36- let conf = conf. allow_raw ( true ) ;
3739
3840 let inner = conf. create ( ) . map_err ( io:: Error :: other) ?;
3941 Ok ( CreatedShm { shm : Shm { inner } } )
@@ -44,17 +46,15 @@ pub fn create(size: usize) -> io::Result<CreatedShm> {
4446/// # Errors
4547///
4648/// Returns an error if the mapping does not exist or cannot be mapped.
47- #[ cfg( not( target_os = "linux" ) ) ]
49+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
4850pub fn open ( id : & str , size : usize ) -> io:: Result < Shm > {
4951 let conf = ShmemConf :: new ( ) . size ( size) . os_id ( id) ;
50- #[ cfg( target_os = "windows" ) ]
51- let conf = conf. allow_raw ( true ) ;
5252
5353 let inner = conf. open ( ) . map_err ( io:: Error :: other) ?;
5454 Ok ( Shm { inner } )
5555}
5656
57- #[ cfg( not( target_os = "linux" ) ) ]
57+ #[ cfg( not( any ( target_os = "linux" , target_os = "windows" ) ) ) ]
5858#[ expect( clippy:: len_without_is_empty, reason = "shared-memory mappings are always non-empty" ) ]
5959impl Shm {
6060 /// Returns this mapping's opaque platform identifier.
0 commit comments