Replace libgcc version of ctz with our own.

On upcoming arm64 port libgcc ctz* are not usable in standalone
	environment. Since we need ctz* for this case and implementation is
	in C we may as well use it on all concerned platforms.
This commit is contained in:
Vladimir Serbinenko 2013-11-15 03:28:34 +01:00
parent a9f25a0819
commit 6fcec43954
4 changed files with 100 additions and 1 deletions

View file

@ -1,3 +1,11 @@
2013-11-15 Vladimir Serbinenko <phcoder@gmail.com>
Replace libgcc version of ctz with our own.
On upcoming arm64 port libgcc ctz* are not usable in standalone
environment. Since we need ctz* for this case and implementation is
in C we may as well use it on all concerned platforms.
2013-11-14 Vladimir Serbinenko <phcoder@gmail.com> 2013-11-14 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Probe for linking format rather than guessing it based * configure.ac: Probe for linking format rather than guessing it based

View file

@ -822,7 +822,7 @@ fi
fi fi
# Check for libgcc symbols # 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_LINKER" = x1 ; then if test "x$TARGET_APPLE_LINKER" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib" CFLAGS="$TARGET_CFLAGS -nostdlib"

View file

@ -614,6 +614,85 @@ __umodsi3 (grub_uint32_t a, grub_uint32_t b)
return ret; return ret;
} }
#endif
#ifdef NEED_CTZDI2
unsigned
__ctzdi2 (grub_uint64_t x)
{
unsigned ret = 0;
if (!x)
return 64;
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 >>= 1;
ret |= 1;
}
return ret;
}
#endif
#ifdef NEED_CTZSI2
unsigned
__ctzsi2 (grub_uint32_t x)
{
unsigned ret = 0;
if (!x)
return 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 >>= 1;
ret |= 1;
}
return ret;
}
#endif #endif

View file

@ -465,6 +465,18 @@ EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b);
#endif #endif
#if defined (__sparc64__) || defined (__powerpc__)
unsigned
EXPORT_FUNC (__ctzdi2) (grub_uint64_t x);
#define NEED_CTZDI2 1
#endif
#if defined (__mips__) || defined (__arm__)
unsigned
EXPORT_FUNC (__ctzsi2) (grub_uint32_t x);
#define NEED_CTZSI2 1
#endif
#ifdef __arm__ #ifdef __arm__
grub_uint32_t grub_uint32_t
EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b);