about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorCarl-Anton Ingmarsson <mail@carlanton.se>2014-01-01 19:04:35 +0100
committerCarl-Anton Ingmarsson <mail@carlanton.se>2014-01-01 22:27:49 +0100
commit19d8ab8d5a311e502a55189d2a34858f8413fbef (patch)
tree1e0b152932895eeae4bcb2a2a834e06e8372ae19 /src/libnative
parent3abc63365895aff78815ea7b57374486f91daebd (diff)
libnative: Use [from|to]_be16 instead of bswap16
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/net.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs
index 6736641c858..241a69ad4e6 100644
--- a/src/libnative/io/net.rs
+++ b/src/libnative/io/net.rs
@@ -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 {