Skip to content

Commit

Permalink
Separate HorizonOS hostent from newlib module
Browse files Browse the repository at this point in the history
  • Loading branch information
Meziu committed Sep 1, 2024
1 parent b3207ad commit 91d0de1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
8 changes: 8 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 Down
35 changes: 15 additions & 20 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 @@ -90,26 +105,6 @@ s! {
pub s_addr: ::in_addr_t,
}

pub struct hostent {
pub h_name: *mut ::c_char,
pub h_aliases: *mut *mut ::c_char,

#[cfg(not(target_os = "horizon"))]
pub h_addrtype: ::c_int,
#[cfg(target_os = "horizon")]
pub h_addrtype: u16,

#[cfg(not(target_os = "horizon"))]
pub h_length: ::c_int,
#[cfg(target_os = "horizon")]
pub h_length: u16,

pub h_addr_list: *mut *mut ::c_char,

#[cfg(not(target_os = "horizon"))]
pub h_addr: *mut ::c_char,
}

pub struct pollfd {
pub fd: ::c_int,
pub events: ::c_int,
Expand Down

0 comments on commit 91d0de1

Please sign in to comment.