include: split target_long definition from cpu-defs

While we will continue to include this via cpu-defs it is useful to be
able to define this separately for 32 and 64 bit versions of an
otherwise target independent compilation unit.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Message-Id: <20230302190846.2593720-25-alex.bennee@linaro.org>
Message-Id: <20230303025805.625589-25-richard.henderson@linaro.org>
This commit is contained in:
Alex Bennée 2023-03-02 18:58:00 -08:00
parent bcbc36a98f
commit 4692a86f1c
3 changed files with 44 additions and 18 deletions

View File

@ -137,6 +137,7 @@ F: docs/devel/tcg*
F: include/exec/cpu*.h F: include/exec/cpu*.h
F: include/exec/exec-all.h F: include/exec/exec-all.h
F: include/exec/tb-flush.h F: include/exec/tb-flush.h
F: include/exec/target_long.h
F: include/exec/helper*.h F: include/exec/helper*.h
F: include/sysemu/cpus.h F: include/sysemu/cpus.h
F: include/sysemu/tcg.h F: include/sysemu/tcg.h

View File

@ -55,24 +55,7 @@
# endif # endif
#endif #endif
#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) #include "exec/target_long.h"
/* target_ulong is the type of a virtual address */
#if TARGET_LONG_SIZE == 4
typedef int32_t target_long;
typedef uint32_t target_ulong;
#define TARGET_FMT_lx "%08x"
#define TARGET_FMT_ld "%d"
#define TARGET_FMT_lu "%u"
#elif TARGET_LONG_SIZE == 8
typedef int64_t target_long;
typedef uint64_t target_ulong;
#define TARGET_FMT_lx "%016" PRIx64
#define TARGET_FMT_ld "%" PRId64
#define TARGET_FMT_lu "%" PRIu64
#else
#error TARGET_LONG_SIZE undefined
#endif
#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)

View File

@ -0,0 +1,42 @@
/*
* Target Long Definitions
*
* Copyright (c) 2003 Fabrice Bellard
* Copyright (c) 2023 Linaro Ltd
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _TARGET_LONG_H_
#define _TARGET_LONG_H_
/*
* Usually this should only be included via cpu-defs.h however for
* certain cases where we want to build only two versions of a binary
* object we can include directly. However the build-system must
* ensure TARGET_LONG_BITS is defined directly.
*/
#ifndef TARGET_LONG_BITS
#error TARGET_LONG_BITS not defined
#endif
#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
/* target_ulong is the type of a virtual address */
#if TARGET_LONG_SIZE == 4
typedef int32_t target_long;
typedef uint32_t target_ulong;
#define TARGET_FMT_lx "%08x"
#define TARGET_FMT_ld "%d"
#define TARGET_FMT_lu "%u"
#elif TARGET_LONG_SIZE == 8
typedef int64_t target_long;
typedef uint64_t target_ulong;
#define TARGET_FMT_lx "%016" PRIx64
#define TARGET_FMT_ld "%" PRId64
#define TARGET_FMT_lu "%" PRIu64
#else
#error TARGET_LONG_SIZE undefined
#endif
#endif /* _TARGET_LONG_H_ */