From 54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Mon, 14 Apr 2014 20:04:14 +1000 Subject: Use the unsigned integer types for bitwise intrinsics. Exposing ctpop, ctlz, cttz and bswap as taking signed i8/i16/... is just exposing the internal LLVM names pointlessly (LLVM doesn't have "signed integers" or "unsigned integers", it just has sized integer types with (un)signed *operations*). These operations are semantically working with raw bytes, which the unsigned types model better. --- src/libnative/io/net.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libnative') diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index cef6a247a00..2e64b82a84a 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -26,10 +26,10 @@ use super::{IoResult, retry, keep_going}; #[cfg(unix)] pub type sock_t = super::file::fd_t; pub fn htons(u: u16) -> u16 { - mem::to_be16(u as i16) as u16 + mem::to_be16(u) } pub fn ntohs(u: u16) -> u16 { - mem::from_be16(u as i16) as u16 + mem::from_be16(u) } enum InAddr { -- cgit 1.4.1-3-g733a5