From: Mathieu Desnoyers Date: Thu, 7 Mar 2024 17:32:36 +0000 (-0500) Subject: Implement rseq_hweight_ulong with __builtin_popcountl X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=d9b46e1c0d5d468e68115160b2c3f0ac580b32d7;p=librseq.git Implement rseq_hweight_ulong with __builtin_popcountl Signed-off-by: Mathieu Desnoyers Change-Id: I483d53c7c5402e034b8d468e0ed2ab048184f069 --- diff --git a/src/rseq-alloc-utils.h b/src/rseq-alloc-utils.h index e486dcf..6a57c3d 100644 --- a/src/rseq-alloc-utils.h +++ b/src/rseq-alloc-utils.h @@ -110,11 +110,7 @@ long rseq_get_page_len(void) static inline int rseq_hweight_ulong(unsigned long v) { - int count; - - for (count = 0; v; count++) - v &= v - 1; - return count; + return __builtin_popcountl(v); } #endif /* _RSEQ_ALLOC_UTILS_H */