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:
parent
a9f25a0819
commit
6fcec43954
4 changed files with 100 additions and 1 deletions
|
@ -614,6 +614,85 @@ __umodsi3 (grub_uint32_t a, grub_uint32_t b)
|
|||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue