[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/26] include/qemu/bswap.h: Handle being included outside extern
From: |
Peter Maydell |
Subject: |
[PULL 20/26] include/qemu/bswap.h: Handle being included outside extern "C" block |
Date: |
Mon, 10 May 2021 13:25:42 +0100 |
Make bswap.h handle being included outside an 'extern "C"' block:
all system headers are included first, then all declarations are
put inside an 'extern "C"' block.
This requires a little rearrangement as currently we have an ifdef
ladder that has some system includes and some local declarations
or definitions, and we need to separate those out.
We want to do this because dis-asm.h includes bswap.h, dis-asm.h
may need to be included from C++ files, and system headers should
not be included within 'extern "C"' blocks.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/bswap.h | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 4aaf992b5d7..2d3bb8bbedd 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -1,8 +1,6 @@
#ifndef BSWAP_H
#define BSWAP_H
-#include "fpu/softfloat-types.h"
-
#ifdef CONFIG_MACHINE_BSWAP_H
# include <sys/endian.h>
# include <machine/bswap.h>
@@ -12,7 +10,18 @@
# include <endian.h>
#elif defined(CONFIG_BYTESWAP_H)
# include <byteswap.h>
+#define BSWAP_FROM_BYTESWAP
+# else
+#define BSWAP_FROM_FALLBACKS
+#endif /* ! CONFIG_MACHINE_BSWAP_H */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "fpu/softfloat-types.h"
+
+#ifdef BSWAP_FROM_BYTESWAP
static inline uint16_t bswap16(uint16_t x)
{
return bswap_16(x);
@@ -27,7 +36,9 @@ static inline uint64_t bswap64(uint64_t x)
{
return bswap_64(x);
}
-# else
+#endif
+
+#ifdef BSWAP_FROM_FALLBACKS
static inline uint16_t bswap16(uint16_t x)
{
return (((x & 0x00ff) << 8) |
@@ -53,7 +64,10 @@ static inline uint64_t bswap64(uint64_t x)
((x & 0x00ff000000000000ULL) >> 40) |
((x & 0xff00000000000000ULL) >> 56));
}
-#endif /* ! CONFIG_MACHINE_BSWAP_H */
+#endif
+
+#undef BSWAP_FROM_BYTESWAP
+#undef BSWAP_FROM_FALLBACKS
static inline void bswap16s(uint16_t *s)
{
@@ -494,4 +508,8 @@ DO_STN_LDN_P(be)
#undef le_bswaps
#undef be_bswaps
+#ifdef __cplusplus
+}
+#endif
+
#endif /* BSWAP_H */
--
2.20.1
- [PULL 10/26] target/arm: Make functions used by translate-vfp global, (continued)
- [PULL 10/26] target/arm: Make functions used by translate-vfp global, Peter Maydell, 2021/05/10
- [PULL 09/26] target/arm: Move vfp_{load, store}_reg{32, 64} to translate-vfp.c.inc, Peter Maydell, 2021/05/10
- [PULL 11/26] target/arm: Make translate-vfp.c.inc its own compilation unit, Peter Maydell, 2021/05/10
- [PULL 14/26] target/arm: Move NeonGenThreeOpEnvFn typedef to translate.h, Peter Maydell, 2021/05/10
- [PULL 15/26] target/arm: Make functions used by translate-neon global, Peter Maydell, 2021/05/10
- [PULL 13/26] target/arm: Delete unused typedef, Peter Maydell, 2021/05/10
- [PULL 16/26] target/arm: Make translate-neon.c.inc its own compilation unit, Peter Maydell, 2021/05/10
- [PULL 18/26] hw/sd/omap_mmc: Use device_cold_reset() instead of device_legacy_reset(), Peter Maydell, 2021/05/10
- [PULL 17/26] target/arm: Make WFI a NOP for userspace emulators, Peter Maydell, 2021/05/10
- [PULL 22/26] hw/arm/imx25_pdk: Fix error message for invalid RAM size, Peter Maydell, 2021/05/10
- [PULL 20/26] include/qemu/bswap.h: Handle being included outside extern "C" block,
Peter Maydell <=
- [PULL 19/26] osdep: Make os-win32.h and os-posix.h handle 'extern "C"' themselves, Peter Maydell, 2021/05/10
- [PULL 21/26] include/disas/dis-asm.h: Handle being included outside 'extern "C"', Peter Maydell, 2021/05/10
- [PULL 23/26] hw/misc/mps2-scc: Add "QEMU interface" comment, Peter Maydell, 2021/05/10
- [PULL 25/26] hw/arm/mps2-tz: Implement AN524 memory remapping via machine property, Peter Maydell, 2021/05/10
- [PULL 24/26] hw/misc/mps2-scc: Support using CFG0 bit 0 for remapping, Peter Maydell, 2021/05/10
- [PULL 26/26] hw/arm/xlnx: Fix PHY address for xilinx-zynq-a9, Peter Maydell, 2021/05/10