aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xandroid-configure.sh11
-rw-r--r--android/config/freebsd-x86/config-host.h1
-rw-r--r--android/config/linux-x86/config-host.h2
-rw-r--r--bswap.h16
4 files changed, 21 insertions, 9 deletions
diff --git a/android-configure.sh b/android-configure.sh
index 30d6f3c..b992064 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -355,9 +355,9 @@ fi
# check whether we have <byteswap.h>
#
-feature_check_header HAVE_BYTESWAP_H "<byteswap.h>"
-
-feature_check_header HAVE_FNMATCH_H "<fnmatch.h>"
+feature_check_header HAVE_BYTESWAP_H "<byteswap.h>"
+feature_check_header HAVE_MACHINE_BSWAP_H "<machine/bswap.h>"
+feature_check_header HAVE_FNMATCH_H "<fnmatch.h>"
# Build the config.make file
#
@@ -404,7 +404,10 @@ echo "/* This file was autogenerated by '$PROGNAME' */" > $config_h
echo "#define CONFIG_QEMU_SHAREDIR \"/usr/local/share/qemu\"" >> $config_h
echo "#define HOST_LONG_BITS $HOST_LONGBITS" >> $config_h
if [ "$HAVE_BYTESWAP_H" = "yes" ] ; then
- echo "#define HAVE_BYTESWAP_H 1" >> $config_h
+ echo "#define CONFIG_BYTESWAP_H 1" >> $config_h
+fi
+if [ "$HAVE_MACHINE_BYTESWAP_H" = "yes" ] ; then
+ echo "#define CONFIG_MACHINE_BSWAP_H 1" >> $config_h
fi
if [ "$HAVE_FNMATCH_H" = "yes" ] ; then
echo "#define CONFIG_FNMATCH 1" >> $config_h
diff --git a/android/config/freebsd-x86/config-host.h b/android/config/freebsd-x86/config-host.h
index b5a7f72..5518924 100644
--- a/android/config/freebsd-x86/config-host.h
+++ b/android/config/freebsd-x86/config-host.h
@@ -2,6 +2,7 @@
#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu"
#define HOST_I386 1
#define HOST_LONG_BITS 32
+#define CONFIG_MACHINE_BSWAP_H 1
#define CONFIG_FNMATCH 1
#define CONFIG_GDBSTUB 1
#define CONFIG_SLIRP 1
diff --git a/android/config/linux-x86/config-host.h b/android/config/linux-x86/config-host.h
index df63ac8..894cbe6 100644
--- a/android/config/linux-x86/config-host.h
+++ b/android/config/linux-x86/config-host.h
@@ -2,7 +2,7 @@
#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu"
#define HOST_I386 1
#define HOST_LONG_BITS 32
-#define HAVE_BYTESWAP_H 1
+#define CONFIG_BYTESWAP_H 1
#define CONFIG_FNMATCH 1
#define CONFIG_GDBSTUB 1
#define CONFIG_SLIRP 1
diff --git a/bswap.h b/bswap.h
index 90bd66f..20caae6 100644
--- a/bswap.h
+++ b/bswap.h
@@ -5,13 +5,13 @@
#include <inttypes.h>
-#ifdef HAVE_MACHINE_BSWAP_H
+#ifdef CONFIG_MACHINE_BSWAP_H
#include <sys/endian.h>
#include <sys/types.h>
#include <machine/bswap.h>
#else
-#ifdef HAVE_BYTESWAP_H
+#ifdef CONFIG_BYTESWAP_H
#include <byteswap.h>
#else
@@ -47,7 +47,7 @@
(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
})
-#endif /* !HAVE_BYTESWAP_H */
+#endif /* !CONFIG_BYTESWAP_H */
static inline uint16_t bswap16(uint16_t x)
{
@@ -64,7 +64,7 @@ static inline uint64_t bswap64(uint64_t x)
return bswap_64(x);
}
-#endif /* ! HAVE_MACHINE_BSWAP_H */
+#endif /* ! CONFIG_MACHINE_BSWAP_H */
static inline void bswap16s(uint16_t *s)
{
@@ -205,8 +205,10 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
#ifdef HOST_WORDS_BIGENDIAN
#define cpu_to_32wu cpu_to_be32wu
+#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v)
#else
#define cpu_to_32wu cpu_to_le32wu
+#define leul_to_cpu(v) (v)
#endif
#undef le_bswap
@@ -214,4 +216,10 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
#undef le_bswaps
#undef be_bswaps
+/* len must be one of 1, 2, 4 */
+static inline uint32_t qemu_bswap_len(uint32_t value, int len)
+{
+ return bswap32(value) >> (32 - 8 * len);
+}
+
#endif /* BSWAP_H */