Skip to content

Commit e656000

Browse files
committed
Add macos version of socketpair
1 parent 43be4ec commit e656000

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎rules/socket/tgt_refcount.rs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn t3() -> libcc2rs::SockaddrUn {
1515
Default::default()
1616
}
1717

18+
#[cfg(target_os = "linux")]
1819
fn f11(a0: i32, a1: i32, a2: i32, a3: Ptr<i32>) -> i32 {
1920
use nix::sys::socket::{AddressFamily, SockFlag, SockProtocol, SockType};
2021
let __out = a3.clone();
@@ -47,6 +48,34 @@ fn f11(a0: i32, a1: i32, a2: i32, a3: Ptr<i32>) -> i32 {
4748
}
4849
}
4950

51+
#[cfg(target_os = "macos")]
52+
fn f11(a0: i32, a1: i32, a2: i32, a3: Ptr<i32>) -> i32 {
53+
use nix::sys::socket::{AddressFamily, SockFlag, SockProtocol, SockType};
54+
let __out = a3.clone();
55+
match (AddressFamily::from_i32(a0), SockType::try_from(a1)) {
56+
(Some(__f), Ok(__t)) => {
57+
let __proto: Option<SockProtocol> = None;
58+
match nix::sys::socket::socketpair(__f, __t, __proto, SockFlag::empty()) {
59+
Ok((__a, __b)) => {
60+
__out.write(::std::os::fd::IntoRawFd::into_raw_fd(__a));
61+
__out
62+
.offset(1)
63+
.write(::std::os::fd::IntoRawFd::into_raw_fd(__b));
64+
0
65+
}
66+
Err(__e) => {
67+
libcc2rs::cpp2rust_errno().write(__e as i32);
68+
-1
69+
}
70+
}
71+
}
72+
_ => {
73+
libcc2rs::cpp2rust_errno().write(::libc::EINVAL);
74+
-1
75+
}
76+
}
77+
}
78+
5079
fn f9(a0: i32, a1: AnyPtr, a2: usize, a3: i32) -> isize {
5180
let __buf = a1.reinterpret_cast::<u8>();
5281
match __buf.with_slice_mut(a2, |__s| {

0 commit comments

Comments
 (0)