include/exec/memory.h | 19 ++++++++++++++++++- memory.c | 18 ------------------ 2 files changed, 18 insertions(+), 19 deletions(-)
devend_memop can rely on the fact that the result is always either
0 or MO_BSWAP, corresponding respectively to host endianness and
the opposite. Native (target) endianness in turn can be either
the host endianness, in which case MO_BSWAP is only returned for
host-opposite endianness, or the opposite, in which case 0 is only
returned for host endianness.
With this in mind, devend_memop can be compiled as a setcond+shift
for every target. Do this and, while at it, move it to
include/exec/memory.h since !NEED_CPU_H files do not (and should not)
need it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/exec/memory.h | 19 ++++++++++++++++++-
memory.c | 18 ------------------
2 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 2dd810259d..d898cfb5db 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2201,8 +2201,25 @@ address_space_write_cached(MemoryRegionCache *cache, hwaddr addr,
}
}
+#ifdef NEED_CPU_H
/* enum device_endian to MemOp. */
-MemOp devend_memop(enum device_endian end);
+MemOp devend_memop(enum device_endian end)
+{
+ QEMU_BUILD_BUG_ON(DEVICE_HOST_ENDIAN != DEVICE_LITTLE_ENDIAN &&
+ DEVICE_HOST_ENDIAN != DEVICE_BIG_ENDIAN);
+
+#ifdef BSWAP_NEEDED
+ /* Swap if non-host endianness or native (target) endianness */
+ return (end == DEVICE_HOST_ENDIAN) ? 0 : MO_BSWAP;
+#else
+ const int non_host_endianness =
+ DEVICE_LITTLE_ENDIAN ^ DEVICE_BIG_ENDIAN ^ DEVICE_HOST_ENDIAN;
+
+ /* In this case, native (target) endianness needs no swap. */
+ return (end == non_host_endianness) ? MO_BSWAP : 0;
+#endif
+}
+#endif
#endif
diff --git a/memory.c b/memory.c
index 61a254c3f9..b9dd6b94ca 100644
--- a/memory.c
+++ b/memory.c
@@ -3267,21 +3267,3 @@ static void memory_register_types(void)
}
type_init(memory_register_types)
-
-MemOp devend_memop(enum device_endian end)
-{
- static MemOp conv[] = {
- [DEVICE_LITTLE_ENDIAN] = MO_LE,
- [DEVICE_BIG_ENDIAN] = MO_BE,
- [DEVICE_NATIVE_ENDIAN] = MO_TE,
- [DEVICE_HOST_ENDIAN] = 0,
- };
- switch (end) {
- case DEVICE_LITTLE_ENDIAN:
- case DEVICE_BIG_ENDIAN:
- case DEVICE_NATIVE_ENDIAN:
- return conv[end];
- default:
- g_assert_not_reached();
- }
-}
--
2.21.0
On 9/12/19 10:18 AM, Paolo Bonzini wrote: > devend_memop can rely on the fact that the result is always either > 0 or MO_BSWAP, corresponding respectively to host endianness and > the opposite. Native (target) endianness in turn can be either > the host endianness, in which case MO_BSWAP is only returned for > host-opposite endianness, or the opposite, in which case 0 is only > returned for host endianness. > > With this in mind, devend_memop can be compiled as a setcond+shift > for every target. Do this and, while at it, move it to > include/exec/memory.h since !NEED_CPU_H files do not (and should not) > need it. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > include/exec/memory.h | 19 ++++++++++++++++++- > memory.c | 18 ------------------ > 2 files changed, 18 insertions(+), 19 deletions(-) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
Patchew URL: https://patchew.org/QEMU/20190912141820.30702-1-pbonzini@redhat.com/ Hi, This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally. === TEST SCRIPT BEGIN === #!/bin/bash make docker-image-centos7 V=1 NETWORK=1 time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END === libudev no default devices yes warning: Python 2 support is deprecated warning: Python 3 will be required for building future versions of QEMU cross containers no NOTE: guest cross-compilers enabled: cc --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/i386/cpu.h:1792, from /tmp/qemu-test/src/disas.c:7: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- from /tmp/qemu-test/src/target/i386/cpu.h:1792, from /tmp/qemu-test/src/tcg/tcg.h:28, from /tmp/qemu-test/src/tcg/tcg-common.c:26: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/i386/cpu.h:1792, from /tmp/qemu-test/src/exec.c:25: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/i386/cpu.h:1792, from /tmp/qemu-test/src/arch_init.c:25: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/arm/cpu.h:3141, from /tmp/qemu-test/src/exec.c:25: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/i386/cpu.h:1792, from /tmp/qemu-test/src/tcg/tcg-op-vec.c:21: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- from /tmp/qemu-test/src/target/i386/cpu.h:1792, from /tmp/qemu-test/src/tcg/tcg.h:28, from /tmp/qemu-test/src/tcg/tcg-op-gvec.c:21: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- from /tmp/qemu-test/src/target/arm/cpu.h:3141, from /tmp/qemu-test/src/tcg/tcg.h:28, from /tmp/qemu-test/src/tcg/tcg-common.c:26: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- from /tmp/qemu-test/src/tcg/tcg.h:28, from /tmp/qemu-test/src/tcg/tcg-op.h:28, from /tmp/qemu-test/src/tcg/optimize.c:27: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/i386/cpu.h:1792, from /tmp/qemu-test/src/tcg/tcg-op.c:26: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/i386/cpu.h:1792, from /tmp/qemu-test/src/tcg/tcg.c:43: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/arm/cpu.h:3141, from /tmp/qemu-test/src/tcg/tcg-op.c:26: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/arm/cpu.h:3141, from /tmp/qemu-test/src/tcg/tcg-op-vec.c:21: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- from /tmp/qemu-test/src/target/arm/cpu.h:3141, from /tmp/qemu-test/src/tcg/tcg.h:28, from /tmp/qemu-test/src/tcg/tcg-op-gvec.c:21: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors --- In file included from /tmp/qemu-test/src/include/exec/cpu-all.h:23:0, from /tmp/qemu-test/src/target/arm/cpu.h:3141, from /tmp/qemu-test/src/tcg/tcg.c:43: /tmp/qemu-test/src/include/exec/memory.h:2206:7: error: no previous prototype for 'devend_memop' [-Werror=missing-prototypes] MemOp devend_memop(enum device_endian end) ^ cc1: all warnings being treated as errors The full log is available at http://patchew.org/logs/20190912141820.30702-1-pbonzini@redhat.com/testing.docker-quick@centos7/?type=message. --- Email generated automatically by Patchew [https://patchew.org/]. Please send your feedback to patchew-devel@redhat.com
© 2016 - 2024 Red Hat, Inc.