diff --git a/configure.ac b/configure.ac index 4ad7584..0182b42 100644 --- a/configure.ac +++ b/configure.ac @@ -829,7 +848,7 @@ CFLAGS="$TARGET_CFLAGS -Wl,--defsym,abort=main" fi # Check for libgcc symbols -AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x __ctzdi2 __ctzsi2) +AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x) if test "x$TARGET_APPLE_CC" = x1 ; then CFLAGS="$TARGET_CFLAGS -nostdlib" diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 194e770..0b3bd6d 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -615,6 +615,74 @@ __umodsi3 (grub_uint32_t a, grub_uint32_t b) } +unsigned +__ctzdi2 (grub_uint64_t x) +{ + unsigned ret = 0; + if (!(x & 0xffffffff)) + { + x >>= 32; + ret += 32; + } + if (!(x & 0xffff)) + { + x >>= 16; + ret += 16; + } + if (!(x & 0xff)) + { + x >>= 8; + ret += 8; + } + if (!(x & 0xf)) + { + x >>= 4; + ret += 4; + } + if (!(x & 0x3)) + { + x >>= 2; + ret += 2; + } + if (!(x & 0x1)) + { + x >>= 2; + ret++; + } + return ret; +} +unsigned +__ctzsi2 (grub_uint32_t x) +{ + unsigned ret = 0; + if (!(x & 0xffff)) + { + x >>= 16; + ret += 16; + } + if (!(x & 0xff)) + { + x >>= 8; + ret += 8; + } + if (!(x & 0xf)) + { + x >>= 4; + ret += 4; + } + if (!(x & 0x3)) + { + x >>= 2; + ret += 2; + } + if (!(x & 0x1)) + { + x >>= 2; + ret++; + } + return ret; +} + #endif #ifdef __arm__ diff --git a/include/grub/misc.h b/include/grub/misc.h index a46e086..192f503 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -463,6 +463,11 @@ EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); grub_uint32_t EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); +unsigned +EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); +unsigned +EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); + #endif #ifdef __arm__