From d00c1c7a1d32aa66bcfa5a0bb3fd6ce0fffb4fb9 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 7 Oct 2020 19:35:55 +0100 Subject: [PATCH] compile.h, utils.h: rename popcount Rename `popcountl` to `popcntul` to avoid name conflicts with NetBSD system headers. Remove the unused `popcount` function. Closes #502 Signed-off-by: Yuxuan Shui --- src/compiler.h | 4 ++-- src/utils.h | 4 ---- src/x.c | 8 ++++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/compiler.h b/src/compiler.h index 814bdd8..550507f 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -111,6 +111,6 @@ typedef unsigned long ulong; typedef unsigned int uint; -static inline int popcount(uint x) { - return __builtin_popcount(x); +static inline int attr_const popcntul(unsigned long a) { + return __builtin_popcountl(a); } diff --git a/src/utils.h b/src/utils.h index 683c7a3..13a77fa 100644 --- a/src/utils.h +++ b/src/utils.h @@ -136,10 +136,6 @@ static inline int attr_const normalize_i_range(int i, int min, int max) { /// clamp `val` into interval [min, max] #define clamp(val, min, max) max2(min2(val, max), min) -static inline int attr_const popcountl(unsigned long a) { - return __builtin_popcountl(a); -} - /** * Normalize a double value to a specific range. * diff --git a/src/x.c b/src/x.c index 86b257b..9db8e21 100644 --- a/src/x.c +++ b/src/x.c @@ -632,10 +632,10 @@ struct xvisual_info x_get_visual_info(xcb_connection_t *c, xcb_visualid_t visual return (struct xvisual_info){-1, -1, -1, -1, -1, 0}; } - int red_size = popcountl(pictfmt->direct.red_mask), - blue_size = popcountl(pictfmt->direct.blue_mask), - green_size = popcountl(pictfmt->direct.green_mask), - alpha_size = popcountl(pictfmt->direct.alpha_mask); + int red_size = popcntul(pictfmt->direct.red_mask), + blue_size = popcntul(pictfmt->direct.blue_mask), + green_size = popcntul(pictfmt->direct.green_mask), + alpha_size = popcntul(pictfmt->direct.alpha_mask); return (struct xvisual_info){ .red_size = red_size,