[PATCH 1/8] vga: remove unused macros

Paolo Bonzini posted 8 patches 11 months ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
There is a newer version of this series
[PATCH 1/8] vga: remove unused macros
Posted by Paolo Bonzini 11 months ago
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/display/vga.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/hw/display/vga.c b/hw/display/vga.c
index 37557c3442a..18d966ecd3e 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -103,12 +103,6 @@ const uint8_t gr_mask[16] = {
 #define PAT(x) (x)
 #endif
 
-#if HOST_BIG_ENDIAN
-#define BIG 1
-#else
-#define BIG 0
-#endif
-
 #if HOST_BIG_ENDIAN
 #define GET_PLANE(data, p) (((data) >> (24 - (p) * 8)) & 0xff)
 #else
@@ -134,14 +128,6 @@ static const uint32_t mask16[16] = {
     PAT(0xffffffff),
 };
 
-#undef PAT
-
-#if HOST_BIG_ENDIAN
-#define PAT(x) (x)
-#else
-#define PAT(x) cbswap_32(x)
-#endif
-
 static uint32_t expand4[256];
 static uint16_t expand2[256];
 static uint8_t expand4to8[16];
-- 
2.43.0
Re: [PATCH 1/8] vga: remove unused macros
Posted by BALATON Zoltan 11 months ago
On Sun, 31 Dec 2023, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/display/vga.c | 14 --------------
> 1 file changed, 14 deletions(-)
>
> diff --git a/hw/display/vga.c b/hw/display/vga.c
> index 37557c3442a..18d966ecd3e 100644
> --- a/hw/display/vga.c
> +++ b/hw/display/vga.c
> @@ -103,12 +103,6 @@ const uint8_t gr_mask[16] = {
> #define PAT(x) (x)
> #endif

While at it you could also move this definiton dows to where it's used so 
it's clear where it's needed.

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>

> -#if HOST_BIG_ENDIAN
> -#define BIG 1
> -#else
> -#define BIG 0
> -#endif
> -
> #if HOST_BIG_ENDIAN
> #define GET_PLANE(data, p) (((data) >> (24 - (p) * 8)) & 0xff)
> #else
> @@ -134,14 +128,6 @@ static const uint32_t mask16[16] = {
>     PAT(0xffffffff),
> };
>
> -#undef PAT
> -
> -#if HOST_BIG_ENDIAN
> -#define PAT(x) (x)
> -#else
> -#define PAT(x) cbswap_32(x)
> -#endif
> -
> static uint32_t expand4[256];
> static uint16_t expand2[256];
> static uint8_t expand4to8[16];
>
Re: [PATCH 1/8] vga: remove unused macros
Posted by Paolo Bonzini 10 months, 4 weeks ago
On Sun, Dec 31, 2023 at 5:01 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:
>
> On Sun, 31 Dec 2023, Paolo Bonzini wrote:
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> > hw/display/vga.c | 14 --------------
> > 1 file changed, 14 deletions(-)
> >
> > diff --git a/hw/display/vga.c b/hw/display/vga.c
> > index 37557c3442a..18d966ecd3e 100644
> > --- a/hw/display/vga.c
> > +++ b/hw/display/vga.c
> > @@ -103,12 +103,6 @@ const uint8_t gr_mask[16] = {
> > #define PAT(x) (x)
> > #endif
>
> While at it you could also move this definiton dows to where it's used so
> it's clear where it's needed.

In fact PAT() can be replaced with const_le32(), and GET_PLANE() can
use a byte swap, which is just as fast as tweaking the shift count these
days[1]:

#define GET_PLANE(data, p) ((cpu_to_le32(data) >> ((p) * 8)) & 0xff)

and it can even be inlined

Paolo

[1] see following instructions, only sparc is missing:

arm/aarch64 - rev
i386 - bswapl
loongarch - revb.2w
mips - wsbh + rotr
ppc - brw
riscv - rev8 ( + srli on riscv64)
s390 - lrvgr