Skip to content

Commit c4a9d8a

Browse files
committed
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.
1 parent 168b2d1 commit c4a9d8a

File tree

15 files changed

+238
-219
lines changed

15 files changed

+238
-219
lines changed

src/libnative/io/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ use super::{IoResult, retry, keep_going};
2626
#[cfg(unix)] pub type sock_t = super::file::fd_t;
2727

2828
pub fn htons(u: u16) -> u16 {
29-
mem::to_be16(u as i16) as u16
29+
mem::to_be16(u)
3030
}
3131
pub fn ntohs(u: u16) -> u16 {
32-
mem::from_be16(u as i16) as u16
32+
mem::from_be16(u)
3333
}
3434

3535
enum InAddr {

src/librustc/middle/typeck/check/mod.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4143,21 +4143,21 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
41434143
"nearbyintf64" => (0, vec!( ty::mk_f64() ), ty::mk_f64()),
41444144
"roundf32" => (0, vec!( ty::mk_f32() ), ty::mk_f32()),
41454145
"roundf64" => (0, vec!( ty::mk_f64() ), ty::mk_f64()),
4146-
"ctpop8" => (0, vec!( ty::mk_i8() ), ty::mk_i8()),
4147-
"ctpop16" => (0, vec!( ty::mk_i16() ), ty::mk_i16()),
4148-
"ctpop32" => (0, vec!( ty::mk_i32() ), ty::mk_i32()),
4149-
"ctpop64" => (0, vec!( ty::mk_i64() ), ty::mk_i64()),
4150-
"ctlz8" => (0, vec!( ty::mk_i8() ), ty::mk_i8()),
4151-
"ctlz16" => (0, vec!( ty::mk_i16() ), ty::mk_i16()),
4152-
"ctlz32" => (0, vec!( ty::mk_i32() ), ty::mk_i32()),
4153-
"ctlz64" => (0, vec!( ty::mk_i64() ), ty::mk_i64()),
4154-
"cttz8" => (0, vec!( ty::mk_i8() ), ty::mk_i8()),
4155-
"cttz16" => (0, vec!( ty::mk_i16() ), ty::mk_i16()),
4156-
"cttz32" => (0, vec!( ty::mk_i32() ), ty::mk_i32()),
4157-
"cttz64" => (0, vec!( ty::mk_i64() ), ty::mk_i64()),
4158-
"bswap16" => (0, vec!( ty::mk_i16() ), ty::mk_i16()),
4159-
"bswap32" => (0, vec!( ty::mk_i32() ), ty::mk_i32()),
4160-
"bswap64" => (0, vec!( ty::mk_i64() ), ty::mk_i64()),
4146+
"ctpop8" => (0, vec!( ty::mk_u8() ), ty::mk_u8()),
4147+
"ctpop16" => (0, vec!( ty::mk_u16() ), ty::mk_u16()),
4148+
"ctpop32" => (0, vec!( ty::mk_u32() ), ty::mk_u32()),
4149+
"ctpop64" => (0, vec!( ty::mk_u64() ), ty::mk_u64()),
4150+
"ctlz8" => (0, vec!( ty::mk_u8() ), ty::mk_u8()),
4151+
"ctlz16" => (0, vec!( ty::mk_u16() ), ty::mk_u16()),
4152+
"ctlz32" => (0, vec!( ty::mk_u32() ), ty::mk_u32()),
4153+
"ctlz64" => (0, vec!( ty::mk_u64() ), ty::mk_u64()),
4154+
"cttz8" => (0, vec!( ty::mk_u8() ), ty::mk_u8()),
4155+
"cttz16" => (0, vec!( ty::mk_u16() ), ty::mk_u16()),
4156+
"cttz32" => (0, vec!( ty::mk_u32() ), ty::mk_u32()),
4157+
"cttz64" => (0, vec!( ty::mk_u64() ), ty::mk_u64()),
4158+
"bswap16" => (0, vec!( ty::mk_u16() ), ty::mk_u16()),
4159+
"bswap32" => (0, vec!( ty::mk_u32() ), ty::mk_u32()),
4160+
"bswap64" => (0, vec!( ty::mk_u64() ), ty::mk_u64()),
41614161

41624162
"volatile_load" =>
41634163
(1, vec!( ty::mk_imm_ptr(tcx, param(ccx, 0)) ), param(ccx, 0)),

src/librustc/util/sha2.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,21 @@ use serialize::hex::ToHex;
2020
/// Write a u32 into a vector, which must be 4 bytes long. The value is written in big-endian
2121
/// format.
2222
fn write_u32_be(dst: &mut[u8], input: u32) {
23-
use std::cast::transmute;
2423
use std::mem::to_be32;
2524
assert!(dst.len() == 4);
2625
unsafe {
27-
let x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
28-
*x = to_be32(input as i32);
26+
let x = dst.unsafe_mut_ref(0) as *mut _ as *mut u32;
27+
*x = to_be32(input);
2928
}
3029
}
3130

3231
/// Read a vector of bytes into a vector of u32s. The values are read in big-endian format.
3332
fn read_u32v_be(dst: &mut[u32], input: &[u8]) {
34-
use std::cast::transmute;
3533
use std::mem::to_be32;
3634
assert!(dst.len() * 4 == input.len());
3735
unsafe {
38-
let mut x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
39-
let mut y: *i32 = transmute(input.unsafe_ref(0));
36+
let mut x = dst.unsafe_mut_ref(0) as *mut _ as *mut u32;
37+
let mut y = input.unsafe_ref(0) as *_ as *u32;
4038
for _ in range(0, dst.len()) {
4139
*x = to_be32(*y);
4240
x = x.offset(1);

src/librustuv/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use uvll;
3232
/// Generic functions related to dealing with sockaddr things
3333
////////////////////////////////////////////////////////////////////////////////
3434

35-
pub fn htons(u: u16) -> u16 { mem::to_be16(u as i16) as u16 }
36-
pub fn ntohs(u: u16) -> u16 { mem::from_be16(u as i16) as u16 }
35+
pub fn htons(u: u16) -> u16 { mem::to_be16(u) }
36+
pub fn ntohs(u: u16) -> u16 { mem::from_be16(u) }
3737

3838
pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
3939
len: uint) -> ip::SocketAddr {

src/libserialize/ebml.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ pub mod reader {
179179
];
180180

181181
unsafe {
182-
let ptr = data.as_ptr().offset(start as int) as *i32;
183-
let val = from_be32(*ptr) as u32;
182+
let ptr = data.as_ptr().offset(start as int) as *u32;
183+
let val = from_be32(*ptr);
184184

185185
let i = (val >> 28u) as uint;
186186
let (shift, mask) = SHIFT_MASK_TABLE[i];

src/libstd/intrinsics.rs

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -394,26 +394,50 @@ extern "rust-intrinsic" {
394394

395395
pub fn roundf32(x: f32) -> f32;
396396
pub fn roundf64(x: f64) -> f64;
397+
}
398+
#[cfg(not(stage0))]
399+
extern "rust-intrinsic" {
400+
pub fn ctpop8(x: u8) -> u8;
401+
pub fn ctpop16(x: u16) -> u16;
402+
pub fn ctpop32(x: u32) -> u32;
403+
pub fn ctpop64(x: u64) -> u64;
404+
405+
pub fn ctlz8(x: u8) -> u8;
406+
pub fn ctlz16(x: u16) -> u16;
407+
pub fn ctlz32(x: u32) -> u32;
408+
pub fn ctlz64(x: u64) -> u64;
409+
410+
pub fn cttz8(x: u8) -> u8;
411+
pub fn cttz16(x: u16) -> u16;
412+
pub fn cttz32(x: u32) -> u32;
413+
pub fn cttz64(x: u64) -> u64;
414+
415+
pub fn bswap16(x: u16) -> u16;
416+
pub fn bswap32(x: u32) -> u32;
417+
pub fn bswap64(x: u64) -> u64;
418+
}
397419

398-
pub fn ctpop8(x: i8) -> i8;
399-
pub fn ctpop16(x: i16) -> i16;
400-
pub fn ctpop32(x: i32) -> i32;
401-
pub fn ctpop64(x: i64) -> i64;
402-
403-
pub fn ctlz8(x: i8) -> i8;
404-
pub fn ctlz16(x: i16) -> i16;
405-
pub fn ctlz32(x: i32) -> i32;
406-
pub fn ctlz64(x: i64) -> i64;
407-
408-
pub fn cttz8(x: i8) -> i8;
409-
pub fn cttz16(x: i16) -> i16;
410-
pub fn cttz32(x: i32) -> i32;
411-
pub fn cttz64(x: i64) -> i64;
412-
413-
pub fn bswap16(x: i16) -> i16;
414-
pub fn bswap32(x: i32) -> i32;
415-
pub fn bswap64(x: i64) -> i64;
420+
// NOTE: remove this after a snap, and merge the extern block above
421+
macro_rules! stage0_hack {
422+
($( $u_ty:ty, $i_ty:ty => $($name:ident),*);*) => {
423+
$(
424+
$(
425+
#[cfg(stage0)]
426+
pub unsafe fn $name(x: $u_ty) -> $u_ty {
427+
extern "rust-intrinsic" { fn $name(x: $i_ty) -> $i_ty; }
428+
$name(x as $i_ty) as $u_ty
429+
}
430+
)*)*
431+
}
432+
}
433+
stage0_hack! {
434+
u8, i8 => ctpop8, ctlz8, cttz8;
435+
u16, i16 => ctpop16, ctlz16, cttz16, bswap16;
436+
u32, i32 => ctpop32, ctlz32, cttz32, bswap32;
437+
u64, i64 => ctpop64, ctlz64, cttz64, bswap64
438+
}
416439

440+
extern "rust-intrinsic" {
417441
pub fn i8_add_with_overflow(x: i8, y: i8) -> (i8, bool);
418442
pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool);
419443
pub fn i32_add_with_overflow(x: i32, y: i32) -> (i32, bool);

src/libstd/io/extensions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
8383
assert!(size <= 8u);
8484
match size {
8585
1u => f(&[n as u8]),
86-
2u => f(unsafe { transmute::<i16, [u8, ..2]>(to_le16(n as i16)) }),
87-
4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_le32(n as i32)) }),
88-
8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_le64(n as i64)) }),
86+
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_le16(n as u16)) }),
87+
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_le32(n as u32)) }),
88+
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_le64(n)) }),
8989
_ => {
9090

9191
let mut bytes = vec!();
@@ -123,9 +123,9 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
123123
assert!(size <= 8u);
124124
match size {
125125
1u => f(&[n as u8]),
126-
2u => f(unsafe { transmute::<i16, [u8, ..2]>(to_be16(n as i16)) }),
127-
4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_be32(n as i32)) }),
128-
8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_be64(n as i64)) }),
126+
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_be16(n as u16)) }),
127+
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_be32(n as u32)) }),
128+
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_be64(n)) }),
129129
_ => {
130130
let mut bytes = vec!();
131131
let mut i = size;
@@ -166,7 +166,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
166166
let ptr = data.as_ptr().offset(start as int);
167167
let out = buf.as_mut_ptr();
168168
copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size);
169-
from_be64(*(out as *i64)) as u64
169+
from_be64(*(out as *u64))
170170
}
171171
}
172172

