From f7d17d62b52a2d684a0efdb4a86684dfb056f803 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 10 Jun 2016 13:20:19 -0700 Subject: [PATCH] Util: Make clz consistent --- include/mgba-util/math.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/mgba-util/math.h b/include/mgba-util/math.h index 9e239869c..4cc1d7195 100644 --- a/include/mgba-util/math.h +++ b/include/mgba-util/math.h @@ -18,6 +18,9 @@ static inline uint32_t popcount32(unsigned bits) { static inline unsigned clz32(uint32_t bits) { #if defined(__GNUC__) || __clang__ + if (!bits) { + return 32; + } return __builtin_clz(bits); #else static const int table[256] = {