diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-14 20:04:14 +1000 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-04-15 19:45:00 -0700 |
| commit | 54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d (patch) | |
| tree | efe91e930ac4527e3057fe65571df112ef5b8607 /src/libnative | |
| parent | 93dc55518840ee3cbd570c0d85aa7a445752af8b (diff) | |
| download | rust-54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d.tar.gz rust-54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d.zip | |
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.
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/net.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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 { |