src/libstd/mem.rs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -99,128 +99,128 @@ pub unsafe fn move_val_init<T>(dst: &mut T, src: T) {
9999
intrinsics::move_val_init(dst, src)
100100
}
101101

102-
/// Convert an i16 to little endian from the target's endianness.
102+
/// Convert an u16 to little endian from the target's endianness.
103103
///
104104
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
105-
#[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: i16) -> i16 { x }
105+
#[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: u16) -> u16 { x }
106106

107-
/// Convert an i16 to little endian from the target's endianness.
107+
/// Convert an u16 to little endian from the target's endianness.
108108
///
109109
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
110-
#[cfg(target_endian = "big")] #[inline] pub fn to_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
110+
#[cfg(target_endian = "big")] #[inline] pub fn to_le16(x: u16) -> u16 { unsafe { bswap16(x) } }
111111

112-
/// Convert an i32 to little endian from the target's endianness.
112+
/// Convert an u32 to little endian from the target's endianness.
113113
///
114114
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
115-
#[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: i32) -> i32 { x }
115+
#[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: u32) -> u32 { x }
116116

117-
/// Convert an i32 to little endian from the target's endianness.
117+
/// Convert an u32 to little endian from the target's endianness.
118118
///
119119
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
120-
#[cfg(target_endian = "big")] #[inline] pub fn to_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
120+
#[cfg(target_endian = "big")] #[inline] pub fn to_le32(x: u32) -> u32 { unsafe { bswap32(x) } }
121121

