diff mbox series

[1/8] vga: remove unused macros

Message ID 20231231093918.239549-2-pbonzini@redhat.com
State New
Headers show
Series vga: improve emulation fidelity | expand

Commit Message

Paolo Bonzini Dec. 31, 2023, 9:39 a.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/display/vga.c | 14 --------------
 1 file changed, 14 deletions(-)

Comments

BALATON Zoltan Dec. 31, 2023, 4:01 p.m. UTC | #1
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];
>
Paolo Bonzini Jan. 2, 2024, 3:13 p.m. UTC | #2
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
diff mbox series

Patch

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];