]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Replace libgcc version of ctz with our own.
authorVladimir Serbinenko <phcoder@gmail.com>
Fri, 15 Nov 2013 02:28:34 +0000 (03:28 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Fri, 15 Nov 2013 02:28:34 +0000 (03:28 +0100)
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.

ChangeLog
configure.ac
grub-core/kern/misc.c
include/grub/misc.h

index 4281e5b20a9a0c66a432ba41f4b07410586359e8..6d502f8fe5ffbcad89c3a17d45e093bbe2f634fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * configure.ac: Probe for linking format rather than guessing it based
index 19b22344f961cfae330ced6e0792fa490ae60716..2c4f019f61abd3bec3fe20c3af92b687c6ea7d60 100644 (file)
@@ -822,7 +822,7 @@ fi
 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_LINKER" = x1 ; then
 CFLAGS="$TARGET_CFLAGS -nostdlib"
index 194e7703a4de0a804c6f5e6f09e474c488f921bf..f61ff00c144980f3fd12f0d5201e0d279ddbc887 100644 (file)
@@ -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
 
index a46e086845158041948db83d330b098ce991453b..9c8faf274dc268e9e941e79e6797a62aaadecf28 100644 (file)
@@ -465,6 +465,18 @@ EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b);
 
 #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__
 grub_uint32_t
 EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b);