Skip to content

Commit 5234f34

Browse files
committed
add constants and structs for vsock on macos
1 parent 1e8c55c commit 5234f34

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ fn test_apple(target: &str) {
283283
"sys/uio.h",
284284
"sys/un.h",
285285
"sys/utsname.h",
286+
"sys/vsock.h",
286287
"sys/wait.h",
287288
"sys/xattr.h",
288289
"syslog.h",

src/unix/bsd/apple/mod.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,15 @@ s_no_extra_traits! {
13811381
pub struct os_unfair_lock_s {
13821382
_os_unfair_lock_opaque: u32,
13831383
}
1384+
1385+
#[cfg_attr(libc_packedN, repr(packed(1)))]
1386+
pub struct sockaddr_vm {
1387+
pub svm_len: ::c_uchar,
1388+
pub svm_family: ::sa_family_t,
1389+
pub svm_reserved1: ::c_ushort,
1390+
pub svm_port: ::c_uint,
1391+
pub svm_cid: ::c_uint,
1392+
}
13841393
}
13851394

13861395
impl siginfo_t {
@@ -2683,6 +2692,52 @@ cfg_if! {
26832692
self._os_unfair_lock_opaque.hash(state);
26842693
}
26852694
}
2695+
2696+
impl PartialEq for sockaddr_vm {
2697+
fn eq(&self, other: &sockaddr_vm) -> bool {
2698+
self.svm_len == other.svm_len
2699+
&& self.svm_family == other.svm_family
2700+
&& self.svm_reserved1 == other.svm_reserved1
2701+
&& self.svm_port == other.svm_port
2702+
&& self.svm_cid == other.svm_cid
2703+
}
2704+
}
2705+
2706+
impl Eq for sockaddr_vm {}
2707+
2708+
impl ::fmt::Debug for sockaddr_vm {
2709+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
2710+
let svm_len = self.svm_len;
2711+
let svm_family = self.svm_family;
2712+
let svm_reserved1 = self.svm_reserved1;
2713+
let svm_port = self.svm_port;
2714+
let svm_cid = self.svm_cid;
2715+
2716+
f.debug_struct("sockaddr_vm")
2717+
.field("svm_len",&svm_len)
2718+
.field("svm_family",&svm_family)
2719+
.field("svm_reserved1",&svm_reserved1)
2720+
.field("svm_port",&svm_port)
2721+
.field("svm_cid",&svm_cid)
2722+
.finish()
2723+
}
2724+
}
2725+
2726+
impl ::hash::Hash for sockaddr_vm {
2727+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
2728+
let svm_len = self.svm_len;
2729+
let svm_family = self.svm_family;
2730+
let svm_reserved1 = self.svm_reserved1;
2731+
let svm_port = self.svm_port;
2732+
let svm_cid = self.svm_cid;
2733+
2734+
svm_len.hash(state);
2735+
svm_family.hash(state);
2736+
svm_reserved1.hash(state);
2737+
svm_port.hash(state);
2738+
svm_cid.hash(state);
2739+
}
2740+
}
26862741
}
26872742
}
26882743

@@ -3644,6 +3699,9 @@ pub const AF_SYSTEM: ::c_int = 32;
36443699
pub const AF_NETBIOS: ::c_int = 33;
36453700
pub const AF_PPP: ::c_int = 34;
36463701
pub const pseudo_AF_HDRCMPLT: ::c_int = 35;
3702+
pub const AF_IEEE80211: ::c_int = 37;
3703+
pub const AF_UTUN: ::c_int = 38;
3704+
pub const AF_VSOCK: ::c_int = 40;
36473705
pub const AF_SYS_CONTROL: ::c_int = 2;
36483706

36493707
pub const SYSPROTO_EVENT: ::c_int = 1;
@@ -3685,6 +3743,7 @@ pub const PF_NATM: ::c_int = AF_NATM;
36853743
pub const PF_SYSTEM: ::c_int = AF_SYSTEM;
36863744
pub const PF_NETBIOS: ::c_int = AF_NETBIOS;
36873745
pub const PF_PPP: ::c_int = AF_PPP;
3746+
pub const PF_VSOCK: ::c_int = AF_VSOCK;
36883747

36893748
pub const NET_RT_DUMP: ::c_int = 1;
36903749
pub const NET_RT_FLAGS: ::c_int = 2;
@@ -5002,6 +5061,13 @@ pub const SSTOP: u32 = 4;
50025061
/// Awaiting collection by parent.
50035062
pub const SZOMB: u32 = 5;
50045063

5064+
// sys/vsock.h
5065+
pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF;
5066+
pub const VMADDR_CID_HYPERVISOR: ::c_uint = 0;
5067+
pub const VMADDR_CID_RESERVED: ::c_uint = 1;
5068+
pub const VMADDR_CID_HOST: ::c_uint = 2;
5069+
pub const VMADDR_PORT_ANY: ::c_uint = 0xFFFFFFFF;
5070+
50055071
cfg_if! {
50065072
if #[cfg(libc_const_extern_fn)] {
50075073
const fn __DARWIN_ALIGN32(p: usize) -> usize {

0 commit comments

Comments
 (0)