Commit 680270f8 authored by Carles Cufi's avatar Carles Cufi Committed by Andrew Boie
Browse files

toolchain: Add a popcount macro for GCC



Hamming Weight or "popcount" consists in counting the number of bits set
to 1 in a particular word. This commit adds a macro to be able to use
the existing builtin for this purpose with the GCC compiler.

Change-Id: Iec64c19e897de2bc02e981071465bbe230ee9add
Signed-off-by: default avatarCarles Cufi <carles.cufi@nordicsemi.no>
parent b80db0a4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ do { \
#define likely(x)   __builtin_expect((long)!!(x), 1L)
#define unlikely(x) __builtin_expect((long)!!(x), 0L)

#define popcount(x) __builtin_popcount(x)

#define __weak __attribute__((__weak__))
#define __unused __attribute__((__unused__))