* sb.c (sb_check): Use __builtin_clzll when size_t is not the
authorAlan Modra <amodra@gmail.com>
Mon, 29 Oct 2012 10:17:52 +0000 (10:17 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 29 Oct 2012 10:17:52 +0000 (10:17 +0000)
same size as long.

gas/ChangeLog
gas/sb.c

index deefdd6629e145992a21f1ba5b65ff20476ef9cc..81759bdfda826ed7b39a06508130010d2a2cd215 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-29  Alan Modra  <amodra@gmail.com>
+
+       * sb.c (sb_check): Use __builtin_clzll when size_t is not the
+       same size as long.
+
 2012-10-29  Alan Modra  <amodra@gmail.com>
 
        * config/tc-ppc.c (ppc_znop): Remove unused vars.
index f68402fc470f6af031241d32f62d7388e1af6246..f21f46e9d27c27efeb1e918062bbd8ad36b3f661 100644 (file)
--- a/gas/sb.c
+++ b/gas/sb.c
@@ -137,7 +137,10 @@ sb_check (sb *ptr, size_t len)
       if ((ssize_t) want < 0)
        as_fatal ("string buffer overflow");
 #if GCC_VERSION >= 3004
-      max = (size_t) 1 << (CHAR_BIT * sizeof (want) - __builtin_clzl (want));
+      max = (size_t) 1 << (CHAR_BIT * sizeof (want)
+                          - (sizeof (want) <= sizeof (long)
+                             ? __builtin_clzl ((long) want)
+                             : __builtin_clzll ((long long) want)));
 #else
       max = 128;
       while (want > max)