aboutsummaryrefslogtreecommitdiff
path: root/vendor/half/src/leading_zeros.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/half/src/leading_zeros.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/half/src/leading_zeros.rs')
-rw-r--r--vendor/half/src/leading_zeros.rs62
1 files changed, 0 insertions, 62 deletions
diff --git a/vendor/half/src/leading_zeros.rs b/vendor/half/src/leading_zeros.rs
deleted file mode 100644
index 6c73148..0000000
--- a/vendor/half/src/leading_zeros.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-// https://doc.rust-lang.org/std/primitive.u16.html#method.leading_zeros
-
-#[cfg(not(any(all(
- target_arch = "spirv",
- not(all(
- target_feature = "IntegerFunctions2INTEL",
- target_feature = "SPV_INTEL_shader_integer_functions2"
- ))
-))))]
-pub(crate) const fn leading_zeros_u16(x: u16) -> u32 {
- x.leading_zeros()
-}
-
-#[cfg(all(
- target_arch = "spirv",
- not(all(
- target_feature = "IntegerFunctions2INTEL",
- target_feature = "SPV_INTEL_shader_integer_functions2"
- ))
-))]
-pub(crate) const fn leading_zeros_u16(x: u16) -> u32 {
- leading_zeros_u16_fallback(x)
-}
-
-#[cfg(any(
- test,
- all(
- target_arch = "spirv",
- not(all(
- target_feature = "IntegerFunctions2INTEL",
- target_feature = "SPV_INTEL_shader_integer_functions2"
- ))
- )
-))]
-const fn leading_zeros_u16_fallback(mut x: u16) -> u32 {
- use crunchy::unroll;
- let mut c = 0;
- let msb = 1 << 15;
- unroll! { for i in 0 .. 16 {
- if x & msb == 0 {
- c += 1;
- } else {
- return c;
- }
- #[allow(unused_assignments)]
- if i < 15 {
- x <<= 1;
- }
- }}
- c
-}
-
-#[cfg(test)]
-mod test {
-
- #[test]
- fn leading_zeros_u16_fallback() {
- for x in [44, 97, 304, 1179, 23571] {
- assert_eq!(super::leading_zeros_u16_fallback(x), x.leading_zeros());
- }
- }
-}