mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 21:13:44 +02:00
cleanup
This commit is contained in:
parent
c3466078bf
commit
54d6fba6c5
1 changed files with 2 additions and 96 deletions
|
@ -23,24 +23,6 @@ mod fast_int_memory_access {
|
|||
unsafe { *b.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i64_from_le_bytes(b: &[u8]) -> i64 {
|
||||
assert!(b.len() >= 8);
|
||||
unsafe { *b.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i32_from_le_bytes(b: &[u8]) -> i32 {
|
||||
assert!(b.len() >= 4);
|
||||
unsafe { *b.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i16_from_le_bytes(b: &[u8]) -> i16 {
|
||||
assert!(b.len() >= 2);
|
||||
unsafe { *b.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn u128_from_ne_bytes(b: &[u8]) -> u128 {
|
||||
assert!(b.len() >= 16);
|
||||
|
@ -65,24 +47,6 @@ mod fast_int_memory_access {
|
|||
unsafe { *b.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i64_from_ne_bytes(b: &[u8]) -> i64 {
|
||||
assert!(b.len() >= 8);
|
||||
unsafe { *b.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i32_from_ne_bytes(b: &[u8]) -> i32 {
|
||||
assert!(b.len() >= 4);
|
||||
unsafe { *b.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i16_from_ne_bytes(b: &[u8]) -> i16 {
|
||||
assert!(b.len() >= 2);
|
||||
unsafe { *b.as_ptr().cast() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn u64_from_be_bytes(b: &[u8]) -> u64 {
|
||||
assert!(b.len() >= 8);
|
||||
|
@ -100,24 +64,6 @@ mod fast_int_memory_access {
|
|||
assert!(b.len() >= 2);
|
||||
unsafe { *b.as_ptr().cast::<u16>() }.swap_bytes()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i64_from_be_bytes(b: &[u8]) -> i64 {
|
||||
assert!(b.len() >= 8);
|
||||
unsafe { *b.as_ptr().cast::<i64>() }.swap_bytes()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i32_from_be_bytes(b: &[u8]) -> i32 {
|
||||
assert!(b.len() >= 4);
|
||||
unsafe { *b.as_ptr().cast::<i32>() }.swap_bytes()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i16_from_be_bytes(b: &[u8]) -> i16 {
|
||||
assert!(b.len() >= 2);
|
||||
unsafe { *b.as_ptr().cast::<i16>() }.swap_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))]
|
||||
|
@ -139,18 +85,8 @@ mod fast_int_memory_access {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i64_from_le_bytes(b: &[u8]) -> i64 {
|
||||
i64::from_le_bytes(b[..8].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i32_from_le_bytes(b: &[u8]) -> i32 {
|
||||
i32::from_le_bytes(b[..4].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i16_from_le_bytes(b: &[u8]) -> i16 {
|
||||
i16::from_le_bytes(b[..2].try_into().unwrap())
|
||||
pub fn u128_from_ne_bytes(b: &[u8]) -> u64 {
|
||||
u128::from_ne_bytes(b[..16].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -168,21 +104,6 @@ mod fast_int_memory_access {
|
|||
u16::from_ne_bytes(b[..2].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i64_from_ne_bytes(b: &[u8]) -> i64 {
|
||||
i64::from_ne_bytes(b[..8].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i32_from_ne_bytes(b: &[u8]) -> i32 {
|
||||
i32::from_ne_bytes(b[..4].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i16_from_ne_bytes(b: &[u8]) -> i16 {
|
||||
i16::from_ne_bytes(b[..2].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn u64_from_be_bytes(b: &[u8]) -> u64 {
|
||||
u64::from_be_bytes(b[..8].try_into().unwrap())
|
||||
|
@ -197,21 +118,6 @@ mod fast_int_memory_access {
|
|||
pub fn u16_from_be_bytes(b: &[u8]) -> u16 {
|
||||
u16::from_be_bytes(b[..2].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i64_from_be_bytes(b: &[u8]) -> i64 {
|
||||
i64::from_be_bytes(b[..8].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i32_from_be_bytes(b: &[u8]) -> i32 {
|
||||
i32::from_be_bytes(b[..4].try_into().unwrap())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn i16_from_be_bytes(b: &[u8]) -> i16 {
|
||||
i16::from_be_bytes(b[..2].try_into().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
pub use fast_int_memory_access::*;
|
||||
|
|
Loading…
Add table
Reference in a new issue