Skip to content

Commit 19d8ab8

Browse files
committed
libnative: Use [from|to]_be16 instead of bswap16
1 parent 3abc633 commit 19d8ab8

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/libnative/io/net.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@ use super::file::keep_going;
2626
#[cfg(windows)] pub type sock_t = libc::SOCKET;
2727
#[cfg(unix)] pub type sock_t = super::file::fd_t;
2828

29-
#[cfg(target_endian = "big")] pub fn htons(x: u16) -> u16 { x }
30-
#[cfg(target_endian = "big")] pub fn ntohs(x: u16) -> u16 { x }
31-
#[cfg(target_endian = "little")]
3229
pub fn htons(u: u16) -> u16 {
33-
unsafe { intrinsics::bswap16(u as i16) as u16 }
30+
intrinsics::to_be16(u as i16) as u16
3431
}
35-
#[cfg(target_endian = "little")]
3632
pub fn ntohs(u: u16) -> u16 {
37-
unsafe { intrinsics::bswap16(u as i16) as u16 }
33+
intrinsics::from_be16(u as i16) as u16
3834
}
3935

4036
enum InAddr {

0 commit comments

Comments
 (0)