summaryrefslogtreecommitdiffstats
path: root/src/common/bit_util.h
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-03-16 03:50:57 +0100
committerFernandoS27 <fsahmkow27@gmail.com>2019-03-27 19:33:44 +0100
commit522957f9f302b9521507a365da5871849a03594d (patch)
tree6d5d9626cb3b5e58fe6fc344917df96d16e52dc8 /src/common/bit_util.h
parentMerge pull request #2285 from lioncash/unused-struct (diff)
downloadyuzu-522957f9f302b9521507a365da5871849a03594d.tar
yuzu-522957f9f302b9521507a365da5871849a03594d.tar.gz
yuzu-522957f9f302b9521507a365da5871849a03594d.tar.bz2
yuzu-522957f9f302b9521507a365da5871849a03594d.tar.lz
yuzu-522957f9f302b9521507a365da5871849a03594d.tar.xz
yuzu-522957f9f302b9521507a365da5871849a03594d.tar.zst
yuzu-522957f9f302b9521507a365da5871849a03594d.zip
Diffstat (limited to '')
-rw-r--r--src/common/bit_util.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/bit_util.h b/src/common/bit_util.h
index 1eea17ba1..14e53c273 100644
--- a/src/common/bit_util.h
+++ b/src/common/bit_util.h
@@ -58,4 +58,23 @@ inline u64 CountLeadingZeroes64(u64 value) {
return __builtin_clzll(value);
}
#endif
+
+inline u32 CountTrailingZeroes32(u32 value) {
+ u32 count = 0;
+ while (((value >> count) & 0xf) == 0 && count < 32)
+ count += 4;
+ while (((value >> count) & 1) == 0 && count < 32)
+ count++;
+ return count;
+}
+
+inline u64 CountTrailingZeroes64(u64 value) {
+ u64 count = 0;
+ while (((value >> count) & 0xf) == 0 && count < 64)
+ count += 4;
+ while (((value >> count) & 1) == 0 && count < 64)
+ count++;
+ return count;
+}
+
} // namespace Common