OSDN Git Service

Fix missing parentheses.
authorChristopher Ferris <cferris@google.com>
Thu, 17 Dec 2015 00:11:04 +0000 (16:11 -0800)
committerChristopher Ferris <cferris@google.com>
Thu, 17 Dec 2015 00:11:04 +0000 (16:11 -0800)
The BIONIC_ROUND_UP_POWER_OF_2 macro did not have parentheses around
the whole expression. This lead to the wrong value being computed when
used as part of a mathematical expression such as this:

  value = BIONIC_ROUND_UP_POWER_OF_2(value) - 1;

This only happens on 64 bit abis.

Change-Id: I6f8afbdaf16fe64a88fa0246d074b3534c9159c1

libc/private/bionic_macros.h

index 4f3cf89..4969bd9 100644 (file)
@@ -42,8 +42,8 @@
   (((value) + (alignment) - 1) & ~((alignment) - 1))
 
 #define BIONIC_ROUND_UP_POWER_OF_2(value) \
-  (sizeof(value) == 8) \
+  ((sizeof(value) == 8) \
     ? (1UL << (64 - __builtin_clzl(static_cast<unsigned long>(value)))) \
-    : (1UL << (32 - __builtin_clz(static_cast<unsigned int>(value))))
+    : (1UL << (32 - __builtin_clz(static_cast<unsigned int>(value)))))
 
 #endif // _BIONIC_MACROS_H_