Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise network definitions for HorizonOS #3863

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/unix/newlib/horizon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ pub type sbintime_t = ::c_longlong;
pub type sigset_t = ::c_ulong;

s! {
pub struct hostent {
pub h_name: *mut ::c_char,
pub h_aliases: *mut *mut ::c_char,
pub h_addrtype: u16,
pub h_length: u16,
pub h_addr_list: *mut *mut ::c_char,
}

pub struct sockaddr {
pub sa_family: ::sa_family_t,
pub sa_data: [::c_char; 26usize],
Expand All @@ -35,6 +43,7 @@ s! {
pub sin_family: ::sa_family_t,
pub sin_port: ::in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [::c_char; 8],
}

pub struct sockaddr_in6 {
Expand Down
26 changes: 16 additions & 10 deletions src/unix/newlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ cfg_if! {
}
}

cfg_if! {
if #[cfg(not(target_os = "horizon"))] {
s!{
pub struct hostent {
pub h_name: *mut ::c_char,
pub h_aliases: *mut *mut ::c_char,
pub h_addrtype: ::c_int,
pub h_length: ::c_int,
pub h_addr_list: *mut *mut ::c_char,
pub h_addr: *mut ::c_char,
}
}
}
}

s! {
// The order of the `ai_addr` field in this struct is crucial
// for converting between the Rust and C types.
Expand Down Expand Up @@ -87,16 +102,7 @@ s! {
}

pub struct in_addr {
pub s_addr: ::in_addr_t,
}

pub struct hostent {
pub h_name: *mut ::c_char,
pub h_aliases: *mut *mut ::c_char,
pub h_addrtype: ::c_int,
pub h_length: ::c_int,
pub h_addr_list: *mut *mut ::c_char,
pub h_addr: *mut ::c_char,
pub s_addr: ::in_addr_t,
}

pub struct pollfd {
Expand Down