Skip to content

Commit

Permalink
libnative: Use [from|to]_be16 instead of bswap16
Browse files Browse the repository at this point in the history
  • Loading branch information
c-a committed Jan 1, 2014
1 parent 3abc633 commit 19d8ab8
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libnative/io/net.rs
Expand Up @@ -26,15 +26,11 @@ use super::file::keep_going;
#[cfg(windows)] pub type sock_t = libc::SOCKET;
#[cfg(unix)] pub type sock_t = super::file::fd_t;

#[cfg(target_endian = "big")] pub fn htons(x: u16) -> u16 { x }
#[cfg(target_endian = "big")] pub fn ntohs(x: u16) -> u16 { x }
#[cfg(target_endian = "little")]
pub fn htons(u: u16) -> u16 {
unsafe { intrinsics::bswap16(u as i16) as u16 }
intrinsics::to_be16(u as i16) as u16
}
#[cfg(target_endian = "little")]
pub fn ntohs(u: u16) -> u16 {
unsafe { intrinsics::bswap16(u as i16) as u16 }
intrinsics::from_be16(u as i16) as u16
}

enum InAddr {
Expand Down

0 comments on commit 19d8ab8

Please sign in to comment.