diff --git a/configure b/configure
index 7e69ea886444f3c9a3c0ac1f2f8b85190f69fb4e..a5eb8323e9d5cce73cc540cb92b5a242bf422d62 100755
--- a/configure
+++ b/configure
@@ -1291,17 +1291,6 @@ esac
fi
-# host long bits test, actually a pointer size test
-cat > $TMPC << EOF
-int sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
-EOF
-if compile_object; then
-hostlongbits=64
-else
-hostlongbits=32
-fi
-
-
##########################################
# NPTL probe
@@ -2988,7 +2977,6 @@ fi
if test "$bigendian" = "yes" ; then
echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
fi
-echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
if test "$mingw32" = "yes" ; then
echo "CONFIG_WIN32=y" >> $config_host_mak
rc_version=`cat $source_path/VERSION`
diff --git a/cpu-defs.h b/cpu-defs.h
index 57a709b6795ddc555df045bc16849742eb2fb23d..4527cbf4f3cc34a1abb32db5a2f8487319197e6e 100644
--- a/cpu-defs.h
+++ b/cpu-defs.h
@@ -60,8 +60,6 @@ typedef uint64_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT)));
#error TARGET_LONG_SIZE undefined
#endif
-#define HOST_LONG_SIZE (HOST_LONG_BITS / 8)
-
#define EXCP_INTERRUPT 0x10000 /* async interruption */
#define EXCP_HLT 0x10001 /* hlt instruction reached */
#define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */
diff --git a/qemu-common.h b/qemu-common.h
index c5e9cad35ec1ce7599eee9414aada42878e34bdf..dbfce6f4c6213edf9463b1575d7173f8b0c3f88c 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -65,6 +65,15 @@ typedef struct Monitor Monitor;
#define TIME_MAX LONG_MAX
#endif
+/* HOST_LONG_BITS is the size of a native pointer in bits. */
+#if UINTPTR_MAX == UINT32_MAX
+# define HOST_LONG_BITS 32
+#elif UINTPTR_MAX == UINT64_MAX
+# define HOST_LONG_BITS 64
+#else
+# error Unknown pointer size
+#endif
+
#ifndef CONFIG_IOVEC
#define CONFIG_IOVEC
struct iovec {
diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h
index 9d61d45ab610e9adf0ea985fbab2472f73e956f8..5cd6fd834f42ea86ebce3fee644e812071ff6955 100644
--- a/target-alpha/cpu.h
+++ b/target-alpha/cpu.h
@@ -21,6 +21,7 @@
#define __CPU_ALPHA_H__
#include "config.h"
+#include "qemu-common.h"
#define TARGET_LONG_BITS 64
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index a961159d5d8004ae2698b6dce2b473e589b183b5..1d2142bfded97b951c692e783a0b0bc95ec11081 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -17,15 +17,10 @@
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-
#include "cpu.h"
#include "disas.h"
#include "host-utils.h"
#include "tcg-op.h"
-#include "qemu-common.h"
#include "helper.h"
#define GEN_HELPER 1
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 49293724897a632e4f61f0c2aee27829276e3f9a..abe1c30d6a7b371f461bf8f387760d9b1f57d31d 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1,11 +1,6 @@
-#include
-#include
-#include
-
#include "cpu.h"
#include "gdbstub.h"
#include "helper.h"
-#include "qemu-common.h"
#include "host-utils.h"
#if !defined(CONFIG_USER_ONLY)
#include "hw/loader.h"
diff --git a/target-cris/cpu.h b/target-cris/cpu.h
index 453afbb66e080e6d40a9c5e42de48f69bb54cc47..222a0625a35be3b7f1f58cac4443e9591f23f3cd 100644
--- a/target-cris/cpu.h
+++ b/target-cris/cpu.h
@@ -20,6 +20,9 @@
#ifndef CPU_CRIS_H
#define CPU_CRIS_H
+#include "config.h"
+#include "qemu-common.h"
+
#define TARGET_LONG_BITS 32
#define CPUState struct CPUCRISState
diff --git a/target-cris/helper.c b/target-cris/helper.c
index 5bc6d810cb64d13b9eb1df6fa1db4002f105a11e..dd7f18e7f49e98fcc441b199087176efb55703ce 100644
--- a/target-cris/helper.c
+++ b/target-cris/helper.c
@@ -18,10 +18,6 @@
* License along with this library; if not, see .
*/
-#include
-#include
-
-#include "config.h"
#include "cpu.h"
#include "mmu.h"
#include "host-utils.h"
diff --git a/target-cris/mmu.c b/target-cris/mmu.c
index d481e39352d282be7d03cc64b5f9f4418d069806..5cd8f275286d539dfd2b4d7c83d5aa30c38b4a9e 100644
--- a/target-cris/mmu.c
+++ b/target-cris/mmu.c
@@ -20,11 +20,6 @@
#ifndef CONFIG_USER_ONLY
-#include
-#include
-#include
-
-#include "config.h"
#include "cpu.h"
#include "mmu.h"
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 70abf8a095efed4fb9f5c44f8873a7ab99a63aa6..cbdc72c9b959e895ee49a823e44d3f33a3785cd1 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -23,19 +23,12 @@
* The condition code translation is in need of attention.
*/
-#include
-#include
-#include
-#include
-#include
-
#include "cpu.h"
#include "disas.h"
#include "tcg-op.h"
#include "helper.h"
#include "mmu.h"
#include "crisv32-decode.h"
-#include "qemu-common.h"
#define GEN_HELPER 1
#include "helper.h"
diff --git a/target-i386/helper.c b/target-i386/helper.c
index d12c9621bd7f3eaed1dd881c4cea1aea458f7756..af6bba26805b3a0f46dbbd40769f15740d1fd198 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -16,14 +16,8 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
#include "cpu.h"
-#include "qemu-common.h"
#include "kvm.h"
#ifndef CONFIG_USER_ONLY
#include "sysemu.h"
diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c
index 2aea71bf85e8fc7e5f56f11d5a808d2e6fa24fdd..63a08d6d9a9afcb1f1f8a4b0170c24501a8e82f8 100644
--- a/target-i386/op_helper.c
+++ b/target-i386/op_helper.c
@@ -22,7 +22,6 @@
#include "dyngen-exec.h"
#include "host-utils.h"
#include "ioport.h"
-#include "qemu-common.h"
#include "qemu-log.h"
#include "cpu-defs.h"
#include "helper.h"
diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h
index 037ef528ed832b30850dde38da7865a6311d731b..b6b6b4c87afbe438f49095e70afc6a77597248ae 100644
--- a/target-lm32/cpu.h
+++ b/target-lm32/cpu.h
@@ -24,6 +24,7 @@
#define CPUState struct CPULM32State
+#include "config.h"
#include "qemu-common.h"
#include "cpu-defs.h"
struct CPULM32State;
diff --git a/target-lm32/helper.c b/target-lm32/helper.c
index fc0b444d81d7c75d15ce356ab375586bbdca32fd..2637c03c912ae3bfdf784c32601800ad0292b7b1 100644
--- a/target-lm32/helper.c
+++ b/target-lm32/helper.c
@@ -17,11 +17,6 @@
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-
-#include "config.h"
#include "cpu.h"
#include "host-utils.h"
diff --git a/target-lm32/translate.c b/target-lm32/translate.c
index 0be105d018dce8f57beea9bfcf338f37844940c6..c80e48b39e9d2e4f5f03680dfcf8899e8237220a 100644
--- a/target-lm32/translate.c
+++ b/target-lm32/translate.c
@@ -17,18 +17,10 @@
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
-#include
-
#include "cpu.h"
#include "disas.h"
#include "helper.h"
#include "tcg-op.h"
-#include "qemu-common.h"
#include "hw/lm32_pic.h"
diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h
index 0667f8214ad85239acb95627e8e96dbb3d8a0f88..4cc3a35f2e948bf321e41506b5f2d84de7e88ea6 100644
--- a/target-m68k/cpu.h
+++ b/target-m68k/cpu.h
@@ -24,6 +24,7 @@
#define CPUState struct CPUM68KState
+#include "config.h"
#include "qemu-common.h"
#include "cpu-defs.h"
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index 674c8e6f071d86d557d5bc957098ba27902133b1..fa675bfca676216531ff2ccd360a3354c6c3caa8 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -18,12 +18,7 @@
* License along with this library; if not, see .
*/
-#include
-#include
-
-#include "config.h"
#include "cpu.h"
-#include "qemu-common.h"
#include "gdbstub.h"
#include "helpers.h"
diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index 0e7f1fe2c76e3979d4d067d2c04422997c7b2dbd..2bdd9dd1e3dff28c53b8ebdc64dcd2a66ff48847 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -17,13 +17,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
-#include "config.h"
#include "cpu.h"
#include "disas.h"
#include "tcg-op.h"
diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h
index 3ecaeee3463720a73c849efe7e33a084cd8cffbe..409250649d9b773ea9befbea820ea3f14d06ef51 100644
--- a/target-microblaze/cpu.h
+++ b/target-microblaze/cpu.h
@@ -19,6 +19,9 @@
#ifndef CPU_MICROBLAZE_H
#define CPU_MICROBLAZE_H
+#include "config.h"
+#include "qemu-common.h"
+
#define TARGET_LONG_BITS 32
#define CPUState struct CPUMBState
diff --git a/target-microblaze/helper.c b/target-microblaze/helper.c
index 2cf28022bd22b55cd4f55dffe9becb9cb44f7f5a..e1355ff93eb228cc6d07a3cb4c8d0ee760567aa0 100644
--- a/target-microblaze/helper.c
+++ b/target-microblaze/helper.c
@@ -17,11 +17,6 @@
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-
-#include "config.h"
#include "cpu.h"
#include "host-utils.h"
diff --git a/target-microblaze/mmu.c b/target-microblaze/mmu.c
index 281fc8d8c45224dc23221e34beb888abff90c223..7c34ac0971c3b7a96718c7e0f426ec1af3e66a88 100644
--- a/target-microblaze/mmu.c
+++ b/target-microblaze/mmu.c
@@ -16,11 +16,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include "config.h"
#include "cpu.h"
#define D(x)
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 96ce2ece5183041fcf965251fa9e85ddb4473895..725c2ddf9b8d6de685aa8a5e18e3092863ce749d 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -17,19 +17,11 @@
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
-#include
-
#include "cpu.h"
#include "disas.h"
#include "tcg-op.h"
#include "helper.h"
#include "microblaze-decode.h"
-#include "qemu-common.h"
#define GEN_HELPER 1
#include "helper.h"
diff --git a/target-mips/translate.c b/target-mips/translate.c
index d5b1c765fb9d701662baa7b178afb1fa95e198d3..8361d88aa8aa92df688d93cc9578ae57fb73a148 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -20,16 +20,9 @@
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
-
#include "cpu.h"
#include "disas.h"
#include "tcg-op.h"
-#include "qemu-common.h"
#include "helper.h"
#define GEN_HELPER 1
diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index 928fbcf3cbe99206ea80a927b63134abd03912f2..bb76a8b9e0db78d445083dfa06ca8f0c8d61538d 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -16,15 +16,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
#include "cpu.h"
#include "helper_regs.h"
-#include "qemu-common.h"
#include "kvm.h"
#include "kvm_ppc.h"
#include "cpus.h"
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index b2780dbe5580bf821d996900cf45b636fc152a0d..8573e1f775247992a14cdb3a2e499082cf9361ee 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -17,16 +17,10 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
#include "cpu.h"
#include "disas.h"
#include "tcg-op.h"
-#include "qemu-common.h"
#include "host-utils.h"
#include "helper.h"
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index b8893b30271cd10975362db63a0a17f2508b9fdc..e892beca3bbd5821ddf2541be6cccdfd50990c10 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -19,6 +19,9 @@
#ifndef CPU_S390X_H
#define CPU_S390X_H
+#include "config.h"
+#include "qemu-common.h"
+
#define TARGET_LONG_BITS 64
#define ELF_MACHINE EM_S390
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index 10cc9dd5fa54c8c1dfca5747e36b611b8b6dcbc4..c0ec8908a674bb839267533ec17c21f070c6887e 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -18,13 +18,8 @@
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-
#include "cpu.h"
#include "gdbstub.h"
-#include "qemu-common.h"
#include "qemu-timer.h"
#ifndef CONFIG_USER_ONLY
#include "sysemu.h"
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index ee156721857d089e2538e20263e94450a4df4f38..71f9dcdff5de268f1098dc7a55826976a030e55d 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -17,11 +17,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
/* #define DEBUG_ILLEGAL_INSTRUCTIONS */
/* #define DEBUG_INLINE_BRANCHES */
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index aacf96d9a374c3a9512f47db985901ecfd60e5ab..dd0ee4be93af8df8d879f3b55d086af450a24acb 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -16,11 +16,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
-#include
-#include
-#include
-#include
-#include
#define DEBUG_DISAS
#define SH4_DEBUG_DISAS
@@ -29,7 +24,6 @@
#include "cpu.h"
#include "disas.h"
#include "tcg-op.h"
-#include "qemu-common.h"
#include "helper.h"
#define GEN_HELPER 1
diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h
index b4e72cfa6e390db820195623cfb80df551a4491a..f725634801a4657f54e38fed1a86ce4667dc07e9 100644
--- a/target-unicore32/cpu.h
+++ b/target-unicore32/cpu.h
@@ -20,6 +20,8 @@
#define CPUState struct CPUState_UniCore32
+#include "config.h"
+#include "qemu-common.h"
#include "cpu-defs.h"
#include "softfloat.h"
diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
index b5b1cb7c9bb11e29af2c5f66c62d9f88f6463fee..ee7f82bdcdb4180d0e4cfcdfd6802c86296439ee 100644
--- a/target-unicore32/helper.c
+++ b/target-unicore32/helper.c
@@ -5,14 +5,10 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
-#include
-#include
-#include
#include "cpu.h"
#include "gdbstub.h"
#include "helper.h"
-#include "qemu-common.h"
#include "host-utils.h"
static inline void set_feature(CPUState *env, int feature)
diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c
index b723c4ca7bbfb6e37fae706925d679470814e6f5..7c038351b375ec269014305d70609bb95fe0e91a 100644
--- a/target-xtensa/core-dc232b.c
+++ b/target-xtensa/core-dc232b.c
@@ -1,7 +1,6 @@
#include "cpu.h"
#include "exec-all.h"
#include "gdbstub.h"
-#include "qemu-common.h"
#include "host-utils.h"
#include "core-dc232b/core-isa.h"
diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c
index 88de4dd4bad02883fe3c9523ab16eaacd9f001d5..c11d9708e79715894690c295469752a9f4206691 100644
--- a/target-xtensa/core-fsf.c
+++ b/target-xtensa/core-fsf.c
@@ -1,7 +1,6 @@
#include "cpu.h"
#include "exec-all.h"
#include "gdbstub.h"
-#include "qemu-common.h"
#include "host-utils.h"
#include "core-fsf/core-isa.h"
diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c
index 2ef50d656e5667c138944722dcb68492fd3e7fbb..42a559f756572f15fd20bb7c417ab6660ee56409 100644
--- a/target-xtensa/helper.c
+++ b/target-xtensa/helper.c
@@ -28,7 +28,6 @@
#include "cpu.h"
#include "exec-all.h"
#include "gdbstub.h"
-#include "qemu-common.h"
#include "host-utils.h"
#if !defined(CONFIG_USER_ONLY)
#include "hw/loader.h"
diff --git a/thunk.h b/thunk.h
index 109c541f0f3bd3bc52526456865950294df08096..98107431913ad7d580547069f4cfe5cefe4b7e59 100644
--- a/thunk.h
+++ b/thunk.h
@@ -99,7 +99,7 @@ static inline int thunk_type_size(const argtype *type_ptr, int is_host)
case TYPE_PTRVOID:
case TYPE_PTR:
if (is_host) {
- return HOST_LONG_SIZE;
+ return sizeof(void *);
} else {
return TARGET_ABI_BITS / 8;
}
@@ -136,7 +136,7 @@ static inline int thunk_type_align(const argtype *type_ptr, int is_host)
case TYPE_PTRVOID:
case TYPE_PTR:
if (is_host) {
- return HOST_LONG_SIZE;
+ return sizeof(void *);
} else {
return TARGET_ABI_BITS / 8;
}