Skip to content

Commit

Permalink
Fixed conditional programming lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Ciliberti authored and Meziu committed Dec 28, 2021
1 parent 43366e0 commit b3363cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/unix/newlib/horizon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ s! {

pub struct sockaddr_storage {
pub ss_family: ::sa_family_t,
pub __ss_padding: [c_char; 26usize],
pub __ss_padding: [::c_char; 26usize],
}

pub struct sockaddr_in {
pub sin_family: ::sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [::c_uchar; 8usize],
}

pub struct sockaddr_in6 {
Expand Down Expand Up @@ -190,4 +189,6 @@ extern "C" {
f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void,
value: *mut ::c_void,
) -> ::c_int;

pub fn gethostid() -> ::c_long;
}
35 changes: 23 additions & 12 deletions src/unix/newlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ pub type off_t = i64;
pub type pthread_t = ::c_ulong;
pub type pthread_key_t = ::c_uint;
pub type rlim_t = u32;
#[cfg(not(target_os = "horizon"))]
pub type sa_family_t = u8;
#[cfg(target_os = "horizon")]
pub type sa_family_t = u16;

cfg_if! {
if #[cfg(target_os = "horizon")] {
pub type sa_family_t = u16;
} else {
pub type sa_family_t = u8;
}
}

pub type socklen_t = u32;
pub type speed_t = u32;
pub type suseconds_t = i32;
Expand Down Expand Up @@ -480,10 +485,13 @@ pub const SO_SNDLOWAT: ::c_int = 0x1003;
pub const SO_RCVLOWAT: ::c_int = 0x1004;
pub const SO_SNDTIMEO: ::c_int = 0x1005;
pub const SO_RCVTIMEO: ::c_int = 0x1006;
#[cfg(not(target_os = "horizon"))]
pub const SO_ERROR: ::c_int = 0x1007;
#[cfg(target_os = "horizon")]
pub const SO_ERROR: ::c_int = 0x1009;
cfg_if! {
if #[cfg(target_os = "horizon")] {
pub const SO_ERROR: ::c_int = 0x1009;
} else {
pub const SO_ERROR: ::c_int = 0x1007;
}
}
pub const SO_TYPE: ::c_int = 0x1008;

pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
Expand Down Expand Up @@ -518,10 +526,13 @@ pub const TCP_KEEPIDLE: ::c_int = 256;
pub const TCP_KEEPINTVL: ::c_int = 512;
pub const TCP_KEEPCNT: ::c_int = 1024;

#[cfg(not(target_os = "horizon"))]
pub const IP_TOS: ::c_int = 3;
#[cfg(target_os = "horizon")]
pub const IP_TOS: ::c_int = 7;
cfg_if! {
if #[cfg(target_os = "horizon")] {
pub const IP_TOS: ::c_int = 7;
} else {
pub const IP_TOS: ::c_int = 3;
}
}
pub const IP_TTL: ::c_int = 8;
pub const IP_MULTICAST_IF: ::c_int = 9;
pub const IP_MULTICAST_TTL: ::c_int = 10;
Expand Down

0 comments on commit b3363cd

Please sign in to comment.