aboutsummaryrefslogtreecommitdiff
path: root/src/big_int.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/big_int.cpp')
-rw-r--r--src/big_int.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/big_int.cpp b/src/big_int.cpp
index 9cb1ec586..6386b1d6f 100644
--- a/src/big_int.cpp
+++ b/src/big_int.cpp
@@ -281,7 +281,25 @@ void big_int_mul(BigInt *dst, BigInt const *x, BigInt const *y) {
u64 leading_zeros_u64(u64 x) {
#if defined(GB_COMPILER_MSVC)
- return __lzcnt64(x);
+ #if defined(GB_ARCH_64_BIT)
+ return __lzcnt64(x);
+ #else
+ u64 y, n;
+
+ n = 0;
+ y = x;
+ L:
+ if (x < 0) {
+ return n;
+ }
+ if (y == 0) {
+ return 64-n;
+ }
+ n++;
+ x <<= 1;
+ y >>= 1;
+ goto L;
+ #endif
#else
return cast(u64)__builtin_clzll(cast(unsigned long long)x);
#endif