diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c
index 20f308b..4e634df 100644
--- a/fsdev/virtio-9p-marshal.c
+++ b/fsdev/virtio-9p-marshal.c
@@ -11,20 +11,10 @@
   *
   */

-#include <glib.h>
  #include <glib/gprintf.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/time.h>
-#include <utime.h>
-#include <sys/uio.h>
-#include <string.h>
-#include <stdint.h>
-#include <errno.h>

-#include "qemu/compiler.h"
+#include "qemu-common.h"
  #include "virtio-9p-marshal.h"
-#include "qemu/bswap.h"

  void v9fs_string_free(V9fsString *str)
  {
diff --git a/hw/spapr_nvram.c b/hw/spapr_nvram.c
index 680cdba..2960b15 100644
--- a/hw/spapr_nvram.c
+++ b/hw/spapr_nvram.c
@@ -22,6 +22,8 @@
   * THE SOFTWARE.
   */

+#include "qemu-common.h"
+
  #include <libfdt.h>

  #include "sysemu/device_tree.h"
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index e6d4798..07dadc2 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -13,6 +13,10 @@
  #elif defined(CONFIG_BYTESWAP_H)
  # include <byteswap.h>

+#if !defined(HOST_LONG_BITS)
+# error needs HOST_LONG_BITS
+#endif
+
  static inline uint16_t bswap16(uint16_t x)
  {
      return bswap_16(x);