122-
/// Convert an i64 to little endian from the target's endianness.
122+
/// Convert an u64 to little endian from the target's endianness.
123123
///
124124
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
125-
#[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: i64) -> i64 { x }
125+
#[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: u64) -> u64 { x }
126126

127-
/// Convert an i64 to little endian from the target's endianness.
127+
/// Convert an u64 to little endian from the target's endianness.
128128
///
129129
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
130-
#[cfg(target_endian = "big")] #[inline] pub fn to_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
130+
#[cfg(target_endian = "big")] #[inline] pub fn to_le64(x: u64) -> u64 { unsafe { bswap64(x) } }
131131

132132

133-
/// Convert an i16 to big endian from the target's endianness.
133+
/// Convert an u16 to big endian from the target's endianness.
134134
///
135135
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
136-
#[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
136+
#[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: u16) -> u16 { unsafe { bswap16(x) } }
137137

138-
/// Convert an i16 to big endian from the target's endianness.
138+
/// Convert an u16 to big endian from the target's endianness.
139139
///
140140
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
141-
#[cfg(target_endian = "big")] #[inline] pub fn to_be16(x: i16) -> i16 { x }
141+
#[cfg(target_endian = "big")] #[inline] pub fn to_be16(x: u16) -> u16 { x }
142142

143-
/// Convert an i32 to big endian from the target's endianness.
143+
/// Convert an u32 to big endian from the target's endianness.
144144
///
145145
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
146-
#[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
146+
#[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: u32) -> u32 { unsafe { bswap32(x) } }
147147

