Move HOST_LONG_BITS from qemu-common.h to qemu/osdep.h

qemu-common.h should only be included by .c files. Its file comment
explains why: "No header file should depend on qemu-common.h, as this
would easily lead to circular header dependencies."

One of the reasons for headers to include it is HOST_LONG_BITS. Move
that to its more natural home qemu/osdep.h, to facilitate removing
these ill-advised includes later on.

This also lets us use HOST_LONG_BITS in bswap.h instead of duplicating
its definition there to avoid cyclic inclusion.

Backports commit a8139632161d7546218b696cada0a4f64cc78fb7 from qemu
This commit is contained in:
Markus Armbruster 2018-02-21 23:10:39 -05:00 committed by Lioncash
parent 06668850e3
commit 6b1ebd16e6
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 11 additions and 14 deletions

View file

@ -24,16 +24,6 @@
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
#include "unicorn/platform.h" #include "unicorn/platform.h"
/* 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
#include "qemu/bswap.h" #include "qemu/bswap.h"
/* FIXME: Remove NEED_CPU_H. */ /* FIXME: Remove NEED_CPU_H. */

View file

@ -415,11 +415,9 @@ static inline void stfq_be_p(void *ptr, float64 v)
static inline unsigned long leul_to_cpu(unsigned long v) static inline unsigned long leul_to_cpu(unsigned long v)
{ {
/* In order to break an include loop between here and #if HOST_LONG_BITS == 32
qemu-common.h, don't rely on HOST_LONG_BITS. */
#if ULONG_MAX == UINT32_MAX
return le_bswap(v, 32); return le_bswap(v, 32);
#elif ULONG_MAX == UINT64_MAX #elif HOST_LONG_BITS == 64
return le_bswap(v, 64); return le_bswap(v, 64);
#else #else
# error Unknown sizeof long # error Unknown sizeof long

View file

@ -115,6 +115,15 @@
#define TIME_MAX LONG_MAX #define TIME_MAX LONG_MAX
#endif #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 MIN #ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif #endif