From 7aa1f121e4aeae295fb23acd0d474daad84d4f47 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 18 May 2025 12:25:03 -0700 Subject: [PATCH] mi: use common implementation of bit counting function Reduce a bit of unexplained magic, and use ISA extensions where available Signed-off-by: Alan Coopersmith Part-of: --- mi/micmap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mi/micmap.c b/mi/micmap.c index 1259bbba2..e8b3ad568 100644 --- a/mi/micmap.c +++ b/mi/micmap.c @@ -34,6 +34,7 @@ #include "dix/colormap_priv.h" #include "mi/mi_priv.h" +#include "os/osdep.h" #include "scrnintstr.h" #include "colormapst.h" @@ -329,7 +330,6 @@ miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, Pixel redMask, Pixel greenMask, Pixel blueMask) { miVisualsPtr new, *prev, v; - int count; new = malloc(sizeof *new); if (!new) @@ -347,10 +347,7 @@ miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, new->redMask = redMask; new->greenMask = greenMask; new->blueMask = blueMask; - count = (visuals >> 1) & 033333333333; - count = visuals - count - ((count >> 1) & 033333333333); - count = (((count + (count >> 3)) & 030707070707) % 077); /* HAKMEM 169 */ - new->count = count; + new->count = Ones(visuals); for (prev = &miVisuals; (v = *prev); prev = &v->next); *prev = new; return TRUE;