148-
/// Convert an i32 to big endian from the target's endianness.
148+
/// Convert an u32 to big endian from the target's endianness.
149149
///
150150
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
151-
#[cfg(target_endian = "big")] #[inline] pub fn to_be32(x: i32) -> i32 { x }
151+
#[cfg(target_endian = "big")] #[inline] pub fn to_be32(x: u32) -> u32 { x }
152152

153-
/// Convert an i64 to big endian from the target's endianness.
153+
/// Convert an u64 to big endian from the target's endianness.
154154
///
155155
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
156-
#[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
156+
#[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: u64) -> u64 { unsafe { bswap64(x) } }
157157

158-
/// Convert an i64 to big endian from the target's endianness.
158+
/// Convert an u64 to big endian from the target's endianness.
159159
///
160160
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
161-
#[cfg(target_endian = "big")] #[inline] pub fn to_be64(x: i64) -> i64 { x }
161+
#[cfg(target_endian = "big")] #[inline] pub fn to_be64(x: u64) -> u64 { x }
162162

163163

164-
/// Convert an i16 from little endian to the target's endianness.
164+
/// Convert an u16 from little endian to the target's endianness.
165165
///
166166
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
167-
#[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: i16) -> i16 { x }
167+
#[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: u16) -> u16 { x }
168168

169-
/// Convert an i16 from little endian to the target's endianness.
169+
/// Convert an u16 from little endian to the target's endianness.
170170
///
171171
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
172-
#[cfg(target_endian = "big")] #[inline] pub fn from_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
172+
#[cfg(target_endian = "big")] #[inline] pub fn from_le16(x: u16) -> u16 { unsafe { bswap16(x) } }
173173

174-
/// Convert an i32 from little endian to the target's endianness.
174+
/// Convert an u32 from little endian to the target's endianness.
175175
///
176176
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
177-
#[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: i32) -> i32 { x }
177+
#[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: u32) -> u32 { x }
178178

179-
/// Convert an i32 from little endian to the target's endianness.
179+
/// Convert an u32 from little endian to the target's endianness.
180180
///
181181
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
182-
#[cfg(target_endian = "big")] #[inline] pub fn from_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
182+
#[cfg(target_endian = "big")] #[inline] pub fn from_le32(x: u32) -> u32 { unsafe { bswap32(x) } }
183183

184-
/// Convert an i64 from little endian to the target's endianness.
184+
/// Convert an u64 from little endian to the target's endianness.
185185
///
186186
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
187-
#[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: i64) -> i64 { x }
187+
#[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: u64) -> u64 { x }
188188

189-
/// Convert an i64 from little endian to the target's endianness.
189+
/// Convert an u64 from little endian to the target's endianness.
190190
///
191191
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
192-
#[cfg(target_endian = "big")] #[inline] pub fn from_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
192+
#[cfg(target_endian = "big")] #[inline] pub fn from_le64(x: u64) -> u64 { unsafe { bswap64(x) } }
193193

194194

195-
/// Convert an i16 from big endian to the target's endianness.
195+
/// Convert an u16 from big endian to the target's endianness.
196196
///
197197
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
198-
#[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
198+
#[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: u16) -> u16 { unsafe { bswap16(x) } }
199199

200-
/// Convert an i16 from big endian to the target's endianness.
200+
/// Convert an u16 from big endian to the target's endianness.
201201
///
202202
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
203-
#[cfg(target_endian = "big")] #[inline] pub fn from_be16(x: i16) -> i16 { x }
203+
#[cfg(target_endian = "big")] #[inline] pub fn from_be16(x: u16) -> u16 { x }
204204

205-
/// Convert an i32 from big endian to the target's endianness.
205+
/// Convert an u32 from big endian to the target's endianness.
206206
///
207207
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
208-
#[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
208+
#[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: u32) -> u32 { unsafe { bswap32(x) } }
209209

210-
/// Convert an i32 from big endian to the target's endianness.
210+
/// Convert an u32 from big endian to the target's endianness.
211211
///
212212
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
213-
#[cfg(target_endian = "big")] #[inline] pub fn from_be32(x: i32) -> i32 { x }
213+
#[cfg(target_endian = "big")] #[inline] pub fn from_be32(x: u32) -> u32 { x }
214214

215-
/// Convert an i64 from big endian to the target's endianness.
215+
/// Convert an u64 from big endian to the target's endianness.
216216
///
217217
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
218-
#[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
218+
#[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: u64) -> u64 { unsafe { bswap64(x) } }
219219

220-
/// Convert an i64 from big endian to the target's endianness.
220+
/// Convert an u64 from big endian to the target's endianness.
221221
///
222222
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
223-
#[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: i64) -> i64 { x }
223+
#[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: u64) -> u64 { x }
224224

225225

226226
/**

0 commit comments

Comments
 (0)