diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-04-03 14:32:39 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-04-24 10:02:30 +0200 |
commit | a12bc99ef0fc04fa48767c891f7a6db6404e51d5 (patch) | |
tree | f5840c3081c8aea6cddd557635313a2ab2d426a4 /src/boot | |
parent | 6eccc3cfa9dcfea3c8b508a66d2d592e6b9fcb93 (diff) | |
download | systemd-a12bc99ef0fc04fa48767c891f7a6db6404e51d5.tar.gz |
basic/logarithm: add popcount() wrapper
__builtin_popcount() is a bit of a mouthful, so let's provide a helper.
Using _Generic has the advantage that if a type other then the ones on
the list is given, compilation will fail. This is nice, because if by any
change we pass a wider type, it is rejected immediately instead of being
truncated.
log.h is also needed. It is included transitively, but let's include it
directly.
macro.h is *not* needed.
Diffstat (limited to 'src/boot')
-rw-r--r-- | src/boot/efi/splash.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/boot/efi/splash.c b/src/boot/efi/splash.c index f2d9f20e96..8daeb71cb2 100644 --- a/src/boot/efi/splash.c +++ b/src/boot/efi/splash.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "graphics.h" +#include "logarithm.h" #include "proto/graphics-output.h" #include "splash.h" #include "unaligned-fundamental.h" @@ -141,14 +142,14 @@ static void read_channel_maks( channel_shift[R] = __builtin_ctz(dib->channel_mask_r); channel_shift[G] = __builtin_ctz(dib->channel_mask_g); channel_shift[B] = __builtin_ctz(dib->channel_mask_b); - channel_scale[R] = 0xff / ((1 << __builtin_popcount(dib->channel_mask_r)) - 1); - channel_scale[G] = 0xff / ((1 << __builtin_popcount(dib->channel_mask_g)) - 1); - channel_scale[B] = 0xff / ((1 << __builtin_popcount(dib->channel_mask_b)) - 1); + channel_scale[R] = 0xff / ((1 << popcount(dib->channel_mask_r)) - 1); + channel_scale[G] = 0xff / ((1 << popcount(dib->channel_mask_g)) - 1); + channel_scale[B] = 0xff / ((1 << popcount(dib->channel_mask_b)) - 1); if (dib->size >= SIZEOF_BMP_DIB_RGBA && dib->channel_mask_a != 0) { channel_mask[A] = dib->channel_mask_a; channel_shift[A] = __builtin_ctz(dib->channel_mask_a); - channel_scale[A] = 0xff / ((1 << __builtin_popcount(dib->channel_mask_a)) - 1); + channel_scale[A] = 0xff / ((1 << popcount(dib->channel_mask_a)) - 1); } else { channel_mask[A] = 0; channel_shift[A] = 0; |