1313) ) ]
1414#[ cfg( feature = "net" ) ]
1515pub use self :: datalink:: LinkAddr ;
16- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
16+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
1717pub use self :: vsock:: VsockAddr ;
1818use super :: sa_family_t;
1919use crate :: errno:: Errno ;
@@ -248,7 +248,7 @@ pub enum AddressFamily {
248248 #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
249249 Nfc = libc:: AF_NFC ,
250250 /// VMWare VSockets protocol for hypervisor-guest interaction.
251- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
251+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
252252 #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
253253 Vsock = libc:: AF_VSOCK ,
254254 /// ARPANet IMP addresses
@@ -443,7 +443,7 @@ impl AddressFamily {
443443 target_os = "openbsd"
444444 ) ) ]
445445 libc:: AF_LINK => Some ( AddressFamily :: Link ) ,
446- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
446+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
447447 libc:: AF_VSOCK => Some ( AddressFamily :: Vsock ) ,
448448 _ => None ,
449449 }
@@ -1286,7 +1286,7 @@ pub union SockaddrStorage {
12861286 sin6 : SockaddrIn6 ,
12871287 ss : libc:: sockaddr_storage ,
12881288 su : UnixAddr ,
1289- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1289+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
12901290 #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
12911291 vsock : VsockAddr ,
12921292}
@@ -1378,7 +1378,7 @@ impl SockaddrLike for SockaddrStorage {
13781378 libc:: AF_SYSTEM => {
13791379 SysControlAddr :: from_raw ( addr, l) . map ( |sctl| Self { sctl } )
13801380 }
1381- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1381+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
13821382 libc:: AF_VSOCK => {
13831383 VsockAddr :: from_raw ( addr, l) . map ( |vsock| Self { vsock } )
13841384 }
@@ -1554,7 +1554,7 @@ impl SockaddrStorage {
15541554 accessors ! { as_sys_control_addr, as_sys_control_addr_mut, SysControlAddr ,
15551555 AddressFamily :: System , libc:: sockaddr_ctl, sctl}
15561556
1557- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1557+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
15581558 #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
15591559 accessors ! { as_vsock_addr, as_vsock_addr_mut, VsockAddr ,
15601560 AddressFamily :: Vsock , libc:: sockaddr_vm, vsock}
@@ -1604,7 +1604,7 @@ impl fmt::Display for SockaddrStorage {
16041604 #[ cfg( feature = "ioctl" ) ]
16051605 libc:: AF_SYSTEM => self . sctl . fmt ( f) ,
16061606 libc:: AF_UNIX => self . su . fmt ( f) ,
1607- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1607+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
16081608 libc:: AF_VSOCK => self . vsock . fmt ( f) ,
16091609 _ => "<Address family unspecified>" . fmt ( f) ,
16101610 }
@@ -1678,7 +1678,7 @@ impl Hash for SockaddrStorage {
16781678 #[ cfg( feature = "ioctl" ) ]
16791679 libc:: AF_SYSTEM => self . sctl . hash ( s) ,
16801680 libc:: AF_UNIX => self . su . hash ( s) ,
1681- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1681+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
16821682 libc:: AF_VSOCK => self . vsock . hash ( s) ,
16831683 _ => self . ss . hash ( s) ,
16841684 }
@@ -1720,7 +1720,7 @@ impl PartialEq for SockaddrStorage {
17201720 #[ cfg( feature = "ioctl" ) ]
17211721 ( libc:: AF_SYSTEM , libc:: AF_SYSTEM ) => self . sctl == other. sctl ,
17221722 ( libc:: AF_UNIX , libc:: AF_UNIX ) => self . su == other. su ,
1723- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
1723+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
17241724 ( libc:: AF_VSOCK , libc:: AF_VSOCK ) => self . vsock == other. vsock ,
17251725 _ => false ,
17261726 }
@@ -2268,7 +2268,7 @@ mod datalink {
22682268 }
22692269}
22702270
2271- #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
2271+ #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "macos" ) ) ]
22722272#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
22732273pub mod vsock {
22742274 use super :: * ;
@@ -2314,20 +2314,33 @@ pub mod vsock {
23142314 }
23152315
23162316 impl PartialEq for VsockAddr {
2317+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
23172318 fn eq ( & self , other : & Self ) -> bool {
23182319 let ( inner, other) = ( self . 0 , other. 0 ) ;
23192320 ( inner. svm_family , inner. svm_cid , inner. svm_port )
23202321 == ( other. svm_family , other. svm_cid , other. svm_port )
23212322 }
2323+ #[ cfg( target_os = "macos" ) ]
2324+ fn eq ( & self , other : & Self ) -> bool {
2325+ let ( inner, other) = ( self . 0 , other. 0 ) ;
2326+ ( inner. svm_family , inner. svm_cid , inner. svm_port , inner. svm_len )
2327+ == ( other. svm_family , other. svm_cid , other. svm_port , inner. svm_len )
2328+ }
23222329 }
23232330
23242331 impl Eq for VsockAddr { }
23252332
23262333 impl Hash for VsockAddr {
2334+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
23272335 fn hash < H : Hasher > ( & self , s : & mut H ) {
23282336 let inner = self . 0 ;
23292337 ( inner. svm_family , inner. svm_cid , inner. svm_port ) . hash ( s) ;
23302338 }
2339+ #[ cfg( target_os = "macos" ) ]
2340+ fn hash < H : Hasher > ( & self , s : & mut H ) {
2341+ let inner = self . 0 ;
2342+ ( inner. svm_family , inner. svm_cid , inner. svm_port , inner. svm_len ) . hash ( s) ;
2343+ }
23312344 }
23322345
23332346 /// VSOCK Address
@@ -2342,6 +2355,10 @@ pub mod vsock {
23422355 addr. svm_cid = cid;
23432356 addr. svm_port = port;
23442357
2358+ #[ cfg( target_os = "macos" ) ]
2359+ {
2360+ addr. svm_len = std:: mem:: size_of :: < sockaddr_vm > ( ) as u8 ;
2361+ }
23452362 VsockAddr ( addr)
23462363 }
23472364
0 commit comments