summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Nikoleris <nikos.nikoleris@arm.com>2019-05-28 21:23:50 +0100
committerNikos Nikoleris <nikos.nikoleris@arm.com>2019-06-10 17:36:55 +0000
commit61865650cdadccb54b6001554c9b3cb1aa3e6665 (patch)
tree92f6e442b29f71c1099ae53855011dcd6a863b5a
parent542fd370b285b0bd0e13ffa186e46e128e84273f (diff)
downloadgem5-61865650cdadccb54b6001554c9b3cb1aa3e6665.tar.xz
base: Fix ctz32 for systems where unsigned int is not 32bit
The implementation of ctz32 uses __builtin_ctz to count the number of trailing zeros and therefore makes the assumption that an unsigned int is 32bit. This change checks whether that's the case and if not it uses __builtin_ctzl instead. Change-Id: Ic3ed3ada25fd0a93c7eb91d75b954e9924bdbb77 Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19129 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
-rw-r--r--src/base/bitfield.hh6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/base/bitfield.hh b/src/base/bitfield.hh
index 59b239a88..f2893962c 100644
--- a/src/base/bitfield.hh
+++ b/src/base/bitfield.hh
@@ -285,12 +285,12 @@ inline uint64_t alignToPowerOfTwo(uint64_t val)
/**
* Count trailing zeros in a 32-bit value.
*
- * Returns 32 if the value is zero. Note that the GCC builtin is
- * undefined if the value is zero.
+ * @param An input value
+ * @return The number of trailing zeros or 32 if the value is zero.
*/
inline int ctz32(uint32_t value)
{
- return value ? __builtin_ctz(value) : 32;
+ return value ? __builtin_ctzl(value) : 32;
}
/**