include/exec/memory.h | 8 ++++---- include/exec/memory_ldst_cached.h.inc | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-)
void* pointer arithmetic is not in the
C standard. This change allows using
the QEMU headers with a C++ compiler.
Google-Bug-Id: 331190993
Change-Id: I5a064853429f627c17a9213910811dea4ced6174
Signed-off-by: Roman Kiryanov <rkir@google.com>
---
v2: change `char*` into `char *` (add the missing space).
include/exec/memory.h | 8 ++++----
include/exec/memory_ldst_cached.h.inc | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index d7591a60d9..a6d64e39a5 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2839,7 +2839,7 @@ static inline uint8_t address_space_ldub_cached(MemoryRegionCache *cache,
{
assert(addr < cache->len);
if (likely(cache->ptr)) {
- return ldub_p(cache->ptr + addr);
+ return ldub_p((char *)cache->ptr + addr);
} else {
return address_space_ldub_cached_slow(cache, addr, attrs, result);
}
@@ -2850,7 +2850,7 @@ static inline void address_space_stb_cached(MemoryRegionCache *cache,
{
assert(addr < cache->len);
if (likely(cache->ptr)) {
- stb_p(cache->ptr + addr, val);
+ stb_p((char *)cache->ptr + addr, val);
} else {
address_space_stb_cached_slow(cache, addr, val, attrs, result);
}
@@ -3123,7 +3123,7 @@ address_space_read_cached(MemoryRegionCache *cache, hwaddr addr,
assert(addr < cache->len && len <= cache->len - addr);
fuzz_dma_read_cb(cache->xlat + addr, len, cache->mrs.mr);
if (likely(cache->ptr)) {
- memcpy(buf, cache->ptr + addr, len);
+ memcpy(buf, (char *)cache->ptr + addr, len);
return MEMTX_OK;
} else {
return address_space_read_cached_slow(cache, addr, buf, len);
@@ -3144,7 +3144,7 @@ address_space_write_cached(MemoryRegionCache *cache, hwaddr addr,
{
assert(addr < cache->len && len <= cache->len - addr);
if (likely(cache->ptr)) {
- memcpy(cache->ptr + addr, buf, len);
+ memcpy((char *)cache->ptr + addr, buf, len);
return MEMTX_OK;
} else {
return address_space_write_cached_slow(cache, addr, buf, len);
diff --git a/include/exec/memory_ldst_cached.h.inc b/include/exec/memory_ldst_cached.h.inc
index d7834f852c..9426663524 100644
--- a/include/exec/memory_ldst_cached.h.inc
+++ b/include/exec/memory_ldst_cached.h.inc
@@ -30,7 +30,7 @@ static inline uint16_t ADDRESS_SPACE_LD_CACHED(uw)(MemoryRegionCache *cache,
assert(addr < cache->len && 2 <= cache->len - addr);
fuzz_dma_read_cb(cache->xlat + addr, 2, cache->mrs.mr);
if (likely(cache->ptr)) {
- return LD_P(uw)(cache->ptr + addr);
+ return LD_P(uw)((char *)cache->ptr + addr);
} else {
return ADDRESS_SPACE_LD_CACHED_SLOW(uw)(cache, addr, attrs, result);
}
@@ -42,7 +42,7 @@ static inline uint32_t ADDRESS_SPACE_LD_CACHED(l)(MemoryRegionCache *cache,
assert(addr < cache->len && 4 <= cache->len - addr);
fuzz_dma_read_cb(cache->xlat + addr, 4, cache->mrs.mr);
if (likely(cache->ptr)) {
- return LD_P(l)(cache->ptr + addr);
+ return LD_P(l)((char *)cache->ptr + addr);
} else {
return ADDRESS_SPACE_LD_CACHED_SLOW(l)(cache, addr, attrs, result);
}
@@ -54,7 +54,7 @@ static inline uint64_t ADDRESS_SPACE_LD_CACHED(q)(MemoryRegionCache *cache,
assert(addr < cache->len && 8 <= cache->len - addr);
fuzz_dma_read_cb(cache->xlat + addr, 8, cache->mrs.mr);
if (likely(cache->ptr)) {
- return LD_P(q)(cache->ptr + addr);
+ return LD_P(q)((char *)cache->ptr + addr);
} else {
return ADDRESS_SPACE_LD_CACHED_SLOW(q)(cache, addr, attrs, result);
}
@@ -76,7 +76,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(w)(MemoryRegionCache *cache,
{
assert(addr < cache->len && 2 <= cache->len - addr);
if (likely(cache->ptr)) {
- ST_P(w)(cache->ptr + addr, val);
+ ST_P(w)((char *)cache->ptr + addr, val);
} else {
ADDRESS_SPACE_ST_CACHED_SLOW(w)(cache, addr, val, attrs, result);
}
@@ -87,7 +87,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(l)(MemoryRegionCache *cache,
{
assert(addr < cache->len && 4 <= cache->len - addr);
if (likely(cache->ptr)) {
- ST_P(l)(cache->ptr + addr, val);
+ ST_P(l)((char *)cache->ptr + addr, val);
} else {
ADDRESS_SPACE_ST_CACHED_SLOW(l)(cache, addr, val, attrs, result);
}
@@ -98,7 +98,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(q)(MemoryRegionCache *cache,
{
assert(addr < cache->len && 8 <= cache->len - addr);
if (likely(cache->ptr)) {
- ST_P(q)(cache->ptr + addr, val);
+ ST_P(q)((char *)cache->ptr + addr, val);
} else {
ADDRESS_SPACE_ST_CACHED_SLOW(q)(cache, addr, val, attrs, result);
}
--
2.45.2.627.g7a2c4fd464-goog
On 19/6/24 02:04, Roman Kiryanov wrote: > void* pointer arithmetic is not in the > C standard. This change allows using > the QEMU headers with a C++ compiler. > > Google-Bug-Id: 331190993 > Change-Id: I5a064853429f627c17a9213910811dea4ced6174 > Signed-off-by: Roman Kiryanov <rkir@google.com> > --- > v2: change `char*` into `char *` (add the missing space). > > include/exec/memory.h | 8 ++++---- > include/exec/memory_ldst_cached.h.inc | 12 ++++++------ > 2 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/include/exec/memory.h b/include/exec/memory.h > index d7591a60d9..a6d64e39a5 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -2839,7 +2839,7 @@ static inline uint8_t address_space_ldub_cached(MemoryRegionCache *cache, > { > assert(addr < cache->len); > if (likely(cache->ptr)) { > - return ldub_p(cache->ptr + addr); > + return ldub_p((char *)cache->ptr + addr); > } else { > return address_space_ldub_cached_slow(cache, addr, attrs, result); > } > @@ -2850,7 +2850,7 @@ static inline void address_space_stb_cached(MemoryRegionCache *cache, > { > assert(addr < cache->len); > if (likely(cache->ptr)) { > - stb_p(cache->ptr + addr, val); > + stb_p((char *)cache->ptr + addr, val); > } else { > address_space_stb_cached_slow(cache, addr, val, attrs, result); > } > @@ -3123,7 +3123,7 @@ address_space_read_cached(MemoryRegionCache *cache, hwaddr addr, > assert(addr < cache->len && len <= cache->len - addr); > fuzz_dma_read_cb(cache->xlat + addr, len, cache->mrs.mr); > if (likely(cache->ptr)) { > - memcpy(buf, cache->ptr + addr, len); > + memcpy(buf, (char *)cache->ptr + addr, len); > return MEMTX_OK; > } else { > return address_space_read_cached_slow(cache, addr, buf, len); > @@ -3144,7 +3144,7 @@ address_space_write_cached(MemoryRegionCache *cache, hwaddr addr, > { > assert(addr < cache->len && len <= cache->len - addr); > if (likely(cache->ptr)) { > - memcpy(cache->ptr + addr, buf, len); > + memcpy((char *)cache->ptr + addr, buf, len); > return MEMTX_OK; > } else { > return address_space_write_cached_slow(cache, addr, buf, len); > diff --git a/include/exec/memory_ldst_cached.h.inc b/include/exec/memory_ldst_cached.h.inc > index d7834f852c..9426663524 100644 > --- a/include/exec/memory_ldst_cached.h.inc > +++ b/include/exec/memory_ldst_cached.h.inc > @@ -30,7 +30,7 @@ static inline uint16_t ADDRESS_SPACE_LD_CACHED(uw)(MemoryRegionCache *cache, > assert(addr < cache->len && 2 <= cache->len - addr); > fuzz_dma_read_cb(cache->xlat + addr, 2, cache->mrs.mr); > if (likely(cache->ptr)) { > - return LD_P(uw)(cache->ptr + addr); > + return LD_P(uw)((char *)cache->ptr + addr); > } else { > return ADDRESS_SPACE_LD_CACHED_SLOW(uw)(cache, addr, attrs, result); > } > @@ -42,7 +42,7 @@ static inline uint32_t ADDRESS_SPACE_LD_CACHED(l)(MemoryRegionCache *cache, > assert(addr < cache->len && 4 <= cache->len - addr); > fuzz_dma_read_cb(cache->xlat + addr, 4, cache->mrs.mr); > if (likely(cache->ptr)) { > - return LD_P(l)(cache->ptr + addr); > + return LD_P(l)((char *)cache->ptr + addr); > } else { > return ADDRESS_SPACE_LD_CACHED_SLOW(l)(cache, addr, attrs, result); > } > @@ -54,7 +54,7 @@ static inline uint64_t ADDRESS_SPACE_LD_CACHED(q)(MemoryRegionCache *cache, > assert(addr < cache->len && 8 <= cache->len - addr); > fuzz_dma_read_cb(cache->xlat + addr, 8, cache->mrs.mr); > if (likely(cache->ptr)) { > - return LD_P(q)(cache->ptr + addr); > + return LD_P(q)((char *)cache->ptr + addr); > } else { > return ADDRESS_SPACE_LD_CACHED_SLOW(q)(cache, addr, attrs, result); > } > @@ -76,7 +76,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(w)(MemoryRegionCache *cache, > { > assert(addr < cache->len && 2 <= cache->len - addr); > if (likely(cache->ptr)) { > - ST_P(w)(cache->ptr + addr, val); > + ST_P(w)((char *)cache->ptr + addr, val); > } else { > ADDRESS_SPACE_ST_CACHED_SLOW(w)(cache, addr, val, attrs, result); > } > @@ -87,7 +87,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(l)(MemoryRegionCache *cache, > { > assert(addr < cache->len && 4 <= cache->len - addr); > if (likely(cache->ptr)) { > - ST_P(l)(cache->ptr + addr, val); > + ST_P(l)((char *)cache->ptr + addr, val); > } else { > ADDRESS_SPACE_ST_CACHED_SLOW(l)(cache, addr, val, attrs, result); > } > @@ -98,7 +98,7 @@ static inline void ADDRESS_SPACE_ST_CACHED(q)(MemoryRegionCache *cache, > { > assert(addr < cache->len && 8 <= cache->len - addr); > if (likely(cache->ptr)) { > - ST_P(q)(cache->ptr + addr, val); > + ST_P(q)((char *)cache->ptr + addr, val); > } else { > ADDRESS_SPACE_ST_CACHED_SLOW(q)(cache, addr, val, attrs, result); > } Superseded by https://lore.kernel.org/qemu-devel/20240620201654.598024-1-rkir@google.com/.
On 6/18/24 17:04, Roman Kiryanov wrote: > void* pointer arithmetic is not in the > C standard. This change allows using > the QEMU headers with a C++ compiler. > > Google-Bug-Id: 331190993 > Change-Id: I5a064853429f627c17a9213910811dea4ced6174 > Signed-off-by: Roman Kiryanov<rkir@google.com> > --- > v2: change `char*` into `char *` (add the missing space). > > include/exec/memory.h | 8 ++++---- > include/exec/memory_ldst_cached.h.inc | 12 ++++++------ > 2 files changed, 10 insertions(+), 10 deletions(-) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
© 2016 - 2024 Red Hat, Inc.