Skip to content

Commit 6761f3c

Browse files
Andrea CilibertiMeziu
Andrea Ciliberti
authored andcommitted
Fixed conditional programming lint
1 parent 43366e0 commit 6761f3c

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/unix/newlib/horizon/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,6 @@ extern "C" {
190190
f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void,
191191
value: *mut ::c_void,
192192
) -> ::c_int;
193+
194+
pub fn gethostid() -> ::c_long;
193195
}

src/unix/newlib/mod.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ pub type off_t = i64;
1515
pub type pthread_t = ::c_ulong;
1616
pub type pthread_key_t = ::c_uint;
1717
pub type rlim_t = u32;
18-
#[cfg(not(target_os = "horizon"))]
19-
pub type sa_family_t = u8;
20-
#[cfg(target_os = "horizon")]
21-
pub type sa_family_t = u16;
18+
19+
cfg_if! {
20+
if #[cfg(target_os = "horizon")] {
21+
pub type sa_family_t = u16;
22+
} else {
23+
pub type sa_family_t = u8;
24+
}
25+
}
26+
2227
pub type socklen_t = u32;
2328
pub type speed_t = u32;
2429
pub type suseconds_t = i32;
@@ -480,10 +485,13 @@ pub const SO_SNDLOWAT: ::c_int = 0x1003;
480485
pub const SO_RCVLOWAT: ::c_int = 0x1004;
481486
pub const SO_SNDTIMEO: ::c_int = 0x1005;
482487
pub const SO_RCVTIMEO: ::c_int = 0x1006;
483-
#[cfg(not(target_os = "horizon"))]
484-
pub const SO_ERROR: ::c_int = 0x1007;
485-
#[cfg(target_os = "horizon")]
486-
pub const SO_ERROR: ::c_int = 0x1009;
488+
cfg_if! {
489+
if #[cfg(target_os = "horizon")] {
490+
pub const SO_ERROR: ::c_int = 0x1009;
491+
} else {
492+
pub const SO_ERROR: ::c_int = 0x1007;
493+
}
494+
}
487495
pub const SO_TYPE: ::c_int = 0x1008;
488496

489497
pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
@@ -518,10 +526,13 @@ pub const TCP_KEEPIDLE: ::c_int = 256;
518526
pub const TCP_KEEPINTVL: ::c_int = 512;
519527
pub const TCP_KEEPCNT: ::c_int = 1024;
520528

521-
#[cfg(not(target_os = "horizon"))]
522-
pub const IP_TOS: ::c_int = 3;
523-
#[cfg(target_os = "horizon")]
524-
pub const IP_TOS: ::c_int = 7;
529+
cfg_if! {
530+
if #[cfg(target_os = "horizon")] {
531+
pub const IP_TOS: ::c_int = 7;
532+
} else {
533+
pub const IP_TOS: ::c_int = 3;
534+
}
535+
}
525536
pub const IP_TTL: ::c_int = 8;
526537
pub const IP_MULTICAST_IF: ::c_int = 9;
527538
pub const IP_MULTICAST_TTL: ::c_int = 10;

0 commit comments

Comments
 (0)